org.pm4j.core.pm.impl
Class PmTableImpl<T_ROW_ELEMENT_PM extends PmElement>

java.lang.Object
  extended by org.pm4j.core.pm.impl.PmObjectBase
      extended by org.pm4j.core.pm.impl.PmDataInputBase
          extended by org.pm4j.core.pm.impl.PmTableImpl<T_ROW_ELEMENT_PM>
All Implemented Interfaces:
java.lang.Comparable<PmObject>, PmDataInput, PmObject, PmTable<T_ROW_ELEMENT_PM>

public class PmTableImpl<T_ROW_ELEMENT_PM extends PmElement>
extends PmDataInputBase
implements PmTable<T_ROW_ELEMENT_PM>

A table that presents the content of a set of PmElements.

This class provides the model for visual table components (PmTableCol, PmTableRow, PmPager).

The table data related logic is provided by a PageableCollection. This collection supports the logic for

.

Author:
olaf boede

Nested Class Summary
protected static class PmTableImpl.MetaData
           
 
Nested classes/interfaces inherited from class org.pm4j.core.pm.impl.PmObjectBase
PmObjectBase.NameBuilder, PmObjectBase.NameBuilderAbsoluteName, PmObjectBase.NameBuilderShortName, PmObjectBase.NameBuilderTitle
 
Nested classes/interfaces inherited from interface org.pm4j.core.pm.PmTable
PmTable.RowSelectMode, PmTable.WithPager<T_ROW_ELEMENT>
 
Field Summary
 PmPagerImpl<T_ROW_ELEMENT_PM> pager
          A pager that may be used to navigate through the table.
 
Fields inherited from class org.pm4j.core.pm.impl.PmObjectBase
pmCacheLog
 
Fields inherited from interface org.pm4j.core.pm.PmObject
STYLE_CLASS_DISABLED, STYLE_CLASS_ERROR, STYLE_CLASS_INFO, STYLE_CLASS_REQUIRED, STYLE_CLASS_WARN
 
Constructor Summary
PmTableImpl(PmObject pmParent)
          Creates an empty table.
PmTableImpl(PmObject pmParent, PageableCollection<T_ROW_ELEMENT_PM> pageableItems)
          Creates a table that is connected to a data source (a PageableCollection).
 
Method Summary
 void accept(PmVisitor visitor)
           
 java.util.List<PmTableCol> getColumns()
           
 java.util.List<PmTableGenericRow<T_ROW_ELEMENT_PM>> getGenericRows()
          Provides a row representation that may be used by generic a renderer.
 int getNumOfPageRows()
           
 PageableCollection<T_ROW_ELEMENT_PM> getPageableCollection()
           
protected  PageableCollection<T_ROW_ELEMENT_PM> getPageableCollectionImpl()
          Gets called whenever the internal collection is null and getPageableCollection() gets called.
 PmPager getPager()
           
 java.util.List<T_ROW_ELEMENT_PM> getRows()
          Provides only the visible rows.
The provided set may be influenced by filter criteria and paging logic.
 PmTable.RowSelectMode getRowSelectMode()
           
 java.util.List<T_ROW_ELEMENT_PM> getRowsWithChanges()
           
 T_ROW_ELEMENT_PM getSelectedRow()
          Supports PmTable.RowSelectMode.SINGLE.
 java.util.Collection<T_ROW_ELEMENT_PM> getSelectedRows()
           
 int getTotalNumOfRows()
           
 boolean isMultiSelect()
           
protected  boolean isPmReadonlyImpl()
          Sub classes may implement their specific read-only definition here.
 boolean isPmValueChanged()
          Indicates a value change.
protected  PmObjectBase.MetaData makeMetaData()
          Gets called when the meta data instance for this presentation model is not yet available (first call within the VM live time).
protected  void onAddNewRow(T_ROW_ELEMENT_PM newRowPm)
          Gets called whenever a new (transient) row gets added to the table.
protected  void onDeleteRow(T_ROW_ELEMENT_PM deletedRow)
          Gets called whenever a row gets deleted from the table.
protected  void onPmInit()
          Gets called when the meta data part of this PM is initialized and assigned to this instance.
protected  void onPmSelectionChange(PmEvent event)
          Is called whenever an event with the flag PmEvent.SELECTION_CHANGE was fired for this PM.
 void setPageableCollection(PageableCollection<T_ROW_ELEMENT_PM> pageable, boolean preseveSettings)
          Sets an empty pageableCollection if the given parameter is null.
 void setRowSelectMode(PmTable.RowSelectMode rowSelectMode)
           
 
Methods inherited from class org.pm4j.core.pm.impl.PmDataInputBase
commitBufferedPmChanges, isBufferedPmValueMode, pmValidate, resetPmValues, rollbackBufferedPmChanges
 
Methods inherited from class org.pm4j.core.pm.impl.PmObjectBase
addToPmComposite, canSetPmTitle, clearCachedPmValues, clearPmInvalidValues, compareTo, ensurePmMetaDataInitialization, findAnnotationsInPmHierarchy, getPmConversation, getPmConversationImpl, getPmIconPath, getPmMetaData, getPmMetaDataWithoutPmInitCall, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmResKey, getPmResKeyBase, getPmResLoaderCtxtClasses, getPmShortTitle, getPmStyleClasses, getPmStyleClassesImpl, getPmTitle, getPmTitleDef, getPmTitleImpl, getPmTooltip, getPmTooltipImpl, getVisiblePmCommands, getVisiblePmCommands, initMetaData, isMetaDataInitialized, isPmEnabled, isPmEnabledImpl, isPmReadonly, isPmValid, isPmVisible, isPmVisibleImpl, onPmChildStateChange, onPmValueChange, readCacheStrategy, removePmChild, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pm4j.core.pm.PmDataInput
commitBufferedPmChanges, isBufferedPmValueMode, pmValidate, resetPmValues, rollbackBufferedPmChanges
 
Methods inherited from interface org.pm4j.core.pm.PmObject
canSetPmTitle, compareTo, getPmConversation, getPmIconPath, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmShortTitle, getPmStyleClasses, getPmTitle, getPmTooltip, isPmEnabled, isPmReadonly, isPmValid, isPmVisible, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible
 

Field Detail

pager

public final PmPagerImpl<T_ROW_ELEMENT_PM extends PmElement> pager
A pager that may be used to navigate through the table.

Constructor Detail

PmTableImpl

public PmTableImpl(PmObject pmParent)
Creates an empty table.

The table may be connected to some data source by calling #setPageableCollection(PageableCollection).

Parameters:
pmParent - The presentation model context for this table.
pageableItems - Provides the items to be displayed by this table.

PmTableImpl

public PmTableImpl(PmObject pmParent,
                   PageableCollection<T_ROW_ELEMENT_PM> pageableItems)
Creates a table that is connected to a data source (a PageableCollection).

Parameters:
pmParent - The presentation model context for this table.
pageableItems - Provides the items to be displayed by this table.
Method Detail

getColumns

public java.util.List<PmTableCol> getColumns()
Specified by:
getColumns in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The set of columns.

getGenericRows

public java.util.List<PmTableGenericRow<T_ROW_ELEMENT_PM>> getGenericRows()
Description copied from interface: PmTable
Provides a row representation that may be used by generic a renderer.

Specified by:
getGenericRows in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The set of rows as provides by PmTable.getRows().
Each row is encapsulated in a PmTableGenericRow instance.

getRows

public java.util.List<T_ROW_ELEMENT_PM> getRows()
Description copied from interface: PmTable
Provides only the visible rows.
The provided set may be influenced by filter criteria and paging logic.

Specified by:
getRows in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The set of table rows to display.

getRowsWithChanges

public java.util.List<T_ROW_ELEMENT_PM> getRowsWithChanges()
Specified by:
getRowsWithChanges in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The set of rows that contains changed data.

onAddNewRow

protected void onAddNewRow(T_ROW_ELEMENT_PM newRowPm)
Gets called whenever a new (transient) row gets added to the table. Maintains the corresponding changed state for this table.

Parameters:
newRowPm - The new row.

onDeleteRow

protected void onDeleteRow(T_ROW_ELEMENT_PM deletedRow)
Gets called whenever a row gets deleted from the table. Maintains the corresponding changed state for this table.

Parameters:
newRowPm - The new row.

getTotalNumOfRows

public int getTotalNumOfRows()
Specified by:
getTotalNumOfRows in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The total size of the un-filtered row set.

getRowSelectMode

public PmTable.RowSelectMode getRowSelectMode()
Specified by:
getRowSelectMode in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The row selection mode for this table.

setRowSelectMode

public void setRowSelectMode(PmTable.RowSelectMode rowSelectMode)

getNumOfPageRows

public int getNumOfPageRows()
Specified by:
getNumOfPageRows in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The number of rows per table page.

isMultiSelect

public boolean isMultiSelect()
Specified by:
isMultiSelect in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
true if the table supports the selection of multiple rows.

isPmReadonlyImpl

protected boolean isPmReadonlyImpl()
Description copied from class: PmObjectBase
Sub classes may implement their specific read-only definition here.

Overrides:
isPmReadonlyImpl in class PmObjectBase
Returns:
true if the PM is in read-only state.

getSelectedRow

public T_ROW_ELEMENT_PM getSelectedRow()
Description copied from interface: PmTable
Supports PmTable.RowSelectMode.SINGLE. For other select modes it just provides the first selected item.

Specified by:
getSelectedRow in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The selected row or null if none is selected.

getSelectedRows

public java.util.Collection<T_ROW_ELEMENT_PM> getSelectedRows()
Specified by:
getSelectedRows in interface PmTable<T_ROW_ELEMENT_PM extends PmElement>
Returns:
The set of all selected rows.

onPmInit

protected void onPmInit()
Description copied from class: PmObjectBase
Gets called when the meta data part of this PM is initialized and assigned to this instance.

Overrides:
onPmInit in class PmObjectBase

accept

public void accept(PmVisitor visitor)
Specified by:
accept in interface PmObject
Overrides:
accept in class PmObjectBase
Parameters:
visitor - A visitor to call back.

isPmValueChanged

public boolean isPmValueChanged()
Description copied from interface: PmDataInput
Indicates a value change. E.g. a value was entered, but not yet saved by the user.

The changed state usually gets cleared on execution of a PmCommand that required valid values.

Specified by:
isPmValueChanged in interface PmDataInput
Overrides:
isPmValueChanged in class PmDataInputBase
Returns:
true if the value of this PM or one of its composite children was changed.

getPageableCollection

public PageableCollection<T_ROW_ELEMENT_PM> getPageableCollection()
Returns:
The container that handles the table data to display.

getPageableCollectionImpl

protected PageableCollection<T_ROW_ELEMENT_PM> getPageableCollectionImpl()
Gets called whenever the internal collection is null and getPageableCollection() gets called.

Returns:
The collection to use. Never null.

setPageableCollection

public void setPageableCollection(PageableCollection<T_ROW_ELEMENT_PM> pageable,
                                  boolean preseveSettings)
Sets an empty pageableCollection if the given parameter is null.

Parameters:
pageable - The new data set to present.
preseveSettings - Defines if the currently selected items and filter definition should be preserved.

getPager

public PmPager getPager()
Returns:
A pager that may be used to navigate through the table.

onPmSelectionChange

protected void onPmSelectionChange(PmEvent event)
Is called whenever an event with the flag PmEvent.SELECTION_CHANGE was fired for this PM.

Parameters:
event - The fired event.

makeMetaData

protected PmObjectBase.MetaData makeMetaData()
Description copied from class: PmObjectBase
Gets called when the meta data instance for this presentation model is not yet available (first call within the VM live time).

Subclasses that provide more specific meta data should override this method to provide their meta data information container.

Specified by:
makeMetaData in class PmObjectBase
Returns:
A static data container for this presentation model.