Class Tree<M,C>
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.sencha.gxt.widget.core.client.Component
-
- com.sencha.gxt.widget.core.client.tree.Tree<M,C>
-
- Type Parameters:
M
- the model typeC
- the cell data type
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers
,com.google.gwt.event.logical.shared.HasResizeHandlers
,com.google.gwt.event.shared.HasHandlers
,com.google.gwt.user.client.EventListener
,com.google.gwt.user.client.ui.HasEnabled
,com.google.gwt.user.client.ui.HasVisibility
,com.google.gwt.user.client.ui.IsWidget
,HasGestureRecognizers
,CheckProvider<M>
,BeforeCheckChangeEvent.HasBeforeCheckChangeHandlers<M>
,BeforeCollapseItemEvent.HasBeforeCollapseItemHandlers<M>
,BeforeExpandItemEvent.HasBeforeExpandItemHandlers<M>
,BeforeHideEvent.HasBeforeHideHandlers
,BeforeShowContextMenuEvent.HasBeforeShowContextMenuHandler
,BeforeShowEvent.HasBeforeShowHandlers
,BlurEvent.HasBlurHandlers
,CheckChangedEvent.HasCheckChangedHandlers<M>
,CheckChangeEvent.HasCheckChangeHandlers<M>
,CollapseItemEvent.HasCollapseItemHandlers<M>
,DisableEvent.HasDisableHandlers
,EnableEvent.HasEnableHandlers
,ExpandItemEvent.HasExpandItemHandlers<M>
,FocusEvent.HasFocusHandlers
,HideEvent.HasHideHandlers
,MoveEvent.HasMoveHandlers
,ShowContextMenuEvent.HasShowContextMenuHandler
,ShowEvent.HasShowHandlers
,HasFocusSupport
,HasItemId
public class Tree<M,C> extends Component implements BeforeExpandItemEvent.HasBeforeExpandItemHandlers<M>, ExpandItemEvent.HasExpandItemHandlers<M>, BeforeCollapseItemEvent.HasBeforeCollapseItemHandlers<M>, CollapseItemEvent.HasCollapseItemHandlers<M>, BeforeCheckChangeEvent.HasBeforeCheckChangeHandlers<M>, CheckChangeEvent.HasCheckChangeHandlers<M>, CheckProvider<M>
A
Tree
provides support for displaying hierarchical data. The tree gets its data from aTreeStore
. Each model in the store is rendered as an item in the tree. Any updates to the store are automatically pushed to the tree.In GXT version 3,
ModelKeyProvider
s andValueProvider
s provide the interface between your data model, the tree store and the tree. This enables a tree to work with data of any object type. The tree uses a value provider, passed to the constructor, to get the value to display for each model in the tree.You can provide your own implementation of these interfaces, or you can use a Sencha supplied generator to create them for you automatically. A generator runs at compile time to create a Java class that is compiled to JavaScript. The Sencha supplied generator can create classes for interfaces that extend the
PropertyAccess
interface. The generator transparently creates the class at compile time and theGWT.create(Class)
method returns an instance of that class at run time. The generated class is managed by GWT and GXT and you generally do not need to worry about what the class is called, where it is located, or other similar details.To customize the appearance of the item in the tree, provide a cell implementation using
setCell(Cell)
.The following code snippet illustrates the creation of a simple tree with local data for test purposes. For more practical examples that show how to load data from remote sources, see the Async Tree and Async Json Tree examples in the online Explorer demo.
// Generate the key provider and value provider for the Data class DataProperties dp = GWT.create(DataProperties.class); // Create the store that the contains the data to display in the tree TreeStore<Data> s = new TreeStore<Test.Data>(dp.key()); Data r1 = new Data("Parent 1", "value1"); s.add(r1); s.add(r1, new Data("Child 1.1", "value2")); s.add(r1, new Data("Child 1.2", "value3")); Data r2 = new Data("Parent 2", "value4"); s.add(r2); s.add(r2, new Data("Child 2.1", "value5")); s.add(r2, new Data("Child 2.2", "value6")); // Create the tree using the store and value provider for the name field Tree<Data, String> t = new Tree<Data, String>(s, dp.name()); // Add the tree to a container RootPanel.get().add(t);
To use the Sencha supplied generator to create model key providers and value providers, extend the PropertyAccess interface, parameterized with the type of data you want to access (as shown below) and invoke the GWT.create method on its class member (as shown in the code snippet above). This creates an instance of the class that can be used to initialize the tree and tree store. In the following code snippet we define a new interface called DataProperties that extends the PropertyAccess interface and is parameterized with Data, a Plain Old Java Object (POJO).
public interface DataProperties extends PropertyAccess<Data> { @Path("name") ModelKeyProvider<Data> key(); ValueProvider<Data, String> name(); ValueProvider<Data, String> value(); } public class Data { protected String name; protected String value; public Data(String name, String value) { super(); this.name = name; this.value = value; } public String getName() { return name; } public String getValue() { return value; } public void setName(String name) { this.name = name; } public void setValue(String value) { this.value = value; } }
To enable check box support for a tree, add the following:
t.setCheckable(true); t.setCheckStyle(CheckCascade.CHILDREN);
See
Tree.CheckCascade
for additional check box styles.To save and restore the expand / collapse state of tree items, add the following (must be after the tree is added to the container). This works with both local and asynchronous loading of tree items.
t.setStateId("TreeCodeSnippetTest"); StateManager.get().setProvider(new CookieProvider("/", null, null, GXT.isSecure())); TreeStateHandler<Data> sh = new TreeStateHandler<Data>(t); sh.loadState();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Tree.CheckCascade
Check cascade enum.static class
Tree.CheckNodes
Check nodes enum.static class
Tree.CheckState
static class
Tree.Joint
Joint enum.static interface
Tree.TreeAppearance
static class
Tree.TreeNode<M>
Maintains the internal state of nodes contained in the tree.
-
Constructor Summary
Constructors Constructor Description Tree(TreeStore<M> store, ValueProvider<? super M,C> valueProvider)
Creates a new tree panel.Tree(TreeStore<M> store, ValueProvider<? super M,C> valueProvider, Tree.TreeAppearance appearance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistration
addBeforeCheckChangeHandler(BeforeCheckChangeEvent.BeforeCheckChangeHandler<M> handler)
Adds aBeforeCheckChangeEvent.BeforeCheckChangeHandler
handler forBeforeCheckChangeEvent
events.com.google.gwt.event.shared.HandlerRegistration
addBeforeCollapseHandler(BeforeCollapseItemEvent.BeforeCollapseItemHandler<M> handler)
Adds aBeforeCollapseItemEvent.BeforeCollapseItemHandler
handler forBeforeCollapseItemEvent
events.com.google.gwt.event.shared.HandlerRegistration
addBeforeExpandHandler(BeforeExpandItemEvent.BeforeExpandItemHandler<M> handler)
Adds aBeforeExpandItemEvent.BeforeExpandItemHandler
handler forBeforeExpandItemEvent
events.com.google.gwt.event.shared.HandlerRegistration
addCheckChangedHandler(CheckChangedEvent.CheckChangedHandler<M> handler)
Adds aCheckChangedEvent.CheckChangedHandler
handler forCheckChangedEvent
events.com.google.gwt.event.shared.HandlerRegistration
addCheckChangeHandler(CheckChangeEvent.CheckChangeHandler<M> handler)
Adds aCheckChangeEvent.CheckChangeHandler
handler forCheckChangeEvent
events.com.google.gwt.event.shared.HandlerRegistration
addCollapseHandler(CollapseItemEvent.CollapseItemHandler<M> handler)
Adds aCollapseItemEvent.CollapseItemHandler
handler forCollapseItemEvent
events.com.google.gwt.event.shared.HandlerRegistration
addExpandHandler(ExpandItemEvent.ExpandItemHandler<M> handler)
Adds aExpandItemEvent.ExpandItemHandler
handler forExpandItemEvent
events.void
collapseAll()
Collapses all nodes.void
expandAll()
Expands all nodes.Tree.TreeNode<M>
findNode(com.google.gwt.dom.client.Element target)
Returns the tree node for the given target.Tree.TreeNode<M>
findNode(M model)
Returns the tree node for the given model.void
focus()
Try to focus this widget.Tree.TreeAppearance
getAppearance()
Returns the tree appearance.com.google.gwt.cell.client.Cell<C>
getCell()
Return the tree's cell.Tree.CheckState
getChecked(M model)
Returns the models checked state.List<M>
getCheckedSelection()
Returns the current checked selection.Tree.CheckNodes
getCheckNodes()
Returns the child nodes value which determines what node types have a check box.Tree.CheckCascade
getCheckStyle()
The check cascade style value which determines if check box changes cascade to parent and children.IconProvider<M>
getIconProvider()
Returns the model icon provider.TreeSelectionModel<M>
getSelectionModel()
Returns the tree's selection model.TreeStore<M>
getStore()
Returns the tree's store.TreeStyle
getStyle()
Returns the tree style.TreeStore<M>
getTreeStore()
Returns the tree's store.TreeView<M>
getView()
Returns the tree's view.boolean
isAutoExpand()
Returnstrue
if auto expand is enabled.boolean
isAutoLoad()
Returnstrue
if auto load is enabled.boolean
isAutoSelect()
Returnstrue
if select on load is enabled.boolean
isBufferedRender()
Returnstrue
if buffered rendering is enabled.boolean
isCaching()
Returnstrue
when a loader is queried for it's children each time a node is expanded.boolean
isCheckable()
Returnstrue
if check boxes are enabled.boolean
isChecked(M model)
Returns true if the model is checked.boolean
isExpanded(M model)
Returnstrue
if the model is expanded.boolean
isExpandOnFilter()
Returns the if expand all and collapse all is enabled on filter changes.boolean
isLeaf(M model)
Returnstrue
if the model is a leaf node.boolean
isTrackMouseOver()
Returnstrue
if nodes are highlighted on mouse over.void
onBrowserEvent(com.google.gwt.user.client.Event event)
void
redraw()
void
redraw(M parent)
Completely redraws the children of the given parent (or all items if parent is null), throwing away details like currently expanded nodes, etc.void
refresh(M model)
void
scrollIntoView(M model)
Scrolls the tree to ensure the given model is visible.void
setAutoExpand(boolean autoExpand)
If set totrue
, all non leaf nodes will be expanded automatically (defaults tofalse
).void
setAutoLoad(boolean autoLoad)
Sets whether all children should automatically be loaded recursively (defaults to false).void
setAutoSelect(boolean autoSelect)
True to select the first model after the store's data changes (defaults tofalse
).void
setBufferedRender(boolean bufferRender)
True to only render tree nodes that are in view (defaults tofalse
).void
setCaching(boolean caching)
Sets whether the children should be cached after first being retrieved from the store (defaults totrue
).void
setCell(com.google.gwt.cell.client.Cell<C> cell)
Sets the tree's cell.void
setCheckable(boolean checkable)
Sets whether check boxes are used in the tree (defaults tofalse
).void
setChecked(M item, Tree.CheckState checked)
Sets the check state of the item.void
setCheckedSelection(List<M> selection)
Sets the current checked selection.void
setCheckNodes(Tree.CheckNodes checkNodes)
Sets which tree items will display a check box (defaults to BOTH).void
setCheckStyle(Tree.CheckCascade checkStyle)
Sets the cascading behavior for check tree (defaults to PARENTS).void
setExpanded(M model, boolean expand)
Sets the item's expand state.void
setExpanded(M model, boolean expand, boolean deep)
Sets the item's expand state.void
setExpandOnFilter(boolean expandOnFilter)
Sets whether the tree should expand all and collapse all when filters are applied (defaults totrue
).void
setIconProvider(IconProvider<M> iconProvider)
Sets the tree's model icon provider which provides the icon style for each model.void
setLeaf(M model, boolean leaf)
Sets the item's leaf state.void
setLoader(TreeLoader<M> loader)
Sets the tree loader.void
setSelectionModel(TreeSelectionModel<M> sm)
Sets the tree's selection model.void
setStore(TreeStore<M> store)
Assigns a new store to the tree.void
setStyle(TreeStyle style)
Sets the tree style.void
setTrackMouseOver(boolean trackMouseOver)
True to highlight nodes when the mouse is over (defaults totrue
).void
setView(TreeView<M> view)
Sets the tree's view.void
toggle(M model)
Toggles the model's expand state.-
Methods inherited from class com.sencha.gxt.widget.core.client.Component
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disable, disableEvents, enable, enableEvents, fireEvent, getData, getElement, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideToolTip, isAdjustSize, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, removeGestureRecognizer, removeToolTip, setAdjustSize, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setTabIndex, setToolTip, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString
-
-
-
-
Constructor Detail
-
Tree
@UiConstructor public Tree(TreeStore<M> store, ValueProvider<? super M,C> valueProvider)
Creates a new tree panel.- Parameters:
store
- the tree storevalueProvider
- the tree value provider
-
Tree
public Tree(TreeStore<M> store, ValueProvider<? super M,C> valueProvider, Tree.TreeAppearance appearance)
-
-
Method Detail
-
addBeforeCheckChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeCheckChangeHandler(BeforeCheckChangeEvent.BeforeCheckChangeHandler<M> handler)
Description copied from interface:BeforeCheckChangeEvent.HasBeforeCheckChangeHandlers
Adds aBeforeCheckChangeEvent.BeforeCheckChangeHandler
handler forBeforeCheckChangeEvent
events.- Specified by:
addBeforeCheckChangeHandler
in interfaceBeforeCheckChangeEvent.HasBeforeCheckChangeHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addBeforeCollapseHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeCollapseHandler(BeforeCollapseItemEvent.BeforeCollapseItemHandler<M> handler)
Description copied from interface:BeforeCollapseItemEvent.HasBeforeCollapseItemHandlers
Adds aBeforeCollapseItemEvent.BeforeCollapseItemHandler
handler forBeforeCollapseItemEvent
events.- Specified by:
addBeforeCollapseHandler
in interfaceBeforeCollapseItemEvent.HasBeforeCollapseItemHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addBeforeExpandHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeExpandHandler(BeforeExpandItemEvent.BeforeExpandItemHandler<M> handler)
Description copied from interface:BeforeExpandItemEvent.HasBeforeExpandItemHandlers
Adds aBeforeExpandItemEvent.BeforeExpandItemHandler
handler forBeforeExpandItemEvent
events.- Specified by:
addBeforeExpandHandler
in interfaceBeforeExpandItemEvent.HasBeforeExpandItemHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addCheckChangedHandler
public com.google.gwt.event.shared.HandlerRegistration addCheckChangedHandler(CheckChangedEvent.CheckChangedHandler<M> handler)
Description copied from interface:CheckChangedEvent.HasCheckChangedHandlers
Adds aCheckChangedEvent.CheckChangedHandler
handler forCheckChangedEvent
events.- Specified by:
addCheckChangedHandler
in interfaceCheckChangedEvent.HasCheckChangedHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addCheckChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addCheckChangeHandler(CheckChangeEvent.CheckChangeHandler<M> handler)
Description copied from interface:CheckChangeEvent.HasCheckChangeHandlers
Adds aCheckChangeEvent.CheckChangeHandler
handler forCheckChangeEvent
events.- Specified by:
addCheckChangeHandler
in interfaceCheckChangeEvent.HasCheckChangeHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addCollapseHandler
public com.google.gwt.event.shared.HandlerRegistration addCollapseHandler(CollapseItemEvent.CollapseItemHandler<M> handler)
Description copied from interface:CollapseItemEvent.HasCollapseItemHandlers
Adds aCollapseItemEvent.CollapseItemHandler
handler forCollapseItemEvent
events.- Specified by:
addCollapseHandler
in interfaceCollapseItemEvent.HasCollapseItemHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
addExpandHandler
public com.google.gwt.event.shared.HandlerRegistration addExpandHandler(ExpandItemEvent.ExpandItemHandler<M> handler)
Description copied from interface:ExpandItemEvent.HasExpandItemHandlers
Adds aExpandItemEvent.ExpandItemHandler
handler forExpandItemEvent
events.- Specified by:
addExpandHandler
in interfaceExpandItemEvent.HasExpandItemHandlers<M>
- Parameters:
handler
- the handler- Returns:
- the registration for the event
-
collapseAll
public void collapseAll()
Collapses all nodes.
-
expandAll
public void expandAll()
Expands all nodes.
-
findNode
public Tree.TreeNode<M> findNode(com.google.gwt.dom.client.Element target)
Returns the tree node for the given target.- Parameters:
target
- the target element- Returns:
- the tree node or null if no match
-
findNode
public Tree.TreeNode<M> findNode(M model)
Returns the tree node for the given model.- Parameters:
model
- the model- Returns:
- the tree node or null if no match
-
focus
public void focus()
Description copied from class:Component
Try to focus this widget.
-
getAppearance
public Tree.TreeAppearance getAppearance()
Returns the tree appearance.- Returns:
- the tree appearance
-
getCell
public com.google.gwt.cell.client.Cell<C> getCell()
Return the tree's cell.- Returns:
- the cell
-
getChecked
public Tree.CheckState getChecked(M model)
Returns the models checked state.- Parameters:
model
- the model- Returns:
- the check state
-
getCheckedSelection
public List<M> getCheckedSelection()
Returns the current checked selection. Only items that have been rendered will be returned in this list. SetsetAutoLoad(boolean)
totrue
to fully render the tree to receive all checked items in the tree.- Specified by:
getCheckedSelection
in interfaceCheckProvider<M>
- Returns:
- the checked selection
-
getCheckNodes
public Tree.CheckNodes getCheckNodes()
Returns the child nodes value which determines what node types have a check box. Only applies when check boxes have been enabled (setCheckable(boolean)
.- Returns:
- the child nodes value
-
getCheckStyle
public Tree.CheckCascade getCheckStyle()
The check cascade style value which determines if check box changes cascade to parent and children.- Returns:
- the check cascade style
-
getIconProvider
public IconProvider<M> getIconProvider()
Returns the model icon provider.- Returns:
- the icon provider
-
getSelectionModel
public TreeSelectionModel<M> getSelectionModel()
Returns the tree's selection model.- Returns:
- the selection model
-
getTreeStore
public TreeStore<M> getTreeStore()
Returns the tree's store.- Returns:
- the store
- Since:
- 4.0.3
-
getStyle
public TreeStyle getStyle()
Returns the tree style.- Returns:
- the tree style
-
isAutoExpand
public boolean isAutoExpand()
Returnstrue
if auto expand is enabled.- Returns:
- the auto expand state
-
isAutoLoad
public boolean isAutoLoad()
Returnstrue
if auto load is enabled.- Returns:
- the auto load state
-
isAutoSelect
public boolean isAutoSelect()
Returnstrue
if select on load is enabled.- Returns:
- the auto select state
-
isBufferedRender
public boolean isBufferedRender()
Returnstrue
if buffered rendering is enabled.- Returns:
- true for buffered rendering
-
isCaching
public boolean isCaching()
Returnstrue
when a loader is queried for it's children each time a node is expanded. Only applies when using a loader with the tree store.- Returns:
- true if caching
-
isCheckable
public boolean isCheckable()
Returnstrue
if check boxes are enabled.- Returns:
- the check box state
-
isChecked
public boolean isChecked(M model)
Description copied from interface:CheckProvider
Returns true if the model is checked.- Specified by:
isChecked
in interfaceCheckProvider<M>
- Parameters:
model
- the model- Returns:
- the check state
-
isExpanded
public boolean isExpanded(M model)
Returnstrue
if the model is expanded.- Parameters:
model
- the model- Returns:
- true if expanded
-
isExpandOnFilter
public boolean isExpandOnFilter()
Returns the if expand all and collapse all is enabled on filter changes.- Returns:
- the expand all collapse all state
-
isLeaf
public boolean isLeaf(M model)
Returnstrue
if the model is a leaf node. The leaf state allows a tree item to specify if it has children before the children have been realized.- Parameters:
model
- the model- Returns:
- the leaf state
-
isTrackMouseOver
public boolean isTrackMouseOver()
Returnstrue
if nodes are highlighted on mouse over.- Returns:
- true if enabled
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- Specified by:
onBrowserEvent
in interfacecom.google.gwt.user.client.EventListener
- Overrides:
onBrowserEvent
in classComponent
-
refresh
public void refresh(M model)
-
scrollIntoView
public void scrollIntoView(M model)
Scrolls the tree to ensure the given model is visible.- Parameters:
model
- the model to scroll into view
-
setAutoExpand
public void setAutoExpand(boolean autoExpand)
If set totrue
, all non leaf nodes will be expanded automatically (defaults tofalse
).- Parameters:
autoExpand
- the auto expand state to set.
-
setAutoLoad
public void setAutoLoad(boolean autoLoad)
Sets whether all children should automatically be loaded recursively (defaults to false). Useful when the tree must be fully populated when initially rendered.- Parameters:
autoLoad
-true
to auto load
-
setAutoSelect
public void setAutoSelect(boolean autoSelect)
True to select the first model after the store's data changes (defaults tofalse
).- Parameters:
autoSelect
-true
to auto select
-
setBufferedRender
public void setBufferedRender(boolean bufferRender)
True to only render tree nodes that are in view (defaults tofalse
). Set this totrue
when dealing with very large trees.- Parameters:
bufferRender
-true
to buffer render
-
setCaching
public void setCaching(boolean caching)
Sets whether the children should be cached after first being retrieved from the store (defaults totrue
). Whenfalse
, a load request will be made each time a node is expanded.- Parameters:
caching
- the caching state
-
setCell
public void setCell(com.google.gwt.cell.client.Cell<C> cell)
Sets the tree's cell.- Parameters:
cell
- the cell
-
setCheckable
public void setCheckable(boolean checkable)
Sets whether check boxes are used in the tree (defaults tofalse
).- Parameters:
checkable
-true
for check boxes
-
setChecked
public void setChecked(M item, Tree.CheckState checked)
Sets the check state of the item. The checked state will only be set for nodes that have been rendered,setAutoLoad(boolean)
can be used to render all children.- Parameters:
item
- the itemchecked
- the check state
-
setCheckedSelection
public void setCheckedSelection(List<M> selection)
Description copied from interface:CheckProvider
Sets the current checked selection.- Specified by:
setCheckedSelection
in interfaceCheckProvider<M>
- Parameters:
selection
- the checked selection
-
setCheckNodes
public void setCheckNodes(Tree.CheckNodes checkNodes)
Sets which tree items will display a check box (defaults to BOTH).Valid values are:
- BOTH - both nodes and leafs
- PARENT - only nodes with children
- LEAF - only leafs
- Parameters:
checkNodes
- the child nodes value
-
setCheckStyle
public void setCheckStyle(Tree.CheckCascade checkStyle)
Sets the cascading behavior for check tree (defaults to PARENTS). When using CHILDREN, it is important to note that the cascade will only be applied to rendered nodes.setAutoLoad(boolean)
can be used to fully render the tree on render.Valid values are:
- NONE - no cascading
- PARENTS - cascade to parents
- CHILDREN - cascade to children
- Parameters:
checkStyle
- the child style
-
setExpanded
public void setExpanded(M model, boolean expand)
Sets the item's expand state.- Parameters:
model
- the modelexpand
-true
to expand
-
setExpanded
public void setExpanded(M model, boolean expand, boolean deep)
Sets the item's expand state.- Parameters:
model
- the modelexpand
-true
to expanddeep
-true
to expand all children recursively
-
setExpandOnFilter
public void setExpandOnFilter(boolean expandOnFilter)
Sets whether the tree should expand all and collapse all when filters are applied (defaults totrue
).- Parameters:
expandOnFilter
-true
to expand and collapse on filter changes
-
setIconProvider
public void setIconProvider(IconProvider<M> iconProvider)
Sets the tree's model icon provider which provides the icon style for each model.- Parameters:
iconProvider
- the icon provider
-
setLeaf
public void setLeaf(M model, boolean leaf)
Sets the item's leaf state. The leaf state allows control of the expand icon before the children have been realized.- Parameters:
model
- the modelleaf
- the leaf state
-
setLoader
public void setLoader(TreeLoader<M> loader)
Sets the tree loader.- Parameters:
loader
- the loader
-
setSelectionModel
public void setSelectionModel(TreeSelectionModel<M> sm)
Sets the tree's selection model.- Parameters:
sm
- the selection model
-
setStore
public void setStore(TreeStore<M> store)
Assigns a new store to the tree. May be null, in which case the tree must not be attached to the dom. All selection is lost when this takes place and items are re-rendered.- Parameters:
store
- the new store to bind to, or null to detach from the store
-
setStyle
public void setStyle(TreeStyle style)
Sets the tree style.- Parameters:
style
- the tree style
-
setTrackMouseOver
public void setTrackMouseOver(boolean trackMouseOver)
True to highlight nodes when the mouse is over (defaults totrue
).- Parameters:
trackMouseOver
-true
to highlight nodes on mouse over
-
setView
public void setView(TreeView<M> view)
Sets the tree's view. Only needs to be called when customizing the tree's presentation.- Parameters:
view
- the view
-
toggle
public void toggle(M model)
Toggles the model's expand state. If the model is not visible, does nothing.- Parameters:
model
- the model
-
redraw
public void redraw()
- Since:
- 4.0.3
-
redraw
public void redraw(M parent)
Completely redraws the children of the given parent (or all items if parent is null), throwing away details like currently expanded nodes, etc. Not designed to be used to update nodes, look intorefresh(Object)
orStore.update(Object)
.- Parameters:
parent
- the parent of the items to redraw
-
-