Package io.guise.framework.model
Class DefaultTreeModel
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.model.AbstractModel
-
- io.guise.framework.model.DefaultTreeModel
-
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable,com.globalmentor.beans.PropertyConstrainable,ActionListenable,ActionModel,Model,TreeModel
public class DefaultTreeModel extends AbstractModel implements TreeModel
A default implementation of a tree model. If no root node is specified, the root node will be a dummy root node that will not be displayed. If a dummy root node is used, it will automatically be set to an expanded state.- Author:
- Garret Wilson
- See Also:
DummyTreeNodeModel
-
-
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.TreeModel
ROOT_NODE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeModel()Default constructor with a dummy root tree node.DefaultTreeModel(TreeNodeModel<?> rootNode)Root node constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(ActionListener actionListener)Adds an action listener.protected voidfireActionPerformed(int force, int option)Fires an action event to all registered action listeners.protected voidfireActionPerformed(ActionEvent actionEvent)Fires a given action event to all registered action listeners.java.lang.Iterable<ActionListener>getActionListeners()TreeNodeModel<?>getRootNode()voidperformAction()Performs the action with default force and default option.voidperformAction(int force, int option)Performs the action with the given force and option.voidremoveActionListener(ActionListener actionListener)Removes an action listener.voidsetAllExpanded(boolean newAllExpanded)Sets whether all tree nodes are expanded.voidsetRootNode(TreeNodeModel<?> newRootNode)Sets the root node of the tree model.-
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
-
-
-
-
Constructor Detail
-
DefaultTreeModel
public DefaultTreeModel()
Default constructor with a dummy root tree node.
-
DefaultTreeModel
public DefaultTreeModel(TreeNodeModel<?> rootNode)
Root node constructor.- Parameters:
rootNode- The root node of the tree model.- Throws:
java.lang.NullPointerException- if the given root node isnull.
-
-
Method Detail
-
getRootNode
public TreeNodeModel<?> getRootNode()
- Specified by:
getRootNodein interfaceTreeModel- Returns:
- The root node of the tree model.
-
setRootNode
public void setRootNode(TreeNodeModel<?> newRootNode)
Description copied from interface:TreeModelSets the root node of the tree model. This is a bound property.- Specified by:
setRootNodein interfaceTreeModel- Parameters:
newRootNode- The new root node of the tree model.- See Also:
TreeModel.ROOT_NODE_PROPERTY
-
setAllExpanded
public void setAllExpanded(boolean newAllExpanded)
Description copied from interface:TreeModelSets whether all tree nodes are expanded. This method delegates to the root nodeTreeNodeModel.setAllExpanded(boolean).- Specified by:
setAllExpandedin interfaceTreeModel- Parameters:
newAllExpanded-trueif all the nodes should be expanded, orfalseif they should be collapsed.
-
addActionListener
public void addActionListener(ActionListener actionListener)
Description copied from interface:ActionListenableAdds an action listener.- Specified by:
addActionListenerin interfaceActionListenable- Parameters:
actionListener- The action listener to add.
-
removeActionListener
public void removeActionListener(ActionListener actionListener)
Description copied from interface:ActionListenableRemoves an action listener.- Specified by:
removeActionListenerin interfaceActionListenable- Parameters:
actionListener- The action listener to remove.
-
getActionListeners
public java.lang.Iterable<ActionListener> getActionListeners()
- Specified by:
getActionListenersin interfaceActionModel- Returns:
- all registered action listeners.
-
performAction
public void performAction()
Description copied from interface:ActionModelPerforms the action with default force and default option. AnActionEventis fired to all registeredActionListeners. This method delegates toActionModel.performAction(int, int).- Specified by:
performActionin interfaceActionModel
-
performAction
public void performAction(int force, int option)Description copied from interface:ActionModelPerforms the action with the given force and option. AnActionEventis fired to all registeredActionListeners.- Specified by:
performActionin interfaceActionModel- Parameters:
force- The zero-based force, such as 0 for no force or 1 for an action initiated by from a mouse single click.option- The zero-based option, such as 0 for an event initiated by a mouse left button click or 1 for an event initiated by a mouse right button click.
-
fireActionPerformed
protected void fireActionPerformed(int force, int option)Fires an action event to all registered action listeners. This method delegates tofireActionPerformed(ActionEvent).- Parameters:
force- The zero-based force, such as 0 for no force or 1 for an action initiated by from a mouse single click.option- The zero-based option, such as 0 for an event initiated by a mouse left button click or 1 for an event initiaged by a mouse right button click.- See Also:
ActionListener,ActionEvent
-
fireActionPerformed
protected void fireActionPerformed(ActionEvent actionEvent)
Fires a given action event to all registered action listeners.- Parameters:
actionEvent- The action event to fire.
-
-