public class Tree extends Widget implements HasTreeItems.ForIsWidget, HasWidgets.ForIsWidget, SourcesTreeEvents, HasFocus, HasAnimation, HasAllKeyHandlers, HasAllFocusHandlers, HasSelectionHandlers<TreeItem>, HasOpenHandlers<TreeItem>, HasCloseHandlers<TreeItem>, SourcesMouseEvents, HasAllMouseHandlers
TreeItems
that the user can
open, close, and select.
Modifier and Type | Class and Description |
---|---|
static interface |
Tree.Resources
A ClientBundle that provides images for this widget.
|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasTreeItems.ForIsWidget
HasWidgets.ForIsWidget
DEBUG_ID_PREFIX
Constructor and Description |
---|
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) |
Modifier and Type | Method and Description |
---|---|
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.
|
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)
|
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(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<com.google.gwt.user.client.ui.TreeItem>) , addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler<com.google.gwt.user.client.ui.TreeItem>) , and
addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.TreeItem>) instead |
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.
|
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,
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.
|
Iterator<Widget> |
iterator()
Gets an iterator for the contained widgets.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onEnsureDebugId(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.
|
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.
|
Iterator<TreeItem> |
treeItemIterator()
Iterator of tree items.
|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
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
forEach, spliterator
fireEvent
public Tree()
public Tree(Tree.Resources resources)
resources
- a bundle that provides tree specific imagespublic Tree(Tree.Resources resources, boolean useLeafImages)
resources
- a bundle that provides tree specific imagesuseLeafImages
- use leaf images from bundle@Deprecated public Tree(TreeImages images)
Tree(Resources)
images
- a bundle that provides tree specific images@Deprecated public Tree(TreeImages images, boolean useLeafImages)
Tree(Resources, boolean)
images
- a bundle that provides tree specific imagesuseLeafImages
- use leaf images from bundlepublic void add(Widget widget)
add
in interface HasWidgets
widget
- widget to add.HasWidgets.add(com.google.gwt.user.client.ui.Widget)
public void add(IsWidget w)
add
in interface HasWidgets.ForIsWidget
add(Widget)
public HandlerRegistration addBlurHandler(BlurHandler handler)
HasBlurHandlers
BlurEvent
handler.addBlurHandler
in interface HasBlurHandlers
handler
- the blur handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addCloseHandler(CloseHandler<TreeItem> handler)
HasCloseHandlers
CloseEvent
handler.addCloseHandler
in interface HasCloseHandlers<TreeItem>
handler
- the handlerpublic HandlerRegistration addFocusHandler(FocusHandler handler)
HasFocusHandlers
FocusEvent
handler.addFocusHandler
in interface HasFocusHandlers
handler
- the focus handlerHandlerRegistration
used to remove this handler@Deprecated public void addFocusListener(FocusListener listener)
addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)
insteadSourcesFocusEvents
addFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to addpublic TreeItem addItem(SafeHtml itemHtml)
addItem
in interface HasTreeItems
itemHtml
- the html of the item to be addedpublic void addItem(TreeItem item)
addItem
in interface HasTreeItems
item
- the item to be addedpublic void addItem(IsTreeItem isItem)
addItem
in interface HasTreeItems
isItem
- the wrapper of item to be addedpublic TreeItem addItem(Widget widget)
addItem
in interface HasTreeItems
widget
- the widget to be addedpublic TreeItem addItem(IsWidget w)
addItem
in interface HasTreeItems.ForIsWidget
addItem(Widget)
@Deprecated public void addKeyboardListener(KeyboardListener listener)
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)
insteadSourcesKeyboardEvents
addKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to addpublic HandlerRegistration addKeyDownHandler(KeyDownHandler handler)
HasKeyDownHandlers
KeyDownEvent
handler.addKeyDownHandler
in interface HasKeyDownHandlers
handler
- the key down handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addKeyPressHandler(KeyPressHandler handler)
HasKeyPressHandlers
KeyPressEvent
handler.addKeyPressHandler
in interface HasKeyPressHandlers
handler
- the key press handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
HasKeyUpHandlers
KeyUpEvent
handler.addKeyUpHandler
in interface HasKeyUpHandlers
handler
- the key up handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseDownHandler(MouseDownHandler handler)
HasMouseDownHandlers
MouseDownEvent
handler.addMouseDownHandler
in interface HasMouseDownHandlers
handler
- the mouse down handlerHandlerRegistration
used to remove this handler@Deprecated public void addMouseListener(MouseListener listener)
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)
insteadSourcesMouseEvents
addMouseListener
in interface SourcesMouseEvents
listener
- the listener interface to addpublic HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler)
HasMouseMoveHandlers
MouseMoveEvent
handler.addMouseMoveHandler
in interface HasMouseMoveHandlers
handler
- the mouse move handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOutHandler(MouseOutHandler handler)
HasMouseOutHandlers
MouseOutEvent
handler.addMouseOutHandler
in interface HasMouseOutHandlers
handler
- the mouse out handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseOverHandler(MouseOverHandler handler)
HasMouseOverHandlers
MouseOverEvent
handler.addMouseOverHandler
in interface HasMouseOverHandlers
handler
- the mouse over handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
HasMouseUpHandlers
MouseUpEvent
handler.addMouseUpHandler
in interface HasMouseUpHandlers
handler
- the mouse up handlerHandlerRegistration
used to remove this handlerpublic HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler)
HasMouseWheelHandlers
MouseWheelEvent
handler.addMouseWheelHandler
in interface HasMouseWheelHandlers
handler
- the mouse wheel handlerHandlerRegistration
used to remove this handlerpublic final HandlerRegistration addOpenHandler(OpenHandler<TreeItem> handler)
HasOpenHandlers
OpenEvent
handler.addOpenHandler
in interface HasOpenHandlers<TreeItem>
handler
- the handlerpublic HandlerRegistration addSelectionHandler(SelectionHandler<TreeItem> handler)
HasSelectionHandlers
SelectionEvent
handler.addSelectionHandler
in interface HasSelectionHandlers<TreeItem>
handler
- the handlerpublic TreeItem addTextItem(String itemText)
addTextItem
in interface HasTreeItems
itemText
- the text of the item to be added@Deprecated public void addTreeListener(TreeListener listener)
addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<com.google.gwt.user.client.ui.TreeItem>)
, addOpenHandler(com.google.gwt.event.logical.shared.OpenHandler<com.google.gwt.user.client.ui.TreeItem>)
, and
addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.TreeItem>)
insteadSourcesTreeEvents
addTreeListener
in interface SourcesTreeEvents
listener
- the listener interface to addpublic void clear()
clear
in interface HasWidgets
public void ensureSelectedItemVisible()
public TreeItem getItem(int index)
index
- the index to be retrievedpublic int getItemCount()
public TreeItem getSelectedItem()
public int getTabIndex()
Focusable
getTabIndex
in interface Focusable
public TreeItem insertItem(int beforeIndex, SafeHtml itemHtml)
beforeIndex
- the index where the item will be inserteditemHtml
- the html of the item to be addedIndexOutOfBoundsException
- if the index is out of rangepublic void insertItem(int beforeIndex, TreeItem item)
beforeIndex
- the index where the item will be inserteditem
- the item to be addedIndexOutOfBoundsException
- if the index is out of rangepublic TreeItem insertItem(int beforeIndex, Widget widget)
beforeIndex
- the index where the item will be insertedwidget
- the widget to be addedIndexOutOfBoundsException
- if the index is out of rangepublic TreeItem insertTextItem(int beforeIndex, String itemText)
beforeIndex
- the index where the item will be inserteditemText
- the text of the item to be addedIndexOutOfBoundsException
- if the index is out of rangepublic boolean isAnimationEnabled()
HasAnimation
isAnimationEnabled
in interface HasAnimation
public boolean isScrollOnSelectEnabled()
public Iterator<Widget> iterator()
HasWidgets
Iterator.remove()
.iterator
in interface HasWidgets
iterator
in interface Iterable<Widget>
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event receivedpublic boolean remove(Widget w)
HasWidgets
remove
in interface HasWidgets
w
- the widget to be removedtrue
if the widget was presentpublic boolean remove(IsWidget w)
remove
in interface HasWidgets.ForIsWidget
remove(Widget)
@Deprecated public void removeFocusListener(FocusListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by addFocusHandler(com.google.gwt.event.dom.client.FocusHandler)
insteadSourcesFocusEvents
removeFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to removepublic void removeItem(TreeItem item)
removeItem
in interface HasTreeItems
item
- the item to be removedpublic void removeItem(IsTreeItem isItem)
removeItem
in interface HasTreeItems
isItem
- the wrapper of item to be removedpublic void removeItems()
removeItems
in interface HasTreeItems
@Deprecated public void removeKeyboardListener(KeyboardListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by an add*Handler method insteadSourcesKeyboardEvents
removeKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to remove@Deprecated public void removeMouseListener(MouseListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by an add*Handler method insteadSourcesMouseEvents
removeMouseListener
in interface SourcesMouseEvents
listener
- the listener interface to remove@Deprecated public void removeTreeListener(TreeListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by an add*Handler method insteadSourcesTreeEvents
removeTreeListener
in interface SourcesTreeEvents
listener
- the listener interface to removepublic void setAccessKey(char key)
Focusable
setAccessKey
in interface Focusable
key
- the widget's access keypublic void setAnimationEnabled(boolean enable)
HasAnimation
setAnimationEnabled
in interface HasAnimation
enable
- true to enable, false to disablepublic void setFocus(boolean focus)
Focusable
GWTTestCase#delayTestFinish
for more information on how to do this.public void setScrollOnSelectEnabled(boolean enable)
public void setSelectedItem(TreeItem item)
item
- the item to be selected, or null
to deselect all
itemspublic void setSelectedItem(TreeItem item, boolean fireEvents)
item
- the item to be selected, or null
to deselect all
itemsfireEvents
- true
to allow selection events to be firedpublic void setTabIndex(int index)
Focusable
-1
will cause this widget to
be removed from the tab order.setTabIndex
in interface Focusable
index
- the widget's tab indexpublic Iterator<TreeItem> treeItemIterator()
protected void doAttachChildren()
Widget
Widget.onAttach()
for each of its
child widgets.doAttachChildren
in class Widget
Widget.onAttach()
protected void doDetachChildren()
Widget
Widget.onDetach()
for each of its
child widgets.doDetachChildren
in class Widget
Widget.onDetach()
protected boolean isKeyboardNavigationEnabled(TreeItem currentItem)
currentItem
- the currently selected TreeItemtrue
if the Tree will response to arrow keys by
changing the currently selected itemprotected void onEnsureDebugId(String baseID)
TreeItem
.onEnsureDebugId
in class UIObject
baseID
- the base ID used by the main elementUIObject.onEnsureDebugId(String)
Copyright © 2016. All rights reserved.