com.google.gwt.widgetideas.client
Class FastTree

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.widgetideas.client.FastTree
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasFocus, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesFocusEvents, com.google.gwt.user.client.ui.SourcesKeyboardEvents, HasFastTreeItems

public class FastTree
extends com.google.gwt.user.client.ui.Panel
implements com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.HasFocus, HasFastTreeItems

A standard hierarchical tree widget. The tree contains a hierarchy of FastTreeItems.

CSS Style Rules


Nested Class Summary
static interface FastTree.DefaultResources
          Resources used.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
FastTree()
          Constructs a tree.
 
Method Summary
 void add(com.google.gwt.user.client.ui.Widget widget)
          Adds the widget as a root tree item.
static void addDefaultCSS()
          Add the default style sheet and images.
 void addFocusListener(com.google.gwt.user.client.ui.FocusListener listener)
           
 void addItem(FastTreeItem item)
          Adds an item to the root level of this tree.
 FastTreeItem addItem(java.lang.String itemText)
          Adds a simple tree item containing the specified text.
 FastTreeItem addItem(com.google.gwt.user.client.ui.Widget widget)
          Adds a new tree item containing the specified widget.
 void addKeyboardListener(com.google.gwt.user.client.ui.KeyboardListener listener)
           
 void addMouseListener(com.google.gwt.user.client.ui.MouseListener listener)
           
 void clear()
          Clears all tree items from the current tree.
protected  void doAttachChildren()
           
protected  void doDetachChildren()
           
 void ensureSelectedItemVisible()
          Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.
 FastTreeItem getChild(int index)
          Gets the child at the specified index.
 int getChildCount()
          Gets the number of children contained in this item.
 int getChildIndex(FastTreeItem child)
          Gets the index of the specified child item.
 FastTreeItem 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.
protected  FastTreeItem getRoot()
           
 FastTreeItem getSelectedItem()
          Gets the currently selected item.
 int getTabIndex()
           
 java.util.Iterator iterator()
           
protected  void moveSelectionBar(FastTreeItem item)
          Moves the selection bar around the given FastTreeItem.
 void onBrowserEvent(com.google.gwt.user.client.Event event)
           
protected  void onLoad()
           
protected  void onSelection(FastTreeItem item, boolean fireEvents, boolean moveFocus)
           
protected  void onUnload()
          This method is called immediately before a widget will be detached from the browser's document.
 boolean remove(com.google.gwt.user.client.ui.Widget w)
           
 void removeFocusListener(com.google.gwt.user.client.ui.FocusListener listener)
           
 void removeItem(FastTreeItem 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(com.google.gwt.user.client.ui.KeyboardListener listener)
           
 void setAccessKey(char key)
           
 void setFocus(boolean focus)
           
 void setSelectedItem(FastTreeItem item)
          Selects a specified item.
 void setSelectedItem(FastTreeItem item, boolean fireEvents)
          Selects a specified item.
 void setTabIndex(int index)
           
 java.util.Iterator treeItemIterator()
          Iterator of tree items.
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, adopt, disown, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onAttach, onDetach, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, 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

FastTree

public FastTree()
Constructs a tree.

Method Detail

addDefaultCSS

public static void addDefaultCSS()
Add the default style sheet and images.


add

public void add(com.google.gwt.user.client.ui.Widget widget)
Adds the widget as a root tree item.

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

addFocusListener

public void addFocusListener(com.google.gwt.user.client.ui.FocusListener listener)
Specified by:
addFocusListener in interface com.google.gwt.user.client.ui.SourcesFocusEvents

addItem

public void addItem(FastTreeItem item)
Adds an item to the root level of this tree.

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

addItem

public FastTreeItem addItem(java.lang.String itemText)
Adds a simple tree item containing the specified text.

Specified by:
addItem in interface HasFastTreeItems
Parameters:
itemText - the text of the item to be added
Returns:
the item that was added

addItem

public FastTreeItem addItem(com.google.gwt.user.client.ui.Widget widget)
Adds a new tree item containing the specified widget.

Specified by:
addItem in interface HasFastTreeItems
Parameters:
widget - the widget to be added
Returns:
the item that was added

addKeyboardListener

public void addKeyboardListener(com.google.gwt.user.client.ui.KeyboardListener listener)
Specified by:
addKeyboardListener in interface com.google.gwt.user.client.ui.SourcesKeyboardEvents

addMouseListener

public void addMouseListener(com.google.gwt.user.client.ui.MouseListener listener)

clear

public void clear()
Clears all tree items from the current tree.

Specified by:
clear in interface com.google.gwt.user.client.ui.HasWidgets
Overrides:
clear in class com.google.gwt.user.client.ui.Panel

ensureSelectedItemVisible

public void ensureSelectedItemVisible()
Ensures that the currently-selected item is visible, opening its parents and scrolling the tree as necessary.


getChild

public FastTreeItem getChild(int index)
Description copied from interface: HasFastTreeItems
Gets the child at the specified index.

Specified by:
getChild in interface HasFastTreeItems
Parameters:
index - the index to be retrieved
Returns:
the item at that index

getChildCount

public int getChildCount()
Description copied from interface: HasFastTreeItems
Gets the number of children contained in this item.

Specified by:
getChildCount in interface HasFastTreeItems
Returns:
this item's child count.

getChildIndex

public int getChildIndex(FastTreeItem child)
Description copied from interface: HasFastTreeItems
Gets the index of the specified child item.

Specified by:
getChildIndex in interface HasFastTreeItems
Parameters:
child - the child item to be found
Returns:
the child's index, or -1 if none is found

getItem

public FastTreeItem 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 FastTreeItem getSelectedItem()
Gets the currently selected item.

Returns:
the selected item

getTabIndex

public int getTabIndex()
Specified by:
getTabIndex in interface com.google.gwt.user.client.ui.HasFocus

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface com.google.gwt.user.client.ui.HasWidgets

onBrowserEvent

public void onBrowserEvent(com.google.gwt.user.client.Event event)
Specified by:
onBrowserEvent in interface com.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent in class com.google.gwt.user.client.ui.Widget

remove

public boolean remove(com.google.gwt.user.client.ui.Widget w)
Specified by:
remove in interface com.google.gwt.user.client.ui.HasWidgets
Specified by:
remove in class com.google.gwt.user.client.ui.Panel

removeFocusListener

public void removeFocusListener(com.google.gwt.user.client.ui.FocusListener listener)
Specified by:
removeFocusListener in interface com.google.gwt.user.client.ui.SourcesFocusEvents

removeItem

public void removeItem(FastTreeItem item)
Removes an item from the root level of this tree.

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

removeItems

public void removeItems()
Removes all items from the root level of this tree.


removeKeyboardListener

public void removeKeyboardListener(com.google.gwt.user.client.ui.KeyboardListener listener)
Specified by:
removeKeyboardListener in interface com.google.gwt.user.client.ui.SourcesKeyboardEvents

setAccessKey

public void setAccessKey(char key)
Specified by:
setAccessKey in interface com.google.gwt.user.client.ui.HasFocus

setFocus

public void setFocus(boolean focus)
Specified by:
setFocus in interface com.google.gwt.user.client.ui.HasFocus

setSelectedItem

public void setSelectedItem(FastTreeItem item)
Selects a specified item.

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

setSelectedItem

public void setSelectedItem(FastTreeItem 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)
Specified by:
setTabIndex in interface com.google.gwt.user.client.ui.HasFocus

treeItemIterator

public java.util.Iterator treeItemIterator()
Iterator of tree items.


doAttachChildren

protected void doAttachChildren()
Overrides:
doAttachChildren in class com.google.gwt.user.client.ui.Panel

doDetachChildren

protected void doDetachChildren()
Overrides:
doDetachChildren in class com.google.gwt.user.client.ui.Panel

getRoot

protected FastTreeItem getRoot()

moveSelectionBar

protected void moveSelectionBar(FastTreeItem item)
Moves the selection bar around the given FastTreeItem.

Parameters:
item - the item to move selection bar to

onLoad

protected void onLoad()
Overrides:
onLoad in class com.google.gwt.user.client.ui.Panel

onSelection

protected void onSelection(FastTreeItem item,
                           boolean fireEvents,
                           boolean moveFocus)

onUnload

protected void onUnload()
This method is called immediately before a widget will be detached from the browser's document.

Overrides:
onUnload in class com.google.gwt.user.client.ui.Panel