|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.wtk.Component
org.apache.pivot.wtk.TreeView
@DefaultProperty(value="treeData") 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
Renderer interface to customize the appearance of items in a TreeView. |
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 org.apache.pivot.wtk.Component |
---|
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary |
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 | |
---|---|
boolean |
addSelectedPath(Sequence.Tree.Path path)
Adds a path to the selection. |
void |
clear()
Clears any bound values in the component. |
void |
clearSelection()
Clears the selection. |
void |
collapseAll()
Collapses all branches in the tree view. |
void |
collapseBranch(Sequence.Tree.Path path)
Collapses the branch at the specified path. |
void |
expandAll()
Expands all branches in the tree view. |
void |
expandBranch(Sequence.Tree.Path path)
Expands the branch at the specified path. |
Sequence<Sequence.Tree.Path> |
getCheckedPaths()
Gets the sequence of node paths that are checked. |
boolean |
getCheckmarksEnabled()
|
Filter<?> |
getDisabledCheckmarkFilter()
Returns the disabled checkmark filter, which determines which checkboxes are interactive and which are not. |
Filter<?> |
getDisabledNodeFilter()
Returns the disabled node filter, which determines the disabled state of all nodes. |
Sequence.Tree.Path |
getFirstSelectedPath()
Returns the first selected path, as it would appear in a fully expanded tree. |
Sequence.Tree.Path |
getLastSelectedPath()
Returns the last selected path, as it would appear in a fully expanded tree. |
Sequence.Tree.Path |
getNodeAt(int y)
Gets the path to the node found at the specified y-coordinate (relative to the tree view). |
Bounds |
getNodeBounds(Sequence.Tree.Path path)
Gets the bounds of the node at the specified path relative to the tree view. |
TreeView.NodeCheckState |
getNodeCheckState(Sequence.Tree.Path 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. |
int |
getRowIndex(Sequence.Tree.Path path)
Gets the row index of the node, as seen in the current visible nodes list. |
Object |
getSelectedNode()
|
Sequence.Tree.Path |
getSelectedPath()
Returns the currently selected index, even when in multi-select mode. |
ImmutableList<Sequence.Tree.Path> |
getSelectedPaths()
Returns the currently selected paths. |
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. |
String |
getTreeDataKey()
|
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.Tree.Path path)
Tells whether or not the specified branch is expanded. |
boolean |
isNodeChecked(Sequence.Tree.Path path)
Tells whether or not the node at the specified path is checked. |
boolean |
isNodeDisabled(Sequence.Tree.Path path)
Returns the disabled state of a given node. |
boolean |
isNodeSelected(Sequence.Tree.Path path)
|
boolean |
removeSelectedPath(Sequence.Tree.Path path)
Removes a path from the selection. |
void |
setBranchExpanded(Sequence.Tree.Path path,
boolean expanded)
Sets the expansion state of the specified branch. |
void |
setCheckmarksEnabled(boolean checkmarksEnabled)
Enables or disables checkmarks. |
void |
setDisabledCheckmarkFilter(Filter<?> disabledCheckmarkFilter)
Sets the disabled checkmark filter, which determines which checkboxes are interactive and which are not. |
void |
setDisabledNodeFilter(Filter<?> disabledNodeFilter)
Sets the disabled node filter, which determines the disabled state of all nodes. |
void |
setNodeChecked(Sequence.Tree.Path path,
boolean checked)
Sets the check state of the node at the specified path. |
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.Tree.Path path)
|
Sequence<Sequence.Tree.Path> |
setSelectedPaths(Sequence<Sequence.Tree.Path> selectedPaths)
|
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. |
void |
setTreeDataKey(String treeDataKey)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, 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, 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 ImmutableList<Sequence.Tree.Path> getSelectedPaths()
public Sequence<Sequence.Tree.Path> setSelectedPaths(Sequence<Sequence.Tree.Path> selectedPaths)
IllegalStateException
- If selection has been disabled (select mode NONE).public Sequence.Tree.Path getFirstSelectedPath()
public Sequence.Tree.Path getLastSelectedPath()
public Sequence.Tree.Path getSelectedPath()
public void setSelectedPath(Sequence.Tree.Path path)
public Object getSelectedNode()
public boolean addSelectedPath(Sequence.Tree.Path path)
path
-
IllegalStateException
- If multi-select is not enabled.public boolean removeSelectedPath(Sequence.Tree.Path path)
path
-
IllegalStateException
- If multi-select is not enabled.public String getTreeDataKey()
public void setTreeDataKey(String treeDataKey)
public void clear()
Component
clear
in class Component
public void clearSelection()
public boolean isNodeSelected(Sequence.Tree.Path path)
public boolean isNodeDisabled(Sequence.Tree.Path path)
path
- The path to the node whose disabled state is to be tested
public Filter<?> getDisabledNodeFilter()
If the disabled node filter is set to null, all nodes are enabled.
public void setDisabledNodeFilter(Filter<?> disabledNodeFilter)
If the disabled node filter is set to null, all nodes are enabled.
disabledNodeFilter
- The disabled node filter, or null for no disabled node filterpublic 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.Tree.Path path)
path
- The path to the node.
getCheckmarksEnabled()
public TreeView.NodeCheckState getNodeCheckState(Sequence.Tree.Path 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.Tree.Path 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.
IllegalStateException
- If checkmarks are not enabled (see getCheckmarksEnabled()
).TreeView.NodeCheckState.MIXED
public Sequence<Sequence.Tree.Path> 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 Filter<?> getDisabledCheckmarkFilter()
Note: this filter is only relavent if
checkmarksEnabled
is set to true.
public void setDisabledCheckmarkFilter(Filter<?> disabledCheckmarkFilter)
Note: this filter is only relavent if
checkmarksEnabled
is set to true.
enabled.
disabledCheckmarkFilter
- The disabled checkmark filter, or null for no disabled
checkmark filterpublic void setBranchExpanded(Sequence.Tree.Path path, boolean expanded)
path
- The path to the branch node.expanded
- true to expand the branch; false to collapse it.public boolean isBranchExpanded(Sequence.Tree.Path path)
path
- The path to the branch node.
public final void expandBranch(Sequence.Tree.Path path)
path
- The path to the branch node.public final void expandAll()
public final void collapseBranch(Sequence.Tree.Path path)
path
- The path to the branch node.public final void collapseAll()
public Sequence.Tree.Path getNodeAt(int y)
y
- The y-coordinate in pixels.
public Bounds getNodeBounds(Sequence.Tree.Path 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 int getRowIndex(Sequence.Tree.Path path)
path
- The path to the node.
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 |