org.apache.wicket.markup.html.tree
Class DefaultTreeState

java.lang.Object
  extended by org.apache.wicket.markup.html.tree.DefaultTreeState
All Implemented Interfaces:
java.io.Serializable, IClusterable, ITreeState, IDetachable

public class DefaultTreeState
extends java.lang.Object
implements ITreeState, IClusterable, IDetachable

Default implementation of TreeState.

This implementation tries to be as lightweight as possible. By default all nodes are collapsed.

Author:
Matej Knopp
See Also:
Serialized Form

Constructor Summary
DefaultTreeState()
           
 
Method Summary
 void addTreeStateListener(ITreeStateListener l)
          Adds a tree state listener.
 void collapseAll()
          Collapses all nodes of the tree.
 void collapseNode(java.lang.Object node)
          Collapses the given node.
 void detach()
          Detaches model after use.
 void expandAll()
          Expands all nodes of the tree.
 void expandNode(java.lang.Object node)
          Expands the given node.
 java.util.Collection<java.lang.Object> getSelectedNodes()
          Returns the collection of all selected nodes.
 boolean isAllowSelectMultiple()
          Returns whether multiple nodes can be selected.
 boolean isNodeExpanded(java.lang.Object node)
          Returns true if the given node is expanded.
 boolean isNodeSelected(java.lang.Object node)
          Returns true if the given node is selected, false otherwise.
protected  void removeSelectedNodeSilent(java.lang.Object node)
           
 void removeTreeStateListener(ITreeStateListener l)
          Removes a tree state listener.
 void selectNode(java.lang.Object node, boolean selected)
          Selects or deselects node and calls the corresponding method on all registered ITreeStateListeners.
 void setAllowSelectMultiple(boolean value)
          Sets whether multiple nodes can be selected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTreeState

public DefaultTreeState()
Method Detail

addTreeStateListener

public void addTreeStateListener(ITreeStateListener l)
Description copied from interface: ITreeState
Adds a tree state listener. On state change events on the listener are fired.

Specified by:
addTreeStateListener in interface ITreeState
Parameters:
l - Listener to add
See Also:
ITreeState.addTreeStateListener(org.apache.wicket.markup.html.tree.ITreeStateListener)

collapseAll

public void collapseAll()
Description copied from interface: ITreeState
Collapses all nodes of the tree.

Specified by:
collapseAll in interface ITreeState
See Also:
ITreeState.collapseAll()

collapseNode

public void collapseNode(java.lang.Object node)
Description copied from interface: ITreeState
Collapses the given node.

Specified by:
collapseNode in interface ITreeState
Parameters:
node - Node to collapse

expandAll

public void expandAll()
Description copied from interface: ITreeState
Expands all nodes of the tree.

Specified by:
expandAll in interface ITreeState
See Also:
ITreeState.expandAll()

expandNode

public void expandNode(java.lang.Object node)
Description copied from interface: ITreeState
Expands the given node.

Specified by:
expandNode in interface ITreeState
Parameters:
node - Node to expand

getSelectedNodes

public java.util.Collection<java.lang.Object> getSelectedNodes()
Description copied from interface: ITreeState
Returns the collection of all selected nodes.

Specified by:
getSelectedNodes in interface ITreeState
Returns:
The collection of selected nodes
See Also:
ITreeState.getSelectedNodes()

removeSelectedNodeSilent

protected void removeSelectedNodeSilent(java.lang.Object node)

isAllowSelectMultiple

public boolean isAllowSelectMultiple()
Description copied from interface: ITreeState
Returns whether multiple nodes can be selected.

Specified by:
isAllowSelectMultiple in interface ITreeState
Returns:
True if multiple nodes can be selected
See Also:
ITreeState.isAllowSelectMultiple()

isNodeExpanded

public boolean isNodeExpanded(java.lang.Object node)
Description copied from interface: ITreeState
Returns true if the given node is expanded.

Specified by:
isNodeExpanded in interface ITreeState
Parameters:
node - The node to inspect
Returns:
True if the node is expanded

isNodeSelected

public boolean isNodeSelected(java.lang.Object node)
Description copied from interface: ITreeState
Returns true if the given node is selected, false otherwise.

Specified by:
isNodeSelected in interface ITreeState
Parameters:
node - The node to inspect
Returns:
True if the node is selected

removeTreeStateListener

public void removeTreeStateListener(ITreeStateListener l)
Description copied from interface: ITreeState
Removes a tree state listener.

Specified by:
removeTreeStateListener in interface ITreeState
Parameters:
l - The listener to remove
See Also:
ITreeState.removeTreeStateListener(org.apache.wicket.markup.html.tree.ITreeStateListener)

selectNode

public void selectNode(java.lang.Object node,
                       boolean selected)
Selects or deselects node and calls the corresponding method on all registered ITreeStateListeners. If isAllowSelectMultiple is false , any currently selected nodes are deselected.

Specified by:
selectNode in interface ITreeState
Parameters:
node - the node to be selected
selected - true if node is to be selected, false if node is to be deselected

setAllowSelectMultiple

public void setAllowSelectMultiple(boolean value)
Description copied from interface: ITreeState
Sets whether multiple nodes can be selected.

Specified by:
setAllowSelectMultiple in interface ITreeState
Parameters:
value - If true, multiple nodes can be selected. If false, only one node at a time can be selected
See Also:
ITreeState.setAllowSelectMultiple(boolean)

detach

public void detach()
Description copied from interface: IDetachable
Detaches model after use. This is generally used to null out transient references that can be re-attached later.

Specified by:
detach in interface IDetachable


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.