com.extjs.gxt.ui.client.widget.tree
Class TreeItem

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.tree.TreeItem
All Implemented Interfaces:
Observable, com.google.gwt.user.client.EventListener
Direct Known Subclasses:
TreeTableItem

public class TreeItem
extends Component

A item in a Tree. All events are bubbled to the item's parent tree.

Events:
BeforeAdd : TreeEvent(tree, parent, item, index)
Fires before a item is added or inserted. Listeners can set the doit field to false to cancel the action.
BeforeRemove : TreeEvent(tree, parent, item)
Fires before a item is removed. Listeners can set the doit field to false to cancel the action.
BeforeExpand : TreeEvent(tree, item)
Fires before a item is expanded. Listeners can set the doit field to false to cancel the expand.
BeforeCollapse : TreeEvent(tree, item)
Fires before a item is collapsed. Listeners can set the doit field to false to cancel the collapse.
Add : TreeEvent(tree, parent, item, index)
Fires after a item has been added or inserted.
Remove : TreeEvent(tree, parent, item)
Fires after a item has been removed.
Expand : TreeEvent(tree, item)
Fires after a item has been expanded.
Collapse : TreeEvent(tree, item)
Fires ater a item is collapsed.
CheckChange : TreeEvent(tree, item)
Fires after a check state change.
CSS:
.my-tree-item (the item itself)
.my-tree-item-text span (the tree item text)


Nested Class Summary
 
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
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
TreeItem()
          Creates a new tree item.
TreeItem(java.lang.String text)
          Creates a new tree item.
 
Method Summary
 void add(TreeItem item)
          Adds a child item.
 void add(TreeItem item, int index)
          Inserts a child item at the specified position.
 TreeItem firstChild()
          Returns the item's first child.
 com.google.gwt.user.client.Element getContainer()
          Returns the item's container element.
 int getDepth()
          Returns the item's node depth.
 java.lang.String getIconStyle()
          Returns the item's icon style.
 TreeItem getItem(int index)
          Returns the item at the specified index.
 int getItemCount()
          Returns the number of child items.
 java.util.List<TreeItem> getItems()
          Returns the item's children.
 TreeItem getParentItem()
          Returns the item's parent.
 java.lang.String getPath()
          Returns the path for this node.
 java.lang.String getText()
          Returns the item's text.
 java.lang.String getTextStyle()
          Returns the item's text style.
 TreeItemUI getUI()
          Returns the item's ui instance.
 boolean hasChildren()
          Returns true if the item's has children.
 int indexOf(TreeItem item)
          Returns the index of the item or -1 if not found.
 boolean isChecked()
          Returns true if the item is checked.
 boolean isExpanded()
          Returns true if the item is expanded, and false otherwise.
 boolean isLeaf()
          Returns true if the item is a leaf, and false otherwise.
 boolean isRoot()
          Returns true if the item is a root item.
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
 void remove(TreeItem item)
          Removes a child from the item.
 void removeAll()
          Removes all child items.
 void setChecked(boolean checked)
          Sets the item's checked value.
 void setExpanded(boolean expanded)
          Sets the item's expanded state.
 void setExpanded(boolean expanded, boolean deep)
          Sets the item's expand state.
 void setIconStyle(java.lang.String style)
          Sets the item's icon style.
 void setLeaf(boolean leaf)
          Sets the item's leaf state.
 void setText(java.lang.String text)
          Sets the item's text.
 void setTextStyle(java.lang.String style)
          Sets the item's text style.
 void toggle()
          Toggles the item's expand state.
 java.lang.String toString()
           
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addStyleName, addWidgetListener, disable, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getData, getData, getElement, getId, getItemId, getModel, getState, getToolTip, hide, hideToolTip, isEnabled, isRendered, isVisible, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeWidgetListener, render, render, saveState, setBorders, setData, setData, setElement, setEnabled, setEnableState, setHeight, setId, setIntStyleAttribute, setItemId, setPixelSize, setSize, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setWidth, show
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeItem

public TreeItem()
Creates a new tree item.


TreeItem

public TreeItem(java.lang.String text)
Creates a new tree item.

Parameters:
text - the item's text
Method Detail

add

public void add(TreeItem item)
Adds a child item.

Parameters:
item - the item to be added

add

public void add(TreeItem item,
                int index)
Inserts a child item at the specified position.

Parameters:
item - the item to be added
index - index at which the specified element is to be inserted

firstChild

public TreeItem firstChild()
Returns the item's first child.

Returns:
the first child or null

getContainer

public com.google.gwt.user.client.Element getContainer()
Returns the item's container element.

Returns:
the container

getDepth

public int getDepth()
Returns the item's node depth.

Returns:
the depth

getIconStyle

public java.lang.String getIconStyle()
Returns the item's icon style.

Returns:
the icon style

getItem

public TreeItem getItem(int index)
Returns the item at the specified index.

Parameters:
index - the index
Returns:
the item at the index

getItemCount

public int getItemCount()
Returns the number of child items.

Returns:
the child count

getItems

public java.util.List<TreeItem> getItems()
Returns the item's children.

Returns:
the children items

getParentItem

public TreeItem getParentItem()
Returns the item's parent.

Returns:
the parent item

getPath

public java.lang.String getPath()
Returns the path for this node. The path can be used to expand or select this node programmatically.

Returns:
a comma seperated list of tree item id's

getText

public java.lang.String getText()
Returns the item's text.

Returns:
the text

getTextStyle

public java.lang.String getTextStyle()
Returns the item's text style.

Returns:
the text style

getUI

public TreeItemUI getUI()
Returns the item's ui instance.

Returns:
the ui instance

hasChildren

public boolean hasChildren()
Returns true if the item's has children.

Returns:
the children state

indexOf

public int indexOf(TreeItem item)
Returns the index of the item or -1 if not found.

Parameters:
item - the child item
Returns:
the item's index

isChecked

public boolean isChecked()
Returns true if the item is checked.

Returns:
the checked state

isExpanded

public boolean isExpanded()
Returns true if the item is expanded, and false otherwise.

Returns:
the expanded state

isLeaf

public boolean isLeaf()
Returns true if the item is a leaf, and false otherwise. The leaf state allows a tree item to specify if it has children before the children have been realized.

Returns:
the leaf state

isRoot

public boolean isRoot()
Returns true if the item is a root item.

Returns:
the rooot state

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Component
Parameters:
ce - the base event

remove

public void remove(TreeItem item)
Removes a child from the item.

Parameters:
item - the item to be removed

removeAll

public void removeAll()
Removes all child items.


setChecked

public void setChecked(boolean checked)
Sets the item's checked value.

Parameters:
checked - true to check

setExpanded

public void setExpanded(boolean expanded)
Sets the item's expanded state.

Parameters:
expanded - true to expand

setExpanded

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

Parameters:
expanded - true to expand
deep - true to expand all children

setIconStyle

public void setIconStyle(java.lang.String style)
Sets the item's icon style.

Parameters:
style - the icon style

setLeaf

public void setLeaf(boolean leaf)
Sets the item's leaf state. The leaf state allows a tree item to specify if it has children before the children have been realized.

Parameters:
leaf - the state

setText

public void setText(java.lang.String text)
Sets the item's text.

Parameters:
text - the new text

setTextStyle

public void setTextStyle(java.lang.String style)
Sets the item's text style.

Parameters:
style - the text style

toggle

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


toString

public java.lang.String toString()
Overrides:
toString in class Component