com.guiseframework.model
Class DynamicTreeNodeModel<V>

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.model.AbstractModel
          extended by com.guiseframework.model.AbstractValueModel<V>
              extended by com.guiseframework.model.DefaultValueModel<V>
                  extended by com.guiseframework.model.DefaultTreeNodeModel<V>
                      extended by com.guiseframework.model.DynamicTreeNodeModel<V>
Type Parameters:
V - The type of value contained in the tree node.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, ActionListenable, ActionModel, Model, Selectable, TreeNodeModel<V>, Valued<V>, ValueModel<V>, java.lang.Iterable<TreeNodeModel<?>>
Direct Known Subclasses:
AbstractRDFResourceTreeNodeModel, AbstractURFDynamicTreeNodeModel

public abstract class DynamicTreeNodeModel<V>
extends DefaultTreeNodeModel<V>

A node in a tree model that can dynamically load its children when needed.

Child classes must override determineLeaf() and #determineChildNodes().

Property change events on one tree node will be bubbled up the hierarchy, with the source indicating the tree node on which the property change occurred.

Author:
Garret Wilson

Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.guiseframework.model.TreeNodeModel
EXPANDED_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
 
Constructor Summary
DynamicTreeNodeModel(java.lang.Class<V> valueClass)
          Constructs a tree node model indicating the type of value it can hold.
DynamicTreeNodeModel(java.lang.Class<V> valueClass, V initialValue)
          Constructs a tree node model indicating the type of value it can hold, along with an initial value.
 
Method Summary
 void clear()
          Removes all of the child tree nodes from this tree node.
protected abstract  java.util.List<TreeNodeModel<?>> determineChildren()
          Dynamically determines children.
protected abstract  boolean determineLeaf()
          Dynamically determines whether this node is a leaf.
 boolean isLeaf()
          Returns whether this node could be considered a leaf node.
 void setExpanded(boolean newExpanded)
          Sets whether the node is expanded, showing its children, if any.
 
Methods inherited from class com.guiseframework.model.DefaultTreeNodeModel
add, addActionListener, fireActionPerformed, fireActionPerformed, getActionListeners, getChildren, getDepth, getParent, getTreeNodeList, hasChild, hasChildren, isExpanded, isSelected, iterator, performAction, performAction, remove, removeActionListener, setAllExpanded, setChildren, setParent, setSelected
 
Methods inherited from class com.guiseframework.model.DefaultValueModel
clearValue, getDefaultValue, getValue, resetValue, setValue
 
Methods inherited from class com.guiseframework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
 
Methods inherited from class com.guiseframework.model.AbstractModel
getEventListenerManager, getPlainText
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
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
 

Constructor Detail

DynamicTreeNodeModel

public DynamicTreeNodeModel(java.lang.Class<V> valueClass)
Constructs a tree node model indicating the type of value it can hold.

Parameters:
valueClass - The class indicating the type of value held in the model.
Throws:
java.lang.NullPointerException - if the given value class is null.

DynamicTreeNodeModel

public DynamicTreeNodeModel(java.lang.Class<V> valueClass,
                            V initialValue)
Constructs a tree node model indicating the type of value it can hold, along with an initial value.

Parameters:
valueClass - The class indicating the type of value held in the model.
initialValue - The initial value, which will not be validated.
Throws:
java.lang.NullPointerException - if the given value class is null.
Method Detail

isLeaf

public boolean isLeaf()
Returns whether this node could be considered a leaf node. //TODO comment This implementation true if child nodes are not loaded and this is not a predictive dynamic tree node.

Specified by:
isLeaf in interface TreeNodeModel<V>
Overrides:
isLeaf in class DefaultTreeNodeModel<V>
Returns:
true if this is a leaf node, else false if this node should not be considered a leaf.

setExpanded

public void setExpanded(boolean newExpanded)
Sets whether the node is expanded, showing its children, if any. This version ensures that child nodes are loaded or unloaded before expansion or collapsing occurs. This version updates the cached leaf determination if children are loaded in this method. This is a bound property of type Boolean.

Specified by:
setExpanded in interface TreeNodeModel<V>
Overrides:
setExpanded in class DefaultTreeNodeModel<V>
Parameters:
newExpanded - true if the node is expanded
See Also:
TreeNodeModel.EXPANDED_PROPERTY

clear

public void clear()
Removes all of the child tree nodes from this tree node. This version resets the children determined status.

Specified by:
clear in interface TreeNodeModel<V>
Overrides:
clear in class DefaultTreeNodeModel<V>

determineLeaf

protected abstract boolean determineLeaf()
Dynamically determines whether this node is a leaf.

Returns:
Whether this node should be considered a leaf with no children.

determineChildren

protected abstract java.util.List<TreeNodeModel<?>> determineChildren()
Dynamically determines children.

Returns:
The dynamically loaded list of children.


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