eu.webtoolkit.jwt
Class WTree

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WTree

public class WTree
extends WCompositeWidget

A widget that represents a navigatable tree.

WTree provides a tree widget, and coordinates selection functionality.

Unlike the MVC-based WTreeView, the tree renders a widget hierarchy, rather than a hierarhical standard model. This provides extra flexibility (as any widget can be used as contents), at the cost of server-side, client-side and bandwidth resources (especially for large tree tables).

The tree is implemented as a hierarchy of WTreeNode widgets.

Selection is rendered by calling WTreeNode#renderSelected(). Only tree nodes that are selectable may participate in the selection.

CSS

The tree is styled by the current CSS theme. The look can be overridden using the Wt-tree CSS class. The style selectors that affect the rendering of the decoration of the nodes are indicated in the documentation for WTreeNode. In addition, the following selector may be used to style the header:

 .Wt-tree .Wt-selected : selected item
 

A screenshot of the tree:

An example WTree (default)

An example WTree (default)

An example WTree (polished)

An example WTree (polished)

See Also:
WTreeNode, WTreeTable, WTreeView

Constructor Summary
WTree()
          Creates a new tree.
WTree(WContainerWidget parent)
          Creates a new tree.
 
Method Summary
 void clearSelection()
          Clears the current selection.
 java.util.Set<WTreeNode> getSelectedNodes()
          Returns the set of selected tree nodes.
 SelectionMode getSelectionMode()
          Returns the selection mode.
 WTreeNode getTreeRoot()
          Returns the root node.
 boolean isSelected(WTreeNode node)
          Returns if the given node is currently selected.
 Signal itemSelectionChanged()
          Signal that is emitted when the selection changes.
 void select(java.util.Set<WTreeNode> nodes)
          Sets a selection of tree nodes.
 void select(WTreeNode node)
          Selects or unselect the given node.
 void select(WTreeNode node, boolean selected)
          Selects or unselect the given node.
 void setSelectionMode(SelectionMode mode)
          Sets the selection mode.
 void setTreeRoot(WTreeNode node)
          Sets the tree root node.
 
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, getAttributeValue, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, load, propagateSetEnabled, refresh, remove, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setDisabled, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WTree

public WTree(WContainerWidget parent)
Creates a new tree.


WTree

public WTree()
Creates a new tree.

Calls this((WContainerWidget)null)

Method Detail

setTreeRoot

public void setTreeRoot(WTreeNode node)
Sets the tree root node.

The initial value is null.


getTreeRoot

public WTreeNode getTreeRoot()
Returns the root node.

See Also:
setTreeRoot(WTreeNode node)

setSelectionMode

public void setSelectionMode(SelectionMode mode)
Sets the selection mode.

The default selection mode is SelectionMode.NoSelection.


getSelectionMode

public SelectionMode getSelectionMode()
Returns the selection mode.


getSelectedNodes

public java.util.Set<WTreeNode> getSelectedNodes()
Returns the set of selected tree nodes.


select

public void select(java.util.Set<WTreeNode> nodes)
Sets a selection of tree nodes.


select

public void select(WTreeNode node,
                   boolean selected)
Selects or unselect the given node.


select

public final void select(WTreeNode node)
Selects or unselect the given node.

Calls select(node, true)


isSelected

public boolean isSelected(WTreeNode node)
Returns if the given node is currently selected.


clearSelection

public void clearSelection()
Clears the current selection.


itemSelectionChanged

public Signal itemSelectionChanged()
Signal that is emitted when the selection changes.