Methods Summary |
---|
public void | addPropertyChangeListener(java.beans.PropertyChangeListener listener)Adds a PropertyChangeListener to the listener list. The listener is
registered for all bound properties of this class.
If listener is null ,
no exception is thrown and no action is performed.
if (changeSupport == null) {
changeSupport = new PropertyChangeSupport(this);
}
changeSupport.addPropertyChangeListener(listener);
|
public boolean | contains(java.lang.Object o)
return fileCache.contains(o);
|
public void | fireContentsChanged()
// System.out.println("BasicDirectoryModel: firecontentschanged");
fireContentsChanged(this, 0, getSize()-1);
|
protected void | firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)Support for reporting bound property changes for boolean properties.
This method can be called when a bound property has changed and it will
send the appropriate PropertyChangeEvent to any registered
PropertyChangeListeners.
if (changeSupport != null) {
changeSupport.firePropertyChange(propertyName,
oldValue, newValue);
}
|
public java.util.Vector | getDirectories()
synchronized(fileCache) {
if (directories != null) {
return directories;
}
Vector fls = getFiles();
return directories;
}
|
public java.lang.Object | getElementAt(int index)
return fileCache.get(index);
|
public java.util.Vector | getFiles()
synchronized(fileCache) {
if (files != null) {
return files;
}
files = new Vector();
directories = new Vector();
directories.addElement(filechooser.getFileSystemView().createFileObject(
filechooser.getCurrentDirectory(), "..")
);
for (int i = 0; i < getSize(); i++) {
File f = (File)fileCache.get(i);
if (filechooser.isTraversable(f)) {
directories.add(f);
} else {
files.add(f);
}
}
return files;
}
|
public java.beans.PropertyChangeListener[] | getPropertyChangeListeners()Returns an array of all the property change listeners
registered on this component.
if (changeSupport == null) {
return new PropertyChangeListener[0];
}
return changeSupport.getPropertyChangeListeners();
|
public int | getSize()
return fileCache.size();
|
public int | indexOf(java.lang.Object o)
return fileCache.indexOf(o);
|
public void | intervalAdded(javax.swing.event.ListDataEvent e)Obsolete - not used.
|
public void | intervalRemoved(javax.swing.event.ListDataEvent e)Obsolete - not used.
|
public void | invalidateFileCache()This method is used to interrupt file loading thread.
if (loadThread != null) {
loadThread.interrupt();
loadThread.cancelRunnables();
loadThread = null;
}
|
protected boolean | lt(java.io.File a, java.io.File b)
// First ignore case when comparing
int diff = a.getName().toLowerCase().compareTo(b.getName().toLowerCase());
if (diff != 0) {
return diff < 0;
} else {
// May differ in case (e.g. "mail" vs. "Mail")
return a.getName().compareTo(b.getName()) < 0;
}
|
public void | propertyChange(java.beans.PropertyChangeEvent e)
String prop = e.getPropertyName();
if(prop == JFileChooser.DIRECTORY_CHANGED_PROPERTY ||
prop == JFileChooser.FILE_VIEW_CHANGED_PROPERTY ||
prop == JFileChooser.FILE_FILTER_CHANGED_PROPERTY ||
prop == JFileChooser.FILE_HIDING_CHANGED_PROPERTY ||
prop == JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY) {
validateFileCache();
} else if ("UI".equals(prop)) {
Object old = e.getOldValue();
if (old instanceof BasicFileChooserUI) {
BasicFileChooserUI ui = (BasicFileChooserUI) old;
BasicDirectoryModel model = ui.getModel();
if (model != null) {
model.invalidateFileCache();
}
}
} else if ("JFileChooserDialogIsClosingProperty".equals(prop)) {
invalidateFileCache();
}
|
public void | removePropertyChangeListener(java.beans.PropertyChangeListener listener)Removes a PropertyChangeListener from the listener list.
If listener is null, no exception is thrown and no action is performed.
if (changeSupport != null) {
changeSupport.removePropertyChangeListener(listener);
}
|
public boolean | renameFile(java.io.File oldFile, java.io.File newFile)Renames a file in the underlying file system.
synchronized(fileCache) {
if (oldFile.renameTo(newFile)) {
validateFileCache();
return true;
}
return false;
}
|
private synchronized void | setBusy(boolean busy, int fid)Set the busy state for the model. The model is considered
busy when it is running a separate (interruptable)
thread in order to load the contents of a directory.
if (fid == fetchID) {
boolean oldValue = this.busy;
this.busy = busy;
if (changeSupport != null && busy != oldValue) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
firePropertyChange("busy", !busy, busy);
}
});
}
}
|
protected void | sort(java.util.Vector v)
ShellFolder.sortFiles(v);
|
public void | validateFileCache()
File currentDirectory = filechooser.getCurrentDirectory();
if (currentDirectory == null) {
return;
}
if (loadThread != null) {
loadThread.interrupt();
loadThread.cancelRunnables();
}
setBusy(true, ++fetchID);
loadThread = new LoadFilesThread(currentDirectory, fetchID);
loadThread.start();
|