thinwire.ui
Class Tree.Item

java.lang.Object
  extended by thinwire.ui.Tree.Item
All Implemented Interfaces:
HierarchyComponent.Item<Tree,Tree.Item>
Enclosing class:
Tree

public static final class Tree.Item
extends java.lang.Object

An object that represents an item in a Tree component.


Field Summary
static java.lang.String PROPERTY_ITEM_EXPANDED
           
static java.lang.String PROPERTY_ITEM_SELECTED
           
 
Fields inherited from interface thinwire.ui.HierarchyComponent.Item
PROPERTY_ITEM_IMAGE, PROPERTY_ITEM_TEXT, PROPERTY_ITEM_USER_OBJECT
 
Constructor Summary
Tree.Item()
          Constructs a new Item with no text and no image.
Tree.Item(java.lang.String text)
          Constructs a new Item with the specified text and no image.
Tree.Item(java.lang.String text, java.lang.String image)
          Constructs a new Item with the specified text and image.
 
Method Summary
 java.util.List<I> getChildren()
          Get the List that contains the children of this item.
 H getHierarchy()
           
 java.lang.String getImage()
          Get the image file name that is displayed on the left side of the item.
 ImageInfo getImageInfo()
          Returns an immutable ImageInfo class that provides information about the assigned image, such as width, height, format, etc.
 int getIndex()
          A convenience method that returns the index of this item in it's parents children List.
 java.lang.Object getParent()
          Get the parent object of this item.
 java.lang.String getText()
          Get the text that is displayed for the item in the menu.
 java.lang.Object getUserObject()
          Get the user defined value for this item.
 boolean hasChildren()
           
 boolean isExpanded()
          Get the expanded state of the item.
 boolean isSelected()
          Get the selected state of the item.
 void setExpanded(boolean expanded)
          Set the expanded state of the item.
 void setImage(java.lang.String image)
          Set the image file name that is displayed on the left side of the item.
 void setSelected(boolean selected)
          Set the selected state of the item.
 void setText(java.lang.String text)
          Set the text that is displayed for the item in the menu.
 void setUserObject(java.lang.Object value)
          Set a user defined value for this item.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_ITEM_SELECTED

public static final java.lang.String PROPERTY_ITEM_SELECTED
See Also:
Constant Field Values

PROPERTY_ITEM_EXPANDED

public static final java.lang.String PROPERTY_ITEM_EXPANDED
See Also:
Constant Field Values
Constructor Detail

Tree.Item

public Tree.Item()
Constructs a new Item with no text and no image.


Tree.Item

public Tree.Item(java.lang.String text)
Constructs a new Item with the specified text and no image.

Parameters:
text - the text to display for the item.

Tree.Item

public Tree.Item(java.lang.String text,
                 java.lang.String image)
Constructs a new Item with the specified text and image.

Parameters:
text - the text to display for the item.
image - the image to display to the left of the text of the item.
Method Detail

isSelected

public boolean isSelected()
Get the selected state of the item.

Returns:
true if this item is the selected item in the tree, false otherwise.

setSelected

public void setSelected(boolean selected)
Set the selected state of the item.

Parameters:
selected - true if you want to select the item, false if you want to unselect it and select the root item.
Throws:
java.lang.IllegalStateException - if the item has not been added to a tree.

isExpanded

public boolean isExpanded()
Get the expanded state of the item.

Returns:
true if this branch item in the tree is expanded and its children are shown, false otherwise.

setExpanded

public void setExpanded(boolean expanded)
Set the expanded state of the item.

Parameters:
expanded - true if you want to expand this branch item and show its children, false if you want to collapse it and hide the children.

toString

public java.lang.String toString()

getText

public java.lang.String getText()
Description copied from interface: HierarchyComponent.Item
Get the text that is displayed for the item in the menu.

Specified by:
getText in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the text that is displayed for the item, or an empty string if none.

setText

public void setText(java.lang.String text)
Description copied from interface: HierarchyComponent.Item
Set the text that is displayed for the item in the menu.

Specified by:
setText in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Parameters:
text - the text that should be displayed for the item.

getImage

public java.lang.String getImage()
Description copied from interface: HierarchyComponent.Item
Get the image file name that is displayed on the left side of the item.

Specified by:
getImage in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the image that is displayed for the item, or an empty string if none.

setImage

public void setImage(java.lang.String image)
Description copied from interface: HierarchyComponent.Item
Set the image file name that is displayed on the left side of the item.

Specified by:
setImage in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Parameters:
image - the name of the image file that should be displayed for the item.

getImageInfo

public ImageInfo getImageInfo()
Description copied from interface: HierarchyComponent.Item
Returns an immutable ImageInfo class that provides information about the assigned image, such as width, height, format, etc.

Specified by:
getImageInfo in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
an immutable ImageInfo describing this item's image.

getUserObject

public java.lang.Object getUserObject()
Description copied from interface: HierarchyComponent.Item
Get the user defined value for this item.

Specified by:
getUserObject in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the user defined value for this item if one is defined, null otherwise.

setUserObject

public void setUserObject(java.lang.Object value)
Description copied from interface: HierarchyComponent.Item
Set a user defined value for this item.

Specified by:
setUserObject in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getIndex

public int getIndex()
Description copied from interface: HierarchyComponent.Item
A convenience method that returns the index of this item in it's parents children List. Equivalent to item.getParent().getChildren().indexOf(item);.

Specified by:
getIndex in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the index of this item in it's parents children List.

getHierarchy

public H getHierarchy()
Specified by:
getHierarchy in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getParent

public java.lang.Object getParent()
Description copied from interface: HierarchyComponent.Item
Get the parent object of this item.

Specified by:
getParent in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
if this item is the root item, then this returns the Menu, otherwise this returns the parentMenu.Item or null if this item has not yet been added to another Menu.Item.

hasChildren

public boolean hasChildren()
Specified by:
hasChildren in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>

getChildren

public java.util.List<I> getChildren()
Description copied from interface: HierarchyComponent.Item
Get the List that contains the children of this item.

Specified by:
getChildren in interface HierarchyComponent.Item<H extends thinwire.ui.AbstractHierarchyComponent,I extends thinwire.ui.AbstractHierarchyComponent.Item>
Returns:
the List that contains the children of this item or an empty List if there are no children.


ThinWire® is a registered of Custom Credit Systems  Copyright © 2007 All rights reserved.
ThinWire_is_Open_Source_under_the_terms_of_the_LGPLv2.1 SourceForge.net_Project_Page java.net_Member Support_ThinWire,_Digg_our_Story