javax.swing.plaf.basic

Class BasicDirectoryModel

public class BasicDirectoryModel extends AbstractListModel implements PropertyChangeListener

Implements an AbstractListModel for directories where the source of the files is a JFileChooser object. This class is used for sorting and ordering the file list in a JFileChooser L&F object.
Constructor Summary
BasicDirectoryModel(JFileChooser filechooser)
Creates a new BasicDirectoryModel object.
Method Summary
booleancontains(Object o)
Returns whether a given (File) object is included in the list.
voidfireContentsChanged()
Fires a content change event.
Vector<File>getDirectories()
Returns a Vector of (java.io.File) objects containing the directories in this list.
ObjectgetElementAt(int index)
Returns the (java.io.File) object at an index in the list.
Vector<File>getFiles()
Returns a Vector of (java.io.File) objects containing the files in this list.
intgetSize()
Returns the size of the list, which only includes directories if the JFileChooser is set to DIRECTORIES_ONLY.
intindexOf(Object o)
Returns the index of an (java.io.File) object in the list.
voidintervalAdded(ListDataEvent e)
Obsoleted method which does nothing.
voidintervalRemoved(ListDataEvent e)
Obsoleted method which does nothing.
voidinvalidateFileCache()
Obsoleted method which does nothing.
protected booleanlt(File a, File b)
Less than, determine the relative order in the list of two files for sorting purposes.
voidpropertyChange(PropertyChangeEvent e)
Listens for a property change; the change in file selection mode of the associated JFileChooser.
booleanrenameFile(File oldFile, File newFile)
Renames a file - However, does not re-sort the list or replace the old file with the new one in the list.
protected voidsort(Vector<? extends File> v)
Sorts a Vector of File objects.
voidvalidateFileCache()
Re-loads the list of files

Constructor Detail

BasicDirectoryModel

public BasicDirectoryModel(JFileChooser filechooser)
Creates a new BasicDirectoryModel object.

Parameters: filechooser DOCUMENT ME!

Method Detail

contains

public boolean contains(Object o)
Returns whether a given (File) object is included in the list.

Parameters: o - The file object to test.

Returns: true if the list contains the given object.

fireContentsChanged

public void fireContentsChanged()
Fires a content change event.

getDirectories

public Vector<File> getDirectories()
Returns a Vector of (java.io.File) objects containing the directories in this list.

Returns: a Vector

getElementAt

public Object getElementAt(int index)
Returns the (java.io.File) object at an index in the list.

Parameters: index The list index

Returns: a File object

getFiles

public Vector<File> getFiles()
Returns a Vector of (java.io.File) objects containing the files in this list.

Returns: a Vector

getSize

public int getSize()
Returns the size of the list, which only includes directories if the JFileChooser is set to DIRECTORIES_ONLY. Otherwise, both directories and files are included in the count.

Returns: The size of the list.

indexOf

public int indexOf(Object o)
Returns the index of an (java.io.File) object in the list.

Parameters: o The object - normally a File.

Returns: the index of that object, or -1 if it is not in the list.

intervalAdded

public void intervalAdded(ListDataEvent e)
Obsoleted method which does nothing.

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Obsoleted method which does nothing.

invalidateFileCache

public void invalidateFileCache()
Obsoleted method which does nothing.

lt

protected boolean lt(File a, File b)
Less than, determine the relative order in the list of two files for sorting purposes. The order is: directories < files, and thereafter alphabetically, using the default locale collation.

Parameters: a the first file b the second file

Returns: true if a > b, false if a < b.

propertyChange

public void propertyChange(PropertyChangeEvent e)
Listens for a property change; the change in file selection mode of the associated JFileChooser. Reloads the file cache on that event.

Parameters: e - A PropertyChangeEvent.

renameFile

public boolean renameFile(File oldFile, File newFile)
Renames a file - However, does not re-sort the list or replace the old file with the new one in the list.

Parameters: oldFile The old file newFile The new file name

Returns: true if the rename succeeded

sort

protected void sort(Vector<? extends File> v)
Sorts a Vector of File objects.

Parameters: v The Vector to sort.

validateFileCache

public void validateFileCache()
Re-loads the list of files