com.gwtext.client.widgets.tree
Class TreePanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.BoxComponent
                  extended by com.gwtext.client.widgets.Container
                      extended by com.gwtext.client.widgets.Panel
                          extended by com.gwtext.client.widgets.tree.TreePanel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, Observable

public class TreePanel
extends Panel

A Tree widget.


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
TreePanel()
           
TreePanel(com.google.gwt.core.client.JavaScriptObject jsObj)
           
TreePanel(java.lang.String title)
          Construct a new TreePanel.
 
Method Summary
 void addListener(TreePanelListener listener)
          Add a TreePanel listener.
 void collapseAll()
          Collapse all nodes.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
 void expandAll()
          Expand all nodes.
 void expandPath(java.lang.String path, NodeExpansionCallback cb)
          Expands a specified path in this TreePanel.
 TreeNode[] getChecked()
          Return an array of checked TreeNodes starting from the root node.
 TreeNode[] getChecked(TreeNode startNode)
          Return an array of checked TreeNodes starting from the specified startNode.
protected  com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
           
 TreeDragZone getDragZone()
          The dragZone used by this tree if drag is enabled.
 TreeDropZone getDropZone()
          The dropZone used by this tree if drop is enabled.
 TreeLoader getLoader()
          Retrun the TreeLoader associated with the TreePanel.
 TreeNode getNodeById(java.lang.String id)
          Gets a node in this tree by its ID.
 TreeNode getRootNode()
          Returns the root node for this tree.
 TreeSelectionModel getSelectionModel()
          Return the TreePanel's selection model.
 Tree getTree()
          Return the underlying Tree data structure backing the TreePanel.
 boolean getUseArrows()
          True to use Vista-style arrows in the tree (defaults to false)
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
protected  void initComponent()
          This template method is called after the Component has been instantiated but before it's rendered.
 void selectPath(java.lang.String path, NodeSelectionCallback cb)
          Selects the node in this tree at the specified path.
 void setAnimate(boolean animate)
          True to enable animated expand/collapse.
 void setContainerScroll(boolean containerScroll)
          True to register this container with ScrollManager.
 void setDdAppendOnly(java.lang.String ddAppendOnly)
          True if the tree should only allow append drops (use for trees which are sorted).
 void setDdGroup(java.lang.String ddGroup)
          The DD group this TreePanel belongs to (defaults to 'TreeDD').
 void setDdScroll(boolean ddScroll)
          True to enable body scrolling
 void setDropConfig(TreeDropZone dropConfig)
          Custom config to pass to the TreeDropZone instance.
 void setEnableDD(boolean enableDD)
          True to enable drag and drop.
 void setEnableDrag(boolean enableDrag)
          True to enable just drag.
 void setEnableDrop(boolean enableDrop)
          True to enable just drop.
 void setHlColor(java.lang.String hlColor)
          The color of the node highlight (defaults to C3DAF9).
 void setHlDrop(boolean hlDrop)
          False to disable node highlight on drop.
 void setLayout(ContainerLayout layout)
          The layout type to be used in this container.
 void setLines(boolean lines)
          False to disable tree lines (defaults to true).
 void setLoader(TreeLoader loader)
          A TreeLoader for use with this TreePanel.
 void setPathSeparator(java.lang.String separator)
          Set the token used to separate sub-paths in path strings (defaults to '/').
 void setRootNode(Node node)
           
 void setRootVisible(boolean rootVisible)
          False to hide the root node (defaults to true).
 void setSelectionModel(TreeSelectionModel selectionModel)
          Set the Tree seelction model
 void setSingleExpand(boolean singleExpand)
          True if only 1 node per branch may be expanded.
 void setUseArrows(boolean useArrows)
          True to use Vista-style arrows in the tree (defaults to false)
 
Methods inherited from class com.gwtext.client.widgets.Panel
addButton, addListener, addTool, collapse, collapse, expand, expand, getBaseCls, getBody, getBodyStyle, getBodyWrap, getBottomToolbar, getCollapsedCls, getCollapseFirst, getFloating, getFooter, getFrameHeight, getFrameWidth, getHeader, getHtml, getIconCls, getInnerHeight, getInnerWidth, getMinButtonWidth, getShadowOffset, getTabCls, getTitle, getTopToolbar, getUpdateManager, isAnimCollapse, isAutoScroll, isBodyBorder, isBorder, isClosable, isCollapsed, isCollapsible, isFrame, isHeader, isHeaderAsText, isHideCollapseTool, isMaskDisabled, isShadow, isShim, isTitleCollapse, load, load, setAnimCollapse, setAutoLoad, setAutoLoad, setAutoScroll, setBaseCls, setBodyBorder, setBodyStyle, setBorder, setBottomToolbar, setBottomToolbar, setBottomToolbar, setButtonAlign, setButtons, setClosable, setCollapsed, setCollapsedCls, setCollapseFirst, setCollapsible, setContentEl, setDraggable, setFloating, setFooter, setFrame, setHeader, setHeaderAsText, setHideCollapseTool, setHtml, setIconCls, setMargins, setMargins, setMaskDisabled, setMinButtonWidth, setPaddings, setPaddings, setShadow, setShadow, setShadowOffset, setShim, setTabCls, setTitle, setTitle, setTitleCollapse, setTools, setTopToolbar, setTopToolbar, setTopToolbar, toggleCollapse, toggleCollapse
 
Methods inherited from class com.gwtext.client.widgets.Container
add, add, add, add, addListener, bubble, cascade, clear, doLayout, doLayout, findBy, findByID, findByType, getActiveItem, getActiveItemID, getAutoDestroy, getBufferResize, getComponent, getComponent, getComponents, getHideBorders, getItems, getLayout, getMonitorResize, insert, iterator, remove, remove, remove, remove, removeAll, removeAll, setActiveItem, setActiveItemID, setAutoDestroy, setBufferResize, setDefaults, setHideBorders, setMonitorResize
 
Methods inherited from class com.gwtext.client.widgets.BoxComponent
addListener, doOnRender, doOnRender, getAutoHeight, getAutoWidth, getBox, getBox, getHeight, getPosition, getPosition, getSize, getWidth, setAutoHeight, setAutoWidth, setHeight, setHeight, setPagePosition, setPosition, setSize, setSize, setWidth, setWidth, syncSize, updateBox
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getXTypes, hashCode, hide, isCreated, isDisabled, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setVisible, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreePanel

public TreePanel()

TreePanel

public TreePanel(com.google.gwt.core.client.JavaScriptObject jsObj)

TreePanel

public TreePanel(java.lang.String title)
Construct a new TreePanel.

Parameters:
title - the tree panel title
Method Detail

getConfigPrototype

protected com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
Overrides:
getConfigPrototype in class Panel

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class Panel
Returns:
the xtype

initComponent

protected void initComponent()
Description copied from class: Component
This template method is called after the Component has been instantiated but before it's rendered. Subclasses can override it to provide any "constructor" type logic thats desired/

Overrides:
initComponent in class Component

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
Overrides:
create in class Panel

getDragZone

public TreeDragZone getDragZone()
The dragZone used by this tree if drag is enabled.

Returns:
the drag zone, or null if not enabled

getDropZone

public TreeDropZone getDropZone()
The dropZone used by this tree if drop is enabled.

Returns:
the drop zone, or null if not enabled

getTree

public Tree getTree()
Return the underlying Tree data structure backing the TreePanel.

Returns:
the tree data structure

collapseAll

public void collapseAll()
Collapse all nodes.


expandAll

public void expandAll()
Expand all nodes.


expandPath

public void expandPath(java.lang.String path,
                       NodeExpansionCallback cb)
Expands a specified path in this TreePanel. A path can be retrieved from a node with Node.getPath()

Parameters:
path - the path
cb - the callback to call when the expand is complete

getChecked

public TreeNode[] getChecked()
Return an array of checked TreeNodes starting from the root node.

Returns:
array of checked nodes, empty array if no nodes are checked

getChecked

public TreeNode[] getChecked(TreeNode startNode)
Return an array of checked TreeNodes starting from the specified startNode.

Parameters:
startNode - the node to start from
Returns:
array of checked nodes, empty array if no nodes are checked

getLoader

public TreeLoader getLoader()
Retrun the TreeLoader associated with the TreePanel.

Returns:
the tree loader

getNodeById

public TreeNode getNodeById(java.lang.String id)
Gets a node in this tree by its ID.

Parameters:
id - the node ID
Returns:
the node, null if none found

setLayout

public void setLayout(ContainerLayout layout)
Description copied from class: Container
The layout type to be used in this container. If not specified, a default ContainerLayout will be created and used.

Overrides:
setLayout in class Container
Parameters:
layout - the layout to use

getRootNode

public TreeNode getRootNode()
Returns the root node for this tree.

Returns:
the root node

selectPath

public void selectPath(java.lang.String path,
                       NodeSelectionCallback cb)
Selects the node in this tree at the specified path. A path can be retrieved from a node with Node.getPath().

Parameters:
path - the path
cb - the callback to call when the selection is complete

setRootNode

public void setRootNode(Node node)

getSelectionModel

public TreeSelectionModel getSelectionModel()
Return the TreePanel's selection model.

Returns:
the selection model

setPathSeparator

public void setPathSeparator(java.lang.String separator)
Set the token used to separate sub-paths in path strings (defaults to '/').

Parameters:
separator - the path separator

addListener

public void addListener(TreePanelListener listener)
Add a TreePanel listener.

Parameters:
listener - the listener

setAnimate

public void setAnimate(boolean animate)
                throws java.lang.IllegalStateException
True to enable animated expand/collapse. Defaults to true.

Parameters:
animate - true to enable enimation.
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setContainerScroll

public void setContainerScroll(boolean containerScroll)
                        throws java.lang.IllegalStateException
True to register this container with ScrollManager. Doing so provides automatic scrolling of overflow regions in the page during drag operations. Defaults to false.

Parameters:
containerScroll - true to register this container with ScrollManager
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDdAppendOnly

public void setDdAppendOnly(java.lang.String ddAppendOnly)
                     throws java.lang.IllegalStateException
True if the tree should only allow append drops (use for trees which are sorted).

Parameters:
ddAppendOnly - true to allow only append drops
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDdGroup

public void setDdGroup(java.lang.String ddGroup)
                throws java.lang.IllegalStateException
The DD group this TreePanel belongs to (defaults to 'TreeDD').

Parameters:
ddGroup - the DD group
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDdScroll

public void setDdScroll(boolean ddScroll)
                 throws java.lang.IllegalStateException
True to enable body scrolling

Parameters:
ddScroll - true to enable body scrolling.
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setDropConfig

public void setDropConfig(TreeDropZone dropConfig)
                   throws java.lang.IllegalStateException
Custom config to pass to the TreeDropZone instance.

Parameters:
dropConfig - the drop config
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableDD

public void setEnableDD(boolean enableDD)
                 throws java.lang.IllegalStateException
True to enable drag and drop.

Parameters:
enableDD - true to enable drag and drop
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableDrag

public void setEnableDrag(boolean enableDrag)
                   throws java.lang.IllegalStateException
True to enable just drag.

Parameters:
enableDrag - true to enable just drag
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setEnableDrop

public void setEnableDrop(boolean enableDrop)
                   throws java.lang.IllegalStateException
True to enable just drop.

Parameters:
enableDrop - true to enable just drop
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setHlColor

public void setHlColor(java.lang.String hlColor)
                throws java.lang.IllegalStateException
The color of the node highlight (defaults to C3DAF9).

Parameters:
hlColor - the color of the node highlight
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setHlDrop

public void setHlDrop(boolean hlDrop)
               throws java.lang.IllegalStateException
False to disable node highlight on drop.

Parameters:
hlDrop - false to disable drop drop highlight
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLines

public void setLines(boolean lines)
              throws java.lang.IllegalStateException
False to disable tree lines (defaults to true).

Parameters:
lines - false to disable tree lines
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLoader

public void setLoader(TreeLoader loader)
               throws java.lang.IllegalStateException
A TreeLoader for use with this TreePanel.

Parameters:
loader - the tree loader
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setRootVisible

public void setRootVisible(boolean rootVisible)
                    throws java.lang.IllegalStateException
False to hide the root node (defaults to true).

Parameters:
rootVisible - false to hide the root node
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setSelectionModel

public void setSelectionModel(TreeSelectionModel selectionModel)
                       throws java.lang.IllegalStateException
Set the Tree seelction model

Parameters:
selectionModel - the selection model
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setSingleExpand

public void setSingleExpand(boolean singleExpand)
                     throws java.lang.IllegalStateException
True if only 1 node per branch may be expanded.

Parameters:
singleExpand - true if only 1 node per branch may be expanded
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setUseArrows

public void setUseArrows(boolean useArrows)
True to use Vista-style arrows in the tree (defaults to false)

Parameters:
useArrows - true to use Vista-style arrows in the tree (defaults to false)
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getUseArrows

public boolean getUseArrows()
True to use Vista-style arrows in the tree (defaults to false)

Returns:
the useArrows