com.google.gwt.widgetideas.client
Class FastTreeItem

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.widgetideas.client.FastTreeItem
All Implemented Interfaces:
com.google.gwt.user.client.ui.HasHTML, com.google.gwt.user.client.ui.HasText, HasFastTreeItems
Direct Known Subclasses:
ListeningFastTreeItem

public class FastTreeItem
extends com.google.gwt.user.client.ui.UIObject
implements com.google.gwt.user.client.ui.HasHTML, HasFastTreeItems

An item that can be contained within a FastTree.

Example


Nested Class Summary
 
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
FastTreeItem()
          Creates an empty tree item.
FastTreeItem(java.lang.String html)
          Constructs a tree item with the given HTML.
FastTreeItem(com.google.gwt.user.client.ui.Widget widget)
          Constructs a tree item with the given Widget.
 
Method Summary
 void addItem(FastTreeItem item)
          Adds another item as a child to this one.
 FastTreeItem addItem(java.lang.String itemText)
          Adds a child tree item containing the specified text.
 FastTreeItem addItem(com.google.gwt.user.client.ui.Widget widget)
          Adds a child tree item containing the specified widget.
 void becomeInteriorNode()
          Become an interior node.
 void becomeLeafNode()
          Become a leaf node.
protected  void beforeClose()
          Called before the tree item is closed.
protected  void beforeOpen()
          Called before the tree item is opened.
protected  boolean beforeSelectionLost()
          Called when tree item is being unselected.
protected  void ensureChildren()
          Fired when a tree item receives a request to open for the first time.
 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.
 int getControlImageWidth()
          Returns the width of the control open/close image.
protected  com.google.gwt.user.client.ui.HasFocus getFocusableWidget()
          Returns the widget, if any, that should be focused on if this TreeItem is selected.
 java.lang.String getHTML()
           
 FastTreeItem getParentItem()
          Gets this item's parent.
 java.lang.String getText()
           
 FastTree getTree()
          Gets the tree that contains this item.
 com.google.gwt.user.client.ui.Widget getWidget()
          Gets the Widget associated with this tree item.
 boolean hasBeenOpened()
          Has this FastTreeItem ever been opened?
 boolean isInteriorNode()
          Does this FastTreeItem represent an interior node?
 boolean isLeafNode()
          Is this FastTreeItem a leaf node?
 boolean isOpen()
          Is the FastTreeItem open? Returns false if the FastTreeItem is closed or a leaf node.
 boolean isSelected()
          Determines whether this item is currently selected.
 boolean isShowing()
          Returns whether the tree is currently showing this FastTreeItem.
protected  void onSelected()
          Called when a tree item is selected.
 void remove()
          Removes this item from its tree.
 void removeItem(FastTreeItem item)
          Removes an item from the tree.
 void removeItems()
          Removes all of this item's children.
 void setHTML(java.lang.String html)
           
 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)
           
 void setWidget(com.google.gwt.user.client.ui.Widget widget)
           
 
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, setElement, 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

FastTreeItem

public FastTreeItem()
Creates an empty tree item.


FastTreeItem

public FastTreeItem(java.lang.String html)
Constructs a tree item with the given HTML.

Parameters:
html - the item's HTML

FastTreeItem

public FastTreeItem(com.google.gwt.user.client.ui.Widget widget)
Constructs a tree item with the given Widget.

Parameters:
widget - the item's widget
Method Detail

addItem

public void addItem(FastTreeItem item)
Description copied from interface: HasFastTreeItems
Adds another item as a child to this one.

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

addItem

public FastTreeItem addItem(java.lang.String itemText)
Description copied from interface: HasFastTreeItems
Adds a child tree item containing the specified text.

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

addItem

public FastTreeItem addItem(com.google.gwt.user.client.ui.Widget widget)
Description copied from interface: HasFastTreeItems
Adds a child 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

becomeInteriorNode

public void becomeInteriorNode()
Become an interior node.


becomeLeafNode

public void becomeLeafNode()
Become a leaf node.


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

getControlImageWidth

public int getControlImageWidth()
Returns the width of the control open/close image. Must be overridden if the TreeItem is using a control image that is not 16 pixels wide.

Returns:
the width of the control image

getHTML

public java.lang.String getHTML()
Specified by:
getHTML in interface com.google.gwt.user.client.ui.HasHTML

getParentItem

public FastTreeItem getParentItem()
Gets this item's parent.

Returns:
the parent item

getText

public java.lang.String getText()
Specified by:
getText in interface com.google.gwt.user.client.ui.HasText

getTree

public final FastTree getTree()
Gets the tree that contains this item.

Returns:
the containing tree

getWidget

public com.google.gwt.user.client.ui.Widget getWidget()
Gets the Widget associated with this tree item.


hasBeenOpened

public boolean hasBeenOpened()
Has this FastTreeItem ever been opened?

Returns:
whether the FastTreeItem has ever been opened.

isInteriorNode

public boolean isInteriorNode()
Does this FastTreeItem represent an interior node?


isLeafNode

public boolean isLeafNode()
Is this FastTreeItem a leaf node?


isOpen

public boolean isOpen()
Is the FastTreeItem open? Returns false if the FastTreeItem is closed or a leaf node.


isSelected

public boolean isSelected()
Determines whether this item is currently selected.

Returns:
true if it is selected

isShowing

public boolean isShowing()
Returns whether the tree is currently showing this FastTreeItem.


remove

public void remove()
Removes this item from its tree.


removeItem

public void removeItem(FastTreeItem item)
Removes an item from the tree. Note, if you want to switch the node back to be a leaf node, must call becomeLeaf()

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

removeItems

public void removeItems()
Removes all of this item's children.


setHTML

public void setHTML(java.lang.String html)
Specified by:
setHTML in interface com.google.gwt.user.client.ui.HasHTML

setState

public final void setState(boolean open)
Sets whether this item's children are displayed.

Parameters:
open - whether the item is open

setState

public void setState(boolean open,
                     boolean fireEvents)
Sets whether this item's children are displayed.

Parameters:
open - whether the item is open
fireEvents - true to allow open/close events to be fired

setText

public void setText(java.lang.String text)
Specified by:
setText in interface com.google.gwt.user.client.ui.HasText

setWidget

public void setWidget(com.google.gwt.user.client.ui.Widget widget)

beforeClose

protected void beforeClose()
Called before the tree item is closed.


beforeOpen

protected void beforeOpen()
Called before the tree item is opened.


beforeSelectionLost

protected boolean beforeSelectionLost()
Called when tree item is being unselected. Returning false cancels the unselection.


ensureChildren

protected void ensureChildren()
Fired when a tree item receives a request to open for the first time. Should be overridden in child clases.


getFocusableWidget

protected com.google.gwt.user.client.ui.HasFocus getFocusableWidget()
Returns the widget, if any, that should be focused on if this TreeItem is selected.

Returns:
widget to be focused.

onSelected

protected void onSelected()
Called when a tree item is selected.