public class HierarchicalContainerOrderedWrapper extends ContainerOrderedWrapper implements Container.Hierarchical
Container.Ordered
interface while retaining Container.Hierarchical
features.ContainerOrderedWrapper
,
Serialized FormContainer.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.Viewer
Constructor and Description |
---|
HierarchicalContainerOrderedWrapper(Container.Hierarchical toBeWrapped) |
Modifier and Type | Method and Description |
---|---|
boolean |
areChildrenAllowed(Object itemId)
Tests if the Item with given ID can have 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 child Items
or if it is a leaf. |
boolean |
isRoot(Object itemId)
Tests if the Item specified with
itemId is a root Item. |
Collection<?> |
rootItemIds()
Gets the IDs of all Items in the container that don't have a parent.
|
boolean |
setChildrenAllowed(Object itemId,
boolean areChildrenAllowed)
Sets the given Item's capability to have children.
|
boolean |
setParent(Object itemId,
Object newParentId)
Sets the parent of an Item.
|
addContainerProperty, addItem, addItem, addItemAfter, addItemAfter, addItemSetChangeListener, addListener, addListener, addPropertySetChangeListener, containsId, firstItemId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, isFirstId, isLastId, lastItemId, nextItemId, prevItemId, removeAllItems, removeContainerProperty, removeItem, removeItemSetChangeListener, removeListener, removeListener, removePropertySetChangeListener, size, updateOrderWrapper
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
removeItem
addContainerProperty, addItem, addItem, containsId, getContainerProperty, getContainerPropertyIds, getItem, getItemIds, getType, removeAllItems, removeContainerProperty, size
public HierarchicalContainerOrderedWrapper(Container.Hierarchical toBeWrapped)
public boolean areChildrenAllowed(Object itemId)
Container.Hierarchical
areChildrenAllowed
in interface Container.Hierarchical
itemId
- ID of the Item in the container whose child capability is
to be testedtrue
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.Hierarchical
itemId
- ID of the Item whose children the caller is interested incollection
containing the IDs of all other Items that are children in
the container hierarchy; null
if item does not have
any children.public Object getParent(Object itemId)
Container.Hierarchical
getParent
in interface Container.Hierarchical
itemId
- 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 child Items
or if it is a leaf. 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.Hierarchical
itemId
- ID of the Item to be testedtrue
if the specified Item has children,
false
if not (is a leaf)public boolean isRoot(Object itemId)
Container.Hierarchical
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.isRoot
in interface Container.Hierarchical
itemId
- ID of the Item whose root status is to be testedtrue
if the specified Item is a root,
false
if notpublic Collection<?> rootItemIds()
Container.Hierarchical
root
Items. The returned
collection is unmodifiable.rootItemIds
in interface Container.Hierarchical
collection
containing IDs of all root elements of the containerpublic boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException
Container.Hierarchical
Sets the given Item's capability to have children. If the Item
identified with itemId
already has children and
is false this method
fails and Container.Hierarchical.areChildrenAllowed(Object)
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
.
setChildrenAllowed
in interface Container.Hierarchical
itemId
- ID of the Item in the container whose child capability is
to be setareChildrenAllowed
- boolean value specifying if the Item can have children or
nottrue
if the operation succeeded,
false
if notUnsupportedOperationException
public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException
Container.Hierarchical
Sets the parent of an Item. The new parent item must exist and be
able to have children. (
). It is
also possible to detach a node from the hierarchy (and thus make it
root) by setting the parent Container.Hierarchical.areChildrenAllowed(Object)
== truenull
.
This operation is optional.
setParent
in interface Container.Hierarchical
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
true
if the operation succeeded,
false
if notUnsupportedOperationException
Copyright © 2022 Vaadin Ltd. All rights reserved.