|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.itmill.toolkit.data.util.IndexedContainer
com.itmill.toolkit.data.util.HierarchicalContainer
public class HierarchicalContainer
A specialized Container whose contents can be accessed like it was a tree-like structure.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.itmill.toolkit.data.Container |
|---|
Container.Editor, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.Sortable, Container.Viewer |
| Field Summary |
|---|
| Fields inherited from interface com.itmill.toolkit.data.Container |
|---|
NULL_ITEM_ID |
| Constructor Summary | |
|---|---|
HierarchicalContainer()
|
|
| Method Summary | |
|---|---|
Object |
addItem()
Creates a new Item into the list, and assign it an automatic ID. |
Item |
addItem(Object itemId)
Creates a new Item with the given ID into the list. |
boolean |
areChildrenAllowed(Object itemId)
Tests if the Item with given ID can have any children. |
Collection |
getChildren(Object itemId)
Gets the IDs of all Items that are children of the specified Item. |
Object |
getParent(Object itemId)
Gets the ID of the parent Item of the specified Item. |
boolean |
hasChildren(Object itemId)
Tests if the Item specified with itemId has any child
Items, that is, is it a leaf Item. |
boolean |
isRoot(Object itemId)
Tests if the Item specified with itemId is a root
Item. |
boolean |
removeAllItems()
Removes all Items from the list. |
boolean |
removeItem(Object itemId)
Removes the Item corresponding to the given Item ID from the list. |
Collection |
rootItemIds()
Gets the IDs of all Items in the container that don't have a parent. |
boolean |
setChildrenAllowed(Object itemId,
boolean childrenAllowed)
Sets the given Item's capability to have children. |
boolean |
setParent(Object itemId,
Object newParentId)
Sets the parent of an Item. |
| Methods inherited from class com.itmill.toolkit.data.util.IndexedContainer |
|---|
addContainerProperty, addItemAfter, addItemAfter, addItemAt, addItemAt, addListener, addListener, addListener, clone, compare, containsId, equals, firstItemId, getContainerProperty, getContainerPropertyIds, getIdByIndex, getItem, getItemIds, getSortableContainerPropertyIds, getType, hashCode, indexOfId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId, removeContainerProperty, removeListener, removeListener, removeListener, size, sort |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.itmill.toolkit.data.Container |
|---|
addContainerProperty, containsId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, removeContainerProperty, size |
| Constructor Detail |
|---|
public HierarchicalContainer()
| Method Detail |
|---|
public boolean areChildrenAllowed(Object itemId)
Container.HierarchicalManaged interface, the
items created with newItem can have children by
default.
areChildrenAllowed in interface Container.HierarchicalitemId - ID of the Item in the container whose child capability is
to be tested
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.public Collection getChildren(Object itemId)
Container.Hierarchical
getChildren in interface Container.HierarchicalitemId - ID of the Item whose children the caller is interested in
collection
containing the IDs of all other Items that are children in
the container hierarchypublic Object getParent(Object itemId)
Container.Hierarchical
getParent in interface Container.HierarchicalitemId - ID of the Item whose parent the caller wishes to find out.
null if the
specified Item is a root element.public boolean hasChildren(Object itemId)
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.
.
hasChildren in interface Container.HierarchicalitemId - ID of the Item whose leaf status is to be tested
true if the specified Item is a leaf,
false if notpublic boolean isRoot(Object itemId)
Container.HierarchicalitemId 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.
isRoot in interface Container.HierarchicalitemId - ID of the Item whose root status is to be tested
true if the specified Item is a root,
false if notpublic Collection rootItemIds()
Container.Hierarchicalroot Items. The returned
collection is unmodifiable.
rootItemIds in interface Container.Hierarchicalcollection
containing IDs of all root elements of the container
public boolean setChildrenAllowed(Object itemId,
boolean childrenAllowed)
Sets the given Item's capability to have children. If the Item identified
with the itemId already has children and the areChildrenAllowed is false
this method fails and false is returned; the children must
be first explicitly removed with
setParent(Object itemId, Object newParentId) or
Container.removeItem(Object itemId).
setChildrenAllowed in interface Container.HierarchicalitemId - the ID of the Item in the container whose child capability is
to be set.childrenAllowed - the boolean value specifying if the Item can have children or
not.
true if the operation succeeded,
false if not
public boolean setParent(Object itemId,
Object newParentId)
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.
setParent in interface Container.HierarchicalitemId - the ID of the item to be set as the child of the Item
identified with newParentId.newParentId - the ID of the Item that's to be the new parent of the Item
identified with itemId.
true if the operation succeeded,
false if notpublic Object addItem()
IndexedContainernull if the operation fails. After a
successful call you can use the
getItemmethod to fetch the
Item.
addItem in interface ContaineraddItem in class IndexedContainernull in case of a
failureContainer.addItem()public Item addItem(Object itemId)
IndexedContainernull if the operation fails or the Container already
contains a Item with the given ID.
addItem in interface ContaineraddItem in class IndexedContaineritemId - the ID of the Item to be created.
null in case of a failureContainer.addItem(Object)public boolean removeAllItems()
IndexedContainerNote : The Property ID and type information is preserved.
removeAllItems in interface ContainerremoveAllItems in class IndexedContainertrue if the operation succeeded,
false if notContainer.removeAllItems()public boolean removeItem(Object itemId)
IndexedContainer
removeItem in interface ContainerremoveItem in class IndexedContaineritemId - the ID of the Item to remove.
true if the operation succeeded,
false if notContainer.removeItem(Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||