public class GeneratedPropertyContainer extends AbstractContainer implements Container.Indexed, Container.Sortable, Container.Filterable, Container.PropertySetChangeNotifier, Container.ItemSetChangeNotifier
Removing properties from this container does not remove anything from the
wrapped container but instead only hides them from the results. These
properties can be returned to this container by calling
addContainerProperty(Object, Class, Object)
with same property id
which was removed.
If wrapped container is Filterable and/or Sortable it should only be handled through this container as generated properties need to be handled in a specific way when sorting/filtering.
Items returned by this container do not support adding or removing properties. Generated properties are always read-only. Trying to make them editable throws an exception.
Modifier and Type | Class and Description |
---|---|
protected class |
GeneratedPropertyContainer.GeneratedItemAddEvent |
protected class |
GeneratedPropertyContainer.GeneratedItemAddOrRemoveEvent
Base implementation for item add or remove events.
|
protected class |
GeneratedPropertyContainer.GeneratedItemRemoveEvent |
protected static class |
GeneratedPropertyContainer.GeneratedProperty<T>
Property implementation for generated properties
|
class |
GeneratedPropertyContainer.GeneratedPropertyItem
Item implementation for generated properties, used to wrap the Item that
belongs to the wrapped container.
|
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEvent
Container.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent
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 |
---|
GeneratedPropertyContainer(Container.Indexed container)
Constructor for GeneratedPropertyContainer.
|
Modifier and Type | Method and Description |
---|---|
void |
addContainerFilter(Container.Filter filter)
Adds a filter for the container.
|
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds a previously removed property back to GeneratedPropertyContainer.
|
void |
addGeneratedProperty(Object propertyId,
PropertyValueGenerator<?> generator)
Add a new PropertyValueGenerator with given property id.
|
Object |
addItem()
Creates a new Item into the Container, and assign it an automatic ID.
|
Item |
addItem(Object itemId)
Creates a new Item with the given ID in the Container.
|
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.
|
Object |
addItemAt(int index)
Adds a new item at given index (in the filtered view).
|
Item |
addItemAt(int index,
Object newItemId)
Adds a new item at given index (in the filtered view).
|
void |
addItemSetChangeListener(Container.ItemSetChangeListener listener)
Implementation of the corresponding method in
ItemSetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
void |
addListener(Container.ItemSetChangeListener listener) |
void |
addListener(Container.PropertySetChangeListener listener) |
void |
addPropertySetChangeListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in
PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
boolean |
containsId(Object itemId)
Tests if the Container contains the specified Item.
|
Object |
firstItemId()
Gets the ID of the first Item in the Container.
|
Collection<Container.Filter> |
getContainerFilters()
Returns the filters which have been applied to the container
|
Property<?> |
getContainerProperty(Object itemId,
Object propertyId)
Gets the Property identified by the given itemId and propertyId from the
Container.
|
Collection<?> |
getContainerPropertyIds()
Returns a list of propety ids available in this container.
|
Object |
getIdByIndex(int index)
Get the item id for the item at the position given by
index . |
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.
|
List<?> |
getItemIds(int startIndex,
int numberOfItems)
Get
numberOfItems consecutive item ids from the
container, starting with the item id at startIndex . |
Collection<?> |
getSortableContainerPropertyIds()
Gets the container property IDs which can be used to sort the items.
|
Class<?> |
getType(Object propertyId)
Gets the data type of all Properties identified by the given Property ID.
|
Container.Indexed |
getWrappedContainer()
Returns the original underlying container.
|
int |
indexOfId(Object itemId)
Gets the index of the Item corresponding to the itemId.
|
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 . |
void |
removeAllContainerFilters()
Remove all active filters from the container.
|
boolean |
removeAllItems()
Removes all Items from the Container.
|
void |
removeContainerFilter(Container.Filter filter)
Removes a filter from the container.
|
boolean |
removeContainerProperty(Object propertyId)
Marks the given property as hidden.
|
void |
removeGeneratedProperty(Object propertyId)
Removes any possible PropertyValueGenerator with given property id.
|
boolean |
removeItem(Object itemId)
Removes the Item identified by
ItemId from the Container. |
void |
removeItemSetChangeListener(Container.ItemSetChangeListener listener)
Implementation of the corresponding method in
ItemSetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
void |
removeListener(Container.ItemSetChangeListener listener) |
void |
removeListener(Container.PropertySetChangeListener listener) |
void |
removePropertySetChangeListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in
PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
int |
size()
Gets the number of visible Items in the Container.
|
void |
sort(Object[] propertyId,
boolean[] ascending)
Sorts the container items.
|
fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListeners
public GeneratedPropertyContainer(Container.Indexed container)
container
- underlying indexed containerpublic void addGeneratedProperty(Object propertyId, PropertyValueGenerator<?> generator)
propertyId
- property idgenerator
- a property value generatorpublic void removeGeneratedProperty(Object propertyId)
propertyId
- property idpublic void addItemSetChangeListener(Container.ItemSetChangeListener listener)
AbstractContainer
ItemSetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.addItemSetChangeListener
in interface Container.ItemSetChangeNotifier
addItemSetChangeListener
in class AbstractContainer
listener
- listener to be addedItemSetChangeNotifier#addListener(com.vaadin.data.Container.ItemSetChangeListener)
public void addListener(Container.ItemSetChangeListener listener)
addListener
in interface Container.ItemSetChangeNotifier
addListener
in class AbstractContainer
public void removeItemSetChangeListener(Container.ItemSetChangeListener listener)
AbstractContainer
ItemSetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.removeItemSetChangeListener
in interface Container.ItemSetChangeNotifier
removeItemSetChangeListener
in class AbstractContainer
listener
- listener to be removedItemSetChangeNotifier#removeListener(com.vaadin.data.Container.ItemSetChangeListener)
public void removeListener(Container.ItemSetChangeListener listener)
removeListener
in interface Container.ItemSetChangeNotifier
removeListener
in class AbstractContainer
public void addPropertySetChangeListener(Container.PropertySetChangeListener listener)
AbstractContainer
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.addPropertySetChangeListener
in interface Container.PropertySetChangeNotifier
addPropertySetChangeListener
in class AbstractContainer
listener
- The new Listener to be registeredPropertySetChangeNotifier#addListener(com.vaadin.data.Container.PropertySetChangeListener)
public void addListener(Container.PropertySetChangeListener listener)
addListener
in interface Container.PropertySetChangeNotifier
addListener
in class AbstractContainer
public void removePropertySetChangeListener(Container.PropertySetChangeListener listener)
AbstractContainer
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.removePropertySetChangeListener
in interface Container.PropertySetChangeNotifier
removePropertySetChangeListener
in class AbstractContainer
listener
- Listener to be removedPropertySetChangeNotifier#removeListener(com.vaadin.data.Container.
PropertySetChangeListener)
public void removeListener(Container.PropertySetChangeListener listener)
removeListener
in interface Container.PropertySetChangeNotifier
removeListener
in class AbstractContainer
public void addContainerFilter(Container.Filter filter) throws UnsupportedFilterException
Container.Filterable
If a container has multiple filters, only items accepted by all filters are visible.
addContainerFilter
in interface Container.Filterable
UnsupportedFilterException
- if the filter is not supported by the containerpublic void removeContainerFilter(Container.Filter filter)
Container.Filterable
This requires that the equals() method considers the filters as equivalent (same instance or properly implemented equals() method).
removeContainerFilter
in interface Container.Filterable
public void removeAllContainerFilters()
Container.Filterable
removeAllContainerFilters
in interface Container.Filterable
public Collection<Container.Filter> getContainerFilters()
Container.Filterable
getContainerFilters
in interface Container.Filterable
public void sort(Object[] propertyId, boolean[] ascending)
Container.Sortable
Sorting a container can irreversibly change the order of its items or only change the order temporarily, depending on the container.
sort
in interface Container.Sortable
propertyId
- Array of container property IDs, whose values are used to
sort the items in container as primary, secondary, ...
sorting criterion. All of the item IDs must be in the
collection returned by
Container.Sortable.getSortableContainerPropertyIds()
ascending
- Array of sorting order flags corresponding to each
property ID used in sorting. If this array is shorter than
propertyId array, ascending order is assumed for items
where the order is not specified. Use true
to
sort in ascending order, false
to use
descending order.public Collection<?> getSortableContainerPropertyIds()
Container.Sortable
getSortableContainerPropertyIds
in interface Container.Sortable
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 Item addItem(Object itemId) throws UnsupportedOperationException
Container
The new Item is returned, and it is ready to have its Properties
modified. Returns null
if the operation fails or the
Container already contains a Item with the given ID.
This functionality is optional.
addItem
in interface Container
itemId
- ID of the Item to be creatednull
in case of a failureUnsupportedOperationException
- if adding an item with an explicit item ID is not supported
by the containerpublic Item addItemAt(int index, Object newItemId) throws UnsupportedOperationException
Container.Indexed
The indexes of the item currently in the given position and all the following items are incremented.
This method should apply filters to the added item after inserting
it, possibly hiding it immediately. If the container is being sorted,
the item may be added at the correct sorted position instead of the
given position. See Container.Indexed
, Container.Filterable
and
Container.Sortable
for more information.
addItemAt
in interface Container.Indexed
index
- Index (in the filtered and sorted view) at which to add
the new item.newItemId
- Id of the new item to be added.Item
or null if the operation fails.UnsupportedOperationException
- if the operation is not supported by the containerpublic 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 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()
getContainerPropertyIds
in interface Container
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException
addContainerProperty
in interface Container
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are initialized totrue
if the operation succeeded, false
if notUnsupportedOperationException
- if the container does not support explicitly adding container
propertiespublic boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException
getContainerPropertyIds()
and is no longer
be available in Items retrieved from this container.removeContainerProperty
in interface Container
propertyId
- ID of the Property to removetrue
if the operation succeeded, false
if notUnsupportedOperationException
- if the container does not support removing container
propertiespublic Class<?> getType(Object propertyId)
Container
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 Object firstItemId()
Container.Ordered
firstItemId
in interface Container.Ordered
public Object lastItemId()
Container.Ordered
lastItemId
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 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
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 int size()
Container
Filtering can hide items so that they will not be visible through the container API.
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 Object addItem() throws UnsupportedOperationException
Container
The new ID is returned, or null
if the operation fails.
After a successful call you can use the
method to fetch the Item.
getItem
This functionality is optional.
addItem
in interface Container
null
in case of a
failureUnsupportedOperationException
- if adding an item without an explicit item ID is not
supported by the containerpublic boolean removeItem(Object itemId) throws UnsupportedOperationException
Container
ItemId
from the Container.
Containers that support filtering should also allow removing an item that is currently filtered out.
This functionality is optional.
removeItem
in interface Container
itemId
- ID of the Item to removetrue
if the operation succeeded, false
if notUnsupportedOperationException
- if the container does not support removing individual itemspublic boolean removeAllItems() throws UnsupportedOperationException
Container
Note that Property ID and type information is preserved. This functionality is optional.
removeAllItems
in interface Container
true
if the operation succeeded, false
if notUnsupportedOperationException
- if the container does not support removing all itemspublic int indexOfId(Object itemId)
Container.Indexed
true
for the returned index: 0 <= index < size(), or
index = -1 if there is no visible item with that id in the container.indexOfId
in interface Container.Indexed
itemId
- ID of an Item in the Containerpublic Object getIdByIndex(int index)
Container.Indexed
index
.
getIdByIndex
in interface Container.Indexed
index
- the index of the requested item idpublic List<?> getItemIds(int startIndex, int numberOfItems)
Container.Indexed
numberOfItems
consecutive item ids from the
container, starting with the item id at startIndex
.
Implementations should return at most numberOfItems
item
ids, but can contain less if the container has less items than
required to fulfill the request. The returned list must hence contain
all of the item ids from the range:
startIndex
to
max(startIndex + (numberOfItems-1), container.size()-1)
.
For quick migration to new API see:
ContainerHelpers#getItemIdsUsingGetIdByIndex(int, int, Indexed)
getItemIds
in interface Container.Indexed
startIndex
- the index for the first item which id to includenumberOfItems
- the number of consecutive item ids to get from the given
start index, must be >= 0numberOfItems
== 0; not nullpublic Object addItemAt(int index) throws UnsupportedOperationException
Container.Indexed
The indices of the item currently in the given position and all the following items are incremented.
This method should apply filters to the added item after inserting
it, possibly hiding it immediately. If the container is being sorted,
the item may be added at the correct sorted position instead of the
given position. See Container.Indexed
, Container.Ordered
,
Container.Filterable
and Container.Sortable
for more information.
addItemAt
in interface Container.Indexed
index
- Index (in the filtered and sorted view) to add the new
item.UnsupportedOperationException
- if the operation is not supported by the containerpublic Container.Indexed getWrappedContainer()
Copyright © 2017 Vaadin Ltd. All rights reserved.