de.enough.polish.ui
Class TreeItem

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by de.enough.polish.ui.FakeCustomItem
              extended by de.enough.polish.ui.FakeContainerCustomItem
                  extended by de.enough.polish.ui.TreeItem

public class TreeItem
extends FakeContainerCustomItem

Provides a tree of items that can contain several branches.

Each tree branch behaves like a normal J2ME Polish container, so you can specify view-types, columns, colspans, etc.

Copyright (c) Enough Software 2005 - 2008

 history
        16-Feb-2005 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.FakeContainerCustomItem
allowCycling, autoFocusEnabled, autoFocusIndex, availableHeight, containerView, enableScrolling, focusedIndex, focusedItem, focusedStyleFirst, focusedStyleLast, isExpandItems, itemsList, itemStyle, lastPointerPressY, plainStyle, SCROLL_DEFAULT, SCROLL_SMOOTH, scrollSmooth, targetYOffset, yOffset
 
Fields inherited from class de.enough.polish.ui.FakeCustomItem
_bbField, _bbFieldAdded, appearanceMode, background, backgroundHeight, backgroundWidth, backgroundYOffset, border, borderWidth, BUTTON, colSpan, commands, contentHeight, contentWidth, contentX, contentY, cssSelector, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isFocused, isInitialized, isInvisible, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialised, itemCommandListener, itemHeight, itemWidth, label, labelStyle, layout, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, marginBottom, marginLeft, marginRight, marginTop, maximumHeight, maximumWidth, minimumHeight, minimumWidth, NO_POSITION_SET, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, style, TRANSPARENT, VERTICAL, view
 
Fields inherited from class javax.microedition.lcdui.CustomItem
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL
 
Constructor Summary
TreeItem(java.lang.String label)
          Creates a new tree item.
TreeItem(java.lang.String label, Style style)
          Creates a new tree item.
 
Method Summary
 void appendToNode(javax.microedition.lcdui.Item node, javax.microedition.lcdui.Item item)
          Adds the specified item to this tree.
 void appendToNode(Item node, Item item)
          Adds the specified item to this tree.
 void appendToNode(Item node, Item item, Style nodeStyle)
          Adds the specified item to this tree.
 javax.microedition.lcdui.Item appendToNode(javax.microedition.lcdui.Item node, java.lang.String text, javax.microedition.lcdui.Image image)
          Adds the specified text/image to this tree.
 Item appendToNode(Item node, java.lang.String text, javax.microedition.lcdui.Image image)
          Adds the specified text/image to this tree.
 Item appendToNode(Item node, java.lang.String text, javax.microedition.lcdui.Image image, Style childStyle)
          Adds the specified text/image to this tree.
 void appendToRoot(javax.microedition.lcdui.Item item)
          Adds the specified item to this tree.
 void appendToRoot(Item item)
          Adds the specified item to this list.
 void appendToRoot(Item item, Style nodeStyle)
          Adds the specified item to this list.
 javax.microedition.lcdui.Item appendToRoot(java.lang.String text, javax.microedition.lcdui.Image image)
          Appends the specified text and image to this list.
 javax.microedition.lcdui.Item appendToRoot(java.lang.String text, javax.microedition.lcdui.Image image, Style rootStyle)
          Appends the specified text and image to this list and provides it with the given style.
 void collapseAll()
          Collapses all branches of this TreeItem.
protected  Style focus(Style focusStyle, int direction)
          Focuses this item.
 Item[] getSelectedPath()
          Retireves the currently selected path of this tree item.
 java.lang.Object[] getSelectedPathAsAttributes(java.lang.Object key)
          Retireves the currently selected path of this tree item.
 boolean remove(javax.microedition.lcdui.Item item)
          Removes the specified item from this list.
 void removeAll()
          Clears this list.
 void setSelectedPathByAttribute(java.lang.Object key, java.lang.Object[] values)
          Opens the tree and focuses the specified items.
 void setStyle(Style style)
          Sets the style of this item.
 
Methods inherited from class de.enough.polish.ui.FakeContainerCustomItem
add, add, add, add, add, add, add, animate, changeChildStyles, changeChildStyles, clear, createCssSelector, defocus, focus, focus, focusClosestItem, focusClosestItem, focusClosestItemAbove, get, getFocusedIndex, getFocusedItem, getFocusedStyle, getItemAt, getItems, getNumberOfInteractiveItems, getPosition, getRelativeScrollHeight, getRelativeScrollYOffset, getScrollHeight, getScrollYOffset, handleCommand, handleKeyPressed, handleKeyReleased, handleKeyRepeated, handleNavigate, handlePointerPressed, handlePointerReleased, handlePointerScrollReleased, hideNotify, indexOf, initContent, paintBackgroundAndBorder, paintContent, parseIndexUrl, releaseResources, remove, remove, requestDefocus, requestFullInit, scroll, scroll, set, set, setItemsList, setScrollHeight, setScrollYOffset, setScrollYOffset, setStyle, showCommands, showNotify, size, toString
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToContentRegion, animate, containsCommand, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getItemCommandListener, getItemHeight, getItemStateListener, getItemWidth, getLabel, getLabelItem, getLayout, getMinContentHeight, getMinContentWidth, getMinimumHeight, getMinimumWidth, getParent, getPrefContentHeight, getPrefContentWidth, getPreferredHeight, getPreferredWidth, getScreen, getStyle, init, initStyle, isInContentArea, isInItemArea, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, paint, paint, paintBackground, paintBorder, removeCommand, repaintFully, requestInit, setAppearanceMode, setAttribute, setDefaultCommand, setItemCommandListener, setItemCommandListener, setItemStateListener, setLabel, setLayout, setPreferredSize, setVisible, show
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeItem

public TreeItem(java.lang.String label)
Creates a new tree item.

Parameters:
label - the label of this item

TreeItem

public TreeItem(java.lang.String label,
                Style style)
Creates a new tree item.

Parameters:
label - the label of this item
style - the style
Method Detail

appendToRoot

public void appendToRoot(javax.microedition.lcdui.Item item)
Adds the specified item to this tree.

Parameters:
item - the item that should be added

appendToNode

public void appendToNode(javax.microedition.lcdui.Item node,
                         javax.microedition.lcdui.Item item)
Adds the specified item to this tree.

Parameters:
node - the parent node that has been previously added to this tree
item - the item that should be added

appendToNode

public javax.microedition.lcdui.Item appendToNode(javax.microedition.lcdui.Item node,
                                                  java.lang.String text,
                                                  javax.microedition.lcdui.Image image)
Adds the specified text/image to this tree.

Parameters:
node - the parent node that has been previously added to this tree
text - the text
image - the image
Returns:
the created item

remove

public boolean remove(javax.microedition.lcdui.Item item)
Removes the specified item from this list.

Parameters:
item - the item that should be removed
Returns:
true when the item was contained in this list.

appendToRoot

public javax.microedition.lcdui.Item appendToRoot(java.lang.String text,
                                                  javax.microedition.lcdui.Image image)
Appends the specified text and image to this list.

Parameters:
text - the text
image - the image
Returns:
the created item

appendToRoot

public javax.microedition.lcdui.Item appendToRoot(java.lang.String text,
                                                  javax.microedition.lcdui.Image image,
                                                  Style rootStyle)
Appends the specified text and image to this list and provides it with the given style.

Parameters:
text - the text
image - the image
rootStyle - the style
Returns:
return the created item

appendToRoot

public void appendToRoot(Item item)
Adds the specified item to this list.

Parameters:
item - the item that should be added

appendToRoot

public void appendToRoot(Item item,
                         Style nodeStyle)
Adds the specified item to this list.

Parameters:
item - the item that should be added
nodeStyle - the style

appendToNode

public Item appendToNode(Item node,
                         java.lang.String text,
                         javax.microedition.lcdui.Image image)
Adds the specified text/image to this tree.

Parameters:
node - the parent node that has been previously added to this tree
text - the text
image - the image
Returns:
the created item

appendToNode

public Item appendToNode(Item node,
                         java.lang.String text,
                         javax.microedition.lcdui.Image image,
                         Style childStyle)
Adds the specified text/image to this tree.

Parameters:
node - the parent node that has been previously added to this tree
text - the text
image - the image
childStyle - the style
Returns:
the created item

appendToNode

public void appendToNode(Item node,
                         Item item)
Adds the specified item to this tree.

Parameters:
node - the parent node that has been previously added to this tree
item - the item that should be added

appendToNode

public void appendToNode(Item node,
                         Item item,
                         Style nodeStyle)
Adds the specified item to this tree.

Parameters:
node - the parent node that has been previously added to this tree
item - the item that should be added
nodeStyle - the style

removeAll

public void removeAll()
Clears this list.


setStyle

public void setStyle(Style style)
Description copied from class: FakeCustomItem
Sets the style of this item.

Overrides:
setStyle in class FakeContainerCustomItem
Parameters:
style - the new style for this item.

getSelectedPath

public Item[] getSelectedPath()
Retireves the currently selected path of this tree item.

Returns:
an array that contains all selected items

getSelectedPathAsAttributes

public java.lang.Object[] getSelectedPathAsAttributes(java.lang.Object key)
Retireves the currently selected path of this tree item.

Parameters:
key - the key that is used for querying attributes from the focused item
Returns:
an array that contains all attribute values of the selected items. When an item has not registered the specified attribute, the item itself will be put into that array slot.
See Also:
UiAccess.setAttribute(Item, Object, Object), UiAccess.getAttribute(Item, Object)

setSelectedPathByAttribute

public void setSelectedPathByAttribute(java.lang.Object key,
                                       java.lang.Object[] values)
Opens the tree and focuses the specified items. All other branches are collapsed while the specified path(s) is opened. When several pathes do match, the last atching path is focused.

Parameters:
key - the attribute key
values - the values that are set for each item / node
See Also:
UiAccess.setAttribute(Item, Object, Object), UiAccess.getAttribute(Item, Object)

focus

protected Style focus(Style focusStyle,
                      int direction)
Description copied from class: FakeCustomItem
Focuses this item.

Overrides:
focus in class FakeContainerCustomItem
Parameters:
focusStyle - the style which is used to indicate the focused state
direction - the direction from which this item is focused, either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0. When 0 is given, the direction is unknown.
Returns:
the current style of this item

collapseAll

public void collapseAll()
Collapses all branches of this TreeItem.