Package org.jdesktop.swingx.treetable
Class AbstractMutableTreeTableNode
- java.lang.Object
-
- org.jdesktop.swingx.treetable.AbstractMutableTreeTableNode
-
- All Implemented Interfaces:
javax.swing.tree.TreeNode,MutableTreeTableNode,TreeTableNode
- Direct Known Subclasses:
DefaultMutableTreeTableNode
public abstract class AbstractMutableTreeTableNode extends java.lang.Object implements MutableTreeTableNode
AbstractMutableTreeTableNodeprovides an implementation of most of theMutableTreeTableNodefeatures.- Author:
- Karl Schaefer
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowsChildrenprotected java.util.List<MutableTreeTableNode>childrenList of children, if this node has no children the list will be empty.protected MutableTreeTableNodeparentthis node's parent, or null if this node has no parentprotected java.lang.ObjectuserObjectoptional user object
-
Constructor Summary
Constructors Constructor Description AbstractMutableTreeTableNode()AbstractMutableTreeTableNode(java.lang.Object userObject)AbstractMutableTreeTableNode(java.lang.Object userObject, boolean allowsChildren)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(MutableTreeTableNode child)java.util.Enumeration<? extends MutableTreeTableNode>children()Returns an enumeration this node's children.protected java.util.List<MutableTreeTableNode>createChildrenList()Creates the list used to manage the children of this node.booleangetAllowsChildren()TreeTableNodegetChildAt(int childIndex)Overridden to specify the return type.intgetChildCount()intgetIndex(javax.swing.tree.TreeNode node)TreeTableNodegetParent()Overridden to specify the return type.java.lang.ObjectgetUserObject()Returns this node's user object.voidinsert(MutableTreeTableNode child, int index)Adds thechildto this node at the specifiedindex.booleanisEditable(int column)Determines whether the specified column is editable.booleanisLeaf()voidremove(int index)Removes the child node at the specifiedindexfrom this node.voidremove(MutableTreeTableNode node)Removes the specified childnodefrom this node.voidremoveFromParent()Removes this node from it's parent.voidsetAllowsChildren(boolean allowsChildren)Determines whether or not this node is allowed to have children.voidsetParent(MutableTreeTableNode newParent)Sets the parent of this node tonewParent.voidsetUserObject(java.lang.Object object)Sets the user object stored in this node.voidsetValueAt(java.lang.Object aValue, int column)Sets the value for the givencolumn.java.lang.StringtoString()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 Detail
-
parent
protected MutableTreeTableNode parent
this node's parent, or null if this node has no parent
-
children
protected final java.util.List<MutableTreeTableNode> children
List of children, if this node has no children the list will be empty. This list will never be null.
-
userObject
protected transient java.lang.Object userObject
optional user object
-
allowsChildren
protected boolean allowsChildren
-
-
Method Detail
-
createChildrenList
protected java.util.List<MutableTreeTableNode> 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
public void add(MutableTreeTableNode child)
-
insert
public void insert(MutableTreeTableNode child, int index)
Adds thechildto this node at the specifiedindex. This method callssetParentonchildwiththisas the parameter.- Specified by:
insertin 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 specifiedindexfrom this node. This method callssetParentonchildwith anullparameter.- Specified by:
removein interfaceMutableTreeTableNode- Parameters:
index- the index of the child
-
remove
public void remove(MutableTreeTableNode node)
Removes the specified childnodefrom this node. This method callssetParentonchildwith anullparameter.- Specified by:
removein 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:
removeFromParentin interfaceMutableTreeTableNode
-
setParent
public void setParent(MutableTreeTableNode newParent)
Sets the parent of this node tonewParent. This methods remove the node from its old parent.- Specified by:
setParentin interfaceMutableTreeTableNode- Parameters:
newParent- the new parent for this node
-
getUserObject
public java.lang.Object getUserObject()
Returns this node's user object.- Specified by:
getUserObjectin interfaceTreeTableNode- Returns:
- the Object stored at this node by the user
- See Also:
setUserObject(java.lang.Object),toString()
-
setUserObject
public void setUserObject(java.lang.Object object)
Sets the user object stored in this node.- Specified by:
setUserObjectin interfaceTreeTableNode- Parameters:
object- the object to store
-
getChildAt
public TreeTableNode getChildAt(int childIndex)
Overridden to specify the return type. Returns the childTreeNodeat 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:
getChildAtin interfacejavax.swing.tree.TreeNode- Specified by:
getChildAtin interfaceTreeTableNode- Parameters:
childIndex- the index of the child- Returns:
- the
TreeTableNodecorresponding to the specified index
-
getIndex
public int getIndex(javax.swing.tree.TreeNode node)
- Specified by:
getIndexin interfacejavax.swing.tree.TreeNode
-
getParent
public TreeTableNode getParent()
Overridden to specify the return type. Returns the parentTreeTableNodeof the receiver.- Specified by:
getParentin interfacejavax.swing.tree.TreeNode- Specified by:
getParentin interfaceTreeTableNode- Returns:
- the parent
TreeTableNodeornullif this node has no parent (such nodes are usually root nodes).
-
children
public java.util.Enumeration<? extends MutableTreeTableNode> children()
Returns an enumeration this node's children.- Specified by:
childrenin interfaceMutableTreeTableNode- Specified by:
childrenin interfacejavax.swing.tree.TreeNode- Specified by:
childrenin interfaceTreeTableNode- Returns:
- an enumeration of
TreeTableNodes
-
getAllowsChildren
public boolean getAllowsChildren()
- Specified by:
getAllowsChildrenin interfacejavax.swing.tree.TreeNode
-
setAllowsChildren
public void setAllowsChildren(boolean allowsChildren)
Determines whether or not this node is allowed to have children. IfallowsChildrenisfalse, all of this node's children are removed.Note: By default, a node allows children.
- Parameters:
allowsChildren-trueif this node is allowed to have children
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfacejavax.swing.tree.TreeNode
-
isLeaf
public boolean isLeaf()
- Specified by:
isLeafin interfacejavax.swing.tree.TreeNode
-
isEditable
public boolean isEditable(int column)
Determines whether the specified column is editable.- Specified by:
isEditablein interfaceTreeTableNode- Parameters:
column- the column to query- Returns:
- always returns
false
-
setValueAt
public void setValueAt(java.lang.Object aValue, int column)Sets the value for the givencolumn.- Specified by:
setValueAtin interfaceTreeTableNode- Parameters:
aValue- the value to setcolumn- the column to set the value on
-
toString
public java.lang.String toString()
Returns the result of sendingtoString()to this node's user object, or null if this node has no user object.- Overrides:
toStringin classjava.lang.Object- See Also:
getUserObject()
-
-