Package adams.gui.core
Class LazyExpansionTreeNode
- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- adams.gui.core.BaseTreeNode
-
- adams.gui.core.LazyExpansionTreeNode
-
- All Implemented Interfaces:
Transferable
,Serializable
,Cloneable
,MutableTreeNode
,TreeNode
- Direct Known Subclasses:
Node
public abstract class LazyExpansionTreeNode extends BaseTreeNode
Allows for lazy expansion of a node's sub-tree.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_ExpansionOccurred
whether the tree node has been expanded before.-
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
-
-
Constructor Summary
Constructors Constructor Description LazyExpansionTreeNode()
Creates a tree node that has no parent and no children, but which allows children.LazyExpansionTreeNode(Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.LazyExpansionTreeNode(Object userObject, boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canExpand()
Returns whether the node can be expanded at all.boolean
collapse()
Collapses the node and removes all children, resetting the node.protected abstract boolean
doExpand()
Expands this node.protected abstract void
doReset()
Resets the node.boolean
expand()
Expands the node, if not yet occurred.void
expandOrReexpandIfNecessary()
Expands or e-expands the node if necessary.boolean
getExpansionOccurred()
Returns whether the expansion has already occurred.void
reexpand()
Re-expands the node.boolean
requiresReexpand()
Returns whether the node requires reexpanding.void
reset()
Resets the node.void
setExpansionOccurred(boolean value)
Sets whether the expansion has already occurred.-
Methods inherited from class adams.gui.core.BaseTreeNode
getChildren, getTransferData, getTransferDataFlavors, isDataFlavorSupported, toPlainText, toTransferable
-
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
-
-
-
-
Constructor Detail
-
LazyExpansionTreeNode
public LazyExpansionTreeNode()
Creates a tree node that has no parent and no children, but which allows children.
-
LazyExpansionTreeNode
public LazyExpansionTreeNode(Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.- Parameters:
userObject
- an Object provided by the user that constitutes the node's data
-
LazyExpansionTreeNode
public LazyExpansionTreeNode(Object userObject, boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.- Parameters:
userObject
- an Object provided by the user that constitutes the node's dataallowsChildren
- if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node
-
-
Method Detail
-
setExpansionOccurred
public void setExpansionOccurred(boolean value)
Sets whether the expansion has already occurred.- Parameters:
value
- true if the expansion has already occurred.
-
getExpansionOccurred
public boolean getExpansionOccurred()
Returns whether the expansion has already occurred.- Returns:
- true if the expansion has already occurred
-
canExpand
public boolean canExpand()
Returns whether the node can be expanded at all.
Default implementation returns false.- Returns:
- true if it can be expanded
-
doExpand
protected abstract boolean doExpand()
Expands this node.- Returns:
- true if structure below this node was changed
-
expand
public boolean expand()
Expands the node, if not yet occurred.- Returns:
- true if structure below node was changed
- See Also:
doExpand()
-
requiresReexpand
public boolean requiresReexpand()
Returns whether the node requires reexpanding.
Default implementation returns false.- Returns:
- true if it needs to be reexpanded
-
reset
public void reset()
Resets the node.- See Also:
doReset()
-
doReset
protected abstract void doReset()
Resets the node.
-
collapse
public boolean collapse()
Collapses the node and removes all children, resetting the node.- Returns:
- true if sub-tree was changed
-
reexpand
public void reexpand()
Re-expands the node.- See Also:
collapse()
,reset()
,expand()
-
expandOrReexpandIfNecessary
public void expandOrReexpandIfNecessary()
Expands or e-expands the node if necessary.- See Also:
expand()
,reexpand()
-
-