com.vaadin.data.util.
Class ContainerOrderedWrapper
java.lang.Object
com.vaadin.data.util.ContainerOrderedWrapper
All Implemented Interfaces:
Container, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeNotifier, Serializable
Direct Known Subclasses:
- extends Object
- implements Container.Ordered, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier
public class ContainerOrderedWrapper
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.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.vaadin.data.Container |
---|
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 Summary | |
---|---|
ContainerOrderedWrapper(Container toBeWrapped)
Constructs a new ordered wrapper for an existing Container. |
Method Summary | |
---|---|
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 |
addListener(Container.ItemSetChangeListener listener)
Adds an Item set change listener for the object. |
void |
addListener(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 |
removeListener(Container.ItemSetChangeListener listener)
Removes the Item set change listener from the object. |
void |
removeListener(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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
ContainerOrderedWrapper
public ContainerOrderedWrapper(Container toBeWrapped)
- Parameters:
toBeWrapped
- the container whose contents need to be ordered.
Constructs a new ordered wrapper for an existing Container. Works even if the to-be-wrapped container already implements the Container.Ordered interface.
Method Detail |
---|
updateOrderWrapper
public void updateOrderWrapper()
Updates the wrapper's internal ordering information to include all Items in the underlying container.
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.
firstItemId
public Object firstItemId()
- Specified by:
firstItemId
in interfaceContainer.Ordered
- Returns:
- ID of the first visible Item in the Container
Description copied from interface: Container.Ordered
Gets the ID of the first Item in the Container.
isFirstId
public boolean isFirstId(Object itemId)
- Specified by:
isFirstId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of an Item in the Container- Returns:
true
if the Item is first visible item in the Container,false
if not
Description copied from interface: Container.Ordered
Tests if the Item corresponding to the given Item ID is the first Item in the Container.
isLastId
public boolean isLastId(Object itemId)
- Specified by:
isLastId
in interfaceContainer.Ordered
- Returns:
true
if the Item is last visible item in the Container,false
if not
Description copied from interface: Container.Ordered
Tests if the Item corresponding to the given Item ID is the last Item in the Container.
lastItemId
public Object lastItemId()
- Specified by:
lastItemId
in interfaceContainer.Ordered
- Returns:
- ID of the last visible Item in the Container
Description copied from interface: Container.Ordered
Gets the ID of the last Item in the Container..
nextItemId
public Object nextItemId(Object itemId)
- Specified by:
nextItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the next visible Item or
null
Description copied from interface: Container.Ordered
Gets the ID of the Item following the Item that corresponds to
itemId
. If the given Item is the last or not found in
the Container, null
is returned.
prevItemId
public Object prevItemId(Object itemId)
- Specified by:
prevItemId
in interfaceContainer.Ordered
- Parameters:
itemId
- ID of a visible Item in the Container- Returns:
- ID of the previous visible Item or
null
Description copied from interface: Container.Ordered
Gets the ID of the Item preceding the Item that corresponds to
itemId
. If the given Item is the first or not found in
the Container, null
is returned.
addContainerProperty
public boolean addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
throws UnsupportedOperationException
- Specified by:
addContainerProperty
in interfaceContainer
- Parameters:
propertyId
- the ID of the new Property.type
- the Data type of the new Property.defaultValue
- the value all created Properties are initialized to.- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the container does not support explicitly adding container properties
Registers a new Property to all Items in the Container.
addItem
public Object addItem()
throws UnsupportedOperationException
- Returns:
- the autogenerated ID of the new Item or
null
if the operation failed - Throws:
UnsupportedOperationException
- if the addItem is not supported.
Creates a new Item into the Container, assigns it an automatic ID, and adds it to the ordering.
addItem
public Item addItem(Object itemId)
throws UnsupportedOperationException
- Parameters:
itemId
- the ID of the Item to be created.- Returns:
- the added Item or
null
if the operation failed - Throws:
UnsupportedOperationException
- if the addItem is not supported.
Registers a new Item by its ID to the underlying container and to the ordering.
removeAllItems
public boolean removeAllItems()
throws UnsupportedOperationException
- Specified by:
removeAllItems
in interfaceContainer
- Returns:
true
if the operation succeeded, otherwisefalse
- Throws:
UnsupportedOperationException
- if the removeAllItems is not supported.
Removes all items from the underlying container and from the ordering.
removeItem
public boolean removeItem(Object itemId)
throws UnsupportedOperationException
- Specified by:
removeItem
in interfaceContainer
- Parameters:
itemId
- the ID of the Item to be removed.- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the removeItem is not supported.
Removes an Item specified by the itemId from the underlying container and from the ordering.
removeContainerProperty
public boolean removeContainerProperty(Object propertyId)
throws UnsupportedOperationException
- Specified by:
removeContainerProperty
in interfaceContainer
- Parameters:
propertyId
- the ID of the Property to remove.- Returns:
true
if the operation succeeded,false
if not- Throws:
UnsupportedOperationException
- if the removeContainerProperty is not supported.
Removes the specified Property from the underlying container and from the ordering.
Note : The Property will be removed from all the Items in the Container.
containsId
public boolean containsId(Object itemId)
- Specified by:
containsId
in interfaceContainer
- Parameters:
itemId
- ID the of Item to be tested- Returns:
- boolean indicating if the Container holds the specified Item
Description copied from interface: Container
Tests if the Container contains the specified Item. 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.
getItem
public Item getItem(Object itemId)
Description copied from interface: Container
Gets the 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.
getItemIds
public Collection<?> getItemIds()
- Specified by:
getItemIds
in interfaceContainer
- Returns:
- unmodifiable collection of Item IDs
Description copied from interface: Container
Gets the ID's of all visible (after filtering and sorting) Items stored
in the Container. The ID's cannot be modified through the returned
collection.
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.
getContainerProperty
public Property getContainerProperty(Object itemId,
Object propertyId)
- Specified by:
getContainerProperty
in interfaceContainer
- Parameters:
itemId
- ID of the visible Item which contains the PropertypropertyId
- ID of the Property to retrieve- Returns:
- Property with the given ID or
null
Description copied from interface: Container
Gets the Property identified by the given itemId and propertyId from the
Container. If the Container does not contain the item or it is filtered
out, or the Container does not have the Property, null
is
returned.
getContainerPropertyIds
public Collection<?> getContainerPropertyIds()
- Specified by:
getContainerPropertyIds
in interfaceContainer
- Returns:
- unmodifiable collection of Property IDs
Description copied from interface: Container
Gets the ID's of all Properties stored in the Container. The ID's cannot be modified through the returned collection.
getType
public Class<?> getType(Object propertyId)
- Parameters:
propertyId
- ID identifying the Properties- Returns:
- data type of the Properties
Description copied from interface: Container
Gets the data type of all Properties identified by the given Property ID.
size
public int size()
- Returns:
- number of Items in the Container
Description copied from interface: Container
Gets the number of visible Items in the Container. Filtering can hide items so that they will not be visible through the container API.
addListener
public void addListener(Container.ItemSetChangeListener listener)
- Specified by:
addListener
in interfaceContainer.ItemSetChangeNotifier
- Parameters:
listener
- listener to be added
Description copied from interface: Container.ItemSetChangeNotifier
Adds an Item set change listener for the object.
removeListener
public void removeListener(Container.ItemSetChangeListener listener)
- Specified by:
removeListener
in interfaceContainer.ItemSetChangeNotifier
- Parameters:
listener
- listener to be removed
Description copied from interface: Container.ItemSetChangeNotifier
Removes the Item set change listener from the object.
addListener
public void addListener(Container.PropertySetChangeListener listener)
- Specified by:
addListener
in interfaceContainer.PropertySetChangeNotifier
- Parameters:
listener
- The new Listener to be registered
Description copied from interface: Container.PropertySetChangeNotifier
Registers a new Property set change listener for this Container.
removeListener
public void removeListener(Container.PropertySetChangeListener listener)
- Specified by:
removeListener
in interfaceContainer.PropertySetChangeNotifier
- Parameters:
listener
- Listener to be removed
Description copied from interface: Container.PropertySetChangeNotifier
Removes a previously registered Property set change listener.
addItemAfter
public Item addItemAfter(Object previousItemId,
Object newItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Parameters:
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.- Returns:
- new item or null if the operation fails.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- See Also:
Ordered: adding items in filtered or sorted containers
Description copied from interface: Container.Ordered
Adds a new item after the given item.
Adding an item after null item adds the item as first item of the ordered container.
addItemAfter
public Object addItemAfter(Object previousItemId)
throws UnsupportedOperationException
- Specified by:
addItemAfter
in interfaceContainer.Ordered
- Parameters:
previousItemId
- Id of the visible item in ordered container after which to insert the new item.- Returns:
- item id the the created new item or null if the operation fails.
- Throws:
UnsupportedOperationException
- if the operation is not supported by the container- See Also:
Ordered: adding items in filtered or sorted containers
Description copied from interface: Container.Ordered
Adds a new item after the given item.
Adding an item after null item adds the item as first item of the ordered container.