|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.data.util.AbstractContainer
com.vaadin.data.util.AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
com.vaadin.data.util.AbstractBeanContainer<IDTYPE,BEANTYPE>
IDTYPE
- The type of the item identifierBEANTYPE
- The type of the Beanpublic abstract class AbstractBeanContainer<IDTYPE,BEANTYPE>
An abstract base class for in-memory containers for JavaBeans.
The properties of the container are determined automatically by introspecting the used JavaBean class and explicitly adding or removing properties is not supported. Only beans of the same type can be added to the container.
Subclasses should implement any public methods adding items to the container,
typically calling the protected methods addItem(Object, Object)
,
addItemAfter(Object, Object, Object)
and
addItemAt(int, Object, Object)
.
Nested Class Summary | |
---|---|
static interface |
AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE>
Resolver that maps beans to their (item) identifiers, removing the need to explicitly specify item identifiers when there is no need to customize this. |
protected class |
AbstractBeanContainer.PropertyBasedBeanIdResolver
A item identifier resolver that returns the value of a bean property. |
Nested classes/interfaces inherited from class com.vaadin.data.util.AbstractContainer |
---|
AbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEvent |
Constructor Summary | |
---|---|
protected |
AbstractBeanContainer(Class<? super BEANTYPE> type)
Constructs a AbstractBeanContainer for beans of the given type. |
Method Summary | |
---|---|
protected void |
addAll(Collection<? extends BEANTYPE> collection)
Adds all the beans from a Collection in one operation using the
bean item identifier resolver. |
protected BeanItem<BEANTYPE> |
addBean(BEANTYPE bean)
Adds a bean to the container using the bean item id resolver to find its identifier. |
protected BeanItem<BEANTYPE> |
addBeanAfter(IDTYPE previousItemId,
BEANTYPE bean)
Adds a bean to the container after a specified item identifier, using the bean item id resolver to find its identifier. |
protected BeanItem<BEANTYPE> |
addBeanAt(int index,
BEANTYPE bean)
Adds a bean at a specified (filtered view) position in the container using the bean item id resolver to find its identifier. |
void |
addContainerFilter(Container.Filter filter)
Adds a filter for the container. |
void |
addContainerFilter(Object propertyId,
String filterString,
boolean ignoreCase,
boolean onlyMatchPrefix)
Add a filter for given property. |
boolean |
addContainerProperty(Object propertyId,
Class<?> type,
Object defaultValue)
Adds a new Property to all Items in the Container. |
protected boolean |
addContainerProperty(String propertyId,
VaadinPropertyDescriptor<BEANTYPE> propertyDescriptor)
Adds a property for the container and all its items. |
protected BeanItem<BEANTYPE> |
addItem(IDTYPE itemId,
BEANTYPE bean)
Adds the bean to the Container. |
protected BeanItem<BEANTYPE> |
addItemAfter(IDTYPE previousItemId,
IDTYPE newItemId,
BEANTYPE bean)
Adds the bean after the given bean. |
protected BeanItem<BEANTYPE> |
addItemAt(int index,
IDTYPE newItemId,
BEANTYPE bean)
Adds a new bean at the given index. |
void |
addListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
boolean |
addNestedContainerProperty(String propertyId)
Adds a nested container property for the container, e.g. |
protected BeanItem<BEANTYPE> |
createBeanItem(BEANTYPE bean)
Create a BeanItem for a bean using pre-parsed bean metadata (based on getBeanType() ). |
protected AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> |
createBeanPropertyResolver(Object propertyId)
Create an item identifier resolver using a named bean property. |
AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> |
getBeanIdResolver()
Returns the resolver that finds the item ID for a bean. |
Class<? super BEANTYPE> |
getBeanType()
Returns the type of beans this Container can contain. |
Property |
getContainerProperty(Object itemId,
Object propertyId)
Gets the Property identified by the given itemId and propertyId from the Container. |
Collection<String> |
getContainerPropertyIds()
Gets the ID's of all Properties stored in the Container. |
BeanItem<BEANTYPE> |
getItem(Object itemId)
Gets the Item with the given Item ID from the Container. |
Collection<IDTYPE> |
getItemIds()
Gets the ID's of all visible (after filtering and sorting) Items stored in the Container. |
ItemSorter |
getItemSorter()
Returns the ItemSorter used for comparing items in a sort. |
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. |
protected BeanItem<BEANTYPE> |
getUnfilteredItem(Object itemId)
Get an item even if filtered out. |
protected void |
registerNewItem(int position,
IDTYPE itemId,
BeanItem<BEANTYPE> item)
Registers a new item as having been added to the container. |
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. |
void |
removeContainerFilters(Object propertyId)
Remove all filters from the given property. |
boolean |
removeContainerProperty(Object propertyId)
Removes a Property specified by the given Property ID from the Container. |
boolean |
removeItem(Object itemId)
Removes the Item identified by ItemId from the Container. |
void |
removeListener(Container.PropertySetChangeListener listener)
Implementation of the corresponding method in PropertySetChangeNotifier , override with the corresponding public
method and implement the interface to use this. |
protected IDTYPE |
resolveBeanId(BEANTYPE bean)
Use the bean resolver to get the identifier for a bean. |
protected void |
setBeanIdResolver(AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> beanIdResolver)
Sets the resolver that finds the item id for a bean, or null not to use automatic resolving. |
void |
setItemSorter(ItemSorter itemSorter)
Sets the ItemSorter used for comparing items in a sort. |
void |
sort(Object[] propertyId,
boolean[] ascending)
Sort method. |
void |
valueChange(Property.ValueChangeEvent event)
Re-filter the container when one of the monitored properties changes. |
Methods inherited from class com.vaadin.data.util.AbstractContainer |
---|
fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, setItemSetChangeListeners, setPropertySetChangeListeners |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.vaadin.data.Container.Ordered |
---|
addItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemId |
Constructor Detail |
---|
protected AbstractBeanContainer(Class<? super BEANTYPE> type)
AbstractBeanContainer
for beans of the given type.
type
- the type of the beans that will be added to the container.
IllegalArgumentException
- If type
is nullMethod Detail |
---|
public Class<?> getType(Object propertyId)
Container
getType
in interface Container
propertyId
- ID identifying the Properties
protected BeanItem<BEANTYPE> createBeanItem(BEANTYPE bean)
getBeanType()
).
bean
-
BeanItem
or null if bean is nullpublic Class<? super BEANTYPE> getBeanType()
public Collection<String> getContainerPropertyIds()
Container
getContainerPropertyIds
in interface Container
public boolean removeAllItems()
Container
Note that Property ID and type information is preserved. This functionality is optional.
removeAllItems
in interface Container
removeAllItems
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
true
if the operation succeeded, false
if notpublic BeanItem<BEANTYPE> 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.
getItem
in interface Container
getItem
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
itemId
- ID of the Item
to retrieve
Item
with the given ID or null
if the
Item is not found in the Containerprotected BeanItem<BEANTYPE> getUnfilteredItem(Object itemId)
AbstractInMemoryContainer
getUnfilteredItem
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
public Collection<IDTYPE> getItemIds()
Container
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
getItemIds
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
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 retrieve
null
public boolean removeItem(Object itemId)
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
removeItem
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
itemId
- ID of the Item to remove
true
if the operation succeeded, false
if notpublic void valueChange(Property.ValueChangeEvent event)
valueChange
in interface Property.ValueChangeListener
event
- value change event objectpublic void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix)
Container.SimpleFilterable
Filterable#addContainerFilter(Filter)
is recommended
instead of this method. A SimpleStringFilter
can be used with
the new API to implement the old string filtering functionality.
The filter accepts items for which toString() of the value of the
given property contains or starts with given filterString. Other
items are not visible in the container when filtered.
If a container has multiple filters, only items accepted by all
filters are visible.
addContainerFilter
in interface Container.SimpleFilterable
propertyId
- Property for which the filter is applied to.filterString
- String that must match the value of the propertyignoreCase
- Determine if the casing can be ignored when comparing
strings.onlyMatchPrefix
- Only match prefixes; no other matches are included.public void removeAllContainerFilters()
Container.Filterable
removeAllContainerFilters
in interface Container.Filterable
removeAllContainerFilters
in interface Container.SimpleFilterable
public void removeContainerFilters(Object propertyId)
Container.SimpleFilterable
removeContainerFilters
in interface Container.SimpleFilterable
propertyId
- for which to remove filterspublic void addContainerFilter(Container.Filter filter) throws UnsupportedFilterException
Container.Filterable
addContainerFilter
in interface Container.Filterable
UnsupportedFilterException
- if the filter is not supported by the containerpublic void removeContainerFilter(Container.Filter filter)
Container.Filterable
removeContainerFilter
in interface Container.Filterable
public Collection<?> getSortableContainerPropertyIds()
Container.Sortable
getSortableContainerPropertyIds
in interface Container.Sortable
public void sort(Object[] propertyId, boolean[] ascending)
Container.Sortable
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 ItemSorter getItemSorter()
AbstractInMemoryContainer
AbstractInMemoryContainer.setItemSorter(ItemSorter)
for more information.
getItemSorter
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
public void setItemSorter(ItemSorter itemSorter)
AbstractInMemoryContainer
ItemSorter.compare(Object, Object)
method is called with item ids
to perform the sorting. A default ItemSorter is used if this is not
explicitly set.
setItemSorter
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
itemSorter
- The ItemSorter used for comparing two items in a sort (not
null).protected void registerNewItem(int position, IDTYPE itemId, BeanItem<BEANTYPE> item)
AbstractInMemoryContainer
AbstractInMemoryContainer
has already
been updated to reflect the new item when this method is called.
registerNewItem
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
protected BeanItem<BEANTYPE> addItem(IDTYPE itemId, BEANTYPE bean)
Container.addItem(Object)
protected BeanItem<BEANTYPE> addItemAfter(IDTYPE previousItemId, IDTYPE newItemId, BEANTYPE bean)
Container.Ordered.addItemAfter(Object, Object)
protected BeanItem<BEANTYPE> addItemAt(int index, IDTYPE newItemId, BEANTYPE bean)
index
- Index at which the bean should be added.newItemId
- The item id for the bean to add to the container.bean
- The bean to add to the container.
protected BeanItem<BEANTYPE> addBean(BEANTYPE bean) throws IllegalStateException, IllegalArgumentException
bean
- the bean to add
IllegalStateException
- if no bean identifier resolver has been set
IllegalArgumentException
- if an identifier cannot be resolved for the beanaddItem(Object, Object)
protected BeanItem<BEANTYPE> addBeanAfter(IDTYPE previousItemId, BEANTYPE bean) throws IllegalStateException, IllegalArgumentException
previousItemId
- the identifier of the bean after which this bean should be
added, null to add to the beginningbean
- the bean to add
IllegalStateException
- if no bean identifier resolver has been set
IllegalArgumentException
- if an identifier cannot be resolved for the beanaddItemAfter(Object, Object, Object)
protected BeanItem<BEANTYPE> addBeanAt(int index, BEANTYPE bean) throws IllegalStateException, IllegalArgumentException
index
- the index (in the filtered view) at which to add the itembean
- the bean to add
IllegalStateException
- if no bean identifier resolver has been set
IllegalArgumentException
- if an identifier cannot be resolved for the beanaddItemAfter(Object, Object, Object)
protected void addAll(Collection<? extends BEANTYPE> collection) throws IllegalStateException, IllegalArgumentException
Collection
in one operation using the
bean item identifier resolver. More efficient than adding them one by
one.
A bean id resolver must be set before calling this method.
Note: the behavior of this method changed in Vaadin 6.6 - now items are
added at the very end of the unfiltered container and not after the last
visible item if filtering is used.
collection
- The collection of beans to add. Must not be null.
IllegalStateException
- if no bean identifier resolver has been set
IllegalArgumentException
- if the resolver returns a null itemId for one of the beans in
the collectionprotected IDTYPE resolveBeanId(BEANTYPE bean)
bean
-
IllegalStateException
- if no bean resolver is setprotected void setBeanIdResolver(AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> beanIdResolver)
beanIdResolver
- to use or null to disable automatic id resolutionpublic AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> getBeanIdResolver()
protected AbstractBeanContainer.BeanIdResolver<IDTYPE,BEANTYPE> createBeanPropertyResolver(Object propertyId)
propertyId
- property identifier, which must map to a getter in BEANTYPE
public void addListener(Container.PropertySetChangeListener listener)
AbstractContainer
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
addListener
in interface Container.PropertySetChangeNotifier
addListener
in class AbstractContainer
listener
- The new Listener to be registeredPropertySetChangeNotifier#addListener(com.vaadin.data.Container.PropertySetChangeListener)
public void removeListener(Container.PropertySetChangeListener listener)
AbstractContainer
PropertySetChangeNotifier
, override with the corresponding public
method and implement the interface to use this.
removeListener
in interface Container.PropertySetChangeNotifier
removeListener
in class AbstractContainer
listener
- Listener to be removedPropertySetChangeNotifier#removeListener(com.vaadin.data.Container.
PropertySetChangeListener)
public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException
Container
addContainerProperty
in interface Container
addContainerProperty
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
propertyId
- ID of the Propertytype
- Data type of the new PropertydefaultValue
- The value all created Properties are initialized to
true
if the operation succeeded, false
if not
UnsupportedOperationException
- if the container does not support explicitly adding container
propertiesprotected final boolean addContainerProperty(String propertyId, VaadinPropertyDescriptor<BEANTYPE> propertyDescriptor)
propertyId
- propertyDescriptor
-
public boolean addNestedContainerProperty(String propertyId)
propertyId
- propertyType
-
NestedMethodProperty
public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException
Container
removeContainerProperty
in interface Container
removeContainerProperty
in class AbstractInMemoryContainer<IDTYPE,String,BeanItem<BEANTYPE>>
propertyId
- ID of the Property to remove
true
if the operation succeeded, false
if not
UnsupportedOperationException
- if the container does not support removing container
properties
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |