public class FileSystemModel extends AbstractTreeTableModel
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.
modelSupport, root| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
addTreeModelListener, getHierarchicalColumn, getTreeModelListeners, isCellEditable, removeTreeModelListener, setValueAt, valueForPathChangedpublic FileSystemModel()
public FileSystemModel(File root)
root.root - the root for this model; this may be different than the root
directory for a file system.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 TreeTableModelgetColumnClass in class AbstractTreeTableModelcolumn - the index of the columnTableModel.getColumnClass(int)public int getColumnCount()
TreeTableModelJXTreeTable uses
this method to determine how many columns it should create and display by
default.TableModel.getColumnCount()public String getColumnName(int column)
AbstractTreeTableModelcolumnIndex. 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 TreeTableModelgetColumnName in class AbstractTreeTableModelcolumn - the index of the columnTableModel.getColumnName(int)public Object getValueAt(Object node, int column)
TreeTableModelnode 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 queriedTreeTableModel.setValueAt(java.lang.Object, java.lang.Object, int),
TableModel.getValueAt(int, int)public File getRoot()
getRoot in interface TreeModelgetRoot in class AbstractTreeTableModelpublic void setRoot(File root)
root - the new root node to setpublic boolean isLeaf(Object node)
true if node is a leaf.isLeaf in interface TreeModelisLeaf in class AbstractTreeTableModelnode - a node in the tree, obtained from this data sourcenode is a leafCopyright © 2017. All Rights Reserved.