APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicDirectoryModel

extends AbstractListModel<Object>
implements PropertyChangeListener
Class Inheritance
All Implemented Interfaces
java.beans.PropertyChangeListener, java.util.EventListener
Known Direct Subclasses
com.sun.java.swing.plaf.gtk.GTKFileChooserUI.GTKDirectoryModel
Annotations
@SuppressWarnings:serial
Imports
java.beans.PropertyChangeEvent, .PropertyChangeListener, .PropertyChangeSupport, java.io.File, java.util.List, .Vector, java.util.concurrent.Callable, java.util.concurrent.atomic.AtomicInteger, javax.swing.AbstractListModel, .JFileChooser, .SwingUtilities, javax.swing.event.ListDataEvent, javax.swing.filechooser.FileSystemView, sun.awt.shell.ShellFolder

Basic implementation of a file list.
Author
Jeff Dinkins

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class

Field Summary

Modifier and TypeField and Description
private boolean
private PropertyChangeSupport
private Vector<File>
private final AtomicInteger
private final Vector<File>
private final JFileChooser
private Vector<File>
private BasicDirectoryModel.FilesLoader
Inherited from javax.swing.AbstractListModel:
listenerList

Constructor Summary

AccessConstructor and Description
public
BasicDirectoryModel(JFileChooser
an instance of {JFileChooser}
filechooser
)

Constructs a new instance of BasicDirectoryModel.

Method Summary

Modifier and TypeMethod and Description
public void
addPropertyChangeListener(PropertyChangeListener
the property change listener to be added
listener
)

Adds a PropertyChangeListener to the listener list.

public boolean

Returns:

true if an element o is in file cache
contains
(Object
an element
o
)

Returns true if an element o is in file cache, otherwise, returns false.

public void
fireContentsChanged()

Invoked when a content is changed.

protected void
firePropertyChange(String
the property whose value has changed
propertyName
,
Object
the property's previous value
oldValue
,
Object
the property's new value
newValue
)

Support for reporting bound property changes for boolean properties.

public Vector<File>

Returns:

a list of directories
getDirectories
()

Returns a list of directories.

public Object
getElementAt(int index)

Implements javax.swing.ListModel.getElementAt.

Returns the value at the specified index.

public Vector<File>

Returns:

a list of files
getFiles
()

Returns a list of files.

public PropertyChangeListener[]

Returns:

all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
getPropertyChangeListeners
()

Returns an array of all the property change listeners registered on this component.

public int
getSize()

Implements javax.swing.ListModel.getSize.

Returns the length of the list.

public int

Returns:

an index of element o in file cache
indexOf
(Object
an element
o
)

Returns an index of element o in file cache.

public void
intervalAdded(ListDataEvent
list data event
e
)
Deprecated for removal since 17. Obsolete method, not used anymore.

Obsolete - not used.

public void
intervalRemoved(ListDataEvent
list data event
e
)
Deprecated for removal since 17. Obsolete method, not used anymore.

Obsolete - not used.

public void
invalidateFileCache()

This method is used to interrupt file loading thread.

protected boolean

Returns:

a comparison of the file names
lt
(File
a file
a
,
File
another file
b
)
Deprecated for removal since 17. Obsolete method, not used anymore.

Obsolete - not used

public void
propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

public void
removePropertyChangeListener(PropertyChangeListener
the PropertyChangeListener to be removed
listener
)

Removes a PropertyChangeListener from the listener list.

public boolean

Returns:

true if rename succeeded, otherwise false
renameFile
(File
a File object representing the existing file
oldFile
,
File
a File object representing the desired new file name
newFile
)

Renames a file in the underlying file system.

private synchronized void
setBusy(final boolean busy, int fid)

Set the busy state for the model.

protected void
sort(Vector<? extends File>
a list of files
v
)

Sorts a list of files.

public void
validateFileCache()

Validates content of file cache.

Inherited from javax.swing.AbstractListModel:
addListDataListenerfireContentsChangedfireIntervalAddedfireIntervalRemovedgetListDataListenersgetListenersremoveListDataListener

Field Detail

busyback to summary
private boolean busy
changeSupportback to summary
private PropertyChangeSupport changeSupport
directoriesback to summary
private Vector<File> directories
fetchIDback to summary
private final AtomicInteger fetchID
fileCacheback to summary
private final Vector<File> fileCache
filechooserback to summary
private final JFileChooser filechooser
filesback to summary
private Vector<File> files
filesLoaderback to summary
private BasicDirectoryModel.FilesLoader filesLoader

Constructor Detail

BasicDirectoryModelback to summary
public BasicDirectoryModel(JFileChooser filechooser)

Constructs a new instance of BasicDirectoryModel.

Parameters
filechooser:JFileChooser

an instance of {JFileChooser}

Method Detail

addPropertyChangeListenerback to summary
public void addPropertyChangeListener(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.

Parameters
listener:PropertyChangeListener

the property change listener to be added

Since
1.6
See Also
removePropertyChangeListener, getPropertyChangeListeners
containsback to summary
public boolean contains(Object o)

Returns true if an element o is in file cache, otherwise, returns false.

Parameters
o:Object

an element

Returns:boolean

true if an element o is in file cache

fireContentsChangedback to summary
public void fireContentsChanged()

Invoked when a content is changed.

firePropertyChangeback to summary
protected void firePropertyChange(String propertyName, Object oldValue, 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.

Parameters
propertyName:String

the property whose value has changed

oldValue:Object

the property's previous value

newValue:Object

the property's new value

Since
1.6
getDirectoriesback to summary
public Vector<File> getDirectories()

Returns a list of directories.

Returns:Vector<File>

a list of directories

getElementAtback to summary
public Object getElementAt(int index)

Implements javax.swing.ListModel.getElementAt.

Doc from javax.swing.ListModel.getElementAt.

Returns the value at the specified index.

getFilesback to summary
public Vector<File> getFiles()

Returns a list of files.

Returns:Vector<File>

a list of files

getPropertyChangeListenersback to summary
public PropertyChangeListener[] getPropertyChangeListeners()

Returns an array of all the property change listeners registered on this component.

Returns:PropertyChangeListener[]

all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered

Since
1.6
See Also
addPropertyChangeListener, removePropertyChangeListener, java.beans.PropertyChangeSupport#getPropertyChangeListeners
getSizeback to summary
public int getSize()

Implements javax.swing.ListModel.getSize.

Doc from javax.swing.ListModel.getSize.

Returns the length of the list.

indexOfback to summary
public int indexOf(Object o)

Returns an index of element o in file cache.

Parameters
o:Object

an element

Returns:int

an index of element o in file cache

intervalAddedback to summary
public void intervalAdded(ListDataEvent e)

Deprecated

for removal since 17.

Obsolete method, not used anymore.

Obsolete - not used. This method is a no-op.

Parameters
e:ListDataEvent

list data event

Annotations
@Deprecated
since:17
forRemoval:true
intervalRemovedback to summary
public void intervalRemoved(ListDataEvent e)

Deprecated

for removal since 17.

Obsolete method, not used anymore.

Obsolete - not used. This method is a no-op.

Parameters
e:ListDataEvent

list data event

Annotations
@Deprecated
since:17
forRemoval:true
invalidateFileCacheback to summary
public void invalidateFileCache()

This method is used to interrupt file loading thread.

ltback to summary
protected boolean lt(File a, File b)

Deprecated

for removal since 17.

Obsolete method, not used anymore.

Obsolete - not used

Parameters
a:File

a file

b:File

another file

Returns:boolean

a comparison of the file names

Annotations
@Deprecated
since:17
forRemoval:true
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

removePropertyChangeListenerback to summary
public void removePropertyChangeListener(PropertyChangeListener listener)

Removes a PropertyChangeListener from the listener list.

If listener is null, no exception is thrown and no action is performed.

Parameters
listener:PropertyChangeListener

the PropertyChangeListener to be removed

Since
1.6
See Also
addPropertyChangeListener, getPropertyChangeListeners
renameFileback to summary
public boolean renameFile(File oldFile, File newFile)

Renames a file in the underlying file system.

Parameters
oldFile:File

a File object representing the existing file

newFile:File

a File object representing the desired new file name

Returns:boolean

true if rename succeeded, otherwise false

Since
1.4
setBusyback to summary
private synchronized void setBusy(final boolean busy, int fid)

Set the busy state for the model. The model is considered busy when it is running a separate (interruptible) thread in order to load the contents of a directory.

sortback to summary
protected void sort(Vector<? extends File> v)

Sorts a list of files.

Parameters
v:Vector<? extends File>

a list of files

validateFileCacheback to summary
public void validateFileCache()

Validates content of file cache.

javax.swing.plaf.basic back to summary

private final Class BasicDirectoryModel.DoChangeContents

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final List<File>
private final int
private final int
private final List<File>
private final int

Constructor Summary

AccessConstructor and Description
private
DoChangeContents(List<File> addFiles, int addStart, List<File> remFiles, int remStart, int fid)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addFilesback to summary
private final List<File> addFiles
addStartback to summary
private final int addStart
fidback to summary
private final int fid
remFilesback to summary
private final List<File> remFiles
remStartback to summary
private final int remStart

Constructor Detail

DoChangeContentsback to summary
private DoChangeContents(List<File> addFiles, int addStart, List<File> remFiles, int remStart, int fid)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
javax.swing.plaf.basic back to summary

private final Class BasicDirectoryModel.FilesLoader

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final File
private final int
private final boolean
private final FileSystemView
private final Thread
private final boolean

Constructor Summary

AccessConstructor and Description
private
FilesLoader(File currentDirectory, int fid)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
run0()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentDirectoryback to summary
private final File currentDirectory
fidback to summary
private final int fid
fileSelectionEnabledback to summary
private final boolean fileSelectionEnabled
fileSystemViewback to summary
private final FileSystemView fileSystemView
loadThreadback to summary
private final Thread loadThread
useFileHidingback to summary
private final boolean useFileHiding

Constructor Detail

FilesLoaderback to summary
private FilesLoader(File currentDirectory, int fid)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
run0back to summary
private void run0()