|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nextapp.echo.Component nextapp.echo.Container echopoint.EchoPointComponent echopoint.Tree
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.
TreeModel
,
DefaultTreeModel
,
TreeCellRenderer
,
DefaultTreeCellRenderer
,
TreeNode
,
MutableTreeNode
,
DefaultMutableTreeNode
,
Serialized FormNested 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 |
public static final java.lang.String ACTION_COMMAND_PROPERTY
public static final java.lang.String CELL_RENDERER_PROPERTY
public static final java.lang.String LINES_DRAWN_PROPERTY
public static final java.lang.String NULL_ACTION_COMMANDS_RAISE_EVENTS
public static final java.lang.String ROOT_VISIBLE_PROPERTY
public static final java.lang.String ROW_HEIGHT_CHANGED_PROPERTY
public static final java.lang.String SELECTION_MODEL_PROPERTY
public static final java.lang.String SERVER_SIDE_PROPERTY
public static final java.lang.String SHOWS_ROOT_HANDLES_PROPERTY
public static final java.lang.String STYLE_ROOT_VISIBLE
int
public static final java.lang.String STYLE_ROW_HEIGHT
int
public static final java.lang.String STYLE_SHOWS_ROOT_HANDLES
int
public static final java.lang.String TREE_ICONS_PROPERTY
public static final java.lang.String TREE_MODEL_PROPERTY
protected java.lang.String actionCommand
protected transient TreeCellRenderer cellRenderer
protected transient Tree.TreeSelectionForwarder selectionForwarder
protected transient TreeSelectionModel selectionModel
protected boolean serverSideTree
protected boolean showsRootHandles
protected transient TreeIcons treeIcons
protected transient TreeModel treeModel
protected transient TreeModelListener treeModelListener
Constructor Detail |
public Tree(TreeModel newModel)
Tree
which displays the root node and is
created using the specified data model.
public Tree(TreeNode root)
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.
public Tree(TreeNode root, boolean asksAllowsChildren)
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 |
public void addActionListener(nextapp.echo.event.ActionListener l)
ActionListener
.
l
- The ActionListener
to be added.public void addSelectionPath(TreePath path)
path
- the TreePath to addpublic void addSelectionPaths(TreePath[] paths)
paths
- an array of TreePath objects that specifies the nodes
to addpublic void addTreeExpansionListener(TreeExpansionListener tel)
tel
- a TreeExpansionListener that will be notified when
a tree node is expanded or collapsed (a "negative
expansion")public void addTreeSelectionListener(TreeSelectionListener tsl)
tsl
- the TreeSelectionListener that will be notified when
a node is selected or deselected (a "negative
selection")public void addTreeWillExpandListener(TreeWillExpandListener tel)
tel
- a TreeWillExpandListener that will be notified when
a tree node will be expanded or collapsed (a "negative
expansion")public void applyStyle(nextapp.echo.Style style)
nextapp.echo.Component
style names can be used as well.
applyStyle
in interface MouseCursorable
applyStyle
in class EchoPointComponent
Component.applyStyle(nextapp.echo.Style)
protected void clearToggledPaths()
public void collapseAll()
public void collapsePath(TreePath path)
path
- the TreePath identifying a nodeprotected TreeModelListener createTreeModelListener()
public void expandAll()
public void expandPath(TreePath path)
path
- the TreePath identifying a nodepublic void fireActionPerformed(nextapp.echo.event.ActionEvent e)
e
- The ActionEvent
to send.public void fireTreeCollapsed(TreePath path)
path
- the TreePath indicating the node that was collapsedpublic void fireTreeExpanded(TreePath path)
path
- the TreePath indicating the node that was expandedpublic void fireTreeWillCollapse(TreePath path) throws ExpandVetoException
path
- the TreePath indicating the node that was expanded
ExpandVetoException
public void fireTreeWillExpand(TreePath path) throws ExpandVetoException
path
- the TreePath indicating the node that was expanded
ExpandVetoException
protected void fireValueChanged(TreeSelectionEvent e)
e
- the TreeSelectionEvent generated by the TreeSelectionModel
when a node is selected or deselectedpublic java.lang.String getActionCommand()
Tree
public TreeCellRenderer getCellRenderer()
TreeCellRenderer
public nextapp.echo.Component getComponent(java.lang.Object treeNode)
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.
treeNode
- - the tree node in question
TreeCellRenderer.getTreeCellRendererText(Tree, Object, boolean, boolean, boolean)
protected java.util.Enumeration getDescendantToggledPaths(TreePath parent)
parent
.
public java.util.Enumeration getExpandedDescendants(TreePath parent)
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.
public java.lang.Object getLastSelectedPathComponent()
public TreePath getLeadSelectionPath()
public TreeModel getModel()
public int getRowForPath(TreePath path)
path
is being displayed at. If the TreePath
in path
is not valid it will be set to -1.
public int getRowHeight()
public int[] getRowsForPaths(TreePath[] paths)
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.
public int getSelectionCount()
public TreeSelectionModel getSelectionModel()
public TreePath getSelectionPath()
public TreePath[] getSelectionPaths()
public boolean getShowsRootHandles()
public TreeIcons getTreeIcons()
TreeIcons
public boolean hasBeenExpanded(TreePath path)
public void invalidate()
public boolean isCollapsed(TreePath path)
path
- the TreePath to check
public boolean isExpanded(TreePath path)
path
- the TreePath specifying the node to check
public boolean isLinesDrawn()
public boolean isNullActionCommandsRaiseEvents()
public boolean isPathSelected(TreePath path)
path
- a TreePath identifying a node
public boolean isRootVisible()
public boolean isSelectionEmpty()
public boolean isServerSideTree()
public boolean isVisible(TreePath path)
public void makeVisible(TreePath path)
path
- the TreePath to make visiblepublic void removeActionListener(nextapp.echo.event.ActionListener l)
ActionListener
.
l
- The ActionListener
to be removed.protected void removeDescendantToggledPaths(java.util.Enumeration toRemove)
toRemove
that have been expanded.
public void removeSelectionPath(TreePath path)
path
- the TreePath identifying a nodepublic void removeSelectionPaths(TreePath[] paths)
paths
- an array of TreePath objects that specifies the nodes
to removepublic void removeTreeExpansionListener(TreeExpansionListener tel)
tel
- the TreeExpansionListener to removepublic void removeTreeSelectionListener(TreeSelectionListener tsl)
tsl
- the TreeSelectionListener to removepublic void removeTreeWillExpandListener(TreeWillExpandListener tel)
tel
- the TreeWillExpandListener to removepublic void setActionCommand(java.lang.String newActionCommand)
TreeNode
, via their parents to the Tree
itself.
newActionCommand
- Stringpublic void setCellRenderer(TreeCellRenderer newCellRenderer)
newCellRenderer
- the TreeCellRenderer that is to render each cellTreeCellRenderer
public void setEnabled(boolean newValue)
Component.setEnabled(boolean)
public void setExpandedState(TreePath path, boolean state)
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.
public void setLinesDrawn(boolean newDrawLines)
newDrawLines
- booleanpublic void setModel(TreeModel newModel)
newModel
- the TreeModel that is to provide the datapublic void setNullActionCommandsRaiseEvents(boolean newValue)
newValue
- booleanpublic void setRootVisible(boolean rootVisible)
public void setRowHeight(int newRowHeight)
newRowHeight
- intpublic void setSelectionModel(TreeSelectionModel selectionModel)
public void setSelectionPath(TreePath path)
path
- the TreePath specifying the node to selectpublic void setSelectionPaths(TreePath[] paths)
paths
- an array of TreePath objects that specifies the nodes
to selectpublic void setServerSideTree(boolean newServerSideTree)
Tree
is a server side tree.
newServerSideTree
- booleanpublic void setShowsRootHandles(boolean newValue)
public void setTreeIcons(TreeIcons newTreeIcons)
newTreeIcons
- echopoint.tree.TreeIconsTreeIcons
public void setVisible(boolean newValue)
Component.setVisible(boolean)
public void toggleAllNodes(java.lang.Object parent, boolean expand)
public void validate()
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.
validate
in class EchoPointComponent
Component.validate()
public java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue) throws java.lang.Exception
ReflectionSetter
public Object set(Field f, Object newValue) throws Exception { Object oldValue = f.get(this); f.set(this,newValue); return oldValue; }
field
- - the field to be setnewValue
- - the new value to be set
java.lang.Exception
ReflectionSetter.set(Field, Object)
|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |