|
swingx Version 2009-07-31 |
|||||||||
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)
|
int |
getChildCount(Object 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)
|
File |
getRoot()
|
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)
public int getChildCount(Object 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)
public File getRoot()
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
|
swingx Version 2009-07-31 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |