Package org.jdesktop.swingx.treetable
Class AbstractMutableTreeTableNode
java.lang.Object
org.jdesktop.swingx.treetable.AbstractMutableTreeTableNode
- All Implemented Interfaces:
TreeNode
,MutableTreeTableNode
,TreeTableNode
- Direct Known Subclasses:
DefaultMutableTreeTableNode
AbstractMutableTreeTableNode
provides an implementation of most of
the MutableTreeTableNode
features.- Author:
- Karl Schaefer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
allows children for this nodeprotected final List<MutableTreeTableNode>
List of children, if this node has no children the list will be empty.protected MutableTreeTableNode
this node's parent, or null if this node has no parentprotected Object
optional user object -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty tree table nodeAbstractMutableTreeTableNode
(Object userObject) Creates a tree table node for userObjectAbstractMutableTreeTableNode
(Object userObject, boolean allowsChildren) Creates a tree table node for userObject -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(MutableTreeTableNode child) add a child note to the treeEnumeration<? extends MutableTreeTableNode>
children()
Returns an enumeration this node's children.protected List<MutableTreeTableNode>
Creates the list used to manage the children of this node.boolean
getChildAt
(int childIndex) Overridden to specify the return type.int
int
Overridden to specify the return type.Returns this node's user object.void
insert
(MutableTreeTableNode child, int index) Adds thechild
to this node at the specifiedindex
.boolean
isEditable
(int column) Determines whether the specified column is editable.boolean
isLeaf()
void
remove
(int index) Removes the child node at the specifiedindex
from this node.void
remove
(MutableTreeTableNode node) Removes the specified childnode
from this node.void
Removes this node from it's parent.void
setAllowsChildren
(boolean allowsChildren) Determines whether or not this node is allowed to have children.void
setParent
(MutableTreeTableNode newParent) Sets the parent of this node tonewParent
.void
setUserObject
(Object object) Sets the user object stored in this node.void
setValueAt
(Object aValue, int column) Sets the value for the givencolumn
.toString()
Returns the result of sendingtoString()
to this node's user object, or null if this node has no user object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jdesktop.swingx.treetable.TreeTableNode
getColumnCount, getValueAt
-
Field Details
-
parent
this node's parent, or null if this node has no parent -
children
List of children, if this node has no children the list will be empty. This list will never be null. -
userObject
optional user object -
allowsChildren
protected boolean allowsChildrenallows children for this node
-
-
Constructor Details
-
AbstractMutableTreeTableNode
public AbstractMutableTreeTableNode()Creates an empty tree table node -
AbstractMutableTreeTableNode
Creates a tree table node for userObject- Parameters:
userObject
- optional user object
-
AbstractMutableTreeTableNode
Creates a tree table node for userObject- Parameters:
userObject
- optional user objectallowsChildren
- allows children for this node
-
-
Method Details
-
createChildrenList
Creates the list used to manage the children of this node.This method is called by the constructor.
- Returns:
- a list; this list is guaranteed to be non-
null
-
add
add a child note to the tree- Parameters:
child
- tree table node
-
insert
Adds thechild
to this node at the specifiedindex
. This method callssetParent
onchild
withthis
as the parameter.- Specified by:
insert
in interfaceMutableTreeTableNode
- Parameters:
child
- the node to add as a childindex
- the index of the child
-
remove
public void remove(int index) Removes the child node at the specifiedindex
from this node. This method callssetParent
onchild
with anull
parameter.- Specified by:
remove
in interfaceMutableTreeTableNode
- Parameters:
index
- the index of the child
-
remove
Removes the specified childnode
from this node. This method callssetParent
onchild
with anull
parameter.- Specified by:
remove
in interfaceMutableTreeTableNode
- Parameters:
node
- the index of the child
-
removeFromParent
public void removeFromParent()Removes this node from it's parent. Most implementations will usegetParent().remove(this)
.- Specified by:
removeFromParent
in interfaceMutableTreeTableNode
-
setParent
Sets the parent of this node tonewParent
. This methods remove the node from its old parent.- Specified by:
setParent
in interfaceMutableTreeTableNode
- Parameters:
newParent
- the new parent for this node
-
getUserObject
Returns this node's user object.- Specified by:
getUserObject
in interfaceTreeTableNode
- Returns:
- the Object stored at this node by the user
- See Also:
-
setUserObject
Sets the user object stored in this node.- Specified by:
setUserObject
in interfaceTreeTableNode
- Parameters:
object
- the object to store
-
getChildAt
Overridden to specify the return type. Returns the childTreeNode
at indexchildIndex
. Models that utilize this node should verify the column count before querying this node, since nodes may return differing sizes even for the same model.- Specified by:
getChildAt
in interfaceTreeNode
- Specified by:
getChildAt
in interfaceTreeTableNode
- Parameters:
childIndex
- the index of the child- Returns:
- the
TreeTableNode
corresponding to the specified index
-
getIndex
-
getParent
Overridden to specify the return type. Returns the parentTreeTableNode
of the receiver.- Specified by:
getParent
in interfaceTreeNode
- Specified by:
getParent
in interfaceTreeTableNode
- Returns:
- the parent
TreeTableNode
ornull
if this node has no parent (such nodes are usually root nodes).
-
children
Returns an enumeration this node's children.- Specified by:
children
in interfaceMutableTreeTableNode
- Specified by:
children
in interfaceTreeNode
- Specified by:
children
in interfaceTreeTableNode
- Returns:
- an enumeration of
MutableTreeTableNode
s
-
getAllowsChildren
public boolean getAllowsChildren()- Specified by:
getAllowsChildren
in interfaceTreeNode
-
setAllowsChildren
public void setAllowsChildren(boolean allowsChildren) Determines whether or not this node is allowed to have children. IfallowsChildren
isfalse
, all of this node's children are removed.Note: By default, a node allows children.
- Parameters:
allowsChildren
-true
if this node is allowed to have children
-
getChildCount
public int getChildCount()- Specified by:
getChildCount
in interfaceTreeNode
-
isLeaf
public boolean isLeaf() -
isEditable
public boolean isEditable(int column) Determines whether the specified column is editable.- Specified by:
isEditable
in interfaceTreeTableNode
- Parameters:
column
- the column to query- Returns:
- always returns
false
-
setValueAt
Sets the value for the givencolumn
.impl does nothing. It is provided for convenience.
- Specified by:
setValueAt
in interfaceTreeTableNode
- Parameters:
aValue
- the value to setcolumn
- the column to set the value on
-
toString
Returns the result of sendingtoString()
to this node's user object, or null if this node has no user object.
-