de.jaret.util.ui.table.model
Class PropCol

java.lang.Object
  extended by de.jaret.util.ui.table.model.AbstractColumn
      extended by de.jaret.util.ui.table.model.PropCol
All Implemented Interfaces:
IColumn, java.util.Comparator<IRow>

public class PropCol
extends AbstractColumn
implements IColumn

Column implementation for the jaret table using reflection (getPropName, setPropName) to retrieve the column value. Does not support listening for property changes on the underlying POJO (But will fire a valueChanged if the model is changed by setValue). Supports property paths and an optional accessor (IPropColAccessor).

Version:
$Id: PropCol.java 400 2007-05-01 17:40:47Z olk $
Author:
Peter Kliem

Field Summary
protected  IPropColAccessor _accessor
          optional accessor.
protected  java.lang.Class<?> _contentClass
          content class if specified directly.
protected  boolean _editable
          true if the column is editable.
protected  java.lang.String _headerLabel
          header label string.
protected  java.lang.String _id
          id string.
protected  java.lang.String _prop
          name of the mapped property (or path separeted by dots).
protected  java.lang.String[] _propPath
          array of property names parsed from the property.
protected  boolean _supportSorting
          true if the col should be able to sort the table.
 
Fields inherited from class de.jaret.util.ui.table.model.AbstractColumn
_listeners
 
Constructor Summary
PropCol(java.lang.String id, java.lang.String label, java.lang.String prop)
          Construct the column.
PropCol(java.lang.String id, java.lang.String label, java.lang.String prop, java.lang.Class<?> contentClass)
          Construct the column.
PropCol(java.lang.String id, java.lang.String label, java.lang.String prop, java.lang.Class<?> contentClass, IPropColAccessor accessor)
          Construct the column.
 
Method Summary
 int compare(IRow r1, IRow r2)
           Sorting default behaviour: compare toString().
 java.lang.Class<?> getContentClass()
          To allow null values as column value and to support cell editing and displaying a column may support this method for supplying the information.
 java.lang.Class<?> getContentClass(IRow row)
          Default implementation: no difference to getContentClass().
 java.lang.String getHeaderLabel()
          Return a textual label to be displayed as the column header label.
 java.lang.String getId()
          Id is used for storing the column width.
 java.lang.Object getValue(IRow row)
          Retrieve the value of the column for the given row.
 boolean isEditable()
          Deafult: cols are aditable.
protected  boolean isRealModification(java.lang.Object o1, java.lang.Object o2)
          Check whether there is a real modification between two (possible null) objects.
 void setEditable(boolean editable)
          Set whether the column should be editable.
 void setSupportSorting(boolean supportSorting)
          Set whether the column should support sorting.
 void setValue(IRow row, java.lang.Object value)
          Set the value of the coloumn for a given row.
 boolean supportsSorting()
          Check whether the column supports sorting.
 
Methods inherited from class de.jaret.util.ui.table.model.AbstractColumn
addColumnListener, displayHeader, fireValueChanged, isEditable, remColumnListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.jaret.util.ui.table.model.IColumn
addColumnListener, displayHeader, isEditable, remColumnListener
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

_id

protected java.lang.String _id
id string.


_headerLabel

protected java.lang.String _headerLabel
header label string.


_prop

protected java.lang.String _prop
name of the mapped property (or path separeted by dots).


_propPath

protected java.lang.String[] _propPath
array of property names parsed from the property.


_supportSorting

protected boolean _supportSorting
true if the col should be able to sort the table.


_editable

protected boolean _editable
true if the column is editable.


_contentClass

protected java.lang.Class<?> _contentClass
content class if specified directly.


_accessor

protected IPropColAccessor _accessor
optional accessor.

Constructor Detail

PropCol

public PropCol(java.lang.String id,
               java.lang.String label,
               java.lang.String prop,
               java.lang.Class<?> contentClass,
               IPropColAccessor accessor)
Construct the column.

Parameters:
id - id of the column
label - header label
prop - property name (usually starting with a capital letter or path)
contentClass - class of the objects held by the column
accessor - optinal accessor to be invoked on the property to retrive/set the value

PropCol

public PropCol(java.lang.String id,
               java.lang.String label,
               java.lang.String prop,
               java.lang.Class<?> contentClass)
Construct the column.

Parameters:
id - id of the column
label - header label
prop - property name (usually starting with a capital letter or path)
contentClass - class of the objects held by the column

PropCol

public PropCol(java.lang.String id,
               java.lang.String label,
               java.lang.String prop)
Construct the column.

Parameters:
id - id of the column
label - header label
prop - property name (usually starting with a capital letter or path)
Method Detail

getId

public java.lang.String getId()
Id is used for storing the column width. It has to be unique among all columns if the use of the view state persisting support will be used.

Specified by:
getId in interface IColumn
Returns:
unique id.

getHeaderLabel

public java.lang.String getHeaderLabel()
Return a textual label to be displayed as the column header label.

Specified by:
getHeaderLabel in interface IColumn
Returns:
header label

getValue

public java.lang.Object getValue(IRow row)
Retrieve the value of the column for the given row.

Specified by:
getValue in interface IColumn
Parameters:
row - the row
Returns:
the column value for the given row.

getContentClass

public java.lang.Class<?> getContentClass(IRow row)
Default implementation: no difference to getContentClass(). To specify a content class per row this method may be implemented to reflect the appropriate class.

Specified by:
getContentClass in interface IColumn
Overrides:
getContentClass in class AbstractColumn
Parameters:
row - row of which to get the content class
Returns:
contained class or null if the information is not available.

isRealModification

protected boolean isRealModification(java.lang.Object o1,
                                     java.lang.Object o2)
Check whether there is a real modification between two (possible null) objects.

Parameters:
o1 - object1
o2 - object 2
Returns:
true if a real modification has been detected

setValue

public void setValue(IRow row,
                     java.lang.Object value)
Set the value of the coloumn for a given row.

Specified by:
setValue in interface IColumn
Parameters:
row - the row
value - value to set

compare

public int compare(IRow r1,
                   IRow r2)
Sorting default behaviour: compare toString().

Specified by:
compare in interface java.util.Comparator<IRow>

supportsSorting

public boolean supportsSorting()
Check whether the column supports sorting.

Specified by:
supportsSorting in interface IColumn
Returns:
true when sorting is supported.

setSupportSorting

public void setSupportSorting(boolean supportSorting)
Set whether the column should support sorting.

Parameters:
supportSorting - true if sorting should be supported

getContentClass

public java.lang.Class<?> getContentClass()
To allow null values as column value and to support cell editing and displaying a column may support this method for supplying the information.

Specified by:
getContentClass in interface IColumn
Returns:
the contained class or null if the information is not available.

isEditable

public boolean isEditable()
Deafult: cols are aditable.

Specified by:
isEditable in interface IColumn
Overrides:
isEditable in class AbstractColumn
Returns:
true

setEditable

public void setEditable(boolean editable)
Set whether the column should be editable.

Parameters:
editable - true for allow edit


Copyright © 2012. All Rights Reserved.