|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.treetable.AbstractTreeTableModel
org.jdesktop.swingx.treetable.FileSystemModel
public class FileSystemModel
A tree table model to simulate a file system.
This tree table model implementation extends AbstractTreeTableModel
.
The file system metaphor demonstrates that it is often easier to directly
implement tree structures directly instead of using intermediaries, such as
TreeTableNode
.
A comparison of this class with SimpleFileSystemModel
, shows that
extending AbstractTreeTableModel
is often easier than creating a model
from scratch.
A "full" version of this model might allow editing of file names, the deletion of files, and the movement of files. This simple implementation does not intend to tackle such problems, but this implementation may be extended to handle such details.
Field Summary |
---|
Fields inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel |
---|
modelSupport, root |
Constructor Summary | |
---|---|
FileSystemModel()
Creates a file system model using the root directory as the model root. |
|
FileSystemModel(File root)
Creates a file system model using the specified root . |
Method Summary | |
---|---|
File |
getChild(Object parent,
int index)
Returns the child of parent at index index
in the parent's
child array. |
int |
getChildCount(Object parent)
Returns the number of children of parent . |
Class<?> |
getColumnClass(int column)
Returns the most specific superclass for all the cell values in the column. |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int column)
Returns the name of the column at columnIndex . |
int |
getIndexOfChild(Object parent,
Object child)
Returns the index of child in parent. |
File |
getRoot()
Returns the root of the tree. |
Object |
getValueAt(Object node,
int column)
Returns the value for the node at columnIndex . |
boolean |
isLeaf(Object node)
Returns true if node is a leaf. |
void |
setRoot(File root)
Sets the root for this tree table model. |
Methods inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel |
---|
addTreeModelListener, getHierarchicalColumn, getTreeModelListeners, isCellEditable, removeTreeModelListener, setValueAt, valueForPathChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileSystemModel()
public FileSystemModel(File root)
root
.
root
- the root for this model; this may be different than the root
directory for a file system.Method Detail |
---|
public File getChild(Object parent, int index)
parent
at index index
in the parent's
child array. parent
must be a node previously obtained
from this data source. This should not return null
if index
is a valid index for parent
(that is index >= 0 &&
index < getChildCount(parent
)).
parent
- a node in the tree, obtained from this data source
parent
at index index
public int getChildCount(Object parent)
parent
.
Returns 0 if the node
is a leaf or if it has no children. parent
must be a node
previously obtained from this data source.
parent
- a node in the tree, obtained from this data source
parent
public Class<?> getColumnClass(int column)
JXTreeTable
to set up a default
renderer and editor for the column.
getColumnClass
in interface TreeTableModel
getColumnClass
in class AbstractTreeTableModel
column
- the index of the column
TableModel.getColumnClass(int)
public int getColumnCount()
TreeTableModel
JXTreeTable
uses
this method to determine how many columns it should create and display by
default.
TableModel.getColumnCount()
public String getColumnName(int column)
AbstractTreeTableModel
columnIndex
. This is used to
initialize the table's column header name. Note: this name does not need
to be unique; two columns in a table can have the same name.
getColumnName
in interface TreeTableModel
getColumnName
in class AbstractTreeTableModel
column
- the index of the column
TableModel.getColumnName(int)
public Object getValueAt(Object node, int column)
TreeTableModel
node
at columnIndex
. The
node
must be managed by this model. Unamanaged nodes should throw
an IllegalArgumentException
.
node
- the node whose value is to be queriedcolumn
- the column whose value is to be queried
TreeTableModel.setValueAt(java.lang.Object, java.lang.Object, int)
,
TableModel.getValueAt(int, int)
public int getIndexOfChild(Object parent, Object child)
parent
or child
is null
, returns -1.
If either parent
or child
don't
belong to this tree model, returns -1.
parent
- a note in the tree, obtained from this data sourcechild
- the node we are interested in
child
or parent
are null
or don't belong to this tree modelpublic File getRoot()
null
only if the tree has no nodes.
getRoot
in interface TreeModel
getRoot
in class AbstractTreeTableModel
public void setRoot(File root)
root
- the new root node to setpublic boolean isLeaf(Object node)
true
if node
is a leaf.
isLeaf
in interface TreeModel
isLeaf
in class AbstractTreeTableModel
node
- a node in the tree, obtained from this data source
node
is a leaf
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |