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

java.lang.Object
  extended by de.jaret.util.ui.table.model.DefaultTableViewState
All Implemented Interfaces:
ITableViewState, ICellStyleListener
Direct Known Subclasses:
DefaultHierarchicalTableViewState

public class DefaultTableViewState
extends java.lang.Object
implements ITableViewState, ICellStyleListener

Default implementation of a TableViewState for the jaret table.

Version:
$Id: DefaultTableViewState.java 472 2007-05-22 22:30:07Z olk $
Author:
Peter Kliem

Nested Class Summary
 class DefaultTableViewState.ColumnConfiguration
          Simple helper class holding the onfiguration information for a column.
 class DefaultTableViewState.RowConfiguration
          Simple helper class holding the configuration for a row.
 
Nested classes/interfaces inherited from interface de.jaret.util.ui.table.model.ITableViewState
ITableViewState.ColumnResizeMode, ITableViewState.HAlignment, ITableViewState.RowHeightMode, ITableViewState.VAlignment
 
Field Summary
protected  ICellStyleProvider _cellStyleProvider
          the cell style provider used.
protected  java.util.Map<IColumn,DefaultTableViewState.ColumnConfiguration> _colConfigurations
          map of column configurations.
protected  ITableViewState.ColumnResizeMode _columnResizeMode
          The colummn resize mode used by the table.
protected  int _defaultColumnWidth
           
protected  int _defaultRowHeight
           
protected  ITableViewState.RowHeightMode _defaultRowHeightMode
          Default row height mode for new rows.
protected  java.util.List<ITableViewStateListener> _listeners
          listener list for the tableviewstate listeners.
protected  int _maximalColumnWidth
           
protected  int _maximalRowHeight
           
protected  int _minimalColumnWidth
           
protected  int _minimalRowHeight
           
protected  java.util.Map<IRow,DefaultTableViewState.RowConfiguration> _rowConfiguations
          map of row configurations.
protected  java.util.List<IColumn> _sortedColumns
          the sorted list (for display) of columns.
 
Constructor Summary
DefaultTableViewState()
          Constructor.
 
Method Summary
 void addTableViewStateListener(ITableViewStateListener tvsl)
          Add a listener to be informed about changes on the viewstate.
 void cellStyleChanged(IRow row, IColumn column, ICellStyle style)
          Will be called whenever a style changed.
 boolean columnResizingAllowed(IColumn column)
          Check whether resizing of a column is allowed.
protected  void fireCellStyleChanged(IRow row, IColumn column, ICellStyle cellStyle)
           
protected  void fireColumnOrderChanged()
           
protected  void fireColumnVisibilityChanged(IColumn column, boolean visible)
           
protected  void fireColumnWidthChanged(IColumn column, int newWidth)
           
protected  void fireColumnWidthsChanged()
           
protected  void fireRowHeightChanged(IRow row, int newHeight)
          Inform listeners about a change in the height of a row.
protected  void fireRowHeightModeChanged(IRow row, ITableViewState.RowHeightMode newMode)
           
protected  void fireSortingChanged()
           
 ICellStyle getCellStyle(IRow row, IColumn column)
          Retrieve the cell style for a specified cell.
 ICellStyleProvider getCellStyleProvider()
          Retrieve the cell style provider of the viewstate.
 ITableViewState.ColumnResizeMode getColumnResizeMode()
          Retrieve the mode used when resizing a column.
 boolean getColumnSortingDirection(IColumn column)
          Retrieve the sorting direction for a column.
 int getColumnSortingPosition(IColumn column)
          Retrieve the position in the sorting order set.
 boolean getColumnVisible(IColumn column)
          Check whether a column is visible.
 int getColumnWidth(IColumn column)
          retrive the width of a column.
 int getMinimalColWidth()
          Retrieve the minimum column width.
 int getMinimalRowHeight()
          Get the configured minimal row heigth.
 int getRowHeight(IRow row)
          Retrieve the current height of a row.
 ITableViewState.RowHeightMode getRowHeightMode()
          Retrieve the default row heigth mode.
 ITableViewState.RowHeightMode getRowHeigthMode(IRow row)
          Retrieve the row heigth mode for a specific row.
 java.util.List<IColumn> getSortedColumns()
          Retrieve the list of columns in their display order.
 void removeTableViewStateListener(ITableViewStateListener tvsl)
          Remove a listener from the viewstate.
 void setCellStyleProvider(ICellStyleProvider cellStyleProvider)
          
 void setColumnResizeMode(ITableViewState.ColumnResizeMode columnResizeMode)
          Set the mode to use when the size of a column changes.
 void setColumnResizingAllowed(IColumn column, boolean resizingAllowed)
          Set whether resizing a column is allowed.
 void setColumnVisible(IColumn column, boolean visible)
          Set the visibility of a column.
 void setColumnVisible(java.lang.String columnId, boolean visible)
          Set the visibility of a column.
 void setColumnWidth(IColumn column, int width)
          Set the width of a column.
 void setMinimalColWidth(int minimalColumnWidth)
          Set the minimum col width.
 void setMinimalRowHeight(int minimalRowHeight)
          Set the minimal row height.
 void setRowHeight(int height)
          Set the row height for ALL rows.
 void setRowHeight(IRow row, int height)
          Set the height of a row.
 void setRowHeightMode(IRow row, ITableViewState.RowHeightMode mode)
          Set the row height mode for a specific row.
 void setRowHeightMode(ITableViewState.RowHeightMode mode)
          Set the row heigth mode for all rows and the mode to use as the default for new rows.
 void setSortedColumns(java.util.List<IColumn> sortedColumns)
          Set the order of the columns.
 void setSorting(IColumn column)
          Handle the slection of a column for sorting (handle a click).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rowConfiguations

protected java.util.Map<IRow,DefaultTableViewState.RowConfiguration> _rowConfiguations
map of row configurations.


_colConfigurations

protected java.util.Map<IColumn,DefaultTableViewState.ColumnConfiguration> _colConfigurations
map of column configurations.


_listeners

protected java.util.List<ITableViewStateListener> _listeners
listener list for the tableviewstate listeners.


_minimalRowHeight

protected int _minimalRowHeight

_maximalRowHeight

protected int _maximalRowHeight

_defaultRowHeight

protected int _defaultRowHeight

_minimalColumnWidth

protected int _minimalColumnWidth

_maximalColumnWidth

protected int _maximalColumnWidth

_defaultColumnWidth

protected int _defaultColumnWidth

_sortedColumns

protected java.util.List<IColumn> _sortedColumns
the sorted list (for display) of columns.


_cellStyleProvider

protected ICellStyleProvider _cellStyleProvider
the cell style provider used.


_columnResizeMode

protected ITableViewState.ColumnResizeMode _columnResizeMode
The colummn resize mode used by the table.


_defaultRowHeightMode

protected ITableViewState.RowHeightMode _defaultRowHeightMode
Default row height mode for new rows.

Constructor Detail

DefaultTableViewState

public DefaultTableViewState()
Constructor.

Method Detail

getRowHeight

public int getRowHeight(IRow row)
Retrieve the current height of a row.

Specified by:
getRowHeight in interface ITableViewState
Parameters:
row - row to query the height for.
Returns:
height in pixel.

setRowHeight

public void setRowHeight(IRow row,
                         int height)
Set the height of a row.

Specified by:
setRowHeight in interface ITableViewState
Parameters:
row - row
height - height

setRowHeight

public void setRowHeight(int height)
Set the row height for ALL rows.

Specified by:
setRowHeight in interface ITableViewState
Parameters:
height - height

getRowHeigthMode

public ITableViewState.RowHeightMode getRowHeigthMode(IRow row)
Retrieve the row heigth mode for a specific row.

Specified by:
getRowHeigthMode in interface ITableViewState
Parameters:
row - row to get the heigth mode for
Returns:
the row height mode

setRowHeightMode

public void setRowHeightMode(IRow row,
                             ITableViewState.RowHeightMode mode)
Set the row height mode for a specific row.

Specified by:
setRowHeightMode in interface ITableViewState
Parameters:
row - row to set the height mode for
mode - mode to set.

setRowHeightMode

public void setRowHeightMode(ITableViewState.RowHeightMode mode)
Set the row heigth mode for all rows and the mode to use as the default for new rows.

Specified by:
setRowHeightMode in interface ITableViewState
Parameters:
mode - mode to be used.

getRowHeightMode

public ITableViewState.RowHeightMode getRowHeightMode()
Retrieve the default row heigth mode.

Specified by:
getRowHeightMode in interface ITableViewState
Returns:
the default row height mode.

getColumnWidth

public int getColumnWidth(IColumn column)
retrive the width of a column.

Specified by:
getColumnWidth in interface ITableViewState
Parameters:
column - column
Returns:
the width in pixel

setColumnWidth

public void setColumnWidth(IColumn column,
                           int width)
Set the width of a column.

Specified by:
setColumnWidth in interface ITableViewState
Parameters:
column - column
width - width in pixel

getColumnVisible

public boolean getColumnVisible(IColumn column)
Check whether a column is visible.

Specified by:
getColumnVisible in interface ITableViewState
Parameters:
column - column
Returns:
true if the col is visible

setColumnVisible

public void setColumnVisible(IColumn column,
                             boolean visible)
Set the visibility of a column.

Specified by:
setColumnVisible in interface ITableViewState
Parameters:
column - column
visible - true for visible

setColumnVisible

public void setColumnVisible(java.lang.String columnId,
                             boolean visible)
Set the visibility of a column.

Specified by:
setColumnVisible in interface ITableViewState
Parameters:
columnId - id of the column
visible - true for visible

getSortedColumns

public java.util.List<IColumn> getSortedColumns()
Retrieve the list of columns in their display order.

Specified by:
getSortedColumns in interface ITableViewState
Returns:
List of columnsin their display order

setSortedColumns

public void setSortedColumns(java.util.List<IColumn> sortedColumns)
Set the order of the columns.

Specified by:
setSortedColumns in interface ITableViewState
Parameters:
sortedColumns - ordered list of columns

getColumnSortingPosition

public int getColumnSortingPosition(IColumn column)
Retrieve the position in the sorting order set.

Specified by:
getColumnSortingPosition in interface ITableViewState
Parameters:
column - column
Returns:
position

getColumnSortingDirection

public boolean getColumnSortingDirection(IColumn column)
Retrieve the sorting direction for a column.

Specified by:
getColumnSortingDirection in interface ITableViewState
Parameters:
column - column to check the sorting direction
Returns:
true for ascending, false for descending

setSorting

public void setSorting(IColumn column)
Handle the slection of a column for sorting (handle a click).

Specified by:
setSorting in interface ITableViewState
Parameters:
column - column to add to the sorting (or to reverse its sorting direction)

addTableViewStateListener

public void addTableViewStateListener(ITableViewStateListener tvsl)
Add a listener to be informed about changes on the viewstate.

Specified by:
addTableViewStateListener in interface ITableViewState
Parameters:
tvsl - listener to add

removeTableViewStateListener

public void removeTableViewStateListener(ITableViewStateListener tvsl)
Remove a listener from the viewstate.

Specified by:
removeTableViewStateListener in interface ITableViewState
Parameters:
tvsl - listener to be removed

fireRowHeightChanged

protected void fireRowHeightChanged(IRow row,
                                    int newHeight)
Inform listeners about a change in the height of a row.

Parameters:
row - row
newHeight - new row height

fireRowHeightModeChanged

protected void fireRowHeightModeChanged(IRow row,
                                        ITableViewState.RowHeightMode newMode)

fireColumnWidthChanged

protected void fireColumnWidthChanged(IColumn column,
                                      int newWidth)

fireColumnWidthsChanged

protected void fireColumnWidthsChanged()

fireColumnVisibilityChanged

protected void fireColumnVisibilityChanged(IColumn column,
                                           boolean visible)

fireSortingChanged

protected void fireSortingChanged()

fireColumnOrderChanged

protected void fireColumnOrderChanged()

fireCellStyleChanged

protected void fireCellStyleChanged(IRow row,
                                    IColumn column,
                                    ICellStyle cellStyle)

getMinimalRowHeight

public int getMinimalRowHeight()
Get the configured minimal row heigth.

Specified by:
getMinimalRowHeight in interface ITableViewState
Returns:
minimal row height

setMinimalRowHeight

public void setMinimalRowHeight(int minimalRowHeight)
Set the minimal row height.

Specified by:
setMinimalRowHeight in interface ITableViewState
Parameters:
minimalRowHeight - value to set

getMinimalColWidth

public int getMinimalColWidth()
Retrieve the minimum column width.

Specified by:
getMinimalColWidth in interface ITableViewState
Returns:
the minimum width a col can be shrinked to

setMinimalColWidth

public void setMinimalColWidth(int minimalColumnWidth)
Set the minimum col width.

Specified by:
setMinimalColWidth in interface ITableViewState
Parameters:
minimalColumnWidth - width a column can be minimal sized to

getCellStyleProvider

public ICellStyleProvider getCellStyleProvider()
Retrieve the cell style provider of the viewstate.

Specified by:
getCellStyleProvider in interface ITableViewState
Returns:
the cell style provider

setCellStyleProvider

public void setCellStyleProvider(ICellStyleProvider cellStyleProvider)


getCellStyle

public ICellStyle getCellStyle(IRow row,
                               IColumn column)
Retrieve the cell style for a specified cell.

Specified by:
getCellStyle in interface ITableViewState
Parameters:
row - row of the cell
column - column of the cell
Returns:
the cellstyle for the cell

cellStyleChanged

public void cellStyleChanged(IRow row,
                             IColumn column,
                             ICellStyle style)
Will be called whenever a style changed. inform listeners abou the received cell style change.

Specified by:
cellStyleChanged in interface ICellStyleListener
Parameters:
row - row
column - column
style - changed style

columnResizingAllowed

public boolean columnResizingAllowed(IColumn column)
Check whether resizing of a column is allowed.

Specified by:
columnResizingAllowed in interface ITableViewState
Parameters:
column - column
Returns:
true if resizing is allowed

setColumnResizingAllowed

public void setColumnResizingAllowed(IColumn column,
                                     boolean resizingAllowed)
Set whether resizing a column is allowed.

Specified by:
setColumnResizingAllowed in interface ITableViewState
Parameters:
column - column
resizingAllowed - true for allow resizing

getColumnResizeMode

public ITableViewState.ColumnResizeMode getColumnResizeMode()
Description copied from interface: ITableViewState
Retrieve the mode used when resizing a column.

Specified by:
getColumnResizeMode in interface ITableViewState
Returns:
Returns the columnResizeMode.

setColumnResizeMode

public void setColumnResizeMode(ITableViewState.ColumnResizeMode columnResizeMode)
Description copied from interface: ITableViewState
Set the mode to use when the size of a column changes.

Specified by:
setColumnResizeMode in interface ITableViewState
Parameters:
columnResizeMode - The columnResizeMode to set.


Copyright © 2012. All Rights Reserved.