public class ContainerOrderedWrapper extends Object implements Container.Ordered, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier
A wrapper class for adding external ordering to containers not implementing
the Container.Ordered
interface.
If the wrapped container is changed directly (that is, not through the
wrapper), and does not implement Container.ItemSetChangeNotifier and/or
Container.PropertySetChangeNotifier the hierarchy information must be updated
with the updateOrderWrapper()
method.
Container.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 |
---|
ContainerOrderedWrapper(Container toBeWrapped)
Constructs a new ordered wrapper for an existing Container.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Registers a new Property to all Items in the Container.
|
Object |
addItem()
Creates a new Item into the Container, assigns it an automatic ID, and
adds it to the ordering.
|
Item |
addItem(Object itemId)
Registers a new Item by its ID to the underlying container and to the
ordering.
|
Object |
addItemAfter(Object previousItemId)
Adds a new item after the given item.
|
Item |
addItemAfter(Object previousItemId,
Object newItemId)
Adds a new item after the given item.
|
void |
addItemSetChangeListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object.
|
void |
addListener(Container.ItemSetChangeListener listener)
Deprecated.
As of 7.0, replaced by
addItemSetChangeListener(Container.ItemSetChangeListener) |
void |
addListener(Container.PropertySetChangeListener listener)
Deprecated.
As of 7.0, replaced by
addPropertySetChangeListener(Container.PropertySetChangeListener) |
void |
addPropertySetChangeListener(Container.PropertySetChangeListener listener)
Registers a new Property set change listener for this Container.
|
boolean |
containsId(Object itemId)
Tests if the Container contains the specified Item.
|
Object |
firstItemId()
Gets the ID of the first Item in the Container.
|
Property |
getContainerProperty(Object itemId,
Object propertyId)
Gets the Property identified by the given itemId and propertyId from the
Container.
|
Collection<?> |
getContainerPropertyIds()
Gets the ID's of all Properties stored in the Container.
|
Item |
getItem(Object itemId)
Gets the
Item with the given Item ID from the Container. |
Collection<?> |
getItemIds()
Gets the ID's of all visible (after filtering and sorting) Items stored
in the Container.
|
Class<?> |
getType(Object propertyId)
Gets the data type of all Properties identified by the given Property ID.
|
boolean |
isFirstId(Object itemId)
Tests if the Item corresponding to the given Item ID is the first
Item in the Container.
|
boolean |
isLastId(Object itemId)
Tests if the Item corresponding to the given Item ID is the last Item
in the Container.
|
Object |
lastItemId()
Gets the ID of the last Item in the Container..
|
Object |
nextItemId(Object itemId)
Gets the ID of the Item following the Item that corresponds to
itemId . |
Object |
prevItemId(Object itemId)
Gets the ID of the Item preceding the Item that corresponds to
itemId . |
boolean |
removeAllItems()
Removes all items from the underlying container and from the ordering.
|
boolean |
removeContainerProperty(Object propertyId)
Removes the specified Property from the underlying container and from the
ordering.
|
boolean |
removeItem(Object itemId)
Removes an Item specified by the itemId from the underlying container and
from the ordering.
|
void |
removeItemSetChangeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object.
|
void |
removeListener(Container.ItemSetChangeListener listener)
Deprecated.
As of 7.0, replaced by
removeItemSetChangeListener(Container.ItemSetChangeListener) |
void |
removeListener(Container.PropertySetChangeListener listener)
Deprecated.
As of 7.0, replaced by
removePropertySetChangeListener(Container.PropertySetChangeListener) |
void |
removePropertySetChangeListener(Container.PropertySetChangeListener listener)
Removes a previously registered Property set change listener.
|
int |
size()
Gets the number of visible Items in the Container.
|
void |
updateOrderWrapper()
Updates the wrapper's internal ordering information to include all Items
in the underlying container.
|
public ContainerOrderedWrapper(Container toBeWrapped)
toBeWrapped
- the container whose contents need to be ordered.public void updateOrderWrapper()
Note : If the contents of the wrapped container change without the wrapper's knowledge, this method needs to be called to update the ordering information of the Items.
public Object firstItemId()
Container.Ordered
firstItemId
in interface Container.Ordered
public boolean isFirstId(Object itemId)
Container.Ordered
isFirstId
in interface Container.Ordered
itemId
- ID of an Item in the Containertrue
if the Item is first visible item in the
Container, false
if notpublic boolean isLastId(Object itemId)
Container.Ordered
isLastId
in interface Container.Ordered
true
if the Item is last visible item in the
Container, false
if notpublic Object lastItemId()
Container.Ordered
lastItemId
in interface Container.Ordered
public Object nextItemId(Object itemId)
Container.Ordered
itemId
. If the given Item is the last or not found in
the Container, null
is returned.nextItemId
in interface Container.Ordered
itemId
- ID of a visible Item in the Containernull
public Object prevItemId(Object itemId)
Container.Ordered
itemId
. If the given Item is the first or not found in
the Container, null
is returned.prevItemId
in interface Container.Ordered
itemId
- ID of a visible Item in the Containernull
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException
addContainerProperty
in interface Container
propertyId
- the ID of the new Property.type
- the Data type of the new Property.defaultValue
- the value all created Properties are initialized to.true
if the operation succeeded, false
if notUnsupportedOperationException
- if the container does not support explicitly adding container
propertiespublic Object addItem() throws UnsupportedOperationException
addItem
in interface Container
null
if the
operation failedUnsupportedOperationException
- if the addItem is not supported.public Item addItem(Object itemId) throws UnsupportedOperationException
addItem
in interface Container
itemId
- the ID of the Item to be created.null
if the operation failedUnsupportedOperationException
- if the addItem is not supported.public boolean removeAllItems() throws UnsupportedOperationException
removeAllItems
in interface Container
true
if the operation succeeded, otherwise
false
UnsupportedOperationException
- if the removeAllItems is not supported.public boolean removeItem(Object itemId) throws UnsupportedOperationException
removeItem
in interface Container
itemId
- the ID of the Item to be removed.true
if the operation succeeded, false
if notUnsupportedOperationException
- if the removeItem is not supported.public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException
Note : The Property will be removed from all the Items in the Container.
removeContainerProperty
in interface Container
propertyId
- the ID of the Property to remove.true
if the operation succeeded, false
if notUnsupportedOperationException
- if the removeContainerProperty is not supported.public boolean containsId(Object itemId)
Container
Filtering can hide items so that they will not be visible through the container API, and this method should respect visibility of items (i.e. only indicate visible items as being in the container) if feasible for the container.
containsId
in interface Container
itemId
- ID the of Item to be testedpublic Item getItem(Object itemId)
Container
Item
with the given Item ID from the Container. If the
Container does not contain the requested Item, null
is
returned.
Containers should not return Items that are filtered out.
public Collection<?> getItemIds()
Container
If the container is Container.Ordered
, the collection returned by this
method should follow that order. If the container is Container.Sortable
,
the items should be in the sorted order.
Calling this method for large lazy containers can be an expensive operation and should be avoided when practical.
getItemIds
in interface Container
public Property getContainerProperty(Object itemId, Object propertyId)
Container
null
is
returned.getContainerProperty
in interface Container
itemId
- ID of the visible Item which contains the PropertypropertyId
- ID of the Property to retrievenull
public Collection<?> getContainerPropertyIds()
Container
getContainerPropertyIds
in interface Container
public Class<?> getType(Object propertyId)
Container
public int size()
Container
Filtering can hide items so that they will not be visible through the container API.
public void addItemSetChangeListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
addItemSetChangeListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be added@Deprecated public void addListener(Container.ItemSetChangeListener listener)
addItemSetChangeListener(Container.ItemSetChangeListener)
addListener
in interface Container.ItemSetChangeNotifier
public void removeItemSetChangeListener(Container.ItemSetChangeListener listener)
Container.ItemSetChangeNotifier
removeItemSetChangeListener
in interface Container.ItemSetChangeNotifier
listener
- listener to be removed@Deprecated public void removeListener(Container.ItemSetChangeListener listener)
removeItemSetChangeListener(Container.ItemSetChangeListener)
removeListener
in interface Container.ItemSetChangeNotifier
public void addPropertySetChangeListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
addPropertySetChangeListener
in interface Container.PropertySetChangeNotifier
listener
- The new Listener to be registered@Deprecated public void addListener(Container.PropertySetChangeListener listener)
addPropertySetChangeListener(Container.PropertySetChangeListener)
addListener
in interface Container.PropertySetChangeNotifier
public void removePropertySetChangeListener(Container.PropertySetChangeListener listener)
Container.PropertySetChangeNotifier
removePropertySetChangeListener
in interface Container.PropertySetChangeNotifier
listener
- Listener to be removed@Deprecated public void removeListener(Container.PropertySetChangeListener listener)
removePropertySetChangeListener(Container.PropertySetChangeListener)
removeListener
in interface Container.PropertySetChangeNotifier
public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException
Container.Ordered
Adding an item after null item adds the item as first item of the ordered container.
addItemAfter
in interface Container.Ordered
previousItemId
- Id of the visible item in ordered container after which to
insert the new item.newItemId
- Id of the new item to be added.UnsupportedOperationException
- if the operation is not supported by the containerOrdered: adding items in filtered or sorted containers
public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException
Container.Ordered
Adding an item after null item adds the item as first item of the ordered container.
addItemAfter
in interface Container.Ordered
previousItemId
- Id of the visible item in ordered container after which to
insert the new item.UnsupportedOperationException
- if the operation is not supported by the containerOrdered: adding items in filtered or sorted containers
Copyright © 2019 Vaadin Ltd. All rights reserved.