Interface TreeHandler
-
- All Superinterfaces:
ComponentHandler<Object>
public interface TreeHandler extends ComponentHandler<Object>
A specialized
ComponentHandler
interface for dealing with tree components.A tree component provides some enhanced functionality not covered by the default methods defined in the
ComponentHandler
interface. Therefore this interface is available for accessing this special functionality. New methods have been introduced for dealing for instance with querying the tree's selection or registering special event handlers.Note that this
ComponentHandler
is of typeObject
. This is due to the fact that a tree supports both single and multiple selections. In the former case the handler's data is an object of type
. In the latter case it is an array of this type.TreeNodePath
- Version:
- $Id: TreeHandler.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addExpansionListener(TreeExpansionListener l)
Adds aTreeExpansionListener
to this tree component.void
addPreExpansionListener(TreePreExpansionListener l)
Adds aTreePreExpansionListener
to this tree component.void
addSelectedPath(TreeNodePath path)
Adds the specified path to the selection of the tree.void
clearSelection()
Removes the selection.void
collapse(TreeNodePath path)
Collapses the node specified by the given path.void
expand(TreeNodePath path)
Expands the node specified by the given path.org.apache.commons.configuration.HierarchicalConfiguration
getModel()
Returns the tree's data model.TreeNodePath
getSelectedPath()
Returns the path to the selected node.TreeNodePath[]
getSelectedPaths()
Returns an array with the paths to all selected nodes.void
removeExpansionListener(TreeExpansionListener l)
Removes the specified expansion listener from this tree component.void
removePreExpansionListener(TreePreExpansionListener l)
Removes the specifiedTreePreExpansionListener
from this tree component.void
setSelectedPath(TreeNodePath path)
Sets a single selected node.-
Methods inherited from interface net.sf.jguiraffe.gui.forms.ComponentHandler
getComponent, getData, getOuterComponent, getType, isEnabled, setData, setEnabled
-
-
-
-
Method Detail
-
getSelectedPath
TreeNodePath getSelectedPath()
Returns the path to the selected node. This method can be used for trees supporting single selection only. TheTreeNodePath
object returned points to the selected node. If nothing is selected, result will be null.- Returns:
- the path to the selected node
-
setSelectedPath
void setSelectedPath(TreeNodePath path)
Sets a single selected node. Using this method the selection of the tree is set to exactly one node.- Parameters:
path
- the path to the selected node (must not be null)
-
getSelectedPaths
TreeNodePath[] getSelectedPaths()
Returns an array with the paths to all selected nodes. This method can be used if multiple selection is active for querying all selected nodes at once. If nothing is selected, an empty array is returned.- Returns:
- an array with the paths of all selected nodes
-
addSelectedPath
void addSelectedPath(TreeNodePath path)
Adds the specified path to the selection of the tree. With this method the selection can be extended. For this to work the tree must support multiple selection.- Parameters:
path
- the path pointing to the node which should be added to the selection (must not be null)
-
clearSelection
void clearSelection()
Removes the selection. After calling this method no node is selected any more.
-
addExpansionListener
void addExpansionListener(TreeExpansionListener l)
Adds aTreeExpansionListener
to this tree component. This listener will be notified whenever a node of this tree is expanded or collapsed.- Parameters:
l
- the listener to add (must not be null)- Throws:
IllegalArgumentException
- if the listener is null
-
removeExpansionListener
void removeExpansionListener(TreeExpansionListener l)
Removes the specified expansion listener from this tree component.- Parameters:
l
- the listener to remove
-
addPreExpansionListener
void addPreExpansionListener(TreePreExpansionListener l)
Adds aTreePreExpansionListener
to this tree component. This listener will be notified whenever a tree node is about to be expanded or collapsed and has the opportunity to forbid this operation.- Parameters:
l
- the listener to add (must not be null)- Throws:
IllegalArgumentException
- if the listener is null
-
removePreExpansionListener
void removePreExpansionListener(TreePreExpansionListener l)
Removes the specifiedTreePreExpansionListener
from this tree component.- Parameters:
l
- the listener to remove
-
expand
void expand(TreeNodePath path)
Expands the node specified by the given path.- Parameters:
path
- the path
-
collapse
void collapse(TreeNodePath path)
Collapses the node specified by the given path.- Parameters:
path
- the path
-
getModel
org.apache.commons.configuration.HierarchicalConfiguration getModel()
Returns the tree's data model. This is a hierarchical configuration object. By manipulating this configuration the tree's content can be changed.- Returns:
- the configuration that serves as data model for this tree
-
-