EchoPoint
2.1.0rc5

echopointng
Class Tree

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by echopointng.ComponentEx
          extended by echopointng.AbleComponent
              extended by echopointng.Tree
All Implemented Interfaces:
AccessKeyable, Attributeable, Borderable, Delegateable, Heightable, Insetable, MouseCursorable, Sizeable, ToolTipable, Widthable, Serializable, RenderIdSupport

public class Tree
extends AbleComponent

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

A 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.

Tree also supports node selection via its TreeSelectionModel.

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.

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

Nested Class Summary
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 Style DEFAULT_STYLE
           
static String INPUT_SELECT
          Used as an INPUT name to indicate that a node is to be selected
static String INPUT_TOGGLE
          Used as an INPUT name to indicate that a node is to be toggled, ie expanded or contracted
static String MODEL_STRUCTURE_CHANGED_PROPERTY
           
static String NODE_CHANGED_PROPERTY
           
static String PROPERTY_ACTION_COMMAND
           
static String PROPERTY_CELL_RENDERER
           
static String PROPERTY_CELL_WIDTH_CONTRAINED
           
static String PROPERTY_LINES_DRAWN
           
static String PROPERTY_MODEL
           
static String PROPERTY_NULL_ACTION_COMMANDS_RAISE_EVENTS
           
static String PROPERTY_PARTIAL_UPDATE_SUPPORT
           
static String PROPERTY_ROOT_AUTO_EXPANDED
           
static String PROPERTY_ROOT_VISIBLE
           
static String PROPERTY_ROW_HEIGHT
           
static String PROPERTY_SCROLL_INTO_VIEW_USED
           
static String PROPERTY_SELECTION_INCLUDES_ICON
           
static String PROPERTY_SELECTION_MODEL
           
static String PROPERTY_SHOWS_ROOT_HANDLES
           
static String PROPERTY_TREE_ICONS
           
 
Fields inherited from class echopointng.ComponentEx
PROPERTY_HIDDEN
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopointng.able.AccessKeyable
PROPERTY_ACCESS_KEY
 
Fields inherited from interface echopointng.able.Borderable
PROPERTY_BORDER
 
Fields inherited from interface echopointng.able.MouseCursorable
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, PROPERTY_MOUSE_CURSOR, PROPERTY_MOUSE_CURSOR_URI
 
Fields inherited from interface echopointng.able.Insetable
DEFAULT_INSETS, DEFAULT_OUTSETS, PROPERTY_INSETS, PROPERTY_OUTSETS
 
Fields inherited from interface echopointng.able.Widthable
PROPERTY_WIDTH
 
Fields inherited from interface echopointng.able.Heightable
PROPERTY_HEIGHT
 
Fields inherited from interface echopointng.able.ToolTipable
PROPERTY_TOOL_TIP_TEXT
 
Constructor Summary
Tree()
          Returns a Tree with a DefaultMutableTreeNode as its root, which displays the root node.
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(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.
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.
 void collapseRow(int row)
          Ensures that the node in the specified row is collapsed.
protected  TreeModelListener createTreeModelListener()
          Creates and returns an instance of TreeModelListener.
 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 expandRow(int row)
          Ensures that the node in the specified row is expanded and viewable.
 void fireActionPerformed(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.
 String getActionCommand()
          Returns the action command string of the Tree
 TreeCellRenderer getCellRenderer()
          Returns the current TreeCellRenderer that is rendering each cell.
 Component getComponent(Object treeNode)
          Returns the Component that will be used to render the provided tree node.
protected  Enumeration getDescendantToggledPaths(TreePath parent)
          Returns an Enumeration of TreePaths that have been expanded that are descendants of parent.
 Collection getDirtyPaths()
           
 Enumeration getExpandedDescendants(TreePath parent)
          Returns an Enumeration of the descendants of path that are currently expanded.
 Collection getLastExpandedPaths()
          This will return a collection of TresePath that have expanded within the Tree.
 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.
 boolean getPartialUpdateSupport()
          Returns true if the partial update support is currently enabled.
 TreePath getPathForRow(int row)
          Returns the path for the specified row.
 int getRowCount()
          Returns the number of rows that are currently being displayed in the Tree.
 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 hasEverBeenExpanded(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 isCellWidthConstrained()
          Returns true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.
 boolean isCollapsed(int row)
          Returns true if the node at the specified display row is collapsed.
 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(int row)
          Returns true if the node at the specified display row is currently expanded.
 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's with '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 isRootAutoExpanded()
          Returns true if the root node of the tree is expanded when the TreeModel is first set.
 boolean isRootVisible()
          Returns true if the root node of the tree is displayed.
 boolean isScrollIntoViewUsed()
           
 boolean isSelectionEmpty()
          Returns true if the selection is currently empty.
 boolean isSelectionIncludesIcon()
           
 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 processInput(String name, Object value)
           
 void removeActionListener(ActionListener l)
          Removes an ActionListener.
protected  void removeDescendantToggledPaths(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.
 void setActionCommand(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 setCellWidthConstrained(boolean newValue)
          Set to true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.
 void setEnabled(boolean newValue)
           
protected  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 newTreeModel)
          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 setPartialUpdateSupport(boolean newValue)
          If this is set to true, the Tree rendering code is given a hint on whether it can perform partial updates to speed up visual performance.
 void setRootAutoExpanded(boolean rootExpanded)
          Determines whether or not the root node from the TreeModel is automatically expanded when the model is set into the Tree.
 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 setScrollIntoViewUsed(boolean newValue)
          Tree has the ability to "scroll" a peer or child into view when a node is expanded.
 void setSelectionIncludesIcon(boolean newValue)
          Set to true if the selection of a tree node includes the area around the node icon or false if it does not.
 void setSelectionModel(TreeSelectionModel newSelectionModel)
          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 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(TreePath parentPath, boolean expand)
          Toggles all nodes as expanded or collapsed depending on expand starting from parentPath.
 void validate()
          Called just before the tree is rendered.
 
Methods inherited from class echopointng.AbleComponent
getAccessKey, getBorder, getHeight, getInsets, getMouseCursor, getMouseCursorUri, getOutsets, getToolTipText, getWidth, setAccessKey, setBorder, setHeight, setInsets, setMouseCursor, setMouseCursorUri, setOutsets, setToolTipText, setWidth
 
Methods inherited from class echopointng.ComponentEx
getAttribute, getAttributeNames, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, isHidden, setAttribute, setHidden, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setRenderId, setStyle, setStyleName, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 
Methods inherited from interface echopointng.able.Delegateable
getRenderProperty, getRenderProperty
 

Field Detail

INPUT_TOGGLE

public static final String INPUT_TOGGLE
Used as an INPUT name to indicate that a node is to be toggled, ie expanded or contracted

See Also:
Constant Field Values

INPUT_SELECT

public static final String INPUT_SELECT
Used as an INPUT name to indicate that a node is to be selected

See Also:
Constant Field Values

PROPERTY_ACTION_COMMAND

public static final String PROPERTY_ACTION_COMMAND
See Also:
Constant Field Values

PROPERTY_CELL_RENDERER

public static final String PROPERTY_CELL_RENDERER
See Also:
Constant Field Values

PROPERTY_LINES_DRAWN

public static final String PROPERTY_LINES_DRAWN
See Also:
Constant Field Values

PROPERTY_NULL_ACTION_COMMANDS_RAISE_EVENTS

public static final String PROPERTY_NULL_ACTION_COMMANDS_RAISE_EVENTS
See Also:
Constant Field Values

PROPERTY_ROOT_VISIBLE

public static final String PROPERTY_ROOT_VISIBLE
See Also:
Constant Field Values

PROPERTY_ROW_HEIGHT

public static final String PROPERTY_ROW_HEIGHT
See Also:
Constant Field Values

PROPERTY_SELECTION_MODEL

public static final String PROPERTY_SELECTION_MODEL
See Also:
Constant Field Values

PROPERTY_SHOWS_ROOT_HANDLES

public static final String PROPERTY_SHOWS_ROOT_HANDLES
See Also:
Constant Field Values

PROPERTY_TREE_ICONS

public static final String PROPERTY_TREE_ICONS
See Also:
Constant Field Values

PROPERTY_MODEL

public static final String PROPERTY_MODEL
See Also:
Constant Field Values

PROPERTY_ROOT_AUTO_EXPANDED

public static final String PROPERTY_ROOT_AUTO_EXPANDED
See Also:
Constant Field Values

PROPERTY_PARTIAL_UPDATE_SUPPORT

public static final String PROPERTY_PARTIAL_UPDATE_SUPPORT
See Also:
Constant Field Values

PROPERTY_CELL_WIDTH_CONTRAINED

public static final String PROPERTY_CELL_WIDTH_CONTRAINED
See Also:
Constant Field Values

PROPERTY_SELECTION_INCLUDES_ICON

public static final String PROPERTY_SELECTION_INCLUDES_ICON
See Also:
Constant Field Values

PROPERTY_SCROLL_INTO_VIEW_USED

public static final String PROPERTY_SCROLL_INTO_VIEW_USED
See Also:
Constant Field Values

NODE_CHANGED_PROPERTY

public static final String NODE_CHANGED_PROPERTY
See Also:
Constant Field Values

MODEL_STRUCTURE_CHANGED_PROPERTY

public static final String MODEL_STRUCTURE_CHANGED_PROPERTY
See Also:
Constant Field Values

DEFAULT_STYLE

public static final Style DEFAULT_STYLE
Constructor Detail

Tree

public Tree()
Returns a Tree with a DefaultMutableTreeNode as its root, which displays the root node.


Tree

public Tree(TreeNode root)
Returns a Tree with the specified TreeNode as its root, which displays the root node.


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.


Tree

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

Method Detail

processInput

public void processInput(String name,
                         Object value)
Overrides:
processInput in class Component
See Also:
Component.processInput(java.lang.String, java.lang.Object)

addActionListener

public void addActionListener(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")

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

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(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

getActionCommand

public 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 Component getComponent(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)

getExpandedDescendants

public 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 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

getLastExpandedPaths

public Collection getLastExpandedPaths()
This will return a collection of TresePath that have expanded within the Tree. This will be automatically cleared each time a Tree is rendered so dont rely on it.

Returns:
a collection of TresePath that have expanded within the Tree.

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.


getRowsForPaths

public int[] getRowsForPaths(TreePath[] paths)
Returns the rows that the TreePath instances in path are being displayed at. The returned array is 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.


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

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:
the TreeIcons being used by the Tree
See Also:
TreeIcons

hasEverBeenExpanded

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

Parameters:
path - = The TreePath in question

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

getPathForRow

public TreePath getPathForRow(int row)
Returns the path for the specified row. If row is not visible, null is returned.

Parameters:
row - an integer specifying a row
Returns:
the TreePath to the specified node, null if row < 0 or row >= getRowCount()

getRowCount

public int getRowCount()
Returns the number of rows that are currently being displayed in the Tree.

Returns:
the number of rows that are being displayed in the Tree

isExpanded

public boolean isExpanded(int row)
Returns true if the node at the specified display row is currently expanded.

Parameters:
row - the row to check, where 0 is the first row in the display
Returns:
true if the node is currently expanded, otherwise false

isCollapsed

public boolean isCollapsed(int row)
Returns true if the node at the specified display row is collapsed.

Parameters:
row - the row to check, where 0 is the first row in the display
Returns:
true if the node is currently collapsed, otherwise false

expandRow

public void expandRow(int row)
Ensures that the node in the specified row is expanded and viewable.

If row is < 0 or >=getRowCount this will have no effect.

Parameters:
row - an integer specifying a display row, where 0 is the first row in the display

collapseRow

public void collapseRow(int row)
Ensures that the node in the specified row is collapsed.

If row is < 0 or >=getRowCount this will have no effect.

Parameters:
row - an integer specifying a display row, where 0 is the first row in the display

isLinesDrawn

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

Returns:
boolean

isScrollIntoViewUsed

public boolean isScrollIntoViewUsed()
Returns:
true if the last expanded node will be scroll into view

setScrollIntoViewUsed

public void setScrollIntoViewUsed(boolean newValue)
Tree has the ability to "scroll" a peer or child into view when a node is expanded. This provides a more pleasant user experience. If this flag is ste to true, the Tree will "scroll" the peer of an expanded node into view and if it has not peer then it will "scroll" the last child of the expanded node into view.

If you child node counts are quite high, you may not want this behaviour and hence you should set it to false.

Parameters:
newValue - a new boolean flag value

isNullActionCommandsRaiseEvents

public boolean isNullActionCommandsRaiseEvents()
Returns TRUE of TreeNode's with '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.


isRootAutoExpanded

public boolean isRootAutoExpanded()
Returns true if the root node of the tree is expanded when the TreeModel is first set.


isSelectionEmpty

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

Returns:
true if the selection is currently empty

isCellWidthConstrained

public boolean isCellWidthConstrained()
Returns true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.

Returns:
true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.

setCellWidthConstrained

public void setCellWidthConstrained(boolean newValue)
Set to true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.

Parameters:
newValue - - true if the Tree cells use as much UI width as possible or false if the cells try to contrain their UI width.

isSelectionIncludesIcon

public boolean isSelectionIncludesIcon()
Returns:
true if the selection of a tree node includes the area around the node icon or false if it does not.

setSelectionIncludesIcon

public void setSelectionIncludesIcon(boolean newValue)
Set to true if the selection of a tree node includes the area around the node icon or false if it does not.

Parameters:
newValue - - true if the selection of a tree node includes the area around the node icon or false if it does not.

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(ActionListener l)
Removes an ActionListener.

Parameters:
l - The ActionListener to be removed.

removeDescendantToggledPaths

protected void removeDescendantToggledPaths(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(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.

NOTE : Some TreeCellRender implementations such as DefaultTreeeCellRenderer are implemented as a Component. While this is perfectly valid, please note that the implementation is not added a a child of Tree and hence inheritied styles from the component hierarchy do not apply. Not adding the implementation as a child component allows for "static" implementations of TreeCellRender that are derived from Component.

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

setEnabled

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

setLinesDrawn

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

Parameters:
newDrawLines - boolean

setPartialUpdateSupport

public void setPartialUpdateSupport(boolean newValue)
If this is set to true, the Tree rendering code is given a hint on whether it can perform partial updates to speed up visual performance. By default this is true. Partial update support costs more in terms of server memory because the old state must be tracked. But it can result in better visual performance.

Parameters:
newValue - - a true value cause partial updates to be used by the rendering

getPartialUpdateSupport

public boolean getPartialUpdateSupport()
Returns true if the partial update support is currently enabled.

If this is set to true, the Tree rendering code is given a hint on whether it can perform partial updates to speed up visual performance. By default this is true. Partial update support costs more in terms of server memory because the old state must be tracked. But it can result in better visual performance.

Returns:
true if the partial update support is currently enabled.

setModel

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

Parameters:
newTreeModel - - 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.


setRootAutoExpanded

public void setRootAutoExpanded(boolean rootExpanded)
Determines whether or not the root node from the TreeModel is automatically expanded when the model is set into the Tree.

By default it is and hence the 2nd child level of the TreeModel will be accessed and shown.

If this is false, then only the root node will be accessed and displayed when a TreeModel is first set and the Tree is rendered.


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 newSelectionModel)
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

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 - - the new icons to use
See Also:
TreeIcons

setVisible

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

toggleAllNodes

public void toggleAllNodes(TreePath parentPath,
                           boolean expand)
Toggles all nodes as expanded or collapsed depending on expand starting from parentPath.


createTreeModelListener

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


clearToggledPaths

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


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

getDescendantToggledPaths

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


setExpandedState

protected 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.


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 Component

getDirtyPaths

public Collection getDirtyPaths()
Returns:
the collection of pending changed paths (needed for partial updates when rendering)

EchoPoint
2.1.0rc5