public class TreeItem extends UIObject implements IsTreeItem, HasTreeItems, HasHTML, HasSafeHtml
Tree
.
Each tree item is assigned a unique DOM id in order to support ARIA. See
Accessibility
for more information.
Modifier and Type | Class and Description |
---|---|
static class |
TreeItem.TreeItemImpl
Implementation class for
TreeItem . |
static class |
TreeItem.TreeItemImplIE8ToIE10
IE specific implementation class for
TreeItem . |
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasTreeItems.ForIsWidget
DEBUG_ID_PREFIX
Constructor and Description |
---|
TreeItem()
Creates an empty tree item.
|
TreeItem(SafeHtml html)
Constructs a tree item with the given HTML.
|
TreeItem(Widget widget)
Constructs a tree item with the given
Widget . |
Modifier and Type | Method and Description |
---|---|
void |
addItem(IsTreeItem isItem)
Adds another item as a child to this one.
|
TreeItem |
addItem(SafeHtml itemHtml)
Adds a child tree item containing the specified html.
|
void |
addItem(TreeItem item)
Adds another item as a child to this one.
|
TreeItem |
addItem(Widget widget)
Adds a child tree item containing the specified widget.
|
TreeItem |
addTextItem(String itemText)
Adds a child tree item containing the specified text.
|
TreeItem |
asTreeItem()
Returns the
TreeItem aspect of the receiver. |
TreeItem |
getChild(int index)
Gets the child at the specified index.
|
int |
getChildCount()
Gets the number of children contained in this item.
|
int |
getChildIndex(TreeItem child)
Gets the index of the specified child item.
|
protected Focusable |
getFocusable()
Returns a suggested
Focusable instance to use when this tree item
is selected. |
protected HasFocus |
getFocusableWidget()
Deprecated.
use
getFocusable() instead |
String |
getHTML()
Gets this object's contents as HTML.
|
TreeItem |
getParentItem()
Gets this item's parent.
|
boolean |
getState()
Gets whether this item's children are displayed.
|
String |
getText()
Gets this object's text.
|
Tree |
getTree()
Gets the tree that contains this item.
|
Object |
getUserObject()
Gets the user-defined object associated with this item.
|
Widget |
getWidget()
Gets the
Widget associated with this tree item. |
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 as a child to this one.
|
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 |
isSelected()
Determines whether this item is currently selected.
|
protected void |
onEnsureDebugId(String baseID)
Affected Elements:
-content = The text or
Widget next to the image.
-child# = The child at the specified index.
|
void |
remove()
Removes this item from its tree.
|
void |
removeItem(IsTreeItem isItem)
Removes one of this item's children.
|
void |
removeItem(TreeItem item)
Removes one of this item's children.
|
void |
removeItems()
Removes all of this item's children.
|
void |
setHTML(SafeHtml html)
Sets this object's contents via known-safe HTML.
|
void |
setHTML(String html)
Sets this object's contents via HTML.
|
void |
setSelected(boolean selected)
Selects or deselects this item.
|
void |
setState(boolean open)
Sets whether this item's children are displayed.
|
void |
setState(boolean open,
boolean fireEvents)
Sets whether this item's children are displayed.
|
void |
setText(String text)
Sets this object's text.
|
void |
setUserObject(Object userObj)
Sets the user-defined object associated with this item.
|
void |
setWidget(Widget newWidget)
Sets the current widget.
|
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, sinkEvents, toString, unsinkEvents
public TreeItem()
public TreeItem(SafeHtml html)
html
- the item's HTMLpublic TreeItem(Widget widget)
Widget
.widget
- the item's widgetpublic TreeItem addItem(SafeHtml itemHtml)
addItem
in interface HasTreeItems
itemHtml
- the item's HTMLpublic 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 addTextItem(String itemText)
addTextItem
in interface HasTreeItems
itemText
- the text of the item to be addedpublic TreeItem asTreeItem()
IsTreeItem
TreeItem
aspect of the receiver.asTreeItem
in interface IsTreeItem
public TreeItem getChild(int index)
index
- the index to be retrievedpublic int getChildCount()
public int getChildIndex(TreeItem child)
child
- the child item to be found-1
if none is foundpublic String getHTML()
HasHTML
public TreeItem getParentItem()
public boolean getState()
true
if the item is openpublic final Tree getTree()
public Object getUserObject()
public Widget getWidget()
Widget
associated with this tree item.public TreeItem insertItem(int beforeIndex, SafeHtml itemHtml) throws IndexOutOfBoundsException
beforeIndex
- the index where the item will be inserteditemHtml
- the item's HTMLIndexOutOfBoundsException
- if the index is out of rangepublic void insertItem(int beforeIndex, TreeItem item) throws IndexOutOfBoundsException
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) throws IndexOutOfBoundsException
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 item's textIndexOutOfBoundsException
- if the index is out of rangepublic boolean isSelected()
true
if it is selectedpublic void remove()
public 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
public void setHTML(String html)
HasHTML
HasText.setText(String)
whenever possible.public void setHTML(SafeHtml html)
HasSafeHtml
The object will behave exactly the same as when a widget's
HasHTML.setHTML(String)
method is
invoked; however the SafeHtml
passed to this method observes the
contract that it can be used in an HTML context without causing unsafe
script execution. Thus, unlike
HasHTML.setHTML(String)
, using this
method cannot result in Cross-Site Scripting security vulnerabilities.
setHTML
in interface HasSafeHtml
html
- the object's new HTML, represented as a SafeHtml
objectpublic void setSelected(boolean selected)
selected
- true
to select the item, false
to
deselect itpublic void setState(boolean open)
open
- whether the item is openpublic void setState(boolean open, boolean fireEvents)
open
- whether the item is openfireEvents
- true
to allow open/close events to bepublic void setText(String text)
HasText
public void setUserObject(Object userObj)
userObj
- the item's user-defined objectpublic void setWidget(Widget newWidget)
newWidget
- Widget to setprotected Focusable getFocusable()
Focusable
instance to use when this tree item
is selected. The tree maintains focus if this method returns null. By
default, if the tree item contains a focusable widget, that widget is
returned.
Note, the Tree
will ignore this value if the user clicked on an
input element such as a button or text area when selecting this item.@Deprecated protected HasFocus getFocusableWidget()
getFocusable()
insteadprotected void onEnsureDebugId(String baseID)
Widget
next to the image.onEnsureDebugId
in class UIObject
baseID
- the base ID used by the main elementUIObject.onEnsureDebugId(String)
Copyright © 2016. All rights reserved.