public class FilesystemDataSource extends Object implements TreeDataSource
HierarchicalDataSource
wherein tree nodes represent files in the local filesystem. The
ignoreFiles
argument of some forms of the constructor allows
for the creation of directory-only data sources. These are useful for
driving a directory chooser, for example.File
Modifier and Type | Class and Description |
---|---|
class |
FilesystemDataSource.FileRoot
A virtual filesystem root.
|
Modifier and Type | Field and Description |
---|---|
private static String |
ALL_FILESYSTEMS |
private static String[] |
columns |
private static Icon |
COMPUTER_ICON |
private Date |
date |
private static String |
DATE_COLUMN |
private static Icon |
DOCUMENT_ICON |
private static String[] |
emptyList |
private static String |
FILE_COLUMN |
private static Icon |
FOLDER_CLOSED_ICON |
private static Icon |
FOLDER_LOCKED_ICON |
private static Icon |
FOLDER_OPEN_ICON |
private boolean |
ignoreFiles |
private LocaleManager |
lm |
private FilesystemDataSource.FileRoot |
root |
private static String |
SIZE_COLUMN |
private static String |
TIME_COLUMN |
private static Class[] |
types |
COLUMN_NAMES_PROPERTY, COLUMN_TYPES_PROPERTY
Constructor and Description |
---|
FilesystemDataSource()
Construct a new
FilesystemDataSource with roots
for all available filesystems. |
FilesystemDataSource(boolean ignoreFiles)
Construct a new
FilesystemDataSource with roots
for all available filesystems. |
FilesystemDataSource(File[] roots)
Construct a new
FilesystemDataSource wiht the given roots. |
FilesystemDataSource(File[] roots,
boolean ignoreFiles)
Construct a new
FilesystemDataSource . |
FilesystemDataSource(File root,
boolean ignoreFiles)
Construct a new
FilesystemDataSource . |
Modifier and Type | Method and Description |
---|---|
private void |
_init(FilesystemDataSource.FileRoot root,
boolean ignoreFiles) |
Object[] |
getChildren(Object node)
Get the children of a given node.
|
Icon |
getIcon(Object node,
boolean isExpanded)
Get the icon for a node.
|
String |
getLabel(Object node)
Get the label for a node.
|
Object |
getRoot()
Get the root object.
|
Object |
getValueForProperty(Object node,
String property)
Get the value for a given property.
|
boolean |
isExpandable(Object node)
Determine if this node is expandable.
|
private File[] |
makeNodes(File parent,
String[] list) |
private FilesystemDataSource.FileRoot root
private static final Icon FOLDER_OPEN_ICON
private static final Icon FOLDER_CLOSED_ICON
private static final Icon FOLDER_LOCKED_ICON
private static final Icon DOCUMENT_ICON
private static final Icon COMPUTER_ICON
private boolean ignoreFiles
private LocaleManager lm
private static final String FILE_COLUMN
private static final String SIZE_COLUMN
private static final String DATE_COLUMN
private static final String TIME_COLUMN
private static final String ALL_FILESYSTEMS
public FilesystemDataSource()
FilesystemDataSource
with roots
for all available filesystems.public FilesystemDataSource(File[] roots)
FilesystemDataSource
wiht the given roots.roots
- The filesystem roots for this datasource.public FilesystemDataSource(boolean ignoreFiles)
FilesystemDataSource
with roots
for all available filesystems.ignoreFiles
- A flag specifying whether ordinary files
(non-directories) should be ignored or displayed.public FilesystemDataSource(File root, boolean ignoreFiles)
FilesystemDataSource
.root
- The root directory.ignoreFiles
- A flag specifying whether ordinary files
(non-directories) should be ignored or displayed.IllegalArgumentException
- if root
is not
a directory.public FilesystemDataSource(File[] roots, boolean ignoreFiles)
FilesystemDataSource
.roots
- The root directories.ignoreFiles
- A flag specifying whether ordinary files
(non-directories) should be ignored or displayed.IllegalArgumentException
- if root
is not
a directory.private void _init(FilesystemDataSource.FileRoot root, boolean ignoreFiles)
public Object getRoot()
getRoot
in interface TreeDataSource
FileRoot
"virtual root" object which is
the parent of the root files with which this data source was
created.public Object[] getChildren(Object node)
getChildren
in interface TreeDataSource
node
- The node that children are being requested for.public String getLabel(Object node)
TreeDataSource
getLabel
in interface TreeDataSource
node
- The node.public Icon getIcon(Object node, boolean isExpanded)
TreeDataSource
getIcon
in interface TreeDataSource
node
- The node.isExpanded
- The current expanded state of the node.public boolean isExpandable(Object node)
TreeDataSource
isExpandable
in interface TreeDataSource
node
- The node.public Object getValueForProperty(Object node, String property)
getValueForProperty
in interface TreeDataSource
node
- The node.property
- The name of the property; one of the constants defined
above, or some arbitrary application-defined property.null
if
there is no value for this property.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses