org.springframework.richclient.widget.table
Class PropertyColumnTableDescription

Show UML class diagram
java.lang.Object
  extended by org.springframework.richclient.widget.table.PropertyColumnTableDescription
All Implemented Interfaces:
TableDescription

public class PropertyColumnTableDescription
extends Object
implements TableDescription

PropertyColumnTableDescription is the default implementation of TableDescription which uses class introspection to create columns. Each column is based on a property of the class and thus should be accessible through an isXXX or getXXX method.

Additionally writing capabilities are available by providing a specific TableCellEditor. When using this table description with a detail form and a backing formModel, take a look at the ValueModelTableCellEditor.

Nested properties can be accessed using the dot notation: 'propertyA.propertyB'. At any point in this chaining getting a null value will stop evaluating the expression and returns null.

Typical usage of a PropertyColumnTableDescription:
 PropertyColumnTableDescription tableDesc = new PropertyColumnTableDescription("id", MyType.class);
 tableDesc.addPropertyColumn("propertyA");
 tableDesc.addPropertyColumn("propertyB").addRenderer(MySpecificTableCellRenderer);
 tableDesc.addPropertyColumn("propertyC").addMinWidth(25).addMaxWidth(100);
 

More possibilities and additional addXXX methods can be found in the PropertyColumn class.

NOTE: this class provides a number of addPropertyColumn(...) methods to add columns. As there are many features on a column, this led to a huge number of these constructions. To simplify the PropertyColumnTableDescription class and the adding of new features, a new way of column creation has been implemented with the addXXX methods on the PropertyColumn class. New features will be exclusive to the addXXX methods.


Constructor Summary
PropertyColumnTableDescription(Class forEntityType)
           
PropertyColumnTableDescription(Class forEntityType, Comparator defaultComparator)
           
PropertyColumnTableDescription(String id, Class forEntityType)
           
PropertyColumnTableDescription(String id, Class forEntityType, Comparator defaultComparator)
           
PropertyColumnTableDescription(String id, Class forEntityType, int numberOfColumns)
           
PropertyColumnTableDescription(String id, Class forEntityType, int numberOfColumns, Comparator defaultComparator)
          Constructor creating a PropertyColumnTableDescription based on the given type.
 
Method Summary
 PropertyColumn addPropertyColumn(String propertyName)
           
 PropertyColumn addPropertyColumn(String propertyName, Class<?> propertyType)
          Create and add a column for the given property.
 void addPropertyColumn(String propertyName, Class propertyType, int minWidth, int maxWidth)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer, Comparator comparator)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, int width, TableCellRenderer renderer, boolean visible)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, String[] headerKeys, int minWidth, int maxWidth, boolean resizable, Boolean isInTextFilter)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, String[] headerKeys, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer, Boolean isInTextFilter)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, String[] headerKeys, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer, Boolean isInTextFilter, Comparator comparator)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, TableCellEditor editor)
          Deprecated.  
 void addPropertyColumn(String propertyName, Class propertyType, TableCellRenderer renderer)
          Deprecated.  
 void addPropertyColumn(String propertyName, int width)
          Deprecated.  
 void addPropertyColumn(String propertyName, int width, boolean visible)
          Deprecated.  
 PropertyColumn addPropertyColumn(String propertyName, int width, Comparator comparator)
          Deprecated.  
 void addPropertyColumn(String propertyName, int minWidth, int maxWidth)
          Deprecated.  
 void addPropertyColumn(String propertyName, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer)
          Deprecated.  
 void addPropertyColumn(String propertyName, int minWidth, int maxWidth, boolean resizable, TableCellRenderer renderer, Comparator comparator)
          Deprecated.  
 void addPropertyColumn(String propertyName, int width, TableCellRenderer renderer)
          Deprecated.  
 void addPropertyColumn(String propertyName, int width, TableCellRenderer renderer, boolean visible)
          Deprecated.  
 PropertyColumn addPropertyColumn(String propertyName, TableCellRenderer renderer)
          Deprecated.  
 void addSelectPropertyColumn(String propertyName)
           
 void addSelectPropertyColumn(String propertyName, Comparator<?> comparator)
           
 void addSelectPropertyColumn(String propertyName, int width)
           
 void addSelectPropertyColumn(String propertyName, int minWidth, int maxWidth)
           
 void addSelectPropertyColumn(String propertyName, int minWidth, int maxWidth, Comparator comparator)
           
 void addSelectPropertyColumn(String propertyName, String[] headerKeys, int minWidth, int maxWidth, boolean resizable, Comparator comparator)
           
 void addSelectPropertyColumn(String propertyName, String[] headerKeys, int minWidth, int maxWidth, boolean resizable, Comparator comparator, boolean visible)
           
 Comparator getColumnComparator(int propertyIndex)
          The comparator for a column
 int getColumnCount()
          Returns the column count
 TableCellEditor getColumnEditor(int propertyIndex)
          The cell editorr for a column
 TableCellRenderer getColumnRenderer(int propertyIndex)
          The column renderer for a column
 Class<?> getDataType()
           
 Comparator<?> getDefaultComparator()
          The default comparator
 String getHeader(int propertyIndex)
          Column header.
 int getMaxColumnWidth(int propertyIndex)
          Maximum width for a column
 int getMinColumnWidth(int propertyIndex)
          Minimum width for a column
 String[] getPropertiesInTextFilter()
          De properties to be included in the text filter
 Class getType(int propertyIndex)
          Datatype for a column
 Object getValue(Object rowObject, int propertyIndex)
          Value of a columnn for a certain row object
 boolean hasSelectColumn()
           
 boolean isResizable(int propertyIndex)
          If the column is resizable
 boolean isSelectColumn(int propertyIndex)
          Whether this column is a selection column
 boolean isVisible(int propertyIndex)
          Whether the column is initially visible or not
 void setDefaultComparator(Comparator<?> defaultComparator)
          Set the comparator to use as default (when table is filled or other specific sorting is removed).
 void setPropertyColumns(Collection<PropertyColumn> propertyColumns)
           
 void setValue(Object rowObject, int propertyIndex, Object newValue)
          Sets the value of a column of a certain row object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyColumnTableDescription

public PropertyColumnTableDescription(Class forEntityType)
See Also:
PropertyColumnTableDescription(String, Class, int, Comparator)

PropertyColumnTableDescription

public PropertyColumnTableDescription(Class forEntityType,
                                      Comparator defaultComparator)
See Also:
PropertyColumnTableDescription(String, Class, int, Comparator)

PropertyColumnTableDescription

public PropertyColumnTableDescription(String id,
                                      Class forEntityType,
                                      Comparator defaultComparator)
See Also:
PropertyColumnTableDescription(String, Class, int, Comparator)

PropertyColumnTableDescription

public PropertyColumnTableDescription(String id,
                                      Class forEntityType)
See Also:
PropertyColumnTableDescription(String, Class, int, Comparator)

PropertyColumnTableDescription

public PropertyColumnTableDescription(String id,
                                      Class forEntityType,
                                      int numberOfColumns)
See Also:
PropertyColumnTableDescription(String, Class, int, Comparator)

PropertyColumnTableDescription

public PropertyColumnTableDescription(String id,
                                      Class forEntityType,
                                      int numberOfColumns,
                                      Comparator defaultComparator)
Constructor creating a PropertyColumnTableDescription based on the given type. Each column created will need to have a corresponding property path on this type.

Parameters:
id - id used to fetch messages for the column headers.
forEntityType - type of the row item.
numberOfColumns - expected number of columns.
defaultComparator - comparator for the default sorting. Initial table will be sorted according to this comparator as well as when all other specific sorting is removed.
Method Detail

addPropertyColumn

public PropertyColumn addPropertyColumn(String propertyName)
See Also:
addPropertyColumn(String, Class)

addPropertyColumn

public PropertyColumn addPropertyColumn(String propertyName,
                                        Class<?> propertyType)
Create and add a column for the given property. Property type is passed or determined (when null) by examining the Accessor and headerKeys are added based upon the id of the PropertyColumnTableDescription, the propertyName and the postfix "HEADER".

Parameters:
propertyName - name of the property.
propertyType - type of the property. If null a type will be determined by examining the accessor method.

setPropertyColumns

public void setPropertyColumns(Collection<PropertyColumn> propertyColumns)

addPropertyColumn

public PropertyColumn addPropertyColumn(String propertyName,
                                        int width,
                                        Comparator comparator)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withComparator(Comparator), PropertyColumn.withFixedWidth(int)

addPropertyColumn

public PropertyColumn addPropertyColumn(String propertyName,
                                        TableCellRenderer renderer)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withRenderer(javax.swing.table.TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              TableCellEditor editor)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withEditor(javax.swing.table.TableCellEditor)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              TableCellRenderer renderer)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              int minWidth,
                              int maxWidth)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int width)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withFixedWidth(int)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int width,
                              boolean visible)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withFixedWidth(int), PropertyColumn.withVisible(boolean)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int width,
                              TableCellRenderer renderer,
                              boolean visible)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withFixedWidth(int), PropertyColumn.withRenderer(TableCellRenderer), PropertyColumn.withVisible(boolean)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              int width,
                              TableCellRenderer renderer,
                              boolean visible)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withFixedWidth(int), PropertyColumn.withRenderer(TableCellRenderer), PropertyColumn.withVisible(boolean)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int width,
                              TableCellRenderer renderer)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withFixedWidth(int), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int minWidth,
                              int maxWidth)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer,
                              Comparator comparator)
Deprecated. 

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer), PropertyColumn.withComparator(Comparator)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer,
                              Comparator comparator)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withComparator(Comparator), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              String[] headerKeys,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              Boolean isInTextFilter)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              String[] headerKeys,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer,
                              Boolean isInTextFilter)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer)

addPropertyColumn

public void addPropertyColumn(String propertyName,
                              Class propertyType,
                              String[] headerKeys,
                              int minWidth,
                              int maxWidth,
                              boolean resizable,
                              TableCellRenderer renderer,
                              Boolean isInTextFilter,
                              Comparator comparator)
Deprecated. 

WARNING: propertyType is discarded, it should be fetched from the entityType through introspection.

See Also:
addPropertyColumn(String), PropertyColumn.withComparator(Comparator), PropertyColumn.withMinWidth(int), PropertyColumn.withMaxWidth(int), PropertyColumn.withResizable(boolean), PropertyColumn.withRenderer(TableCellRenderer)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    Comparator<?> comparator)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    int width)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    int minWidth,
                                    int maxWidth)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    int minWidth,
                                    int maxWidth,
                                    Comparator comparator)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    String[] headerKeys,
                                    int minWidth,
                                    int maxWidth,
                                    boolean resizable,
                                    Comparator comparator)

addSelectPropertyColumn

public void addSelectPropertyColumn(String propertyName,
                                    String[] headerKeys,
                                    int minWidth,
                                    int maxWidth,
                                    boolean resizable,
                                    Comparator comparator,
                                    boolean visible)

getDataType

public Class<?> getDataType()
Specified by:
getDataType in interface TableDescription
Returns:
Type van row objects

getDefaultComparator

public Comparator<?> getDefaultComparator()
Description copied from interface: TableDescription
The default comparator

Specified by:
getDefaultComparator in interface TableDescription

setDefaultComparator

public void setDefaultComparator(Comparator<?> defaultComparator)
Set the comparator to use as default (when table is filled or other specific sorting is removed).


hasSelectColumn

public boolean hasSelectColumn()
Specified by:
hasSelectColumn in interface TableDescription
Returns:
TRUE if the table has a selection column

getPropertiesInTextFilter

public String[] getPropertiesInTextFilter()
De properties to be included in the text filter

Specified by:
getPropertiesInTextFilter in interface TableDescription

getColumnCount

public int getColumnCount()
Returns the column count

Specified by:
getColumnCount in interface TableDescription

getValue

public Object getValue(Object rowObject,
                       int propertyIndex)
Value of a columnn for a certain row object

Specified by:
getValue in interface TableDescription

setValue

public void setValue(Object rowObject,
                     int propertyIndex,
                     Object newValue)
Sets the value of a column of a certain row object

Specified by:
setValue in interface TableDescription

getHeader

public String getHeader(int propertyIndex)
Description copied from interface: TableDescription
Column header.

Specified by:
getHeader in interface TableDescription

getType

public Class getType(int propertyIndex)
Datatype for a column

Specified by:
getType in interface TableDescription

getMinColumnWidth

public int getMinColumnWidth(int propertyIndex)
Description copied from interface: TableDescription
Minimum width for a column

Specified by:
getMinColumnWidth in interface TableDescription

getMaxColumnWidth

public int getMaxColumnWidth(int propertyIndex)
Description copied from interface: TableDescription
Maximum width for a column

Specified by:
getMaxColumnWidth in interface TableDescription

isResizable

public boolean isResizable(int propertyIndex)
Description copied from interface: TableDescription
If the column is resizable

Specified by:
isResizable in interface TableDescription

isVisible

public boolean isVisible(int propertyIndex)
Whether the column is initially visible or not

Specified by:
isVisible in interface TableDescription

getColumnRenderer

public TableCellRenderer getColumnRenderer(int propertyIndex)
Description copied from interface: TableDescription
The column renderer for a column

Specified by:
getColumnRenderer in interface TableDescription

getColumnEditor

public TableCellEditor getColumnEditor(int propertyIndex)
Description copied from interface: TableDescription
The cell editorr for a column

Specified by:
getColumnEditor in interface TableDescription

isSelectColumn

public boolean isSelectColumn(int propertyIndex)
Description copied from interface: TableDescription
Whether this column is a selection column

Specified by:
isSelectColumn in interface TableDescription

getColumnComparator

public Comparator getColumnComparator(int propertyIndex)
Description copied from interface: TableDescription
The comparator for a column

Specified by:
getColumnComparator in interface TableDescription


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.