org.millstone.base.ui
Class Tree

java.lang.Object
  |
  +--org.millstone.base.ui.AbstractComponent
        |
        +--org.millstone.base.ui.AbstractField
              |
              +--org.millstone.base.ui.Select
                    |
                    +--org.millstone.base.ui.Tree
All Implemented Interfaces:
Buffered, BufferedValidatable, Component, Container, Container.Hierarchical, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer, java.util.EventListener, MethodEventSource, Paintable, Property, Property.Editor, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, VariableOwner

public class Tree
extends Select
implements Container.Hierarchical

MenuTree component. MenuTree can be used to select an item (or multiple items) from a hierarchical set of items.

Since:
3.0
Version:
3.0.3
Author:
IT Mill Ltd.

Nested Class Summary
 class Tree.CollapseEvent
          Collapse event
static interface Tree.CollapseListener
          Collapse event listener
 class Tree.ExpandEvent
          Event to fired when a node is expanded.
static interface Tree.ExpandListener
          Expand event listener
 
Nested classes inherited from class org.millstone.base.ui.AbstractField
AbstractField.ReadOnlyStatusChangeEvent, AbstractField.ValueChangeEvent
 
Nested classes inherited from class org.millstone.base.data.Container
Container.Editor, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Viewer
 
Nested classes inherited from class org.millstone.base.data.Buffered
Buffered.SourceException
 
Nested classes inherited from class org.millstone.base.data.Property
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
Nested classes inherited from class org.millstone.base.ui.Component
Component.Listener
 
Nested classes inherited from class org.millstone.base.terminal.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from class org.millstone.base.ui.Select
ITEM_CAPTION_MODE_EXPLICIT, ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID, ITEM_CAPTION_MODE_ICON_ONLY, ITEM_CAPTION_MODE_ID, ITEM_CAPTION_MODE_INDEX, ITEM_CAPTION_MODE_ITEM, ITEM_CAPTION_MODE_PROPERTY, itemIdMapper, items
 
Fields inherited from interface org.millstone.base.data.Container
NULL_ITEM_ID
 
Constructor Summary
Tree()
          Create new empty tree
Tree(java.lang.String caption)
          Create new empty tree with caption.
Tree(java.lang.String caption, Container dataSource)
          Create new tree with caption and connect it to a Container.
 
Method Summary
 void addActionHandler(Action.Handler actionHandler)
          Adds an action handler.
 void addListener(Tree.CollapseListener listener)
          Add collapse listener
 void addListener(Tree.ExpandListener listener)
          Add expand listener
 boolean areChildrenAllowed(java.lang.Object itemId)
          Tests if the Item with given ID can have any children.
 void changeVariables(java.lang.Object source, java.util.Map variables)
          Invoked when the value of a variable has changed.
 boolean collapseItem(java.lang.Object itemId)
          Collapse an item.
 boolean collapseItemsRecursively(java.lang.Object startItemId)
          Collapse items recursively Collapse all the children recursively starting from an item.
 boolean expandItem(java.lang.Object itemId)
          Expand an item.
 boolean expandItemsRecursively(java.lang.Object startItemId)
          Expand items recursively Expands all the children recursively starting from an item.
protected  void fireCollapseEvent(java.lang.Object itemId)
          Emit collapse event.
protected  void fireExpandEvent(java.lang.Object itemId)
          Emit expand event.
 void focus()
          Focusing to this component is not supported.
 java.util.Collection getChildren(java.lang.Object itemId)
          Gets the IDs of all Items that are children of the specified Item.
 java.lang.Object getParent(java.lang.Object itemId)
          Gets the ID of the parent Item of the specified Item.
 java.lang.String getTag()
          Get component UIDL tag.
 java.util.Collection getVisibleItemIds()
          Get the visible item ids.
 boolean hasChildren(java.lang.Object itemId)
          Tests if the Item specified with itemId has any child Items, that is, is it a leaf Item.
 boolean isExpanded(java.lang.Object itemId)
          Check is an item is expanded
 boolean isRoot(java.lang.Object itemId)
          Tests if the Item specified with itemId is a root Item.
 boolean isSelectable()
          Getter for property selectable.
 void paintContent(PaintTarget target)
          Paint the content of this component.
 void removeActionHandler(Action.Handler actionHandler)
          Removes an action handler.
 void removeListener(Tree.CollapseListener listener)
          Remove collapse listener
 void removeListener(Tree.ExpandListener listener)
          Remove expand listener
 java.util.Collection rootItemIds()
          Gets the IDs of all Items in the container that don't have a parent.
 boolean setChildrenAllowed(java.lang.Object itemId, boolean areChildrenAllowed)
          Sets the given Item's capability to have children.
 void setContainerDataSource(Container newDataSource)
          Set the container as data-source for viewing.
 void setNewItemsAllowed(boolean allowNewOptions)
          Adding new items is not supported.
 boolean setParent(java.lang.Object itemId, java.lang.Object newParentId)
          Sets the parent of an Item.
 void setSelectable(boolean selectable)
          Setter for property selectable.
 
Methods inherited from class org.millstone.base.ui.Select
addContainerProperty, addItem, addItem, addListener, addListener, containerItemSetChange, containerPropertySetChange, containsId, fireItemSetChange, firePropertySetChange, getContainerDataSource, getContainerProperty, getContainerPropertyIds, getItem, getItemCaption, getItemCaptionMode, getItemCaptionPropertyId, getItemIcon, getItemIconPropertyId, getItemIds, getNullSelectionItemId, getType, getType, getValue, isMultiSelect, isNewItemsAllowed, isSelected, removeAllItems, removeContainerProperty, removeItem, removeListener, removeListener, select, setItemCaption, setItemCaptionMode, setItemCaptionPropertyId, setItemIcon, setItemIconPropertyId, setMultiSelect, setNullSelectionItemId, setValue, size, unselect
 
Methods inherited from class org.millstone.base.ui.AbstractField
addListener, addListener, addValidator, commit, constructField, discard, fireReadOnlyStatusChange, fireValueChange, getErrorMessage, getPropertyDataSource, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isValid, isWriteThrough, removeListener, removeListener, removeValidator, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setWriteThrough, toString, validate, valueChange
 
Methods inherited from class org.millstone.base.ui.AbstractComponent
addListener, addListener, addListener, addListener, attach, childRequestedRepaint, dependsOn, detach, fireComponentEvent, fireEvent, getApplication, getCaption, getComponentError, getDescription, getDirectDependencies, getIcon, getLocale, getParent, getStyle, getWindow, isEnabled, isImmediate, isVisible, paint, removeDirectDependency, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setDescription, setEnabled, setIcon, setImmediate, setLocale, setParent, setStyle, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.millstone.base.data.Container
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, removeAllItems, removeContainerProperty, removeItem, size
 

Constructor Detail

Tree

public Tree()
Create new empty tree


Tree

public Tree(java.lang.String caption)
Create new empty tree with caption.


Tree

public Tree(java.lang.String caption,
            Container dataSource)
Create new tree with caption and connect it to a Container.

Method Detail

isExpanded

public boolean isExpanded(java.lang.Object itemId)
Check is an item is expanded

Returns:
true iff the item is expanded

expandItem

public boolean expandItem(java.lang.Object itemId)
Expand an item.

Returns:
True iff the expand operation succeeded

expandItemsRecursively

public boolean expandItemsRecursively(java.lang.Object startItemId)
Expand items recursively Expands all the children recursively starting from an item. Operation succeeds only if all expandable items are expanded.

Returns:
True iff the expand operation succeeded

collapseItem

public boolean collapseItem(java.lang.Object itemId)
Collapse an item.

Returns:
True iff the collapse operation succeeded

collapseItemsRecursively

public boolean collapseItemsRecursively(java.lang.Object startItemId)
Collapse items recursively Collapse all the children recursively starting from an item. Operation succeeds only if all expandable items are collapsed.

Returns:
True iff the collapse operation succeeded

isSelectable

public boolean isSelectable()
Getter for property selectable.

The tree is selectable by default.

Returns:
Value of property selectable.

setSelectable

public void setSelectable(boolean selectable)
Setter for property selectable.

The tree is selectable by default.

Parameters:
selectable - New value of property selectable.

getTag

public java.lang.String getTag()
Description copied from class: Select
Get component UIDL tag.

Overrides:
getTag in class Select
Returns:
Component UIDL tag as string.
See Also:
AbstractComponent.getTag()

changeVariables

public void changeVariables(java.lang.Object source,
                            java.util.Map variables)
Description copied from class: Select
Invoked when the value of a variable has changed.

Specified by:
changeVariables in interface VariableOwner
Overrides:
changeVariables in class Select
See Also:
VariableOwner.changeVariables(Object source, Map variables)

paintContent

public void paintContent(PaintTarget target)
                  throws PaintException
Description copied from class: Select
Paint the content of this component.

Overrides:
paintContent in class Select
Throws:
PaintException - The paint operation failed.
See Also:
AbstractComponent.paintContent(PaintTarget)

areChildrenAllowed

public boolean areChildrenAllowed(java.lang.Object itemId)
Description copied from interface: Container.Hierarchical
Tests if the Item with given ID can have any children. If the Container also implements the Managed interface, the items created with newItem can have children by default.

Specified by:
areChildrenAllowed in interface Container.Hierarchical
Parameters:
itemId - ID of the Item in the container whose child capability is to be tested
Returns:
true if the specified Item exists in the Container and it can have children, false if it's not found from the container or it can't have children.
See Also:
Container.Hierarchical.areChildrenAllowed(Object)

getChildren

public java.util.Collection getChildren(java.lang.Object itemId)
Description copied from interface: Container.Hierarchical
Gets the IDs of all Items that are children of the specified Item. The returned collection is unmodifiable.

Specified by:
getChildren in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose children the caller is interested in
Returns:
An unmodifiable collection containing the IDs of all other Items that are children in the container hierarchy
See Also:
Container.Hierarchical.getChildren(Object)

getParent

public java.lang.Object getParent(java.lang.Object itemId)
Description copied from interface: Container.Hierarchical
Gets the ID of the parent Item of the specified Item.

Specified by:
getParent in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose parent the caller wishes to find out.
Returns:
the ID of the parent Item. Will be null if the specified Item is a root element.
See Also:
Container.Hierarchical.getParent(Object)

hasChildren

public boolean hasChildren(java.lang.Object itemId)
Description copied from interface: Container.Hierarchical

Tests if the Item specified with itemId has any child Items, that is, is it a leaf Item. The Container.Hierarchical.getChildren(Object itemId) method always returns null for leaf Items.

Note that being a leaf does not imply whether or not an Item is allowed to have children.

.

Specified by:
hasChildren in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose leaf status is to be tested
Returns:
true if the specified Item is a leaf, false if not
See Also:
Container.Hierarchical.hasChildren(Object)

isRoot

public boolean isRoot(java.lang.Object itemId)
Description copied from interface: Container.Hierarchical
Tests if the Item specified with itemId is a root Item. The hierarchical container can have more than one root and must have at least one unless it is empty. The Container.Hierarchical.getParent(Object itemId) method always returns null for root Items.

Specified by:
isRoot in interface Container.Hierarchical
Parameters:
itemId - ID of the Item whose root status is to be tested
Returns:
true if the specified Item is a root, false if not
See Also:
Container.Hierarchical.isRoot(Object)

rootItemIds

public java.util.Collection rootItemIds()
Description copied from interface: Container.Hierarchical
Gets the IDs of all Items in the container that don't have a parent. Such items are called root Items. The returned collection is unmodifiable.

Specified by:
rootItemIds in interface Container.Hierarchical
Returns:
An unmodifiable collection containing IDs of all root elements of the container
See Also:
Container.Hierarchical.rootItemIds()

setChildrenAllowed

public boolean setChildrenAllowed(java.lang.Object itemId,
                                  boolean areChildrenAllowed)
Description copied from interface: Container.Hierarchical

Sets the given Item's capability to have children. If the Item identified with itemId already has children and areChildrenAllowed is false this method fails and false is returned; the children must be first explicitly removed with Container.Hierarchical.setParent(Object itemId, Object newParentId) or Container.removeItem(Object itemId).

This operation is optional. If it is not implemented, the method always returns false.

Specified by:
setChildrenAllowed in interface Container.Hierarchical
Parameters:
itemId - ID of the Item in the container whose child capability is to be set
areChildrenAllowed - boolean value specifying if the Item can have children or not
Returns:
true if the operation succeeded, false if not
See Also:
Container.Hierarchical.setChildrenAllowed(Object, boolean)

setParent

public boolean setParent(java.lang.Object itemId,
                         java.lang.Object newParentId)
Description copied from interface: Container.Hierarchical

Sets the parent of an Item. The new parent item must exist and be able to have children. (canHaveChildren(newParentId) == true). It is also possible to detach a node from the hierarchy (and thus make it root) by setting the parent null.

This operation is optional.

Specified by:
setParent in interface Container.Hierarchical
Parameters:
itemId - ID of the item to be set as the child of the Item identified with newParentId
newParentId - ID of the Item that's to be the new parent of the Item identified with itemId
Returns:
true if the operation succeeded, false if not
See Also:
Container.Hierarchical.setParent(Object, Object)

setContainerDataSource

public void setContainerDataSource(Container newDataSource)
Description copied from class: Select
Set the container as data-source for viewing.

Specified by:
setContainerDataSource in interface Container.Viewer
Overrides:
setContainerDataSource in class Select
Parameters:
newDataSource - The new data source Item
See Also:
Container.Viewer.setContainerDataSource(Container)

addListener

public void addListener(Tree.ExpandListener listener)
Add expand listener

Parameters:
listener - Listener to be added.

removeListener

public void removeListener(Tree.ExpandListener listener)
Remove expand listener

Parameters:
listener - Listener to be removed.

fireExpandEvent

protected void fireExpandEvent(java.lang.Object itemId)
Emit expand event.


addListener

public void addListener(Tree.CollapseListener listener)
Add collapse listener

Parameters:
listener - Listener to be added.

removeListener

public void removeListener(Tree.CollapseListener listener)
Remove collapse listener

Parameters:
listener - Listener to be removed.

fireCollapseEvent

protected void fireCollapseEvent(java.lang.Object itemId)
Emit collapse event.


addActionHandler

public void addActionHandler(Action.Handler actionHandler)
Adds an action handler.

See Also:
Action.Container.addActionHandler(Action.Handler)

removeActionHandler

public void removeActionHandler(Action.Handler actionHandler)
Removes an action handler.

See Also:
Action.Container.removeActionHandler(Action.Handler)

getVisibleItemIds

public java.util.Collection getVisibleItemIds()
Description copied from class: Select
Get the visible item ids. In Select, this returns list of all item ids, but can be overriden in subclasses if they paint only part of the items to the terminal or null if no items is visible.

Overrides:
getVisibleItemIds in class Select
See Also:
Select.getVisibleItemIds()

setNewItemsAllowed

public void setNewItemsAllowed(boolean allowNewOptions)
                        throws java.lang.UnsupportedOperationException
Adding new items is not supported.

Overrides:
setNewItemsAllowed in class Select
Parameters:
allowNewOptions - New value of property allowNewOptions.
Throws:
java.lang.UnsupportedOperationException - if set to true.
See Also:
Select.setNewItemsAllowed(boolean)

focus

public void focus()
           throws java.lang.UnsupportedOperationException
Focusing to this component is not supported.

Overrides:
focus in class AbstractField
Throws:
java.lang.UnsupportedOperationException - if invoked.
See Also:
AbstractField.focus()


Copyright © 2000,2001,2002 IT Mill Ltd. All Rights Reserved.