|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.TreeItem
public class TreeItem
An item that can be contained within a
Tree
.
Each tree item is assigned a unique DOM id in order to support ARIA. See
Accessibility
for more information.
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 | |
---|---|
static class |
TreeItem.TreeItemImpl
Implementation class for TreeItem . |
static class |
TreeItem.TreeItemImplIE8ToIE10
IE specific implementation class for TreeItem . |
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 |
Field Summary | |
---|---|
(package private) static int |
IMAGE_PAD
|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR |
Constructor Summary | |
---|---|
TreeItem()
Creates an empty tree item. |
|
TreeItem(boolean isRoot)
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 . |
Method Summary | |
---|---|
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(java.lang.String itemText)
Adds a child tree item containing the specified text. |
(package private) void |
addTreeItems(java.util.List<TreeItem> accum)
|
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. |
(package private) java.util.ArrayList<TreeItem> |
getChildren()
|
(package private) Element |
getContentElem()
|
protected Focusable |
getFocusable()
Returns a suggested Focusable instance to use when this tree item
is selected. |
protected HasFocus |
getFocusableWidget()
Deprecated. use getFocusable() instead |
java.lang.String |
getHTML()
Gets this object's contents as HTML. |
(package private) Element |
getImageElement()
|
(package private) Element |
getImageHolderElement()
|
TreeItem |
getParentItem()
Gets this item's parent. |
boolean |
getState()
Gets whether this item's children are displayed. |
java.lang.String |
getText()
Gets this object's text. |
Tree |
getTree()
Gets the tree that contains this item. |
java.lang.Object |
getUserObject()
Gets the user-defined object associated with this item. |
Widget |
getWidget()
Gets the Widget associated with this tree item. |
(package private) void |
initChildren()
|
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,
java.lang.String itemText)
Inserts a child tree item at the specified index containing the specified text. |
(package private) boolean |
isFullNode()
|
boolean |
isSelected()
Determines whether this item is currently selected. |
(package private) void |
maybeRemoveItemFromParent(TreeItem item)
Remove a tree item from its parent if it has one. |
protected void |
onEnsureDebugId(java.lang.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(java.lang.String html)
Sets this object's contents via HTML. |
(package private) void |
setParentItem(TreeItem parent)
|
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(java.lang.String text)
Sets this object's text. |
(package private) void |
setTree(Tree newTree)
|
void |
setUserObject(java.lang.Object userObj)
Sets the user-defined object associated with this item. |
void |
setWidget(Widget newWidget)
Sets the current widget. |
(package private) void |
updateState(boolean animate,
boolean updateTreeSelection)
|
(package private) void |
updateStateRecursive()
|
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, replaceElement, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, sinkEvents, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final int IMAGE_PAD
Constructor Detail |
---|
public TreeItem()
public TreeItem(SafeHtml html)
html
- the item's HTMLpublic TreeItem(Widget widget)
Widget
.
widget
- the item's widgetTreeItem(boolean isRoot)
isRoot
- true if this item is the root of a treeMethod Detail |
---|
public TreeItem addItem(SafeHtml itemHtml)
addItem
in interface HasTreeItems
itemHtml
- the item's HTML
public 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 added
public TreeItem addTextItem(java.lang.String itemText)
addTextItem
in interface HasTreeItems
itemText
- the text of the item to be added
public TreeItem asTreeItem()
IsTreeItem
TreeItem
aspect of the receiver.
asTreeItem
in interface IsTreeItem
public TreeItem getChild(int index)
index
- the index to be retrieved
public int getChildCount()
public int getChildIndex(TreeItem child)
child
- the child item to be found
-1
if none is foundpublic java.lang.String getHTML()
HasHTML
getHTML
in interface HasHTML
public TreeItem getParentItem()
public boolean getState()
true
if the item is openpublic java.lang.String getText()
HasText
getText
in interface HasText
public final Tree getTree()
public java.lang.Object getUserObject()
public Widget getWidget()
Widget
associated with this tree item.
public TreeItem insertItem(int beforeIndex, SafeHtml itemHtml) throws java.lang.IndexOutOfBoundsException
beforeIndex
- the index where the item will be inserteditemHtml
- the item's HTML
java.lang.IndexOutOfBoundsException
- if the index is out of rangepublic void insertItem(int beforeIndex, TreeItem item) throws java.lang.IndexOutOfBoundsException
beforeIndex
- the index where the item will be inserteditem
- the item to be added
java.lang.IndexOutOfBoundsException
- if the index is out of rangepublic TreeItem insertItem(int beforeIndex, Widget widget) throws java.lang.IndexOutOfBoundsException
beforeIndex
- the index where the item will be insertedwidget
- the widget to be added
java.lang.IndexOutOfBoundsException
- if the index is out of rangepublic TreeItem insertTextItem(int beforeIndex, java.lang.String itemText)
beforeIndex
- the index where the item will be inserteditemText
- the item's text
java.lang.IndexOutOfBoundsException
- 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(java.lang.String html)
HasHTML
HasText.setText(String)
whenever possible.
setHTML
in interface HasHTML
html
- the object's new HTMLpublic 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(java.lang.String text)
HasText
setText
in interface HasText
text
- the object's new textpublic void setUserObject(java.lang.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()
instead
protected void onEnsureDebugId(java.lang.String baseID)
Widget
next to the image.
onEnsureDebugId
in class UIObject
baseID
- the base ID used by the main elementUIObject.onEnsureDebugId(String)
void addTreeItems(java.util.List<TreeItem> accum)
java.util.ArrayList<TreeItem> getChildren()
Element getContentElem()
Element getImageElement()
Element getImageHolderElement()
void initChildren()
boolean isFullNode()
void maybeRemoveItemFromParent(TreeItem item)
item
- the tree item to remove from its parentvoid setParentItem(TreeItem parent)
void setTree(Tree newTree)
void updateState(boolean animate, boolean updateTreeSelection)
void updateStateRecursive()
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |