Package io.guise.framework.model
Interface TreeNodeModel<V>
- Type Parameters:
V
- The type of value contained in the tree node.
- All Superinterfaces:
ActionListenable
,ActionModel
,Iterable<TreeNodeModel<?>>
,Model
,com.globalmentor.model.MutableValued<V>
,com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,Selectable
,com.globalmentor.model.Valued<V>
,ValueModel<V>
- All Known Implementing Classes:
DefaultTreeNodeModel
,DummyTreeNodeModel
,DynamicTreeNodeModel
public interface TreeNodeModel<V>
extends ActionModel, ValueModel<V>, Selectable, Iterable<TreeNodeModel<?>>
A node in a tree model. Property change events and action events on one tree node will be bubbled up the hierarchy, with the tree node initiating the event
accessible via
TargetedEvent.getTarget()
.- Author:
- Garret Wilson
-
Field Summary
Fields inherited from interface io.guise.framework.model.Selectable
SELECTED_PROPERTY
Fields inherited from interface io.guise.framework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(TreeNodeModel<?> treeNode) Adds a child tree node to this tree node.void
clear()
Removes all of the child tree nodes from this tree node.int
getDepth()
Returns the zero-based depth of the node within in its tree.boolean
hasChild
(TreeNodeModel<?> treeNode) Determines whether this tree node contains the given child tree node.boolean
boolean
boolean
isLeaf()
Determines whether this node could be considered a leaf node.void
remove
(TreeNodeModel<?> treeNode) Removes a child tree node from this tree node.void
setAllExpanded
(boolean newAllExpanded) Sets whether all tree nodes, including this node, are expanded in this subtree.void
setExpanded
(boolean newExpanded) Sets whether the node is expanded, showing its children, if any.void
setParent
(TreeNodeModel<?> newParent) Sets the parent of this tree node.Methods inherited from interface io.guise.framework.event.ActionListenable
addActionListener, removeActionListener
Methods inherited from interface io.guise.framework.model.ActionModel
getActionListeners, performAction, performAction
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
Methods inherited from interface io.guise.framework.model.Selectable
isSelected, setSelected
Methods inherited from interface io.guise.framework.model.ValueModel
clearValue, getDefaultValue, getValidator, getValue, getValueClass, isValidValue, resetValue, setValidator, setValue, validateValue
-
Field Details
-
EXPANDED_PROPERTY
The expanded bound property.
-
-
Method Details
-
isExpanded
boolean isExpanded()- Returns:
- Whether the node is expanded, showing its children, if any.
-
setExpanded
void setExpanded(boolean newExpanded) Sets whether the node is expanded, showing its children, if any. This is a bound property of typeBoolean
.- Parameters:
newExpanded
-true
if the node is expanded.- See Also:
-
setAllExpanded
void setAllExpanded(boolean newAllExpanded) Sets whether all tree nodes, including this node, are expanded in this subtree.- Parameters:
newAllExpanded
-true
if all the nodes in this tree should be expanded, orfalse
if they should be collapsed.- See Also:
-
isLeaf
boolean isLeaf()Determines whether this node could be considered a leaf node. This method may returnfalse
even if it currently has no children, if it intends to load them later and there is no way to know ahead of time if there will be children.- Returns:
true
if this is a leaf node, elsefalse
if this node should not be considered a leaf.
-
hasChildren
boolean hasChildren()- Returns:
- Whether this tree node has children. This implementation delegates to the tree node list.
-
hasChild
Determines whether this tree node contains the given child tree node.- Parameters:
treeNode
- The tree node to check.- Returns:
true
if this tree node contains the given tree node.
-
add
Adds a child tree node to this tree node.- Parameters:
treeNode
- The tree node to add.- Throws:
IllegalArgumentException
- if the tree node already has a parent.
-
remove
Removes a child tree node from this tree node.- Parameters:
treeNode
- The child tree node to remove.- Throws:
IllegalArgumentException
- if the tree node is not a child of this tree node.
-
clear
void clear()Removes all of the child tree nodes from this tree node. -
getParent
TreeNodeModel<?> getParent()- Returns:
- The parent of this node, or
null
if this node has no parent.
-
setParent
Sets the parent of this tree node. This method is managed by other tree nodes, and normally should not be called by applications. A tree node cannot be given a parent if it already has a parent. A tree node's parent cannot be removed this component is still a child of that parent. A tree node's parent cannot be set unless that parent already recognizes this tree node as one of its children. If a tree node is given the same parent it already has, no action occurs.- Parameters:
newParent
- The new parent for this tree node, ornull
if this tree node is being removed from a parent.- Throws:
IllegalStateException
- if a parent is provided and this tree node already has a parent.IllegalStateException
- if no parent is provided and this tree node's old parent still recognizes this tree node as its child.IllegalArgumentException
- if a parent is provided and the given parent does not already recognize this tree node as its child.- See Also:
-
getDepth
int getDepth()Returns the zero-based depth of the node within in its tree. This result represents the number of levels above this node needed to reach the root node.- Returns:
- The zero-based depth of this node from the root.
-