|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectti.swing.treetable.AbstractTreeModel
ti.chimera.fs.FileSystemTreeModel
Class that makes a TreeModel of the file system AbstractFileSystem
.
There are some additional "add-ons" that you should use to ensure proper
behavior of your tree. (XXX I should probably just add a factory method to
install the TreeCellRenderer and TreeExpansionListener, and any other steps
that may get added in the future....)
JTree tree = new JTree( new FileSystemTreeModel( "/", null ) ) tree.setCellRenderer( new FileSystemTreeModel.FileSystemTreeCellRenderer() ); tree.addTreeExpansionListener( new FileSystemTreeModel.FileSystemTreeExpansionListener() );
Nested Class Summary | |
static class |
FileSystemTreeModel.FileSystemNode
Because the AbstractFileSystem.children() can be expensive, we cache the results in the FileSystemNode. |
static class |
FileSystemTreeModel.FileSystemTreeCellRenderer
A TreeCellRenderer that uses the icons set
with #setFileIcon . |
static class |
FileSystemTreeModel.FileSystemTreeExpansionListener
A TreeExpansionListener which helps the
TreeModel track what files are visible, so that the
model can make intelligent choices about what files to watch (poll)
for changes. |
static interface |
FileSystemTreeModel.FileSystemTreeFilter
Filter which controls what files are visible in the model. |
Field Summary |
Fields inherited from class ti.swing.treetable.AbstractTreeModel |
listenerList, root |
Constructor Summary | |
FileSystemTreeModel(oscript.fs.AbstractFile root,
FileSystemTreeModel.FileSystemTreeFilter filter)
Class Constructor. |
|
FileSystemTreeModel(java.lang.String path,
FileSystemTreeModel.FileSystemTreeFilter filter)
Class Constructor. |
Method Summary | |
java.lang.Object |
getChild(java.lang.Object parent,
int idx)
|
int |
getChildCount(java.lang.Object parent)
|
static javax.swing.Icon |
getFileIcon(java.lang.String extension)
Get the icon associated with the specified file type. |
static java.lang.String |
getFileInfo(java.lang.String extension)
|
FileSystemTreeModel.FileSystemNode |
getFileSystemNode(oscript.fs.AbstractFile file)
Cached lookup of FileSystemNode |
FileSystemTreeModel.FileSystemNode |
getFileSystemNode(java.lang.String path)
Cached lookup of FileSystemNode |
javax.swing.tree.TreePath |
getTreePath(oscript.fs.AbstractFile file)
Utility to go from AbstractFile to TreePath |
boolean |
isLeaf(java.lang.Object node)
Is the particular node a leaf node? |
protected static oscript.fs.AbstractFile |
pathToFile(java.lang.String path)
utility to go from path to file... |
static void |
setFileInfo(java.lang.String extension,
javax.swing.Icon icon,
java.lang.String info)
Set the icon to draw, and the description of the type, for files of the specified type (as determined by file extension). |
Methods inherited from class ti.swing.treetable.AbstractTreeModel |
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getIndexOfChild, getRoot, removeTreeModelListener, valueForPathChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileSystemTreeModel(java.lang.String path, FileSystemTreeModel.FileSystemTreeFilter filter)
path
- the path to the root node of the treefilter
- the filter, or null
public FileSystemTreeModel(oscript.fs.AbstractFile root, FileSystemTreeModel.FileSystemTreeFilter filter)
root
- the root node of the treefilter
- the filter, or null
Method Detail |
public boolean isLeaf(java.lang.Object node)
AbstractTreeModel
isLeaf
in interface javax.swing.tree.TreeModel
isLeaf
in class AbstractTreeModel
public java.lang.Object getChild(java.lang.Object parent, int idx)
public int getChildCount(java.lang.Object parent)
public FileSystemTreeModel.FileSystemNode getFileSystemNode(java.lang.String path)
public FileSystemTreeModel.FileSystemNode getFileSystemNode(oscript.fs.AbstractFile file)
public static void setFileInfo(java.lang.String extension, javax.swing.Icon icon, java.lang.String info)
extension
- the file type extensionicon
- the icon to display for this file type, or null
info
- an info string describing the file type, or null
public static javax.swing.Icon getFileIcon(java.lang.String extension)
extension
- the file type extension
null
if nonepublic static java.lang.String getFileInfo(java.lang.String extension)
public javax.swing.tree.TreePath getTreePath(oscript.fs.AbstractFile file)
protected static final oscript.fs.AbstractFile pathToFile(java.lang.String path)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |