com.extjs.gxt.ui.client.widget.treegrid
Class TreeGrid<M extends ModelData>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.grid.Grid<M>
                      extended by com.extjs.gxt.ui.client.widget.treegrid.TreeGrid<M>
Type Parameters:
M - the model type
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
EditorTreeGrid

public class TreeGrid<M extends ModelData>
extends Grid<M>

A hierarchical tree grid bound to a TreeStore.

A TreeGridCellRenderer can be assigned to the ColumnConfig in which the tree will be displayed.

With state enabled, TreePanel will save and restore the expand state of the nodes in the tree. A ModelKeyProvider must specified with the TreeStore this tree is bound to. Save and restore works with both local, and asynchronous loading of children.


Nested Class Summary
 class TreeGrid.TreeNode
           
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  java.util.Map<M,java.lang.String> cache
           
protected  boolean filtering
           
protected  TreeLoader<M> loader
           
protected  java.util.Map<java.lang.String,TreeGrid.TreeNode> nodes
           
protected  TreeGridView treeGridView
           
protected  TreeStore<M> treeStore
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.grid.Grid
cm, editSupport, sm, store, stringProvider, view, viewReady
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
TreeGrid(TreeStore store, ColumnModel cm)
           
 
Method Summary
protected  TreePanel.Joint calcualteJoint(M model)
           
protected  com.google.gwt.user.client.ui.AbstractImagePrototype calculateIconStyle(M model)
           
 void collapseAll()
          Collapses all nodes.
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
protected  void doApplyStoreState(java.util.Map<java.lang.String,java.lang.Object> state)
           
 void expandAll()
          Expands all nodes.
protected  int findLastOpenChildIndex(M model)
           
 TreeGrid.TreeNode findNode(com.google.gwt.user.client.Element target)
          Returns the tree node for the given target.
protected  TreeGrid.TreeNode findNode(M m)
           
protected  java.lang.String generateModelId(M m)
           
 ModelIconProvider<M> getIconProvider()
          Returns the model icon provider.
 TreeStyle getStyle()
          Returns the tree style.
 TreeStore<M> getTreeStore()
          Returns the tree's tree store.
 TreeGridView getTreeView()
          Returns the tree's view.
protected  boolean hasChildren(M m)
           
 boolean isAutoExpand()
          Returns true if auto expand is enabled.
 boolean isAutoLoad()
          Returns true if auto load is enabled.
 boolean isCaching()
          Returns true when a loader is queried for it's children each time a node is expanded.
 boolean isColumnLines()
          Returns true if column lines are enabled.
 boolean isExpanded(M model)
          Returns true if the model is expanded.
 boolean isExpandOnFilter()
          Returns the if expand all and collapse all is enabled on filter changes.
 boolean isLeaf(M model)
          Returns true if the model is a leaf node.
protected  void onAdd(TreeStoreEvent<M> se)
           
protected  void onAfterRenderView()
           
protected  void onClick(GridEvent<M> e)
           
protected  void onDataChanged(TreeStoreEvent<M> se)
           
protected  void onDoubleClick(GridEvent<M> e)
           
protected  void onFilter(TreeStoreEvent<M> se)
           
protected  void onRemove(TreeStoreEvent<M> se)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onUpdate(TreeStoreEvent<M> se)
           
 void reconfigure(ListStore<M> store, ColumnModel cm)
          Reconfigures the grid to use a different Store and Column Model.
 void reconfigure(TreeStore<M> store, ColumnModel cm)
           
protected  void refresh(M model)
           
protected  java.lang.String register(M m)
           
protected  void renderChildren(M parent, boolean auto)
           
 void setAutoExpand(boolean autoExpand)
          If set to true, all non leaf nodes will be expanded automatically (defaults to false).
 void setAutoLoad(boolean autoLoad)
          Sets whether all children should automatically be loaded recursively (defaults to false).
 void setCaching(boolean caching)
          Sets whether the children should be cached after first being retrieved from the store (defaults to true).
 void setColumnLines(boolean columnLines)
          True to enable column separation lines (defaults to false).
 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 to true).
 void setIconProvider(ModelIconProvider<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 setView(GridView view)
          Sets the view's grid (pre-render).
 void toggle(M model)
          Toggles the model's expand state.
protected  void unregister(M m)
           
 
Methods inherited from class com.extjs.gxt.ui.client.widget.grid.Grid
afterRender, afterRenderView, applyState, disableTextSelection, doAttachChildren, doDetachChildren, getAutoExpandColumn, getAutoExpandMax, getAutoExpandMin, getColumnModel, getEditSupport, getFocusEl, getLazyRowRender, getMinColumnWidth, getModelProcessor, getSelectionModel, getStore, getView, isColumnReordering, isColumnResize, isHideHeaders, isLoadMask, isStripeRows, isTrackMouseOver, isViewReady, notifyHide, notifyShow, onBlur, onComponentEvent, onDisable, onEnable, onFocus, onMouseDown, onMouseUp, onResize, setAriaRole, setAriaState, setAutoExpandColumn, setAutoExpandMax, setAutoExpandMin, setColumnReordering, setColumnResize, setHideHeaders, setLazyRowRender, setLoadMask, setMinColumnWidth, setModelProcessor, setSelectionModel, setStringProvider, setStripeRows, setTrackMouseOver, walkCells
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, onAttach, onBrowserEvent, onDetach, onDetachHelper, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cache

protected java.util.Map<M extends ModelData,java.lang.String> cache

filtering

protected boolean filtering

loader

protected TreeLoader<M extends ModelData> loader

nodes

protected java.util.Map<java.lang.String,TreeGrid.TreeNode> nodes

treeGridView

protected TreeGridView treeGridView

treeStore

protected TreeStore<M extends ModelData> treeStore
Constructor Detail

TreeGrid

public TreeGrid(TreeStore store,
                ColumnModel cm)
Method Detail

collapseAll

public void collapseAll()
Collapses all nodes.


expandAll

public void expandAll()
Expands all nodes.


findNode

public TreeGrid.TreeNode findNode(com.google.gwt.user.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

getIconProvider

public ModelIconProvider<M> getIconProvider()
Returns the model icon provider.

Returns:
the icon provider

getStyle

public TreeStyle getStyle()
Returns the tree style.

Returns:
the tree style

getTreeStore

public TreeStore<M> getTreeStore()
Returns the tree's tree store.

Returns:
the tree store

getTreeView

public TreeGridView getTreeView()
Returns the tree's view.

Returns:
the view

isAutoExpand

public boolean isAutoExpand()
Returns true if auto expand is enabled.

Returns:
the auto expand state

isAutoLoad

public boolean isAutoLoad()
Returns true if auto load is enabled.

Returns:
the auto load state

isCaching

public boolean isCaching()
Returns true 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

isColumnLines

public boolean isColumnLines()
Returns true if column lines are enabled.

Overrides:
isColumnLines in class Grid<M extends ModelData>
Returns:
true if column lines are enabled

isExpanded

public boolean isExpanded(M model)
Returns true 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)
Returns true 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

reconfigure

public void reconfigure(ListStore<M> store,
                        ColumnModel cm)
Description copied from class: Grid
Reconfigures the grid to use a different Store and Column Model. The View will be bound to the new objects and refreshed.

Overrides:
reconfigure in class Grid<M extends ModelData>
Parameters:
store - the new store
cm - the new column model

reconfigure

public void reconfigure(TreeStore<M> store,
                        ColumnModel cm)

setAutoExpand

public void setAutoExpand(boolean autoExpand)
If set to true, all non leaf nodes will be expanded automatically (defaults to false).

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

setCaching

public void setCaching(boolean caching)
Sets whether the children should be cached after first being retrieved from the store (defaults to true). When false, a load request will be made each time a node is expanded.

Parameters:
caching - the caching state

setColumnLines

public void setColumnLines(boolean columnLines)
True to enable column separation lines (defaults to false).

Overrides:
setColumnLines in class Grid<M extends ModelData>
Parameters:
columnLines - true to enable column separation lines

setExpanded

public void setExpanded(M model,
                        boolean expand)
Sets the item's expand state.

Parameters:
model - the model
expand - true to expand

setExpanded

public void setExpanded(M model,
                        boolean expand,
                        boolean deep)
Sets the item's expand state.

Parameters:
model - the model
expand - true to expand
deep - 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 to true).

Parameters:
expandOnFilter - true to expand and collapse on filter changes

setIconProvider

public void setIconProvider(ModelIconProvider<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 model
leaf - the leaf state

setView

public void setView(GridView view)
Description copied from class: Grid
Sets the view's grid (pre-render).

Overrides:
setView in class Grid<M extends ModelData>
Parameters:
view - the view

toggle

public void toggle(M model)
Toggles the model's expand state.

Parameters:
model - the model

calcualteJoint

protected TreePanel.Joint calcualteJoint(M model)

calculateIconStyle

protected com.google.gwt.user.client.ui.AbstractImagePrototype calculateIconStyle(M model)

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class Grid<M extends ModelData>

doApplyStoreState

protected void doApplyStoreState(java.util.Map<java.lang.String,java.lang.Object> state)
Overrides:
doApplyStoreState in class Grid<M extends ModelData>

findLastOpenChildIndex

protected int findLastOpenChildIndex(M model)

findNode

protected TreeGrid.TreeNode findNode(M m)

generateModelId

protected java.lang.String generateModelId(M m)

hasChildren

protected boolean hasChildren(M m)

onAdd

protected void onAdd(TreeStoreEvent<M> se)

onAfterRenderView

protected void onAfterRenderView()
Overrides:
onAfterRenderView in class Grid<M extends ModelData>

onClick

protected void onClick(GridEvent<M> e)
Overrides:
onClick in class Grid<M extends ModelData>

onDataChanged

protected void onDataChanged(TreeStoreEvent<M> se)

onDoubleClick

protected void onDoubleClick(GridEvent<M> e)
Overrides:
onDoubleClick in class Grid<M extends ModelData>

onFilter

protected void onFilter(TreeStoreEvent<M> se)

onRemove

protected void onRemove(TreeStoreEvent<M> se)

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Grid<M extends ModelData>
Parameters:
target - the target element
index - the insert location

onUpdate

protected void onUpdate(TreeStoreEvent<M> se)

refresh

protected void refresh(M model)

register

protected java.lang.String register(M m)

renderChildren

protected void renderChildren(M parent,
                              boolean auto)

unregister

protected void unregister(M m)