Class ContainerOrderedWrapper
- All Implemented Interfaces:
Container,Container.ItemSetChangeNotifier,Container.Ordered,Container.PropertySetChangeNotifier,Serializable
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
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.featurepack.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
ConstructorsConstructorDescriptionContainerOrderedWrapper(Container toBeWrapped) Constructs a new ordered wrapper for an existing Container. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddContainerProperty(Object propertyId, Class<?> type, Object defaultValue) Registers a new Property to all Items in the Container.addItem()Creates a new Item into the Container, assigns it an automatic ID, and adds it to the ordering.Registers a new Item by its ID to the underlying container and to the ordering.addItemAfter(Object previousItemId) Adds a new item after the given item.addItemAfter(Object previousItemId, Object newItemId) Adds a new item after the given item.voidAdds an Item set change listener for the object.voidRegisters a new Property set change listener for this Container.booleancontainsId(Object itemId) Tests if the Container contains the specified Item.Gets the ID of the first Item in the Container.getContainerProperty(Object itemId, Object propertyId) Gets the Property identified by the given itemId and propertyId from the Container.Collection<?> Gets the ID's of all Properties stored in the Container.Gets theItemwith the given Item ID from the Container.Collection<?> Gets the ID's of all visible (after filtering and sorting) Items stored in the Container.Class<?> Gets the data type of all Properties identified by the given Property ID.booleanTests if the Item corresponding to the given Item ID is the first Item in the Container.booleanTests if the Item corresponding to the given Item ID is the last Item in the Container.Gets the ID of the last Item in the Container..nextItemId(Object itemId) Gets the ID of the Item following the Item that corresponds toitemId.prevItemId(Object itemId) Gets the ID of the Item preceding the Item that corresponds toitemId.booleanRemoves all items from the underlying container and from the ordering.booleanremoveContainerProperty(Object propertyId) Removes the specified Property from the underlying container and from the ordering.booleanremoveItem(Object itemId) Removes an Item specified by the itemId from the underlying container and from the ordering.voidRemoves the Item set change listener from the object.voidRemoves a previously registered Property set change listener.intsize()Gets the number of visible Items in the Container.voidUpdates the wrapper's internal ordering information to include all Items in the underlying container.
-
Constructor Details
-
ContainerOrderedWrapper
Constructs a new ordered wrapper for an existing Container. Works even if the to-be-wrapped container already implements the Container.Ordered interface.- Parameters:
toBeWrapped- the container whose contents need to be ordered.
-
-
Method Details
-
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
Description copied from interface:Container.OrderedGets the ID of the first Item in the Container.- Specified by:
firstItemIdin interfaceContainer.Ordered- Returns:
- ID of the first visible Item in the Container
-
isFirstId
Description copied from interface:Container.OrderedTests if the Item corresponding to the given Item ID is the first Item in the Container.- Specified by:
isFirstIdin interfaceContainer.Ordered- Parameters:
itemId- ID of an Item in the Container- Returns:
trueif the Item is first visible item in the Container,falseif not
-
isLastId
Description copied from interface:Container.OrderedTests if the Item corresponding to the given Item ID is the last Item in the Container.- Specified by:
isLastIdin interfaceContainer.Ordered- Returns:
trueif the Item is last visible item in the Container,falseif not
-
lastItemId
Description copied from interface:Container.OrderedGets the ID of the last Item in the Container..- Specified by:
lastItemIdin interfaceContainer.Ordered- Returns:
- ID of the last visible Item in the Container
-
nextItemId
Description copied from interface:Container.OrderedGets the ID of the Item following the Item that corresponds toitemId. If the given Item is the last or not found in the Container,nullis returned.- Specified by:
nextItemIdin interfaceContainer.Ordered- Parameters:
itemId- ID of a visible Item in the Container- Returns:
- ID of the next visible Item or
null
-
prevItemId
Description copied from interface:Container.OrderedGets the ID of the Item preceding the Item that corresponds toitemId. If the given Item is the first or not found in the Container,nullis returned.- Specified by:
prevItemIdin interfaceContainer.Ordered- Parameters:
itemId- ID of a visible Item in the Container- Returns:
- ID of the previous visible Item or
null
-
addContainerProperty
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException Registers a new Property to all Items in the Container.- Specified by:
addContainerPropertyin 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:
trueif the operation succeeded,falseif not- Throws:
UnsupportedOperationException- if the container does not support explicitly adding container properties
-
addItem
Creates a new Item into the Container, assigns it an automatic ID, and adds it to the ordering.- Specified by:
addItemin interfaceContainer- Returns:
- the autogenerated ID of the new Item or
nullif the operation failed - Throws:
UnsupportedOperationException- if the addItem is not supported.
-
addItem
Registers a new Item by its ID to the underlying container and to the ordering.- Specified by:
addItemin interfaceContainer- Parameters:
itemId- the ID of the Item to be created.- Returns:
- the added Item or
nullif the operation failed - Throws:
UnsupportedOperationException- if the addItem is not supported.
-
removeAllItems
Removes all items from the underlying container and from the ordering.- Specified by:
removeAllItemsin interfaceContainer- Returns:
trueif the operation succeeded, otherwisefalse- Throws:
UnsupportedOperationException- if the removeAllItems is not supported.
-
removeItem
Removes an Item specified by the itemId from the underlying container and from the ordering.- Specified by:
removeItemin interfaceContainer- Parameters:
itemId- the ID of the Item to be removed.- Returns:
trueif the operation succeeded,falseif not- Throws:
UnsupportedOperationException- if the removeItem is not supported.
-
removeContainerProperty
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.
- Specified by:
removeContainerPropertyin interfaceContainer- Parameters:
propertyId- the ID of the Property to remove.- Returns:
trueif the operation succeeded,falseif not- Throws:
UnsupportedOperationException- if the removeContainerProperty is not supported.
-
containsId
Description copied from interface:ContainerTests 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.
- Specified by:
containsIdin interfaceContainer- Parameters:
itemId- ID the of Item to be tested- Returns:
- boolean indicating if the Container holds the specified Item
-
getItem
Description copied from interface:ContainerGets theItemwith the given Item ID from the Container. If the Container does not contain the requested Item,nullis returned.Containers should not return Items that are filtered out.
-
getItemIds
Description copied from interface:ContainerGets 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 isContainer.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.
- Specified by:
getItemIdsin interfaceContainer- Returns:
- unmodifiable collection of Item IDs
-
getContainerProperty
Description copied from interface:ContainerGets 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,nullis returned.- Specified by:
getContainerPropertyin 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
-
getContainerPropertyIds
Description copied from interface:ContainerGets the ID's of all Properties stored in the Container. The ID's cannot be modified through the returned collection.- Specified by:
getContainerPropertyIdsin interfaceContainer- Returns:
- unmodifiable collection of Property IDs
-
getType
Description copied from interface:ContainerGets the data type of all Properties identified by the given Property ID. -
size
public int size()Description copied from interface:ContainerGets the number of visible Items in the Container.Filtering can hide items so that they will not be visible through the container API.
-
addItemSetChangeListener
Description copied from interface:Container.ItemSetChangeNotifierAdds an Item set change listener for the object.- Specified by:
addItemSetChangeListenerin interfaceContainer.ItemSetChangeNotifier- Parameters:
listener- listener to be added
-
removeItemSetChangeListener
Description copied from interface:Container.ItemSetChangeNotifierRemoves the Item set change listener from the object.- Specified by:
removeItemSetChangeListenerin interfaceContainer.ItemSetChangeNotifier- Parameters:
listener- listener to be removed
-
addPropertySetChangeListener
Description copied from interface:Container.PropertySetChangeNotifierRegisters a new Property set change listener for this Container.- Specified by:
addPropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Parameters:
listener- The new Listener to be registered
-
removePropertySetChangeListener
Description copied from interface:Container.PropertySetChangeNotifierRemoves a previously registered Property set change listener.- Specified by:
removePropertySetChangeListenerin interfaceContainer.PropertySetChangeNotifier- Parameters:
listener- Listener to be removed
-
addItemAfter
public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException Description copied from interface:Container.OrderedAdds a new item after the given item.Adding an item after null item adds the item as first item of the ordered container.
- Specified by:
addItemAfterin 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:
-
addItemAfter
Description copied from interface:Container.OrderedAdds a new item after the given item.Adding an item after null item adds the item as first item of the ordered container.
- Specified by:
addItemAfterin 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:
-