|
||||||||||
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.DefaultTreeTableModel
public class DefaultTreeTableModel
DefaultTreeTableModel
is a concrete implementation of
AbstractTreeTableModel
and is provided purely as a convenience.
Applications that use JXTreeTable
are expected to provide their own
implementation of a TreeTableModel
, perhaps by extending this class.
Field Summary | |
---|---|
protected Vector |
columnIdentifiers
The Vector of column identifiers. |
Fields inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel |
---|
hierarchicalColumnClass, modelSupport, root |
Constructor Summary | |
---|---|
DefaultTreeTableModel()
Creates a new DefaultTreeTableModel with a null root. |
|
DefaultTreeTableModel(TreeTableNode root)
Creates a new DefaultTreeTableModel with the specified
root . |
|
DefaultTreeTableModel(TreeTableNode root,
Vector columnNames)
Creates a new DefaultTreeTableModel with the specified
root . |
Method Summary | |
---|---|
Object |
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 . |
int |
getColumnCount()
Returns the number of columns in the model. |
String |
getColumnName(int column)
Returns the name of the column at 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. |
int |
getIndexOfChild(Object parent,
Object child)
Returns the index of child in parent. |
TreeTableNode[] |
getPathToRoot(TreeTableNode aNode)
Gets the path from the root to the specified node. |
TreeTableNode |
getRoot()
Returns the root of the tree. |
Object |
getValueAt(Object node,
int column)
Gets the value for the node at column . |
void |
insertNodeInto(MutableTreeTableNode newChild,
MutableTreeTableNode parent,
int index)
Invoked this to insert newChild at location index in parents children. |
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 |
removeNodeFromParent(MutableTreeTableNode node)
Message this to remove node from its parent. |
void |
setColumnIdentifiers(Vector columnIdentifiers)
Replaces the column identifiers in the model. |
void |
setRoot(TreeTableNode root)
|
void |
setValueAt(Object value,
Object node,
int column)
Sets the value for the node at columnIndex to
value . |
Methods inherited from class org.jdesktop.swingx.treetable.AbstractTreeTableModel |
---|
addTreeModelListener, getColumnClass, getHierarchicalColumn, getTreeModelListeners, removeTreeModelListener, valueForPathChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Vector columnIdentifiers
Vector
of column identifiers.
Constructor Detail |
---|
public DefaultTreeTableModel()
DefaultTreeTableModel
with a null
root.
public DefaultTreeTableModel(TreeTableNode root)
DefaultTreeTableModel
with the specified
root
. asksAllowsChildren
is disabled and isLeaf
will provide the same semantics as AbstractTreeTableModel.isLeaf
.
root
- the root node of the treepublic DefaultTreeTableModel(TreeTableNode root, Vector columnNames)
DefaultTreeTableModel
with the specified
root
. asksAllowsChildren
is disabled and isLeaf
will provide the same semantics as AbstractTreeTableModel.isLeaf
.
root
- the root node of the treeMethod Detail |
---|
public void setColumnIdentifiers(Vector columnIdentifiers)
newIdentifier
s is greater than the current number
of columns, new columns are added to the end of each row in the model.
If the number of newIdentifier
s is less than the current
number of columns, all the extra columns at the end of a row are
discarded.
columnIdentifiers
- vector of column identifiers. If
null
, set the model
to zero columnspublic TreeTableNode getRoot()
null
only if the tree has
no nodes.
getRoot
in interface TreeModel
getRoot
in class AbstractTreeTableModel
ClassCastException
- if root
is not a TreeTableNode
. Even though
subclasses have direct access to root
, they should
avoid accessing it directly.AbstractTreeTableModel.root
,
setRoot(TreeTableNode)
public Object getValueAt(Object node, int column)
node
at column
.
node
- the node whose value is to be queriedcolumn
- the column whose value is to be queried
IllegalArgumentException
- if node
is not an instance of TreeTableNode
or is not managed by this model, or column
is not a
valid column indexTreeTableModel.setValueAt(java.lang.Object, java.lang.Object, int)
,
TableModel.getValueAt(int, int)
public void setValueAt(Object value, Object node, int column)
AbstractTreeTableModel
node
at columnIndex
to
value
.
setValueAt
in interface TreeTableModel
setValueAt
in class AbstractTreeTableModel
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)
,
AbstractTreeTableModel.isCellEditable(java.lang.Object, int)
,
TableModel.setValueAt(Object, int, int)
public int getColumnCount()
JXTreeTable
uses
this method to determine how many columns it should create and display by
default.
TableModel.getColumnCount()
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
getColumnName
in class AbstractTreeTableModel
column
- the index of the column
TableModel.getColumnName(int)
public Object 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 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 boolean isCellEditable(Object node, int column)
AbstractTreeTableModel
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
isCellEditable
in class AbstractTreeTableModel
node
- the node whose value to be queriedcolumn
- the column whose value to be queried
TreeTableModel.setValueAt(java.lang.Object, java.lang.Object, int)
,
TableModel.isCellEditable(int, int)
public 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 leafpublic TreeTableNode[] getPathToRoot(TreeTableNode aNode)
aNode
- the node to query
TreeTableNode
s, where
arr[0].equals(getRoot())
and
arr[arr.length - 1].equals(aNode)
, or an empty array if
the node is not found.
NullPointerException
- if aNode
is null
public void setRoot(TreeTableNode root)
public void insertNodeInto(MutableTreeTableNode newChild, MutableTreeTableNode parent, int index)
public void removeNodeFromParent(MutableTreeTableNode node)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |