|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpivot.wtk.Component
pivot.wtk.TreeView
public class TreeView
Class that displays a hierarchical data structure, allowing a user to select one or more paths.
Nested Class Summary | |
---|---|
static class |
TreeView.NodeCheckState
Enumeration defining node check states. |
static interface |
TreeView.NodeEditor
Tree view node editor interface. |
static interface |
TreeView.NodeRenderer
Tree view node renderer interface. |
static class |
TreeView.PathComparator
A comparator that sorts paths by the order in which they would visually appear in a fully expanded tree, otherwise known as their "row order". |
static class |
TreeView.SelectMode
Enumeration defining supported selection modes. |
static interface |
TreeView.Skin
Tree view skin interface. |
Nested classes/interfaces inherited from class pivot.wtk.Component |
---|
Component.Attributes, Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary |
Constructor Summary | |
---|---|
TreeView()
Creates a new TreeView with empty tree data. |
|
TreeView(List<?> treeData)
Creates a new TreeView with the specified tree data. |
Method Summary | |
---|---|
void |
addSelectedPath(Sequence<java.lang.Integer> path)
|
void |
clearSelection()
|
void |
collapseBranch(Sequence<java.lang.Integer> path)
Collapses the branch at the specified path. |
void |
expandBranch(Sequence<java.lang.Integer> path)
Expands the branch at the specified path. |
Sequence<Sequence<java.lang.Integer>> |
getCheckedPaths()
Gets the sequence of node paths that are checked. |
boolean |
getCheckmarksEnabled()
|
Sequence<Sequence<java.lang.Integer>> |
getDisabledPaths()
|
Sequence<java.lang.Integer> |
getFirstSelectedPath()
Returns the first selected path, as it would appear in a fully expanded tree. |
Sequence<java.lang.Integer> |
getLastSelectedPath()
Returns the last selected path, as it would appear in a fully expanded tree. |
Sequence<java.lang.Integer> |
getNodeAt(int y)
Gets the path to the node found at the specified y-coordinate (relative to the tree view). |
Bounds |
getNodeBounds(Sequence<java.lang.Integer> path)
Gets the bounds of the node at the specified path relative to the tree view. |
TreeView.NodeCheckState |
getNodeCheckState(Sequence<java.lang.Integer> path)
Returns the checkmark state of the node at the specified path. |
TreeView.NodeEditor |
getNodeEditor()
Returns the editor used to edit nodes in this tree. |
int |
getNodeIndent(int depth)
Gets the pixel indent of nodes at the specified depth. |
TreeView.NodeRenderer |
getNodeRenderer()
Gets the tree view's node renderer, which is responsible for the appearance of the node data. |
java.lang.Object |
getSelectedNode()
|
Sequence<java.lang.Integer> |
getSelectedPath()
|
Sequence<Sequence<java.lang.Integer>> |
getSelectedPaths()
|
TreeView.SelectMode |
getSelectMode()
Returns the current selection mode. |
boolean |
getShowMixedCheckmarkState()
Tells whether or not the mixed check state will be reported by this tree view. |
List<?> |
getTreeData()
Returns the tree view's data model. |
ListenerList<TreeViewBranchListener> |
getTreeViewBranchListeners()
Gets the TreeViewBranchListeners. |
ListenerList<TreeViewListener> |
getTreeViewListeners()
Gets the TreeViewListeners. |
ListenerList<TreeViewNodeListener> |
getTreeViewNodeListeners()
Gets the TreeViewNodeListeners. |
ListenerList<TreeViewNodeStateListener> |
getTreeViewNodeStateListeners()
Gets the TreeViewNodeStateListeners. |
ListenerList<TreeViewSelectionListener> |
getTreeViewSelectionListeners()
Gets the TreeViewSelectionListeners. |
boolean |
isBranchExpanded(Sequence<java.lang.Integer> path)
Tells whether or not the specified branch is expanded. |
boolean |
isNodeChecked(Sequence<java.lang.Integer> path)
Tells whether or not the node at the specified path is checked. |
boolean |
isNodeDisabled(Sequence<java.lang.Integer> path)
Returns the disabled state of a given node. |
boolean |
isNodeSelected(Sequence<java.lang.Integer> path)
|
void |
removeSelectedPath(Sequence<java.lang.Integer> path)
|
void |
setBranchExpanded(Sequence<java.lang.Integer> path,
boolean expanded)
Sets the expansion state of the specified branch. |
void |
setCheckmarksEnabled(boolean checkmarksEnabled)
Enables or disables checkmarks. |
void |
setNodeChecked(Sequence<java.lang.Integer> path,
boolean checked)
Sets the check state of the node at the specified path. |
void |
setNodeDisabled(Sequence<java.lang.Integer> path,
boolean disabled)
Sets the disabled state of a node. |
void |
setNodeEditor(TreeView.NodeEditor nodeEditor)
Sets the editor used to edit nodes in this tree. |
void |
setNodeRenderer(TreeView.NodeRenderer nodeRenderer)
Sets the tree view's node renderer, which is responsible for the appearance of the node data. |
void |
setSelectedPath(Sequence<java.lang.Integer> path)
|
void |
setSelectedPaths(Sequence<Sequence<java.lang.Integer>> selectedPaths)
|
void |
setSelectMode(java.lang.String selectMode)
Sets the selection mode. |
void |
setSelectMode(TreeView.SelectMode selectMode)
Sets the selection mode. |
void |
setShowMixedCheckmarkState(boolean showMixedCheckmarkState)
Sets whether or not the "mixed" check state will be reported by this tree view. |
protected void |
setSkin(Skin skin)
Sets the skin, replacing any previous skin. |
void |
setTreeData(List<?> treeData)
Sets the tree data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TreeView()
public TreeView(List<?> treeData)
treeData
- Default data set to be used with the tree. This list represents the root
set of items displayed by the tree and will never itself be painted.
Sub-items that also implement the List interface are considered
branches; other items are considered leaves.setTreeData(List)
Method Detail |
---|
protected void setSkin(Skin skin)
TreeView.Skin
interface.
setSkin
in class Component
skin
- The new skin.public List<?> getTreeData()
For instance, a tree view that displays a single root branch would be backed by list with one child (also a list).
public void setTreeData(List<?> treeData)
TreeViewNodeRenderer
is used.
When the tree data is changed, the state of all nodes (expansion,
selection, disabled, and checked) will be cleared since the nodes
themselves are being replaced. Note that corresponding events will
not be fired, since these actions are implied by the
treeDataChanged
event.
treeData
- The data to be presented by the tree.public TreeView.NodeRenderer getNodeRenderer()
TreeViewNodeRenderer
public void setNodeRenderer(TreeView.NodeRenderer nodeRenderer)
nodeRenderer
- The new node renderer.public TreeView.NodeEditor getNodeEditor()
public void setNodeEditor(TreeView.NodeEditor nodeEditor)
nodeEditor
- The node editor for the tree.public TreeView.SelectMode getSelectMode()
public void setSelectMode(TreeView.SelectMode selectMode)
selectModeChanged
event.
selectMode
- The new selection mode.TreeViewListener
,
TreeViewSelectionListener
public final void setSelectMode(java.lang.String selectMode)
selectMode
- The new selection mode.setSelectMode(SelectMode)
public Sequence<Sequence<java.lang.Integer>> getSelectedPaths()
public void setSelectedPaths(Sequence<Sequence<java.lang.Integer>> selectedPaths)
java.lang.IllegalStateException
- If selection has been disabled (select mode NONE).public Sequence<java.lang.Integer> getFirstSelectedPath()
public Sequence<java.lang.Integer> getLastSelectedPath()
public Sequence<java.lang.Integer> getSelectedPath()
java.lang.IllegalStateException
- If the tree view is not in single-select mode.public void setSelectedPath(Sequence<java.lang.Integer> path)
public java.lang.Object getSelectedNode()
public void addSelectedPath(Sequence<java.lang.Integer> path)
java.lang.IllegalStateException
- If multi-select is not enabled.public void removeSelectedPath(Sequence<java.lang.Integer> path)
java.lang.IllegalStateException
- If multi-select is not enabled.public void clearSelection()
public boolean isNodeSelected(Sequence<java.lang.Integer> path)
public boolean isNodeDisabled(Sequence<java.lang.Integer> path)
path
- The path to the node whose disabled state is to be tested
public void setNodeDisabled(Sequence<java.lang.Integer> path, boolean disabled)
path
- The path to the node.disabled
- true to disable the node; false to enable it.public Sequence<Sequence<java.lang.Integer>> getDisabledPaths()
public boolean getCheckmarksEnabled()
public void setCheckmarksEnabled(boolean checkmarksEnabled)
checkmarksEnabledChanged
event.
checkmarksEnabled
- true to enable checkmarks; false to disable them.public boolean getShowMixedCheckmarkState()
TreeView.NodeCheckState.MIXED
public void setShowMixedCheckmarkState(boolean showMixedCheckmarkState)
Changing this flag may result in some nodes changing their reported
check state. Note that the corresponding nodeCheckStateChanged
events will not be fired, since the possibility of such a change
in check state is implied by the
showMixedCheckmarkStateChanged
event.
showMixedCheckmarkState
- true to show the derived mixed state; false to report
so-called "mixed" nodes as unchecked.TreeView.NodeCheckState.MIXED
public boolean isNodeChecked(Sequence<java.lang.Integer> path)
path
- The path to the node.
getCheckmarksEnabled()
public TreeView.NodeCheckState getNodeCheckState(Sequence<java.lang.Integer> path)
Note that the MIXED check state (meaning "the node is not checked, but one or more of its descendants are") is only reported when the tree view is configured as such. Otherwise, such nodes will be reported as UNCHECKED.
path
- The path to the node.
getCheckmarksEnabled()
,
setShowMixedCheckmarkState(boolean)
public void setNodeChecked(Sequence<java.lang.Integer> path, boolean checked)
Note that it is impossible to set the check state of a node to MIXED. This is because the mixed check state is a derived state meaning "the node is not checked, but one or more of its descendants are."
path
- The path to the node.checked
- true to check the node; false to uncheck it.
java.lang.IllegalStateException
- If checkmarks are not enabled (see getCheckmarksEnabled()
).TreeView.NodeCheckState.MIXED
public Sequence<Sequence<java.lang.Integer>> getCheckedPaths()
getCheckmarksEnabled()
), this is guaranteed to
return an empty sequence.
Note that if the tree view is configured to show mixed checkmark states
(see getShowMixedCheckmarkState()
), this will still only return
the nodes that are fully checked.
public void setBranchExpanded(Sequence<java.lang.Integer> path, boolean expanded)
path
- The path to the branch node.expanded
- true to expand the branch; false to collapse it.public boolean isBranchExpanded(Sequence<java.lang.Integer> path)
path
- The path to the branch node.
public final void expandBranch(Sequence<java.lang.Integer> path)
path
- The path to the branch node.public final void collapseBranch(Sequence<java.lang.Integer> path)
path
- The path to the branch node.public Sequence<java.lang.Integer> getNodeAt(int y)
y
- The y-coordinate in pixels.
public Bounds getNodeBounds(Sequence<java.lang.Integer> path)
getNodeIndent(int)
.
path
- The path to the node.
public int getNodeIndent(int depth)
tree data
.
depth
- The depth, where the first child of the root has depth 1, the child of
that branch has depth 2, etc.
public ListenerList<TreeViewListener> getTreeViewListeners()
public ListenerList<TreeViewBranchListener> getTreeViewBranchListeners()
public ListenerList<TreeViewNodeListener> getTreeViewNodeListeners()
public ListenerList<TreeViewNodeStateListener> getTreeViewNodeStateListeners()
public ListenerList<TreeViewSelectionListener> getTreeViewSelectionListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |