Package io.guise.framework.model
Class DynamicTreeNodeModel<V>
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.model.AbstractModel
-
- io.guise.framework.model.AbstractValueModel<V>
-
- io.guise.framework.model.DefaultValueModel<V>
-
- io.guise.framework.model.DefaultTreeNodeModel<V>
-
- io.guise.framework.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
,com.globalmentor.model.MutableValued<V>
,com.globalmentor.model.Valued<V>
,ActionListenable
,ActionModel
,Model
,Selectable
,TreeNodeModel<V>
,ValueModel<V>
,java.lang.Iterable<TreeNodeModel<?>>
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()
anddetermineChildren()
.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 io.guise.framework.model.Selectable
SELECTED_PROPERTY
-
Fields inherited from interface io.guise.framework.model.TreeNodeModel
EXPANDED_PROPERTY
-
Fields inherited from interface io.guise.framework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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()
Determines 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 io.guise.framework.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 io.guise.framework.model.DefaultValueModel
clearValue, getDefaultValue, getValue, resetValue, setValue
-
Methods inherited from class io.guise.framework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
-
Methods inherited from class io.guise.framework.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.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.ValueModel
clearValue, getDefaultValue, getValidator, getValue, getValueClass, isValidValue, resetValue, setValidator, setValue, validateValue
-
-
-
-
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 isnull
.
-
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 isnull
.
-
-
Method Detail
-
isLeaf
public 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.This implementation
TODO commenttrue
if child nodes are not loaded and this is not a predictive dynamic tree node.- Specified by:
isLeaf
in interfaceTreeNodeModel<V>
- Overrides:
isLeaf
in classDefaultTreeNodeModel<V>
- Returns:
true
if this is a leaf node, elsefalse
if this node should not be considered a leaf.
-
setExpanded
public void setExpanded(boolean newExpanded)
Description copied from interface:TreeNodeModel
Sets whether the node is expanded, showing its children, if any. This is a bound property of typeBoolean
.- Specified by:
setExpanded
in interfaceTreeNodeModel<V>
- Overrides:
setExpanded
in classDefaultTreeNodeModel<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 interfaceTreeNodeModel<V>
- Overrides:
clear
in classDefaultTreeNodeModel<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.
-
-