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>
,Iterable<TreeNodeModel<?>>
A node in a tree model that can dynamically load its children when needed.
Child classes must override determineLeaf()
and determineChildren()
.
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
ConstructorDescriptionDynamicTreeNodeModel
(Class<V> valueClass) Constructs a tree node model indicating the type of value it can hold.DynamicTreeNodeModel
(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
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the child tree nodes from this tree node.protected abstract List<TreeNodeModel<?>>
Dynamically determines children.protected abstract boolean
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 java.lang.Iterable
forEach, 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.ValueModel
clearValue, getDefaultValue, getValidator, getValue, getValueClass, isValidValue, resetValue, setValidator, setValue, validateValue
-
Constructor Details
-
DynamicTreeNodeModel
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:
NullPointerException
- if the given value class isnull
.
-
DynamicTreeNodeModel
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:
NullPointerException
- if the given value class isnull
.
-
-
Method Details
-
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:
-
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
Dynamically determines children.- Returns:
- The dynamically loaded list of children.
-