com.sun.xfilechooser
Class XFileChooser

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JFileChooser
                          |
                          +--com.sun.xfilechooser.XFileChooser

public class XFileChooser
extends javax.swing.JFileChooser
implements java.beans.PropertyChangeListener

XFileChooser is an extension of the JFileChooser. It provides a simple mechanism for the user to choose a file locally and remotely via NFS URLs. Instead of returning a File Object which is done in JFileChooser it returns and XFile Object. The XFile object allows access to local and remote files.

See Also:
#javax.swing.JFileChooser, Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static java.lang.String SELECTED_XFILE_CHANGED_PROPERTY
          Identifes change in user's single-file selection.
static java.lang.String SELECTED_XFILES_CHANGED_PROPERTY
          Identifes change in user's multiple-file selection.
static java.lang.String XDIRECTORY_CHANGED_PROPERTY
          Identifies user's directory change.
 
Fields inherited from class javax.swing.JFileChooser
ACCESSORY_CHANGED_PROPERTY, APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY, APPROVE_BUTTON_TEXT_CHANGED_PROPERTY, APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY, APPROVE_OPTION, APPROVE_SELECTION, CANCEL_OPTION, CANCEL_SELECTION, CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY, CUSTOM_DIALOG, DIALOG_TITLE_CHANGED_PROPERTY, DIALOG_TYPE_CHANGED_PROPERTY, DIRECTORIES_ONLY, DIRECTORY_CHANGED_PROPERTY, ERROR_OPTION, FILE_FILTER_CHANGED_PROPERTY, FILE_HIDING_CHANGED_PROPERTY, FILE_SELECTION_MODE_CHANGED_PROPERTY, FILE_SYSTEM_VIEW_CHANGED_PROPERTY, FILE_VIEW_CHANGED_PROPERTY, FILES_AND_DIRECTORIES, FILES_ONLY, MULTI_SELECTION_ENABLED_CHANGED_PROPERTY, OPEN_DIALOG, SAVE_DIALOG, SELECTED_FILE_CHANGED_PROPERTY, SELECTED_FILES_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
XFileChooser()
          Creates a XFileChooser pointing to the user's home directory.
XFileChooser(java.lang.String currentDirectoryPath)
          Creates a XFileChooser using the given path.
XFileChooser(XFile currentDirectory)
          Creates a XFileChooser using the given XFile as the path.
 
Method Summary
 void ensureFileIsVisible(XFile f)
          Make sure that the specified file is viewable, and not hidden.
 XFile getCurrentXDirectory()
          Returns XFile Object of the current directory.
 XFile getSelectedXFile()
          Returns the XFile object of the selected file.
 XFileInputStream getSelectedXFileInputStream()
          Returns the XFileInputStream object of the selected file
 XFileOutputStream getSelectedXFileOutputStream()
          Returns the XFileOutputStream object of the selected file
 XFile[] getSelectedXFiles()
          Returns a list of selected files if the filechooser is set to allow multi-selection.
static void main(java.lang.String[] args)
          Used only for testing of bean
 void propertyChange(java.beans.PropertyChangeEvent e)
          This method gets called when certain bound properties has changed on the associated JFileChooser.
 void setCurrentXDirectory(XFile currentDirectory)
          Sets the current directory.
 void setSelectedXFile(XFile selectedFile)
          Sets the XFile object of the selected file.
 void setSelectedXFiles(XFile[] selectedFiles)
          Sets the list of selected files if the filechooser is set to allow multi-selection.
 
Methods inherited from class javax.swing.JFileChooser
accept, addActionListener, addChoosableFileFilter, approveSelection, cancelSelection, changeToParentDirectory, ensureFileIsVisible, getAcceptAllFileFilter, getAccessibleContext, getAccessory, getApproveButtonMnemonic, getApproveButtonText, getApproveButtonToolTipText, getChoosableFileFilters, getCurrentDirectory, getDescription, getDialogTitle, getDialogType, getFileFilter, getFileSelectionMode, getFileSystemView, getFileView, getIcon, getName, getSelectedFile, getSelectedFiles, getTypeDescription, getUI, getUIClassID, isDirectorySelectionEnabled, isFileHidingEnabled, isFileSelectionEnabled, isMultiSelectionEnabled, isTraversable, removeActionListener, removeChoosableFileFilter, rescanCurrentDirectory, resetChoosableFileFilters, setAccessory, setApproveButtonMnemonic, setApproveButtonMnemonic, setApproveButtonText, setApproveButtonToolTipText, setCurrentDirectory, setDialogTitle, setDialogType, setFileFilter, setFileHidingEnabled, setFileSelectionMode, setFileSystemView, setFileView, setMultiSelectionEnabled, setSelectedFile, setSelectedFiles, showDialog, showOpenDialog, showSaveDialog, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XDIRECTORY_CHANGED_PROPERTY

public static final java.lang.String XDIRECTORY_CHANGED_PROPERTY
Identifies user's directory change.

SELECTED_XFILE_CHANGED_PROPERTY

public static final java.lang.String SELECTED_XFILE_CHANGED_PROPERTY
Identifes change in user's single-file selection.

SELECTED_XFILES_CHANGED_PROPERTY

public static final java.lang.String SELECTED_XFILES_CHANGED_PROPERTY
Identifes change in user's multiple-file selection.
Constructor Detail

XFileChooser

public XFileChooser()
Creates a XFileChooser pointing to the user's home directory. Initializes some of the private variables needed for bean's editor.

XFileChooser

public XFileChooser(java.lang.String currentDirectoryPath)
Creates a XFileChooser using the given path. Passing in a null string causes the file chooser to point to the users home directory.
Parameters:
currentDirectoryPath - a String giving the path to a file or directory

XFileChooser

public XFileChooser(XFile currentDirectory)
Creates a XFileChooser using the given XFile as the path. Passing in a null file causes the file chooser to point to the users's home directory.
Parameters:
currentDirectory - a XFile object specifying the path to a file or directory
Method Detail

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
This method gets called when certain bound properties has changed on the associated JFileChooser. The properties it will listen to include: DIRECTORY_CHANGED_PROPERTY, SELECTED_FILE_CHANGED_PROPERTY, SELECTED_FILES_CHANGED_PROPERTY. This method is needed to create the corresponding XFile for the File object of the selected file or directory.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getCurrentXDirectory

public XFile getCurrentXDirectory()
Returns XFile Object of the current directory.
Returns:
the XFile object of the current directory
See Also:
setCurrentXDirectory(com.sun.xfile.XFile)

setCurrentXDirectory

public void setCurrentXDirectory(XFile currentDirectory)
Sets the current directory. Passing in null sets the filechooser to point to the users's home directory. If the file passed in as currentDirectory is not a directory, the parent of the file will be used as the currentDirectory. If the parent is not traversable, then it will walk up the parent tree until it finds a traversable direcotry, or hits the root of the file system.
Parameters:
currentDirectory - the XFile object of the current directory to point to.
See Also:
getCurrentXDirectory()

getSelectedXFile

public XFile getSelectedXFile()
Returns the XFile object of the selected file. This can be set either by the programmer via setSelectedXFile() or by a user action, such as either typing the filename int the UI or selecting the file from a list in the UI.
Returns:
the XFile object of the selected file
See Also:
setSelectedXFile(com.sun.xfile.XFile)

setSelectedXFile

public void setSelectedXFile(XFile selectedFile)
Sets the XFile object of the selected file. If the file's parent directory is not the current directory, it changed the current directory to be the files parent directory. This just calls the setSelectedFile() of JFileChooser, passing it the corresponding File object of the selected file.
Parameters:
selectedFile - the XFile object of the selected file
See Also:
getSelectedXFile()

getSelectedXFiles

public XFile[] getSelectedXFiles()
Returns a list of selected files if the filechooser is set to allow multi-selection.
Returns:
list of XFile objects of the selected files
See Also:
setSelectedXFiles(com.sun.xfile.XFile[])

setSelectedXFiles

public void setSelectedXFiles(XFile[] selectedFiles)
Sets the list of selected files if the filechooser is set to allow multi-selection.

getSelectedXFileInputStream

public XFileInputStream getSelectedXFileInputStream()
Returns the XFileInputStream object of the selected file
Returns:
XFileInputStream of the selected input file
See Also:
setSelectedXFile(com.sun.xfile.XFile)

getSelectedXFileOutputStream

public XFileOutputStream getSelectedXFileOutputStream()
Returns the XFileOutputStream object of the selected file
Returns:
XFileOutputStream of the selected output file
See Also:
setSelectedXFile(com.sun.xfile.XFile)

ensureFileIsVisible

public void ensureFileIsVisible(XFile f)
Make sure that the specified file is viewable, and not hidden.
Parameters:
f - an XFile object

main

public static void main(java.lang.String[] args)
Used only for testing of bean