public abstract class AbstractTreeTableModel extends Object implements TreeTableModel
TreeTableModel
as a convenient starting
point in defining custom data models for
JXTreeTable
. It takes care of listener
management and contains convenience methods for creating and dispatching
TreeModelEvent
s. To create a concreate instance of
TreeTableModel
you need only to provide implementations for the
following methods:
public int getColumnCount(); public Object getValueAt(Object node, int column); public Object getChild(Object parent, int index); public int getChildCount(Object parent); public int getIndexOfChild(Object parent, Object child); public boolean isLeaf(Object node);
Modifier and Type | Field and Description |
---|---|
protected TreeModelSupport |
modelSupport
Provides support for event dispatching.
|
protected Object |
root
Root node of the model
|
Constructor and Description |
---|
AbstractTreeTableModel()
Constructs an
AbstractTreeTableModel with a null root
node. |
AbstractTreeTableModel(Object root)
Constructs an
AbstractTreeTableModel with the specified root
node. |
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener l) |
Class<?> |
getColumnClass(int column)
Returns the most specific superclass for all the cell values in the
column.
|
String |
getColumnName(int column)
Returns the name of the column at
columnIndex . |
int |
getHierarchicalColumn()
Returns the column that is the "tree" column.
|
Object |
getRoot() |
TreeModelListener[] |
getTreeModelListeners()
Returns an array of all the
TreeModelListener s added
to this JXTreeTable with addTreeModelListener(). |
boolean |
isCellEditable(Object node,
int column)
Returns true if the cell for the
node at columnIndex is
editable. |
boolean |
isLeaf(Object node)
Returns
true if node is a leaf. |
void |
removeTreeModelListener(TreeModelListener l) |
void |
setValueAt(Object value,
Object node,
int column)
Sets the value for the
node at columnIndex to
value . |
void |
valueForPathChanged(TreePath path,
Object newValue)
Called when value for the item identified by path has been changed.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getColumnCount, getValueAt
getChild, getChildCount, getIndexOfChild
protected TreeModelSupport modelSupport
public AbstractTreeTableModel()
AbstractTreeTableModel
with a null
root
node.public AbstractTreeTableModel(Object root)
AbstractTreeTableModel
with the specified root
node.root
- root nodepublic Class<?> getColumnClass(int column)
JXTreeTable
to set up a default
renderer and editor for the column.getColumnClass
in interface TreeTableModel
column
- the index of the columnTableModel.getColumnClass(int)
public String getColumnName(int column)
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
column
- the index of the columnTableModel.getColumnName(int)
public int getHierarchicalColumn()
getHierarchicalColumn
in interface TreeTableModel
public boolean isCellEditable(Object node, int column)
node
at columnIndex
is
editable. Otherwise, setValueAt
on the cell will not change the
value of that cell. The node
must be managed by this model.
Unamanaged nodes should throw an IllegalArgumentException
.isCellEditable
in interface TreeTableModel
node
- the node whose value to be queriedcolumn
- the column whose value to be queriedTreeTableModel.setValueAt(java.lang.Object, java.lang.Object, int)
,
TableModel.isCellEditable(int, int)
public void setValueAt(Object value, Object node, int column)
node
at columnIndex
to
value
.setValueAt
in interface TreeTableModel
value
- the new valuenode
- the node whose value is to be changedcolumn
- the column whose value is to be changedTreeTableModel.getValueAt(java.lang.Object, int)
,
isCellEditable(java.lang.Object, int)
,
TableModel.setValueAt(Object, int, int)
public void valueForPathChanged(TreePath path, Object newValue)
treeNodesChanged
event.
valueForPathChanged
in interface TreeModel
path
- path to the node that has changednewValue
- the new value from the TreeCellEditor
public void addTreeModelListener(TreeModelListener l)
addTreeModelListener
in interface TreeModel
public void removeTreeModelListener(TreeModelListener l)
removeTreeModelListener
in interface TreeModel
public TreeModelListener[] getTreeModelListeners()
TreeModelListener
s added
to this JXTreeTable with addTreeModelListener().TreeModelListener
s added or an empty
array if no listeners have been addedWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses