|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Tree
public class Tree
A standard hierarchical tree widget. The tree contains a hierarchy of
TreeItems
that the user can
open, close, and select.
public class TreeExample implements EntryPoint { public void onModuleLoad() { // Create a tree with a few items in it. TreeItem root = new TreeItem("root"); root.addItem("item0"); root.addItem("item1"); root.addItem("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); } }
Constructor Summary | |
---|---|
Tree()
Constructs an empty tree. |
Method Summary | |
---|---|
void |
add(Widget widget)
Adds the widget as a root tree item. |
void |
addFocusListener(FocusListener listener)
Adds a listener interface to receive mouse events. |
TreeItem |
addItem(java.lang.String itemText)
Adds a simple tree item containing the specified text. |
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)
Adds a listener interface to receive keyboard events. |
void |
addMouseListener(MouseListener listener)
|
void |
addTreeListener(TreeListener listener)
Adds a listener interface to receive tree events. |
void |
clear()
Clears all tree items from the current tree. |
void |
ensureSelectedItemVisible()
Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary. |
java.lang.String |
getImageBase()
Gets this tree's default image package. |
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. |
java.util.Iterator |
iterator()
Returns all TreeItem.ContentPanel elements contained within
this tree. |
protected void |
onAttach()
This method is called when a widget is attached to the browser's document. |
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received. |
protected void |
onDetach()
This method is called when a widget is detached from the browser's document. |
protected void |
onLoad()
This method is called when the widget becomes attached to the browser's document. |
boolean |
remove(Widget w)
Removes a child widget. |
void |
removeFocusListener(FocusListener listener)
Removes a previously added listener interface. |
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)
Removes a previously added listener interface. |
void |
removeTreeListener(TreeListener listener)
Removes a previously added listener interface. |
void |
setAccessKey(char key)
Sets the widget's 'access key'. |
void |
setFocus(boolean focus)
Explicitly focus/unfocus this widget. |
void |
setImageBase(java.lang.String baseUrl)
Sets the base URL under which this tree will find its default images. |
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. |
java.util.Iterator |
treeItemIterator()
Iterator of tree items. |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
getParent, isAttached, removeFromParent |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getTitle, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Tree()
Method Detail |
---|
public void add(Widget widget)
add
in interface HasWidgets
widget
- widget to add.HasWidgets.add(com.google.gwt.user.client.ui.Widget)
public void addFocusListener(FocusListener listener)
SourcesFocusEvents
addFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to addpublic TreeItem addItem(java.lang.String itemText)
itemText
- the text of the item to be added
public void addItem(TreeItem item)
item
- the item to be addedpublic TreeItem addItem(Widget widget)
widget
- the widget to be addedpublic void addKeyboardListener(KeyboardListener listener)
SourcesKeyboardEvents
addKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to addpublic void addMouseListener(MouseListener listener)
public void addTreeListener(TreeListener listener)
SourcesTreeEvents
addTreeListener
in interface SourcesTreeEvents
listener
- the listener interface to addpublic void clear()
clear
in interface HasWidgets
public void ensureSelectedItemVisible()
public java.lang.String getImageBase()
setImageBase(java.lang.String)
public TreeItem getItem(int index)
index
- the index to be retrieved
public int getItemCount()
public TreeItem getSelectedItem()
public int getTabIndex()
HasFocus
getTabIndex
in interface HasFocus
public java.util.Iterator iterator()
TreeItem.ContentPanel
elements contained within
this tree. The existence of the TreeItem.ContentPanel
class
is an implementation detail that may or may not be preserved in future
versions of Tree.
iterator
in interface HasWidgets
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 removed
true
if the widget was presentpublic void removeFocusListener(FocusListener listener)
SourcesFocusEvents
removeFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to removepublic void removeItem(TreeItem item)
item
- the item to be removedpublic void removeItems()
public void removeKeyboardListener(KeyboardListener listener)
SourcesKeyboardEvents
removeKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to removepublic void removeTreeListener(TreeListener listener)
SourcesTreeEvents
removeTreeListener
in interface SourcesTreeEvents
listener
- the listener interface to removepublic void setAccessKey(char key)
HasFocus
setAccessKey
in interface HasFocus
key
- the widget's access keypublic void setFocus(boolean focus)
HasFocus
setFocus
in interface HasFocus
focus
- whether this widget should take focus or release itpublic void setImageBase(java.lang.String baseUrl)
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)
HasFocus
-1
will cause this widget to
be removed from the tab order.
setTabIndex
in interface HasFocus
index
- the widget's tab indexpublic java.util.Iterator treeItemIterator()
protected void onAttach()
Widget
Panel
. To receive
notification when a widget is attached to the document, override the
Widget.onLoad()
method.
onAttach
in class Widget
protected void onDetach()
Widget
Panel
.
onDetach
in class Widget
protected void onLoad()
Widget
onLoad
in class Widget
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |