info.joseluismartin.vaadin.data
Class ContainerDataSource<T>

java.lang.Object
  extended by info.joseluismartin.vaadin.data.ContainerDataSource<T>
All Implemented Interfaces:
com.vaadin.data.Buffered, com.vaadin.data.Container, com.vaadin.data.Container.Indexed, com.vaadin.data.Container.ItemSetChangeNotifier, com.vaadin.data.Container.Ordered, com.vaadin.data.Container.Sortable, com.vaadin.data.Item.PropertySetChangeListener, Serializable

public class ContainerDataSource<T>
extends Object
implements com.vaadin.data.Container, com.vaadin.data.Container.Sortable, com.vaadin.data.Container.Indexed, com.vaadin.data.Container.ItemSetChangeNotifier, com.vaadin.data.Item.PropertySetChangeListener, com.vaadin.data.Buffered

An adapter to use PageableDataSources as Vaadin Container. Use a integer as itemId and load data by page from data source on request.

Author:
Jose Luis Martin - (jlm@joseluismartin.info)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.Container
com.vaadin.data.Container.Editor, com.vaadin.data.Container.Filter, com.vaadin.data.Container.Filterable, com.vaadin.data.Container.Hierarchical, com.vaadin.data.Container.Indexed, com.vaadin.data.Container.ItemSetChangeEvent, com.vaadin.data.Container.ItemSetChangeListener, com.vaadin.data.Container.ItemSetChangeNotifier, com.vaadin.data.Container.Ordered, com.vaadin.data.Container.PropertySetChangeEvent, com.vaadin.data.Container.PropertySetChangeListener, com.vaadin.data.Container.PropertySetChangeNotifier, com.vaadin.data.Container.SimpleFilterable, com.vaadin.data.Container.Sortable, com.vaadin.data.Container.Viewer
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
com.vaadin.data.Buffered.SourceException
 
Constructor Summary
ContainerDataSource()
           
ContainerDataSource(Class<T> entityClass)
           
ContainerDataSource(Class<T> entityClass, PersistentService<T,? extends Serializable> service)
           
 
Method Summary
 boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue)
          
 Object addItem()
          
 com.vaadin.data.Item addItem(Object itemId)
          
 Object addItemAfter(Object previousItemId)
          
 com.vaadin.data.Item addItemAfter(Object previousItemId, Object newItemId)
          
 Object addItemAt(int index)
          
 com.vaadin.data.Item addItemAt(int index, Object newItemId)
          
 void addListener(com.vaadin.data.Container.ItemSetChangeListener listener)
           
 void commit()
          
 boolean containsId(Object itemId)
          
 void discard()
          
 Object firstItemId()
          
 com.vaadin.data.Property getContainerProperty(Object itemId, Object propertyId)
          
 Collection<?> getContainerPropertyIds()
          
 Object getFilter()
           
 Object getIdByIndex(int index)
          
 com.vaadin.data.Item getItem(Object itemId)
          
 com.vaadin.data.Item getItemByIndex(int index)
           
 Collection<?> getItemIds()
          
 ItemIdStrategy getItemIdStrategy()
           
 List<Serializable> getKeys()
          Get all keys from pageable datasource
 Page<T> getPage()
          Gets the page
 int getPageContaining(int index)
           
 int getPageSize()
          Get the page size
 PersistentService<T,? extends Serializable> getService()
           
 Collection<?> getSortableContainerPropertyIds()
          
 List<String> getSortableProperties()
           
 Class<?> getType(Object propertyId)
          
 int indexOfId(Object itemId)
          
 void init()
           
 boolean isFirstId(Object itemId)
          
 boolean isLastId(Object itemId)
          
 boolean isModified()
          
 boolean isReadThrough()
          
 boolean isWriteThrough()
          
 void itemPropertySetChange(com.vaadin.data.Item.PropertySetChangeEvent event)
          
 Object lastItemId()
          
 Object nextItemId(Object itemId)
          
 Object prevItemId(Object itemId)
          
 boolean removeAllItems()
          
 boolean removeContainerProperty(Object propertyId)
          
 boolean removeItem(Object itemId)
          
 void removeListener(com.vaadin.data.Container.ItemSetChangeListener listener)
           
 boolean save()
          Save changes to Persistent Service
 void setFilter(Object filter)
           
 void setItemIdStrategy(ItemIdStrategy itemIdStrategy)
           
 void setPage(Page<T> page)
           
 void setPageSize(int pageSize)
          Set the page size
 void setReadThrough(boolean readThrough)
          
 void setService(PersistentService<T,Serializable> service)
           
 void setSortableProperties(List<String> sortableProperties)
           
 void setWriteThrough(boolean writeThrough)
          
 int size()
          
 void sort(Object[] propertyId, boolean[] ascending)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerDataSource

public ContainerDataSource()

ContainerDataSource

public ContainerDataSource(Class<T> entityClass)

ContainerDataSource

public ContainerDataSource(Class<T> entityClass,
                           PersistentService<T,? extends Serializable> service)
Method Detail

init

public void init()

nextItemId

public Object nextItemId(Object itemId)

Specified by:
nextItemId in interface com.vaadin.data.Container.Ordered

prevItemId

public Object prevItemId(Object itemId)

Specified by:
prevItemId in interface com.vaadin.data.Container.Ordered

firstItemId

public Object firstItemId()

Specified by:
firstItemId in interface com.vaadin.data.Container.Ordered

lastItemId

public Object lastItemId()

Specified by:
lastItemId in interface com.vaadin.data.Container.Ordered

isFirstId

public boolean isFirstId(Object itemId)

Specified by:
isFirstId in interface com.vaadin.data.Container.Ordered

isLastId

public boolean isLastId(Object itemId)

Specified by:
isLastId in interface com.vaadin.data.Container.Ordered

addItemAfter

public Object addItemAfter(Object previousItemId)
                    throws UnsupportedOperationException

Specified by:
addItemAfter in interface com.vaadin.data.Container.Ordered
Throws:
UnsupportedOperationException

addItemAfter

public com.vaadin.data.Item addItemAfter(Object previousItemId,
                                         Object newItemId)
                                  throws UnsupportedOperationException

Specified by:
addItemAfter in interface com.vaadin.data.Container.Ordered
Throws:
UnsupportedOperationException

indexOfId

public int indexOfId(Object itemId)

Specified by:
indexOfId in interface com.vaadin.data.Container.Indexed

getIdByIndex

public Object getIdByIndex(int index)

Specified by:
getIdByIndex in interface com.vaadin.data.Container.Indexed

addItemAt

public Object addItemAt(int index)
                 throws UnsupportedOperationException

Specified by:
addItemAt in interface com.vaadin.data.Container.Indexed
Throws:
UnsupportedOperationException

addItemAt

public com.vaadin.data.Item addItemAt(int index,
                                      Object newItemId)
                               throws UnsupportedOperationException

Specified by:
addItemAt in interface com.vaadin.data.Container.Indexed
Throws:
UnsupportedOperationException

sort

public void sort(Object[] propertyId,
                 boolean[] ascending)

Specified by:
sort in interface com.vaadin.data.Container.Sortable

getSortableContainerPropertyIds

public Collection<?> getSortableContainerPropertyIds()

Specified by:
getSortableContainerPropertyIds in interface com.vaadin.data.Container.Sortable

getItem

public com.vaadin.data.Item getItem(Object itemId)

Specified by:
getItem in interface com.vaadin.data.Container

getPageContaining

public int getPageContaining(int index)

getContainerPropertyIds

public Collection<?> getContainerPropertyIds()

Specified by:
getContainerPropertyIds in interface com.vaadin.data.Container

getItemIds

public Collection<?> getItemIds()

Specified by:
getItemIds in interface com.vaadin.data.Container

getContainerProperty

public com.vaadin.data.Property getContainerProperty(Object itemId,
                                                     Object propertyId)

Specified by:
getContainerProperty in interface com.vaadin.data.Container

getType

public Class<?> getType(Object propertyId)

Specified by:
getType in interface com.vaadin.data.Container

size

public int size()

Specified by:
size in interface com.vaadin.data.Container

containsId

public boolean containsId(Object itemId)

Specified by:
containsId in interface com.vaadin.data.Container

addItem

public com.vaadin.data.Item addItem(Object itemId)
                             throws UnsupportedOperationException

Specified by:
addItem in interface com.vaadin.data.Container
Throws:
UnsupportedOperationException

addItem

public Object addItem()
               throws UnsupportedOperationException

Specified by:
addItem in interface com.vaadin.data.Container
Throws:
UnsupportedOperationException

removeItem

public boolean removeItem(Object itemId)

Specified by:
removeItem in interface com.vaadin.data.Container

addContainerProperty

public boolean addContainerProperty(Object propertyId,
                                    Class<?> type,
                                    Object defaultValue)
                             throws UnsupportedOperationException

Specified by:
addContainerProperty in interface com.vaadin.data.Container
Throws:
UnsupportedOperationException

removeContainerProperty

public boolean removeContainerProperty(Object propertyId)
                                throws UnsupportedOperationException

Specified by:
removeContainerProperty in interface com.vaadin.data.Container
Throws:
UnsupportedOperationException

removeAllItems

public boolean removeAllItems()
                       throws UnsupportedOperationException

Specified by:
removeAllItems in interface com.vaadin.data.Container
Throws:
UnsupportedOperationException

getService

public PersistentService<T,? extends Serializable> getService()

setService

public void setService(PersistentService<T,Serializable> service)

setPage

public void setPage(Page<T> page)

getSortableProperties

public List<String> getSortableProperties()

setSortableProperties

public void setSortableProperties(List<String> sortableProperties)

addListener

public void addListener(com.vaadin.data.Container.ItemSetChangeListener listener)
Specified by:
addListener in interface com.vaadin.data.Container.ItemSetChangeNotifier

removeListener

public void removeListener(com.vaadin.data.Container.ItemSetChangeListener listener)
Specified by:
removeListener in interface com.vaadin.data.Container.ItemSetChangeNotifier

setPageSize

public void setPageSize(int pageSize)
Set the page size

Parameters:
pageSize - the page size to set

getPageSize

public int getPageSize()
Get the page size

Returns:
the page size

getFilter

public Object getFilter()
Returns:
filter Object
See Also:
Page.getFilter()

setFilter

public void setFilter(Object filter)
Parameters:
filter -
See Also:
Page.setFilter(java.lang.Object)

getKeys

public List<Serializable> getKeys()
Get all keys from pageable datasource


getItemIdStrategy

public ItemIdStrategy getItemIdStrategy()
Returns:
the itemIdStrategy

setItemIdStrategy

public void setItemIdStrategy(ItemIdStrategy itemIdStrategy)
Parameters:
itemIdStrategy - the itemIdStrategy to set

getItemByIndex

public com.vaadin.data.Item getItemByIndex(int index)
Parameters:
index -

itemPropertySetChange

public void itemPropertySetChange(com.vaadin.data.Item.PropertySetChangeEvent event)

Specified by:
itemPropertySetChange in interface com.vaadin.data.Item.PropertySetChangeListener

save

public boolean save()
Save changes to Persistent Service

Returns:
true if all items was updated.

commit

public void commit()
            throws com.vaadin.data.Buffered.SourceException,
                   com.vaadin.data.Validator.InvalidValueException

Specified by:
commit in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueException

discard

public void discard()
             throws com.vaadin.data.Buffered.SourceException

Specified by:
discard in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException

isModified

public boolean isModified()

Specified by:
isModified in interface com.vaadin.data.Buffered

isReadThrough

public boolean isReadThrough()

Specified by:
isReadThrough in interface com.vaadin.data.Buffered

isWriteThrough

public boolean isWriteThrough()

Specified by:
isWriteThrough in interface com.vaadin.data.Buffered

setReadThrough

public void setReadThrough(boolean readThrough)
                    throws com.vaadin.data.Buffered.SourceException

Specified by:
setReadThrough in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException

setWriteThrough

public void setWriteThrough(boolean writeThrough)
                     throws com.vaadin.data.Buffered.SourceException,
                            com.vaadin.data.Validator.InvalidValueException

Specified by:
setWriteThrough in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueException

getPage

public Page<T> getPage()
Gets the page

Returns:
the page


Copyright © 2012 JDAL. All Rights Reserved.