A tree component manages a javax.swing.tree.TreeModel
data model, tree node values are rendered as markup using a special object, the renderer,
and may be optionally edited "in place" using a user defined editor.
Any change to the data model is notified to the component and the markup
is rendered again. The data model ever mandates over the markup,
any initial markup content (initial root node) is removed.
Almost a root node must be present in the markup, this element is used as a pattern
to create new tree nodes, and is removed because by default the data model is empty.
This component family uses a javax.swing.tree.TreeSelectionModel to keep
track of selection states. When a tree node is selected (usually by clicking it) the selection
state is updated accordingly using the selection model (this one fires any listener registered).
There is no default decoration of tree node selection,
selection model listeners may be used to decorate the tree node markup when its
selection state changes.
The component internally manages the expand/collapse behavior, when
a mouse event is received (by default one click on handler, double click
if icon or label) usually changes the expand/collapse state, this change
is notified sending a javax.swing.event.TreeExpansionEvent
to the registered listeners, these listeners must be used to manage how the expansion/collapsing
is rendered visually (by default the component does not modify the view,
does not force a default view behavior).
By default this component uses the default renderer and editor and
a javax.swing.tree.DefaultTreeModel data model.
getEditorActivatorEvent() Returns the event type used to activate the tree node edition process by the user.
the event type used to activate the edition.
setToggleClickCount(int toggleClickCount) Sets the number of mouse clicks needed to expand or close a node.
Parameters: toggleClickCount - number of mouse clicks to expand/collapse a node.
Current data model is disconnected from this component, and the new
data model is bound to this component, every change is tracked and
updates the user interfaces accordingly.
If the specified data model is the same instance as the current data model,
then is reset, component listener is removed and added again.
Returns the event type used to activate the tree node edition process by the user.
the event type used to activate the edition. By default is "dblclick". See Also:ItsNatTree.setEditorActivatorEvent(String)
Returns the path of the next node seeing the data model as a list (tree order).
First tries to return the first child, if no child returns the next sibling,
if no next sibling returns the next sibling of the parent node, if none
then the next sibling of the parent of the parent and so on.
Returns the row position of the specified path. This position is obtained
calling the built-in row mapper.
the row position of the path. #getRowMapper()
Current implementation converts a TreePath to the matched row seeing
the tree as a list (root node is 0), where every node is "visible" (in a server point of view,
the same node in the client may be hidden).
Informs whether the specified path is expanded.
Parameters: treePath - the specified path. true if the specified path is expanded, true by default. See Also:org.itsnat.comp.ui.ItsNatTreeCellUI.isExpanded
In a root-less tree the root node has no markup, direct child nodes
are top level nodes. This feature may be used to build trees with "multiple
roots" visually, this is very useful in vertical tree-based menus where
a root node is disturbing.
The tree-table mode only affects to the layout of tree nodes. If not
tree-table (normal) child nodes are contained by the parent tree node markup,
in a tree-table layout is as a list, all tree nodes are "top" level nodes
as whether they all were roots (only from a layout point of view).
public void setEditorActivatorEvent(String eventType)(Code)
Sets the event type used to activate the tree node edition process by the user.
Parameters: eventType - the event type used to activate the edition. See Also:ItsNatTree.getEditorActivatorEvent() See Also:
setExpandsSelectedPaths
public void setExpandsSelectedPaths(boolean newValue)(Code)
Sets the expandsSelectedPaths property. If
true, any time the selection is changed, either via the
TreeSelectionModel, or the cover methods provided by
this component like
ItsNatTree.expandNode(javax.swing.tree.TreePath) ,
the TreePaths parents will be
expanded too to make them visible (visible meaning the parent path is
expanded, not necessarily in the visible rectangle of the tree).
If false, when the selection changes the node parents are not expanded.
This is useful if you wish to have your selection model maintain selected paths
that are not always expanded (all parents expanded).
Parameters: newValue - the new value for expandsSelectedPaths See Also:ItsNatTree.isExpandsSelectedPaths()
public void setToggleClickCount(int toggleClickCount)(Code)
Sets the number of mouse clicks needed to expand or close a node.
Parameters: toggleClickCount - number of mouse clicks to expand/collapse a node. Valid numbers: 0,1 and 2. See Also:ItsNatTree.getToggleClickCount()
Current data model is disconnected from this component, and the new
data model is bound to this component, every change is tracked and
updates the user interfaces accordingly.
If the specified data model is the same instance as the current data model,
then is reset, component listener is removed and added again. Use this technique if
you want to add a data model listener to be executed before the default component listener.
Parameters: dataModel - the new data model. See Also:ItsNatTree.getTreeModel()
If the new selection model is the current defined then is "reset",
component listener is removed and added again. Use this technique if
you want to add a listener to be executed before the default component listener.
The component automatically replaces the current selection model javax.swing.tree.RowMapper
with the internal row mapper (
ItsNatTree.getRowMapper() ) calling
TreeSelectionModel.setRowMapper(RowMapper).