com.guiseframework.model
Interface TreeNodeModel<V>

Type Parameters:
V - The type of value contained in the tree node.
All Superinterfaces:
ActionListenable, ActionModel, java.lang.Iterable<TreeNodeModel<?>>, Model, com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Selectable, Valued<V>, ValueModel<V>
All Known Subinterfaces:
RDFObjectTreeNodeModel<V>
All Known Implementing Classes:
AbstractRDFResourceTreeNodeModel, AbstractURFDynamicTreeNodeModel, DefaultTreeNodeModel, DummyTreeNodeModel, DynamicTreeNodeModel, RDFLiteralTreeNodeModel, RDFResourceTreeNodeModel, URFDynamicTreeNodeModel, URFResourceDynamicTreeNodeModel

public interface TreeNodeModel<V>
extends ActionModel, ValueModel<V>, Selectable, java.lang.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
static java.lang.String EXPANDED_PROPERTY
          The expanded bound property.
 
Fields inherited from interface com.guiseframework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
 
Fields inherited from interface com.guiseframework.model.Model
PLAIN_TEXT_CONTENT_TYPE, XHTML_CONTENT_TYPE, XHTML_FRAGMENT_CONTENT_TYPE
 
Fields inherited from interface com.guiseframework.model.Selectable
SELECTED_PROPERTY
 
Method Summary
 void 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.
 TreeNodeModel<?> getParent()
           
 boolean hasChild(TreeNodeModel<?> treeNode)
          Determines whether this tree node contains the given child tree node.
 boolean hasChildren()
           
 boolean isExpanded()
           
 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 com.guiseframework.model.ActionModel
getActionListeners, performAction, performAction
 
Methods inherited from interface com.guiseframework.event.ActionListenable
addActionListener, removeActionListener
 
Methods inherited from interface com.guiseframework.model.ValueModel
clearValue, getDefaultValue, getValidator, getValue, getValueClass, isValidValue, resetValue, setValidator, setValue, validateValue
 
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 com.guiseframework.model.Selectable
isSelected, setSelected
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

EXPANDED_PROPERTY

static final java.lang.String EXPANDED_PROPERTY
The expanded bound property.

Method Detail

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 type Boolean.

Parameters:
newExpanded - true if the node is expanded.
See Also:
EXPANDED_PROPERTY

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, or false if they should be collapsed.
See Also:
setExpanded(boolean)

isLeaf

boolean isLeaf()
Determines whether this node could be considered a leaf node. This method may return false 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, else false 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

boolean hasChild(TreeNodeModel<?> treeNode)
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

void add(TreeNodeModel<?> treeNode)
Adds a child tree node to this tree node.

Parameters:
treeNode - The tree node to add.
Throws:
java.lang.IllegalArgumentException - if the tree node already has a parent.

remove

void remove(TreeNodeModel<?> treeNode)
Removes a child tree node from this tree node.

Parameters:
treeNode - The child tree node to remove.
Throws:
java.lang.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

void setParent(TreeNodeModel<?> newParent)
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, or null if this tree node is being removed from a parent.
Throws:
java.lang.IllegalStateException - if a parent is provided and this tree node already has a parent.
java.lang.IllegalStateException - if no parent is provided and this tree node's old parent still recognizes this tree node as its child.
java.lang.IllegalArgumentException - if a parent is provided and the given parent does not already recognize this tree node as its child.
See Also:
add(TreeNodeModel), remove(TreeNodeModel)

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.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.