Tree (GWT Javadoc)

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.user.client.ui
Class Tree

    java.lang.Object
      com.google.gwt.user.client.ui.UIObject
          com.google.gwt.user.client.ui.Widget
              com.google.gwt.user.client.ui.Tree

All Implemented Interfaces:
  HasAllFocusHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasBlurHandlers, HasFocusHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasAttachHandlers, HasCloseHandlers<TreeItem>, HasOpenHandlers<TreeItem>, HasSelectionHandlers<TreeItem>, HasHandlers, EventListener, Focusable, HasAnimation, HasFocus, HasTreeItems, HasTreeItems.ForIsWidget, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IsWidget, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents, SourcesTreeEvents, java.lang.Iterable<Widget>

    public class Tree

extends Widget
implements HasTreeItems.ForIsWidget, HasWidgets.ForIsWidget, SourcesTreeEvents, HasFocus, HasAnimation, HasAllKeyHandlers, HasAllFocusHandlers, HasSelectionHandlers<TreeItem>, HasOpenHandlers<TreeItem>, HasCloseHandlers<TreeItem>, SourcesMouseEvents, HasAllMouseHandlers

A standard hierarchical tree widget. The tree contains a hierarchy of `TreeItems` that the user can open, close, and select.

### CSS Style Rules

.gwt-Tree
  the tree itself
.gwt-Tree .gwt-TreeItem
  a tree item
.gwt-Tree .gwt-TreeItem-selected
  a selected tree item

### Example

>     public class TreeExample implements EntryPoint {

>       @Override
>       public void onModuleLoad() {
>         // Create a tree with a few items in it.
>         TreeItem root = new TreeItem();
>         root.setText("root");
>         root.addTextItem("item0");
>         root.addTextItem("item1");
>         root.addTextItem("item2");

>         // Add a CheckBox to the tree
>         TreeItem item = new TreeItem(new CheckBox("item3"));
>         root.addItem(item);

>         Tree t = new Tree();
>         t.addItem(root);

>         // Add it to the root panel.
>         RootPanel.get().add(t);
>       }
>     }

Nested Class Summary
`(package private) static class` | `Tree.ImageAdapter` There are several ways of configuring images for the Tree widget due to deprecated APIs.
`static interface` | `Tree.Resources` A ClientBundle that provides images for this widget.

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
`UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled`

Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasTreeItems
`HasTreeItems.ForIsWidget`

Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
`HasWidgets.ForIsWidget`

Field Summary

Fields inherited from class com.google.gwt.user.client.ui.Widget
`eventsToSink`

Fields inherited from class com.google.gwt.user.client.ui.UIObject
`DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR`

Constructor Summary
`Tree()` Constructs an empty tree.
`Tree(Tree.Resources resources)` Constructs a tree that uses the specified ClientBundle for images.
`Tree(Tree.Resources resources, boolean useLeafImages)` Constructs a tree that uses the specified ClientBundle for images.
`Tree(TreeImages images)` Deprecated. replaced by `Tree(Resources)`
`Tree(TreeImages images, boolean useLeafImages)` Deprecated. replaced by `Tree(Resources, boolean)`

Method Summary
`void` | `add(IsWidget w)` Overloaded version for IsWidget.
`void` | `add(Widget widget)` Adds the widget as a root tree item.
`HandlerRegistration` | `addBlurHandler(BlurHandler handler)` Adds a `BlurEvent` handler.
`HandlerRegistration` | `addCloseHandler(CloseHandler<TreeItem> handler)` Adds a `CloseEvent` handler.
`HandlerRegistration` | `addFocusHandler(FocusHandler handler)` Adds a `FocusEvent` handler.
`void` | `addFocusListener(FocusListener listener)` Deprecated. Use `addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)` instead
`void` | `addItem(IsTreeItem isItem)` Adds an item to the root level of this tree.
`TreeItem` | `addItem(IsWidget w)` Overloaded version for IsWidget.
`TreeItem` | `addItem(SafeHtml itemHtml)` Adds a simple tree item containing the specified html.
`void` | `addItem(TreeItem item)` Adds an item to the root level of this tree.
`TreeItem` | `addItem(Widget widget)` Adds a new tree item containing the specified widget.
`void` | `addKeyboardListener(KeyboardListener listener)` Deprecated. Use `addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler)`, `addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)` and `addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler)` instead
`HandlerRegistration` | `addKeyDownHandler(KeyDownHandler handler)` Adds a `KeyDownEvent` handler.
`HandlerRegistration` | `addKeyPressHandler(KeyPressHandler handler)` Adds a `KeyPressEvent` handler.
`HandlerRegistration` | `addKeyUpHandler(KeyUpHandler handler)` Adds a `KeyUpEvent` handler.
`HandlerRegistration` | `addMouseDownHandler(MouseDownHandler handler)` Adds a `MouseDownEvent` handler.
`void` | `addMouseListener(MouseListener listener)` Deprecated. Use `addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler)` `addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler)`, `addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler)`, `addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler)` and `addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler)` instead
`HandlerRegistration` | `addMouseMoveHandler(MouseMoveHandler handler)` Adds a `MouseMoveEvent` handler.
`HandlerRegistration` | `addMouseOutHandler(MouseOutHandler handler)` Adds a `MouseOutEvent` handler.
`HandlerRegistration` | `addMouseOverHandler(MouseOverHandler handler)` Adds a `MouseOverEvent` handler.
`HandlerRegistration` | `addMouseUpHandler(MouseUpHandler handler)` Adds a `MouseUpEvent` handler.
`HandlerRegistration` | `addMouseWheelHandler(MouseWheelHandler handler)` Adds a `MouseWheelEvent` handler.
`HandlerRegistration` | `addOpenHandler(OpenHandler<TreeItem> handler)` Adds an `OpenEvent` handler.
`HandlerRegistration` | `addSelectionHandler(SelectionHandler<TreeItem> handler)` Adds a `SelectionEvent` handler.
`TreeItem` | `addTextItem(java.lang.String itemText)` Adds a simple tree item containing the specified text.
`void` | `addTreeListener(TreeListener listener)` Deprecated. Use `addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler)`, `addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler)`, and `addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler)` instead
`(package private) void` | `adopt(Widget widget, TreeItem treeItem)`
`void` | `clear()` Clears all tree items from the current tree.
`protected void` | `doAttachChildren()` If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call `Widget.onAttach()` for each of its child widgets.
`protected void` | `doDetachChildren()` If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call `Widget.onDetach()` for each of its child widgets.
`void` | `ensureSelectedItemVisible()` Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.
`(package private) void` | `fireStateChanged(TreeItem item, boolean open)`
`(package private) java.util.Map<Widget,TreeItem>` | `getChildWidgets()`
`(package private) Tree.ImageAdapter` | `getImages()`
`TreeItem` | `getItem(int index)` Gets the top-level tree item at the specified index.
`int` | `getItemCount()` Gets the number of items contained at the root of this tree.
`TreeItem` | `getSelectedItem()` Gets the currently selected item.
`int` | `getTabIndex()` Gets the widget's position in the tab index.
`TreeItem` | `insertItem(int beforeIndex, SafeHtml itemHtml)` Inserts a child tree item at the specified index containing the specified html.
`void` | `insertItem(int beforeIndex, TreeItem item)` Inserts an item into the root level of this tree.
`TreeItem` | `insertItem(int beforeIndex, Widget widget)` Inserts a child tree item at the specified index containing the specified widget.
`TreeItem` | `insertTextItem(int beforeIndex, java.lang.String itemText)` Inserts a child tree item at the specified index containing the specified text.
`boolean` | `isAnimationEnabled()` Returns true if animations are enabled, false if not.
`protected boolean` | `isKeyboardNavigationEnabled(TreeItem currentItem)` Indicates if keyboard navigation is enabled for the Tree and for a given TreeItem.
`boolean` | `isScrollOnSelectEnabled()` Determines whether selecting a tree item will scroll it into view.
`java.util.Iterator<Widget>` | `iterator()` Gets an iterator for the contained widgets.
`(package private) void` | `maybeUpdateSelection(TreeItem itemThatChangedState, boolean isItemOpening)`
`void` | `onBrowserEvent(Event event)` Fired whenever a browser event is received.
`protected void` | `onEnsureDebugId(java.lang.String baseID)` Affected Elements: -root = The root `TreeItem`.
`protected void` | `onLoad()` This method is called immediately after a widget becomes attached to the browser's document.
`(package private) void` | `orphan(Widget widget)`
`boolean` | `remove(IsWidget w)` Overloaded version for IsWidget.
`boolean` | `remove(Widget w)` Removes a child widget.
`void` | `removeFocusListener(FocusListener listener)` Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by `addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)` instead
`void` | `removeItem(IsTreeItem isItem)` Removes an item from the root level of this tree.
`void` | `removeItem(TreeItem item)` Removes an item from the root level of this tree.
`void` | `removeItems()` Removes all items from the root level of this tree.
`void` | `removeKeyboardListener(KeyboardListener listener)` Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead
`void` | `removeMouseListener(MouseListener listener)` Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead
`void` | `removeTreeListener(TreeListener listener)` Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead
`void` | `setAccessKey(char key)` Sets the widget's 'access key'.
`void` | `setAnimationEnabled(boolean enable)` Enable or disable animations.
`void` | `setFocus(boolean focus)` Explicitly focus/unfocus this widget.
`void` | `setScrollOnSelectEnabled(boolean enable)` Enable or disable scrolling a tree item into view when it is selected.
`void` | `setSelectedItem(TreeItem item)` Selects a specified item.
`void` | `setSelectedItem(TreeItem item, boolean fireEvents)` Selects a specified item.
`void` | `setTabIndex(int index)` Sets the widget's position in the tab index.
`(package private) static boolean` | `shouldTreeDelegateFocusToElement(Element elem)`
`(package private) void` | `showClosedImage(TreeItem treeItem)` Called only from `TreeItem`: Shows the closed image on that tree item.
`(package private) void` | `showLeafImage(TreeItem treeItem)` Called only from `TreeItem`: Shows the leaf image on a tree item.
`(package private) void` | `showOpenImage(TreeItem treeItem)` Called only from `TreeItem`: Shows the open image on a tree item.
`java.util.Iterator<TreeItem>` | `treeItemIterator()` Iterator of tree items.

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Constructor Detail

### Tree

    public Tree()

  Constructs an empty tree.

### Tree

    public Tree(Tree.Resources resources)

  Constructs a tree that uses the specified ClientBundle for images.

  Parameters:
    `resources` - a bundle that provides tree specific images

### Tree

    public Tree(Tree.Resources resources,
                boolean useLeafImages)

  Constructs a tree that uses the specified ClientBundle for images. If this tree does not use leaf images, the width of the Resources's leaf image will control the leaf indent.

  Parameters:
    `resources` - a bundle that provides tree specific images
    `useLeafImages` - use leaf images from bundle

### Tree

    @Deprecated
    public Tree(TreeImages images)

  Deprecated. replaced by `Tree(Resources)`

  Constructs a tree that uses the specified image bundle for images.

  Parameters:
    `images` - a bundle that provides tree specific images

### Tree

    @Deprecated
    public Tree(TreeImages images,
                           boolean useLeafImages)

  Deprecated. replaced by `Tree(Resources, boolean)`

  Constructs a tree that uses the specified image bundle for images. If this tree does not use leaf images, the width of the TreeImage's leaf image will control the leaf indent.

  Parameters:
    `images` - a bundle that provides tree specific images
    `useLeafImages` - use leaf images from bundle

Method Detail

### shouldTreeDelegateFocusToElement

    static boolean shouldTreeDelegateFocusToElement(Element elem)

### add

    public void add(Widget widget)

  Adds the widget as a root tree item.

  Specified by:
    `add` in interface `HasWidgets`
  Parameters:
    `widget` - widget to add.
  See Also:
    `HasWidgets.add(com.google.gwt.user.client.ui.Widget)`

### add

    public void add(IsWidget w)

  Overloaded version for IsWidget.

  Specified by:
    `add` in interface `HasWidgets.ForIsWidget`
  See Also:
    `add(Widget)`

### addBlurHandler

    public HandlerRegistration addBlurHandler(BlurHandler handler)

  Description copied from interface: `HasBlurHandlers`
  Adds a `BlurEvent` handler.

  Specified by:
    `addBlurHandler` in interface `HasBlurHandlers`
  Parameters:
    `handler` - the blur handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addCloseHandler

    public HandlerRegistration addCloseHandler(CloseHandler<TreeItem> handler)

  Description copied from interface: `HasCloseHandlers`
  Adds a `CloseEvent` handler.

  Specified by:
    `addCloseHandler` in interface `HasCloseHandlers<TreeItem>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addFocusHandler

    public HandlerRegistration addFocusHandler(FocusHandler handler)

  Description copied from interface: `HasFocusHandlers`
  Adds a `FocusEvent` handler.

  Specified by:
    `addFocusHandler` in interface `HasFocusHandlers`
  Parameters:
    `handler` - the focus handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addFocusListener

    @Deprecated
    public void addFocusListener(FocusListener listener)

  Deprecated. Use `addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)` instead

  Description copied from interface: `SourcesFocusEvents`
  Adds a listener interface to receive focus events.

  Specified by:
    `addFocusListener` in interface `SourcesFocusEvents`
  Parameters:
    `listener` - the listener interface to add

### addItem

    public TreeItem addItem(SafeHtml itemHtml)

  Adds a simple tree item containing the specified html.

  Specified by:
    `addItem` in interface `HasTreeItems`
  Parameters:
    `itemHtml` - the html of the item to be added
  Returns:
    the item that was added

### addItem

    public void addItem(TreeItem item)

  Adds an item to the root level of this tree.

  Specified by:
    `addItem` in interface `HasTreeItems`
  Parameters:
    `item` - the item to be added

### addItem

    public void addItem(IsTreeItem isItem)

  Adds an item to the root level of this tree.

  Specified by:
    `addItem` in interface `HasTreeItems`
  Parameters:
    `isItem` - the wrapper of item to be added

### addItem

    public TreeItem addItem(Widget widget)

  Adds a new tree item containing the specified widget.

  Specified by:
    `addItem` in interface `HasTreeItems`
  Parameters:
    `widget` - the widget to be added
  Returns:
    the new item

### addItem

    public TreeItem addItem(IsWidget w)

  Overloaded version for IsWidget.

  Specified by:
    `addItem` in interface `HasTreeItems.ForIsWidget`
  See Also:
    `addItem(Widget)`

### addKeyboardListener

    @Deprecated
    public void addKeyboardListener(KeyboardListener listener)

  Deprecated. Use `addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler)`, `addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)` and `addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler)` instead

  Description copied from interface: `SourcesKeyboardEvents`
  Adds a listener interface to receive keyboard events.

  Specified by:
    `addKeyboardListener` in interface `SourcesKeyboardEvents`
  Parameters:
    `listener` - the listener interface to add

### addKeyDownHandler

    public HandlerRegistration addKeyDownHandler(KeyDownHandler handler)

  Description copied from interface: `HasKeyDownHandlers`
  Adds a `KeyDownEvent` handler.

  Specified by:
    `addKeyDownHandler` in interface `HasKeyDownHandlers`
  Parameters:
    `handler` - the key down handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addKeyPressHandler

    public HandlerRegistration addKeyPressHandler(KeyPressHandler handler)

  Description copied from interface: `HasKeyPressHandlers`
  Adds a `KeyPressEvent` handler.

  Specified by:
    `addKeyPressHandler` in interface `HasKeyPressHandlers`
  Parameters:
    `handler` - the key press handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addKeyUpHandler

    public HandlerRegistration addKeyUpHandler(KeyUpHandler handler)

  Description copied from interface: `HasKeyUpHandlers`
  Adds a `KeyUpEvent` handler.

  Specified by:
    `addKeyUpHandler` in interface `HasKeyUpHandlers`
  Parameters:
    `handler` - the key up handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseDownHandler

    public HandlerRegistration addMouseDownHandler(MouseDownHandler handler)

  Description copied from interface: `HasMouseDownHandlers`
  Adds a `MouseDownEvent` handler.

  Specified by:
    `addMouseDownHandler` in interface `HasMouseDownHandlers`
  Parameters:
    `handler` - the mouse down handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseListener

    @Deprecated
    public void addMouseListener(MouseListener listener)

  Deprecated. Use `addMouseOverHandler(com.google.gwt.event.dom.client.MouseOverHandler)` `addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler)`, `addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler)`, `addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler)` and `addMouseOutHandler(com.google.gwt.event.dom.client.MouseOutHandler)` instead

  Description copied from interface: `SourcesMouseEvents`
  Adds a listener interface to receive mouse events.

  Specified by:
    `addMouseListener` in interface `SourcesMouseEvents`
  Parameters:
    `listener` - the listener interface to add

### addMouseMoveHandler

    public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler)

  Description copied from interface: `HasMouseMoveHandlers`
  Adds a `MouseMoveEvent` handler.

  Specified by:
    `addMouseMoveHandler` in interface `HasMouseMoveHandlers`
  Parameters:
    `handler` - the mouse move handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseOutHandler

    public HandlerRegistration addMouseOutHandler(MouseOutHandler handler)

  Description copied from interface: `HasMouseOutHandlers`
  Adds a `MouseOutEvent` handler.

  Specified by:
    `addMouseOutHandler` in interface `HasMouseOutHandlers`
  Parameters:
    `handler` - the mouse out handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseOverHandler

    public HandlerRegistration addMouseOverHandler(MouseOverHandler handler)

  Description copied from interface: `HasMouseOverHandlers`
  Adds a `MouseOverEvent` handler.

  Specified by:
    `addMouseOverHandler` in interface `HasMouseOverHandlers`
  Parameters:
    `handler` - the mouse over handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseUpHandler

    public HandlerRegistration addMouseUpHandler(MouseUpHandler handler)

  Description copied from interface: `HasMouseUpHandlers`
  Adds a `MouseUpEvent` handler.

  Specified by:
    `addMouseUpHandler` in interface `HasMouseUpHandlers`
  Parameters:
    `handler` - the mouse up handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addMouseWheelHandler

    public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler)

  Description copied from interface: `HasMouseWheelHandlers`
  Adds a `MouseWheelEvent` handler.

  Specified by:
    `addMouseWheelHandler` in interface `HasMouseWheelHandlers`
  Parameters:
    `handler` - the mouse wheel handler
  Returns:
    `HandlerRegistration` used to remove this handler

### addOpenHandler

    public final HandlerRegistration addOpenHandler(OpenHandler<TreeItem> handler)

  Description copied from interface: `HasOpenHandlers`
  Adds an `OpenEvent` handler.

  Specified by:
    `addOpenHandler` in interface `HasOpenHandlers<TreeItem>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addSelectionHandler

    public HandlerRegistration addSelectionHandler(SelectionHandler<TreeItem> handler)

  Description copied from interface: `HasSelectionHandlers`
  Adds a `SelectionEvent` handler.

  Specified by:
    `addSelectionHandler` in interface `HasSelectionHandlers<TreeItem>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addTextItem

    public TreeItem addTextItem(java.lang.String itemText)

  Adds a simple tree item containing the specified text.

  Specified by:
    `addTextItem` in interface `HasTreeItems`
  Parameters:
    `itemText` - the text of the item to be added
  Returns:
    the item that was added

### addTreeListener

    @Deprecated
    public void addTreeListener(TreeListener listener)

  Deprecated. Use `addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler)`, `addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler)`, and `addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler)` instead

  Description copied from interface: `SourcesTreeEvents`
  Adds a listener interface to receive tree events.

  Specified by:
    `addTreeListener` in interface `SourcesTreeEvents`
  Parameters:
    `listener` - the listener interface to add

### clear

    public void clear()

  Clears all tree items from the current tree.

  Specified by:
    `clear` in interface `HasWidgets`

### ensureSelectedItemVisible

    public void ensureSelectedItemVisible()

  Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.

### getItem

    public TreeItem getItem(int index)

  Gets the top-level tree item at the specified index.

  Parameters:
    `index` - the index to be retrieved
  Returns:
    the item at that index

### getItemCount

    public int getItemCount()

  Gets the number of items contained at the root of this tree.

  Returns:
    this tree's item count

### getSelectedItem

    public TreeItem getSelectedItem()

  Gets the currently selected item.

  Returns:
    the selected item

### getTabIndex

    public int getTabIndex()

  Description copied from interface: `Focusable`
  Gets the widget's position in the tab index.

  Specified by:
    `getTabIndex` in interface `Focusable`
  Returns:
    the widget's tab index

### insertItem

    public TreeItem insertItem(int beforeIndex,
                               SafeHtml itemHtml)

  Inserts a child tree item at the specified index containing the specified html.

  Parameters:
    `beforeIndex` - the index where the item will be inserted
    `itemHtml` - the html of the item to be added
  Returns:
    the item that was added
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is out of range

### insertItem

    public void insertItem(int beforeIndex,
                           TreeItem item)

  Inserts an item into the root level of this tree.

  Parameters:
    `beforeIndex` - the index where the item will be inserted
    `item` - the item to be added
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is out of range

### insertItem

    public TreeItem insertItem(int beforeIndex,
                               Widget widget)

  Inserts a child tree item at the specified index containing the specified widget.

  Parameters:
    `beforeIndex` - the index where the item will be inserted
    `widget` - the widget to be added
  Returns:
    the item that was added
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is out of range

### insertTextItem

    public TreeItem insertTextItem(int beforeIndex,
                                   java.lang.String itemText)

  Inserts a child tree item at the specified index containing the specified text.

  Parameters:
    `beforeIndex` - the index where the item will be inserted
    `itemText` - the text of the item to be added
  Returns:
    the item that was added
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is out of range

### isAnimationEnabled

    public boolean isAnimationEnabled()

  Description copied from interface: `HasAnimation`
  Returns true if animations are enabled, false if not.

  Specified by:
    `isAnimationEnabled` in interface `HasAnimation`

### isScrollOnSelectEnabled

    public boolean isScrollOnSelectEnabled()

  Determines whether selecting a tree item will scroll it into view.

### iterator

    public java.util.Iterator<Widget> iterator()

  Description copied from interface: `HasWidgets`
  Gets an iterator for the contained widgets. This iterator is required to implement `Iterator.remove()`.

  Specified by:
    `iterator` in interface `HasWidgets`
  Specified by:
    `iterator` in interface `java.lang.Iterable<Widget>`

### onBrowserEvent

    public void onBrowserEvent(Event event)

  Description copied from interface: `EventListener`
  Fired whenever a browser event is received.

  Specified by:
    `onBrowserEvent` in interface `EventListener`
  Overrides:
    `onBrowserEvent` in class `Widget`
  Parameters:
    `event` - the event received

### remove

    public boolean remove(Widget w)

  Description copied from interface: `HasWidgets`
  Removes a child widget.

  Specified by:
    `remove` in interface `HasWidgets`
  Parameters:
    `w` - the widget to be removed
  Returns:
    `true` if the widget was present

### remove

    public boolean remove(IsWidget w)

  Overloaded version for IsWidget.

  Specified by:
    `remove` in interface `HasWidgets.ForIsWidget`
  See Also:
    `remove(Widget)`

### removeFocusListener

    @Deprecated
    public void removeFocusListener(FocusListener listener)

  Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by `addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)` instead

  Description copied from interface: `SourcesFocusEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeFocusListener` in interface `SourcesFocusEvents`
  Parameters:
    `listener` - the listener interface to remove

### removeItem

    public void removeItem(TreeItem item)

  Removes an item from the root level of this tree.

  Specified by:
    `removeItem` in interface `HasTreeItems`
  Parameters:
    `item` - the item to be removed

### removeItem

    public void removeItem(IsTreeItem isItem)

  Removes an item from the root level of this tree.

  Specified by:
    `removeItem` in interface `HasTreeItems`
  Parameters:
    `isItem` - the wrapper of item to be removed

### removeItems

    public void removeItems()

  Removes all items from the root level of this tree.

  Specified by:
    `removeItems` in interface `HasTreeItems`

### removeKeyboardListener

    @Deprecated
    public void removeKeyboardListener(KeyboardListener listener)

  Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead

  Description copied from interface: `SourcesKeyboardEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeKeyboardListener` in interface `SourcesKeyboardEvents`
  Parameters:
    `listener` - the listener interface to remove

### removeMouseListener

    @Deprecated
    public void removeMouseListener(MouseListener listener)

  Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead

  Description copied from interface: `SourcesMouseEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeMouseListener` in interface `SourcesMouseEvents`
  Parameters:
    `listener` - the listener interface to remove

### removeTreeListener

    @Deprecated
    public void removeTreeListener(TreeListener listener)

  Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by an add*Handler method instead

  Description copied from interface: `SourcesTreeEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeTreeListener` in interface `SourcesTreeEvents`
  Parameters:
    `listener` - the listener interface to remove

### setAccessKey

    public void setAccessKey(char key)

  Description copied from interface: `Focusable`
  Sets the widget's 'access key'. This key is used (in conjunction with a browser-specific modifier key) to automatically focus the widget.

  Specified by:
    `setAccessKey` in interface `Focusable`
  Parameters:
    `key` - the widget's access key

### setAnimationEnabled

    public void setAnimationEnabled(boolean enable)

  Description copied from interface: `HasAnimation`
  Enable or disable animations.

  Specified by:
    `setAnimationEnabled` in interface `HasAnimation`
  Parameters:
    `enable` - true to enable, false to disable

### setFocus

    public void setFocus(boolean focus)

  Description copied from interface: `Focusable`
  Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.

  Specified by:
    `setFocus` in interface `Focusable`
  Parameters:
    `focus` - whether this widget should take focus or release it

### setScrollOnSelectEnabled

    public void setScrollOnSelectEnabled(boolean enable)

  Enable or disable scrolling a tree item into view when it is selected. Scrolling into view is enabled by default.

### setSelectedItem

    public void setSelectedItem(TreeItem item)

  Selects a specified item.

  Parameters:
    `item` - the item to be selected, or `null` to deselect all items

### setSelectedItem

    public void setSelectedItem(TreeItem item,
                                boolean fireEvents)

  Selects a specified item.

  Parameters:
    `item` - the item to be selected, or `null` to deselect all items
    `fireEvents` - `true` to allow selection events to be fired

### setTabIndex

    public void setTabIndex(int index)

  Description copied from interface: `Focusable`
  Sets the widget's position in the tab index. If more than one widget has the same tab index, each such widget will receive focus in an arbitrary order. Setting the tab index to `-1` will cause this widget to be removed from the tab order.

  Specified by:
    `setTabIndex` in interface `Focusable`
  Parameters:
    `index` - the widget's tab index

### treeItemIterator

    public java.util.Iterator<TreeItem> treeItemIterator()

  Iterator of tree items.

  Returns:
    the iterator

### doAttachChildren

    protected void doAttachChildren()

  Description copied from class: `Widget`
  If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call `Widget.onAttach()` for each of its child widgets.

  Overrides:
    `doAttachChildren` in class `Widget`
  See Also:
    `Widget.onAttach()`

### doDetachChildren

    protected void doDetachChildren()

  Description copied from class: `Widget`
  If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call `Widget.onDetach()` for each of its child widgets.

  Overrides:
    `doDetachChildren` in class `Widget`
  See Also:
    `Widget.onDetach()`

### isKeyboardNavigationEnabled

    protected boolean isKeyboardNavigationEnabled(TreeItem currentItem)

  Indicates if keyboard navigation is enabled for the Tree and for a given TreeItem. Subclasses of Tree can override this function to selectively enable or disable keyboard navigation.

  Parameters:
    `currentItem` - the currently selected TreeItem
  Returns:
    `true` if the Tree will response to arrow keys by changing the currently selected item

### onEnsureDebugId

    protected void onEnsureDebugId(java.lang.String baseID)

  Affected Elements:
  - -root = The root `TreeItem`.

  Overrides:
    `onEnsureDebugId` in class `UIObject`
  Parameters:
    `baseID` - the base ID used by the main element
  See Also:
    `UIObject.onEnsureDebugId(String)`

### onLoad

    protected void onLoad()

  Description copied from class: `Widget`
  This method is called immediately after a widget becomes attached to the browser's document.

  Overrides:
    `onLoad` in class `Widget`

### adopt

    void adopt(Widget widget,
               TreeItem treeItem)

### fireStateChanged

    void fireStateChanged(TreeItem item,
                          boolean open)

### getChildWidgets

    java.util.Map<Widget,TreeItem> getChildWidgets()

### getImages

    Tree.ImageAdapter getImages()

### maybeUpdateSelection

    void maybeUpdateSelection(TreeItem itemThatChangedState,
                              boolean isItemOpening)

### orphan

    void orphan(Widget widget)

### showClosedImage

    void showClosedImage(TreeItem treeItem)

  Called only from `TreeItem`: Shows the closed image on that tree item.

  Parameters:
    `treeItem` - the tree item

### showLeafImage

    void showLeafImage(TreeItem treeItem)

  Called only from `TreeItem`: Shows the leaf image on a tree item.

  Parameters:
    `treeItem` - the tree item

### showOpenImage

    void showOpenImage(TreeItem treeItem)

  Called only from `TreeItem`: Shows the open image on a tree item.

  Parameters:
    `treeItem` - the tree item

Overview | Package | Class | Use | Deprecated | Help
| GWT 2.7.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD