org.pm4j.core.pm.pageable
Class PageablePmsForBeans<T_PM extends PmBean<T_BEAN>,T_BEAN>

java.lang.Object
  extended by org.pm4j.core.pm.pageable.PageablePmsForBeans<T_PM,T_BEAN>
Type Parameters:
T_PM - The kind of PmBean provided by this class.
T_BEAN - The kind of corresponding bean, handled by the backing PageableItems instance.
All Implemented Interfaces:
PageableCollection<T_PM>

public class PageablePmsForBeans<T_PM extends PmBean<T_BEAN>,T_BEAN>
extends java.lang.Object
implements PageableCollection<T_PM>

A PageableItems instance that provides PmBean instances in front of a PageableItems container that handles the corresponding bean instances.

Author:
olaf boede

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.pm4j.core.pm.pageable.PageableCollection
PageableCollection.Filter<T>
 
Constructor Summary
PageablePmsForBeans(PmTable<T_PM> pmCtxt, java.util.Collection<T_BEAN> beans)
           
PageablePmsForBeans(PmTable<T_PM> pmCtxt, PageableCollection<T_BEAN> beanItems)
           
 
Method Summary
 void deSelect(T_PM item)
          Removes the given item from the set of selected items.
 PageableCollection.Filter<?> getBackingItemFilter()
           
 PageableCollection<T_BEAN> getBeans()
           
 int getCurrentPageIdx()
           
 java.util.List<T_PM> getItemsOnPage()
           
 int getNumOfItems()
           
 int getPageSize()
           
 java.util.Collection<T_PM> getSelectedItems()
           
 boolean isMultiSelect()
           
 boolean isSelected(T_PM item)
           
 void onUpdateCollection()
          Gets called whenever the collection behind this instance was updated.
 void select(T_PM item)
          Adds the given item to the set of selected items.
 void setBackingItemFilter(PageableCollection.Filter<?> filter)
          Provides a filter that will be applied to the items of the backing collection.
 void setBeans(PageableCollection<T_BEAN> pageableBeanCollection)
           
 void setCurrentPageIdx(int pageIdx)
           
 void setItemFilter(PageableCollection.Filter<?> filter)
          Provides a filter that will be applied to the items of this collection.
 void setMultiSelect(boolean isMultiSelect)
          Defines the selection behavior.
 void setPageSize(int newSize)
           
 void sortBackingItems(java.util.Comparator<?> sortComparator)
          Provides a sort comparator that will be applied to the items of the backing collection.
 void sortItems(java.util.Comparator<?> sortComparator)
          Sorts the items of this collection based on the given operator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageablePmsForBeans

public PageablePmsForBeans(PmTable<T_PM> pmCtxt,
                           PageableCollection<T_BEAN> beanItems)

PageablePmsForBeans

public PageablePmsForBeans(PmTable<T_PM> pmCtxt,
                           java.util.Collection<T_BEAN> beans)
Method Detail

getItemsOnPage

public java.util.List<T_PM> getItemsOnPage()
Specified by:
getItemsOnPage in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The set of item to display on the current page.

getPageSize

public int getPageSize()
Specified by:
getPageSize in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The number of items to reserve space for on the current page.

setPageSize

public void setPageSize(int newSize)
Specified by:
setPageSize in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
newSize - The new page size. Should be greater than zero.

getCurrentPageIdx

public int getCurrentPageIdx()
Specified by:
getCurrentPageIdx in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The current page number. Starts with one.

setCurrentPageIdx

public void setCurrentPageIdx(int pageIdx)
Specified by:
setCurrentPageIdx in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
pageIdx - Navigates to the specified page.

Valid range: 1 .. #getTotalPageNum().


sortItems

public void sortItems(java.util.Comparator<?> sortComparator)
Description copied from interface: PageableCollection
Sorts the items of this collection based on the given operator.

Specified by:
sortItems in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
sortComparator - The item comparator to use.
May be null to switch sorting off.

sortBackingItems

public void sortBackingItems(java.util.Comparator<?> sortComparator)
Description copied from interface: PageableCollection
Provides a sort comparator that will be applied to the items of the backing collection.

In case of a simple collection (without backing collection), the comparator will be applied to the items of this collection.

Specified by:
sortBackingItems in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
sortComparator - The item comparator to use.
May be null to switch sorting off.

setItemFilter

public void setItemFilter(PageableCollection.Filter<?> filter)
Description copied from interface: PageableCollection
Provides a filter that will be applied to the items of this collection.

Specified by:
setItemFilter in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
filter - The item filter to use.
May be null to switch filtering off.

setBackingItemFilter

public void setBackingItemFilter(PageableCollection.Filter<?> filter)
Description copied from interface: PageableCollection
Provides a filter that will be applied to the items of the backing collection.

In case of a simple collection (without backing collection), the filter will be applied to the items of this collection.

Specified by:
setBackingItemFilter in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
filter - The item filter to use.
May be null to switch filtering off.

getBackingItemFilter

public PageableCollection.Filter<?> getBackingItemFilter()
Specified by:
getBackingItemFilter in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The current filter definition for the backing collection.

getNumOfItems

public int getNumOfItems()
Specified by:
getNumOfItems in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The total number of object within this set.

isSelected

public boolean isSelected(T_PM item)
Specified by:
isSelected in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
item - The item to check.
Returns:
true if the item was selected.

select

public void select(T_PM item)
Description copied from interface: PageableCollection
Adds the given item to the set of selected items.

Has no effect if the item is already selected.

Specified by:
select in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
item - The item to select.

deSelect

public void deSelect(T_PM item)
Description copied from interface: PageableCollection
Removes the given item from the set of selected items.

Has no effect if the item was not selected.

Specified by:
deSelect in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Parameters:
item - The item to deselect.

isMultiSelect

public boolean isMultiSelect()
Specified by:
isMultiSelect in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
true if more than one item can be selected.

setMultiSelect

public void setMultiSelect(boolean isMultiSelect)
Description copied from interface: PageableCollection
Defines the selection behavior.

Specified by:
setMultiSelect in interface PageableCollection<T_PM extends PmBean<T_BEAN>>

getSelectedItems

public java.util.Collection<T_PM> getSelectedItems()
Specified by:
getSelectedItems in interface PageableCollection<T_PM extends PmBean<T_BEAN>>
Returns:
The set of selected items.

onUpdateCollection

public void onUpdateCollection()
Description copied from interface: PageableCollection
Gets called whenever the collection behind this instance was updated.

Specified by:
onUpdateCollection in interface PageableCollection<T_PM extends PmBean<T_BEAN>>

getBeans

public PageableCollection<T_BEAN> getBeans()

setBeans

public void setBeans(PageableCollection<T_BEAN> pageableBeanCollection)