EchoPoint
1.0

echopoint
Class Tree

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.Container
          extended byechopoint.EchoPointComponent
              extended byechopoint.Tree
All Implemented Interfaces:
MouseCursorable, ReflectionSetter, java.io.Serializable, ToolTipPopUpSupport, nextapp.echo.ToolTipSupport

public class Tree
extends EchoPointComponent

The Tree component displays data in a hierarchial manner. The API for this Component has based heavily on the Swing JTree class.

The tree can be a client side or server side generated tree.

A client side tree does not generate events when it is expanded or collapsed and all nodes in the tree are sent to the client. Only when the user clicks on a node within the tree is an event generated. The ability to have a node "selected" within a tree is not provided with client side trees.

A client side tree does however track its "expanded" state, so when the screen is redraw they will display the last view.

So why would you use them? Because they respond instantly to expand and collapse actions, without requiring a trip back to the server.

If the tree has many nodes, then data transmission time may be a problem with a client side tree. Also client trees do not support selection.

A server side tree only renders the visible nodes and an event is generated to expand or collapse nodes as well as when the user clicks on a node. This allows the application to insert more nodes as necessary or on a "just in time" basis.

This also allows the server side Tree to support node selection.

The Tree component supports "bubbling up" actions.

If the objects placed in the Tree implement TreeNode then an action command can be identified with each node. When a node is pressed, the associated action command will be raised with any ActionListeners of the Tree. If no action command is associated with a TreeNode then the path to the ancestors will be followed to look for an action command. If no action command can be found, then the action command of the tree itself will be used.

If you call setNullActionCommandsRaiseEvents(false) then action events will not be raised for TreeNodes that have null action commands. It is TRUE by default.

The Tree and related classes use a magic idString to identify each node. If you use TreeNode derivatives as your nodes, then this will be handled for you. If however you use a custom TreeModel not based on TreeNode, then you will need to watch how these idStrings are generated. The DefaultTreeCellRenderer.getIdString(Tree tree, Object value) method will use System.identityHashCode(value) to get a unique value. Therefore in you TreeModel.getPathToRoot(String idString) method, you need to ensure you use the same idString generation scheme.

See Also:
TreeModel, DefaultTreeModel, TreeCellRenderer, DefaultTreeCellRenderer, TreeNode, MutableTreeNode, DefaultMutableTreeNode, Serialized Form

Nested Class Summary
static class Tree.NestedStyleInfo
          Nested public static StyleInfo class.
protected  class Tree.TreeModelHandler
          Listens to the model and updates the expandedState accordingly when nodes are removed, or changed.
protected  class Tree.TreeRowMapper
          Handles the RowMapper interface for the tree
protected  class Tree.TreeSelectionForwarder
          Handles creating a new TreeSelectionEvent with the Tree as the source and passing it off to all the listeners.
 
Field Summary
static java.lang.String ACTION_COMMAND_PROPERTY
          Bound property name for actionCommand.
protected  java.lang.String actionCommand
          the action command of the Tree
static java.lang.String CELL_RENDERER_PROPERTY
          Bound property name for cellRenderer.
protected  TreeCellRenderer cellRenderer
          The tree cell renderer
static java.lang.String LINES_DRAWN_PROPERTY
          Bound property name for Lines Drawn.
static java.lang.String NULL_ACTION_COMMANDS_RAISE_EVENTS
          Bound property name for NullActionCommandAllows.
static java.lang.String ROOT_VISIBLE_PROPERTY
          Bound property name for rootVisible.
static java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
          Tree Row Height
static java.lang.String SELECTION_MODEL_PROPERTY
          Bound property name for selectionModel.
protected  Tree.TreeSelectionForwarder selectionForwarder
          Creates a new event and passed it off the selectionListeners.
protected  TreeSelectionModel selectionModel
          Models the set of selected nodes in this tree.
static java.lang.String SERVER_SIDE_PROPERTY
          Bound property name for serverSide.
protected  boolean serverSideTree
          Is the tree fully rendered on the server side or some of it is rendered on the server side.
static java.lang.String SHOWS_ROOT_HANDLES_PROPERTY
          Bound property name for showsRootHandles.
protected  boolean showsRootHandles
          True if handles are displayed at the topmost level of the tree.
static java.lang.String STYLE_ROOT_VISIBLE
          A style constant for the Root Visible property.
static java.lang.String STYLE_ROW_HEIGHT
          A style constant for the Row Height property.
static java.lang.String STYLE_SHOWS_ROOT_HANDLES
          A style constant for the Shows Root Handles property.
static java.lang.String TREE_ICONS_PROPERTY
          Bound property name for Tree icons.
static java.lang.String TREE_MODEL_PROPERTY
          Bound property name for treeModel.
protected  TreeIcons treeIcons
          The tree cell renderer
protected  TreeModel treeModel
          The model that defines the tree displayed by this object.
protected  TreeModelListener treeModelListener
          Updates the expandedState.
 
Fields inherited from class echopoint.EchoPointComponent
STYLE_TOOL_TIP_TEXT, TOOL_TIP_TEXT_CHANGED_PROPERTY, toolTipPopUp
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.MouseCursorable
borderStyleSymbolics, CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, STYLE_MOUSE_CURSOR, STYLE_MOUSE_CURSOR_URI
 
Constructor Summary
Tree(TreeModel newModel)
          Returns an instance of a Tree which displays the root node and is created using the specified data model.
Tree(TreeNode root)
          Returns a Tree with the specified TreeNode as its root, which displays the root node.
Tree(TreeNode root, boolean asksAllowsChildren)
          Returns a Tree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.
 
Method Summary
 void addActionListener(nextapp.echo.event.ActionListener l)
          Adds an ActionListener.
 void addSelectionPath(TreePath path)
          Adds the node identified by the specified TreePath to the current selection.
 void addSelectionPaths(TreePath[] paths)
          Adds each path in the array of paths to the current selection.
 void addTreeExpansionListener(TreeExpansionListener tel)
          Adds a listener for TreeExpansion events.
 void addTreeSelectionListener(TreeSelectionListener tsl)
          Adds a listener for TreeSelection events.
 void addTreeWillExpandListener(TreeWillExpandListener tel)
          Adds a listener for TreeWillExpand events.
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
protected  void clearToggledPaths()
          Clears the cache of toggled tree paths.
 void collapseAll()
          Ensures that all the nodes in the tree are collapsed
 void collapsePath(TreePath path)
          Ensures that the node identified by the specified path is collapsed and viewable.
protected  TreeModelListener createTreeModelListener()
          Creates and returns an instance of TreeModelHandler.
 void expandAll()
          Ensures that all the nodes are expanded and viewable.
 void expandPath(TreePath path)
          Ensures that the node identified by the specified path is expanded and viewable.
 void fireActionPerformed(nextapp.echo.event.ActionEvent e)
          Notifies all listeners that have registered for this event type.
 void fireTreeCollapsed(TreePath path)
          Notify all listeners that have registered interest for notification on this event type.
 void fireTreeExpanded(TreePath path)
          Notify all listeners that have registered interest for notification on this event type.
 void fireTreeWillCollapse(TreePath path)
          Notify all listeners that have registered interest for notification on this event type.
 void fireTreeWillExpand(TreePath path)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireValueChanged(TreeSelectionEvent e)
          Notify all listeners that have registered interest for notification on this event type.
 java.lang.String getActionCommand()
          Returns the action command string of the Tree
 TreeCellRenderer getCellRenderer()
          Returns the current TreeCellRenderer that is rendering each cell.
 nextapp.echo.Component getComponent(java.lang.Object treeNode)
          Returns the Component that will be used to render the provided tree node.
protected  java.util.Enumeration getDescendantToggledPaths(TreePath parent)
          Returns an Enumeration of TreePaths that have been expanded that are descendants of parent.
 java.util.Enumeration getExpandedDescendants(TreePath parent)
          Returns an Enumeration of the descendants of path that are currently expanded.
 java.lang.Object getLastSelectedPathComponent()
          Returns the last path component in the first node of the current selection.
 TreePath getLeadSelectionPath()
          Returns the path of the last node added to the selection.
 TreeModel getModel()
          Returns the TreeModel that is providing the data.
 int getRowForPath(TreePath path)
          Returns the row that the TreePath path is being displayed at.
 int getRowHeight()
          Returns the row height to be used for each row within the Tree.
 int[] getRowsForPaths(TreePath[] paths)
          Returns the rows that the TreePath instances in path are being displayed at.
 int getSelectionCount()
          Returns the number of nodes selected.
 TreeSelectionModel getSelectionModel()
          Returns the model for selections.
 TreePath getSelectionPath()
          Returns the path to the first selected node.
 TreePath[] getSelectionPaths()
          Returns the paths of all selected values.
 boolean getShowsRootHandles()
          Returns true if handles for the root nodes are displayed.
 TreeIcons getTreeIcons()
          Returns the TreeIcons being used by the Tree
 boolean hasBeenExpanded(TreePath path)
          Returns true if the node identified by the path has ever been expanded.
 void invalidate()
          Marks the Tree as needing to be re-rendered.
 boolean isCollapsed(TreePath path)
          Returns true if the value identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.
 boolean isExpanded(TreePath path)
          Returns true if the node identified by the path is currently expanded,
 boolean isLinesDrawn()
          Returns true if lines are drawn between tree nodes.
 boolean isNullActionCommandsRaiseEvents()
          Returns TRUE of TreeNode null action commands will still raise events by bubbling up the Tree.
 boolean isPathSelected(TreePath path)
          Returns true if the item identified by the path is currently selected.
 boolean isRootVisible()
          Returns true if the root node of the tree is displayed.
 boolean isSelectionEmpty()
          Returns true if the selection is currently empty.
 boolean isServerSideTree()
          Returns TRUE if the tree is a server side tree.
 boolean isVisible(TreePath path)
          Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are exapnded , Otherwise, this method returns false.
 void makeVisible(TreePath path)
          Ensures that the node identified by path is currently viewable.
 void removeActionListener(nextapp.echo.event.ActionListener l)
          Removes an ActionListener.
protected  void removeDescendantToggledPaths(java.util.Enumeration toRemove)
          Removes any descendants of the TreePaths in toRemove that have been expanded.
 void removeSelectionPath(TreePath path)
          Removes the node identified by the specified path from the current selection.
 void removeSelectionPaths(TreePath[] paths)
          Removes the nodes identified by the specified paths from the current selection.
 void removeTreeExpansionListener(TreeExpansionListener tel)
          Removes a listener for TreeExpansion events.
 void removeTreeSelectionListener(TreeSelectionListener tsl)
          Removes a TreeSelection listener.
 void removeTreeWillExpandListener(TreeWillExpandListener tel)
          Removes a listener for TreeWillExpand events.
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setActionCommand(java.lang.String newActionCommand)
          Sets the action command string of the Tree.
 void setCellRenderer(TreeCellRenderer newCellRenderer)
          Sets the TreeCellRenderer that will be used to draw each cell.
 void setEnabled(boolean newValue)
           
 void setExpandedState(TreePath path, boolean state)
          Sets the expanded state of the path.
 void setLinesDrawn(boolean newDrawLines)
          Sets whether lines are drawn between tree nodes
 void setModel(TreeModel newModel)
          Sets the TreeModel that will provide the data.
 void setNullActionCommandsRaiseEvents(boolean newValue)
          Sets whether TreeNode null action commands will cause an event to be raised.
 void setRootVisible(boolean rootVisible)
          Determines whether or not the root node from the TreeModel is visible.
 void setRowHeight(int newRowHeight)
          Sets the row height to be used for each row within the Tree.
 void setSelectionModel(TreeSelectionModel selectionModel)
          Sets the tree's selection model.
 void setSelectionPath(TreePath path)
          Selects the node identified by the specified path.
 void setSelectionPaths(TreePath[] paths)
          Selects the nodes identified by the specified array of paths.
 void setServerSideTree(boolean newServerSideTree)
          Sets whether the Tree is a server side tree.
 void setShowsRootHandles(boolean newValue)
          Determines whether the node handles are to be displayed.
 void setTreeIcons(TreeIcons newTreeIcons)
          Sets the TreeIcons being used by the Tree
 void setVisible(boolean newValue)
           
 void toggleAllNodes(java.lang.Object parent, boolean expand)
          Toggles all nodes as expanded or collapsed depending on expand starting from parent.
 void validate()
          Called just before the tree is rendered.
 
Methods inherited from class echopoint.EchoPointComponent
getMouseCursor, getMouseCursorURI, getToolTipPopUp, getToolTipText, set, set, set, set, set, set, set, set, set, setEnabledAllChildren, setMouseCursor, setMouseCursorURI, setToolTipText
 
Methods inherited from class nextapp.echo.Component
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setFont, setForeground, setIdentifier, setLocale, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_COMMAND_PROPERTY

public static final java.lang.String ACTION_COMMAND_PROPERTY
Bound property name for actionCommand.

See Also:
Constant Field Values

CELL_RENDERER_PROPERTY

public static final java.lang.String CELL_RENDERER_PROPERTY
Bound property name for cellRenderer.

See Also:
Constant Field Values

LINES_DRAWN_PROPERTY

public static final java.lang.String LINES_DRAWN_PROPERTY
Bound property name for Lines Drawn.

See Also:
Constant Field Values

NULL_ACTION_COMMANDS_RAISE_EVENTS

public static final java.lang.String NULL_ACTION_COMMANDS_RAISE_EVENTS
Bound property name for NullActionCommandAllows.

See Also:
Constant Field Values

ROOT_VISIBLE_PROPERTY

public static final java.lang.String ROOT_VISIBLE_PROPERTY
Bound property name for rootVisible.

See Also:
Constant Field Values

ROW_HEIGHT_CHANGED_PROPERTY

public static final java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
Tree Row Height

See Also:
Constant Field Values

SELECTION_MODEL_PROPERTY

public static final java.lang.String SELECTION_MODEL_PROPERTY
Bound property name for selectionModel.

See Also:
Constant Field Values

SERVER_SIDE_PROPERTY

public static final java.lang.String SERVER_SIDE_PROPERTY
Bound property name for serverSide.

See Also:
Constant Field Values

SHOWS_ROOT_HANDLES_PROPERTY

public static final java.lang.String SHOWS_ROOT_HANDLES_PROPERTY
Bound property name for showsRootHandles.

See Also:
Constant Field Values

STYLE_ROOT_VISIBLE

public static final java.lang.String STYLE_ROOT_VISIBLE
A style constant for the Root Visible property. Values of this key must be of type int

See Also:
Constant Field Values

STYLE_ROW_HEIGHT

public static final java.lang.String STYLE_ROW_HEIGHT
A style constant for the Row Height property. Values of this key must be of type int

See Also:
Constant Field Values

STYLE_SHOWS_ROOT_HANDLES

public static final java.lang.String STYLE_SHOWS_ROOT_HANDLES
A style constant for the Shows Root Handles property. Values of this key must be of type int

See Also:
Constant Field Values

TREE_ICONS_PROPERTY

public static final java.lang.String TREE_ICONS_PROPERTY
Bound property name for Tree icons.

See Also:
Constant Field Values

TREE_MODEL_PROPERTY

public static final java.lang.String TREE_MODEL_PROPERTY
Bound property name for treeModel.

See Also:
Constant Field Values

actionCommand

protected java.lang.String actionCommand
the action command of the Tree


cellRenderer

protected transient TreeCellRenderer cellRenderer
The tree cell renderer


selectionForwarder

protected transient Tree.TreeSelectionForwarder selectionForwarder
Creates a new event and passed it off the selectionListeners.


selectionModel

protected transient TreeSelectionModel selectionModel
Models the set of selected nodes in this tree.


serverSideTree

protected boolean serverSideTree
Is the tree fully rendered on the server side or some of it is rendered on the server side.


showsRootHandles

protected boolean showsRootHandles
True if handles are displayed at the topmost level of the tree.


treeIcons

protected transient TreeIcons treeIcons
The tree cell renderer


treeModel

protected transient TreeModel treeModel
The model that defines the tree displayed by this object.


treeModelListener

protected transient TreeModelListener treeModelListener
Updates the expandedState.

Constructor Detail

Tree

public Tree(TreeModel newModel)
Returns an instance of a Tree which displays the root node and is created using the specified data model.


Tree

public Tree(TreeNode root)
Returns a Tree with the specified TreeNode as its root, which displays the root node. By default, the tree defines a leaf node as any node without children.


Tree

public Tree(TreeNode root,
            boolean asksAllowsChildren)
Returns a Tree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.

Method Detail

addActionListener

public void addActionListener(nextapp.echo.event.ActionListener l)
Adds an ActionListener.

Parameters:
l - The ActionListener to be added.

addSelectionPath

public void addSelectionPath(TreePath path)
Adds the node identified by the specified TreePath to the current selection. If any component of the path isn't viewable, it is made viewable.

Parameters:
path - the TreePath to add

addSelectionPaths

public void addSelectionPaths(TreePath[] paths)
Adds each path in the array of paths to the current selection. If any component of any of the paths isn't viewable, it is made viewable.

Parameters:
paths - an array of TreePath objects that specifies the nodes to add

addTreeExpansionListener

public void addTreeExpansionListener(TreeExpansionListener tel)
Adds a listener for TreeExpansion events.

Parameters:
tel - a TreeExpansionListener that will be notified when a tree node is expanded or collapsed (a "negative expansion")

addTreeSelectionListener

public void addTreeSelectionListener(TreeSelectionListener tsl)
Adds a listener for TreeSelection events.

Parameters:
tsl - the TreeSelectionListener that will be notified when a node is selected or deselected (a "negative selection")

addTreeWillExpandListener

public void addTreeWillExpandListener(TreeWillExpandListener tel)
Adds a listener for TreeWillExpand events.

Parameters:
tel - a TreeWillExpandListener that will be notified when a tree node will be expanded or collapsed (a "negative expansion")

applyStyle

public void applyStyle(nextapp.echo.Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface MouseCursorable
Overrides:
applyStyle in class EchoPointComponent
See Also:
Component.applyStyle(nextapp.echo.Style)

clearToggledPaths

protected void clearToggledPaths()
Clears the cache of toggled tree paths. This does NOT send out any TreeExpansionListener events.


collapseAll

public void collapseAll()
Ensures that all the nodes in the tree are collapsed


collapsePath

public void collapsePath(TreePath path)
Ensures that the node identified by the specified path is collapsed and viewable.

Parameters:
path - the TreePath identifying a node

createTreeModelListener

protected TreeModelListener createTreeModelListener()
Creates and returns an instance of TreeModelHandler. The returned object is responsible for updating the expanded state when the TreeModel changes.


expandAll

public void expandAll()
Ensures that all the nodes are expanded and viewable.


expandPath

public void expandPath(TreePath path)
Ensures that the node identified by the specified path is expanded and viewable.

Parameters:
path - the TreePath identifying a node

fireActionPerformed

public void fireActionPerformed(nextapp.echo.event.ActionEvent e)
Notifies all listeners that have registered for this event type.

Parameters:
e - The ActionEvent to send.

fireTreeCollapsed

public void fireTreeCollapsed(TreePath path)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
path - the TreePath indicating the node that was collapsed

fireTreeExpanded

public void fireTreeExpanded(TreePath path)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
path - the TreePath indicating the node that was expanded

fireTreeWillCollapse

public void fireTreeWillCollapse(TreePath path)
                          throws ExpandVetoException
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
path - the TreePath indicating the node that was expanded
Throws:
ExpandVetoException

fireTreeWillExpand

public void fireTreeWillExpand(TreePath path)
                        throws ExpandVetoException
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

Parameters:
path - the TreePath indicating the node that was expanded
Throws:
ExpandVetoException

fireValueChanged

protected void fireValueChanged(TreeSelectionEvent e)
Notify all listeners that have registered interest for notification on this event type.

Parameters:
e - the TreeSelectionEvent generated by the TreeSelectionModel when a node is selected or deselected

getActionCommand

public java.lang.String getActionCommand()
Returns the action command string of the Tree

Returns:
java.lang.String

getCellRenderer

public TreeCellRenderer getCellRenderer()
Returns the current TreeCellRenderer that is rendering each cell.

Returns:
the TreeCellRenderer that is rendering each cell
See Also:
TreeCellRenderer

getComponent

public nextapp.echo.Component getComponent(java.lang.Object treeNode)
Returns the Component that will be used to render the provided tree node. If this method returns null, then no Component has been associated with a specified tree node and the TreeCellRenderer.getTreeCellRendererText() method will be used to render the Tree cell.

This method is primarily for use by the Tree UI peer rendering code. You should call the "invalidate" and then "validate" methods first before calling this method to ensure that all child Components are known and are valid.

Parameters:
treeNode - - the tree node in question
Returns:
- a component for the node or null
See Also:
TreeCellRenderer.getTreeCellRendererText(Tree, Object, boolean, boolean, boolean)

getDescendantToggledPaths

protected java.util.Enumeration getDescendantToggledPaths(TreePath parent)
Returns an Enumeration of TreePaths that have been expanded that are descendants of parent.


getExpandedDescendants

public java.util.Enumeration getExpandedDescendants(TreePath parent)
Returns an Enumeration of the descendants of path that are currently expanded. If path is not currently expanded, this will return null. If you expand/collapse nodes while iterating over the returned Enumeration this may not return all the expanded paths, or may return paths that are no longer expanded.


getLastSelectedPathComponent

public java.lang.Object getLastSelectedPathComponent()
Returns the last path component in the first node of the current selection.

Returns:
the last Object in the first selected node's TreePath, or null if nothing is selected

getLeadSelectionPath

public TreePath getLeadSelectionPath()
Returns the path of the last node added to the selection.

Returns:
the TreePath of the last node added to the selection.

getModel

public TreeModel getModel()
Returns the TreeModel that is providing the data.

Returns:
the TreeModel that is providing the data

getRowForPath

public int getRowForPath(TreePath path)
Returns the row that the TreePath path is being displayed at. If the TreePath in path is not valid it will be set to -1.


getRowHeight

public int getRowHeight()
Returns the row height to be used for each row within the Tree. If this value is 0 or less, then no row height will be used.

Returns:
int

getRowsForPaths

public int[] getRowsForPaths(TreePath[] paths)
Returns the rows that the TreePath instances in path are being displayed at. The receiver should return an array of the same length as that passed in, and if one of the TreePaths in path is not valid its entry in the array should be set to -1.


getSelectionCount

public int getSelectionCount()
Returns the number of nodes selected.

Returns:
the number of nodes selected

getSelectionModel

public TreeSelectionModel getSelectionModel()
Returns the model for selections. This should always return a non-null value. If you don't want to allow anything to be selected set the selection model to null, which forces an empty selection model to be used.


getSelectionPath

public TreePath getSelectionPath()
Returns the path to the first selected node.

Returns:
the TreePath for the first selected node, or null if nothing is currently selected

getSelectionPaths

public TreePath[] getSelectionPaths()
Returns the paths of all selected values.

Returns:
an array of TreePath objects indicating the selected nodes, or null if nothing is currently selected.

getShowsRootHandles

public boolean getShowsRootHandles()
Returns true if handles for the root nodes are displayed.


getTreeIcons

public TreeIcons getTreeIcons()
Returns the TreeIcons being used by the Tree

Returns:
echopoint.tree.TreeIcons
See Also:
TreeIcons

hasBeenExpanded

public boolean hasBeenExpanded(TreePath path)
Returns true if the node identified by the path has ever been expanded.


invalidate

public void invalidate()
Marks the Tree as needing to be re-rendered.


isCollapsed

public boolean isCollapsed(TreePath path)
Returns true if the value identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.

Parameters:
path - the TreePath to check
Returns:
true if any of the nodes in the node's path are collapsed, false if all nodes in the path are expanded

isExpanded

public boolean isExpanded(TreePath path)
Returns true if the node identified by the path is currently expanded,

Parameters:
path - the TreePath specifying the node to check
Returns:
false if any of the nodes in the node's path are collapsed, true if all nodes in the path are expanded

isLinesDrawn

public boolean isLinesDrawn()
Returns true if lines are drawn between tree nodes.

Returns:
boolean

isNullActionCommandsRaiseEvents

public boolean isNullActionCommandsRaiseEvents()
Returns TRUE of TreeNode null action commands will still raise events by bubbling up the Tree.

Returns:
boolean

isPathSelected

public boolean isPathSelected(TreePath path)
Returns true if the item identified by the path is currently selected.

Parameters:
path - a TreePath identifying a node
Returns:
true if the node is selected

isRootVisible

public boolean isRootVisible()
Returns true if the root node of the tree is displayed.


isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if the selection is currently empty.

Returns:
true if the selection is currently empty

isServerSideTree

public boolean isServerSideTree()
Returns TRUE if the tree is a server side tree.

Returns:
boolean

isVisible

public boolean isVisible(TreePath path)
Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are exapnded , Otherwise, this method returns false.

Returns:
true if the node is viewable, otherwise false

makeVisible

public void makeVisible(TreePath path)
Ensures that the node identified by path is currently viewable.

Parameters:
path - the TreePath to make visible

removeActionListener

public void removeActionListener(nextapp.echo.event.ActionListener l)
Removes an ActionListener.

Parameters:
l - The ActionListener to be removed.

removeDescendantToggledPaths

protected void removeDescendantToggledPaths(java.util.Enumeration toRemove)
Removes any descendants of the TreePaths in toRemove that have been expanded.


removeSelectionPath

public void removeSelectionPath(TreePath path)
Removes the node identified by the specified path from the current selection.

Parameters:
path - the TreePath identifying a node

removeSelectionPaths

public void removeSelectionPaths(TreePath[] paths)
Removes the nodes identified by the specified paths from the current selection.

Parameters:
paths - an array of TreePath objects that specifies the nodes to remove

removeTreeExpansionListener

public void removeTreeExpansionListener(TreeExpansionListener tel)
Removes a listener for TreeExpansion events.

Parameters:
tel - the TreeExpansionListener to remove

removeTreeSelectionListener

public void removeTreeSelectionListener(TreeSelectionListener tsl)
Removes a TreeSelection listener.

Parameters:
tsl - the TreeSelectionListener to remove

removeTreeWillExpandListener

public void removeTreeWillExpandListener(TreeWillExpandListener tel)
Removes a listener for TreeWillExpand events.

Parameters:
tel - the TreeWillExpandListener to remove

setActionCommand

public void setActionCommand(java.lang.String newActionCommand)
Sets the action command string of the Tree. Note that action commands bubble up from the TreeNode, via their parents to the Tree itself.

Parameters:
newActionCommand - String

setCellRenderer

public void setCellRenderer(TreeCellRenderer newCellRenderer)
Sets the TreeCellRenderer that will be used to draw each cell.

Parameters:
newCellRenderer - the TreeCellRenderer that is to render each cell
See Also:
TreeCellRenderer

setEnabled

public void setEnabled(boolean newValue)
See Also:
Component.setEnabled(boolean)

setExpandedState

public void setExpandedState(TreePath path,
                             boolean state)
Sets the expanded state of the path. If state is true, all parents of path as well as path are marked as expanded.

If state is false, all parents of path are marked EXPANDED, but path itself is marked collapsed.

This will fail if a TreeWillExpandListener vetos it.


setLinesDrawn

public void setLinesDrawn(boolean newDrawLines)
Sets whether lines are drawn between tree nodes

Parameters:
newDrawLines - boolean

setModel

public void setModel(TreeModel newModel)
Sets the TreeModel that will provide the data.

Parameters:
newModel - the TreeModel that is to provide the data

setNullActionCommandsRaiseEvents

public void setNullActionCommandsRaiseEvents(boolean newValue)
Sets whether TreeNode null action commands will cause an event to be raised.

Parameters:
newValue - boolean

setRootVisible

public void setRootVisible(boolean rootVisible)
Determines whether or not the root node from the TreeModel is visible.


setRowHeight

public void setRowHeight(int newRowHeight)
Sets the row height to be used for each row within the Tree. If this value is 0 or less, then no row height will be used.

Parameters:
newRowHeight - int

setSelectionModel

public void setSelectionModel(TreeSelectionModel selectionModel)
Sets the tree's selection model. When a null value is specified an empty electionModel is used, which does not allow selections.


setSelectionPath

public void setSelectionPath(TreePath path)
Selects the node identified by the specified path. If any component of the path is hidden (under a collapsed node), it is exposed (made viewable).

Parameters:
path - the TreePath specifying the node to select

setSelectionPaths

public void setSelectionPaths(TreePath[] paths)
Selects the nodes identified by the specified array of paths. If any component in any of the paths is hidden (under a collapsed node), it is exposed (made viewable).

Parameters:
paths - an array of TreePath objects that specifies the nodes to select

setServerSideTree

public void setServerSideTree(boolean newServerSideTree)
Sets whether the Tree is a server side tree.

Parameters:
newServerSideTree - boolean

setShowsRootHandles

public void setShowsRootHandles(boolean newValue)
Determines whether the node handles are to be displayed.


setTreeIcons

public void setTreeIcons(TreeIcons newTreeIcons)
Sets the TreeIcons being used by the Tree

Parameters:
newTreeIcons - echopoint.tree.TreeIcons
See Also:
TreeIcons

setVisible

public void setVisible(boolean newValue)
See Also:
Component.setVisible(boolean)

toggleAllNodes

public void toggleAllNodes(java.lang.Object parent,
                           boolean expand)
Toggles all nodes as expanded or collapsed depending on expand starting from parent.


validate

public void validate()
Called just before the tree is rendered. We run through the tree nodes and try and find any Components that may be rendered by the tree. These will be the Components that are returned by the TreeCellRenderer#getTreeCellRendererComponent(..) method.

We then add them as children of the tree (if they are not already ancestors) so that a component rendering peer is created properly for each cell.

Overrides:
validate in class EchoPointComponent
See Also:
Component.validate()

set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Parameters:
field - - the field to be set
newValue - - the new value to be set
Returns:
the oldValue of the field
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0