com.inmethod.grid.common
Class ColumnsState

java.lang.Object
  extended by com.inmethod.grid.common.ColumnsState
All Implemented Interfaces:
Serializable, Cloneable, IClusterable

public class ColumnsState
extends Object
implements IClusterable, Cloneable

Manages the state (visibility, order and size) of grid columns.

Author:
Matej Knopp
See Also:
Serialized Form

Nested Class Summary
static class ColumnsState.Entry
          State entry for single column.
 
Constructor Summary
ColumnsState(Collection<IGridColumn<M,I>> columns)
          Creates new ColumnsState instance.
ColumnsState(ColumnsState.Entry[] columnStates)
          Creates new ColumnsState instance.
 
Method Summary
 ColumnsState clone()
          Returns deep copy of the object.
 Collection<ColumnsState.Entry> getColumnStates()
          Returns collection of ColumnsState.Entry instances of this ColumnsState.
 boolean getColumnVisibility(String id)
          Returns the visibility of given column.
 int getColumnWidth(String id)
          Returns the width of column with specified id.
 ColumnsState.Entry getEntry(String id)
          Returns the ColumnsState.Entry instance for column with give id, or null if the entry doesn't exist.
<M,I> Collection<IGridColumn<M,I>>
getVisibleColumns(Collection<IGridColumn<M,I>> allColumns)
          Filters the given IGridColumn collection leaving only the columns with visibility set to true.
 void setColumnIndex(String id, int newIndex)
          Moves the column with specified to specified position.
 void setColumnVisibility(String id, boolean newValue)
          Sets the visibility of column with given id.
 void setColumnWidth(String id, int newWidth)
          Sets the width of column with specified id.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnsState

public ColumnsState(Collection<IGridColumn<M,I>> columns)
Creates new ColumnsState instance. The state will be initialized from the specified collection of IGridColumns.

Parameters:
columns -

ColumnsState

public ColumnsState(ColumnsState.Entry[] columnStates)
Creates new ColumnsState instance. The instance will be initialized from the specified ColumnsState.Entry array.

Parameters:
columnStates -
Method Detail

getEntry

public ColumnsState.Entry getEntry(String id)
Returns the ColumnsState.Entry instance for column with give id, or null if the entry doesn't exist.

Parameters:
id - column id
Returns:
entry or null

setColumnWidth

public void setColumnWidth(String id,
                           int newWidth)
Sets the width of column with specified id.

Parameters:
id - column id
newWidth - new width or -1 if initial column width should be used

getColumnWidth

public int getColumnWidth(String id)
Returns the width of column with specified id.

Parameters:
id - column id
Returns:
column width or -1 if initial width should be used

setColumnVisibility

public void setColumnVisibility(String id,
                                boolean newValue)
Sets the visibility of column with given id.

Parameters:
id - column id
newValue -

getColumnVisibility

public boolean getColumnVisibility(String id)
Returns the visibility of given column.

Parameters:
id - column id
Returns:
true if the column is visible, false otherwise

getColumnStates

public Collection<ColumnsState.Entry> getColumnStates()
Returns collection of ColumnsState.Entry instances of this ColumnsState.

Returns:
collection of ColumnsState.Entry instances

setColumnIndex

public void setColumnIndex(String id,
                           int newIndex)
Moves the column with specified to specified position. If the position is out of range throws IndexOutOfBoundsException. If the column with given id is not found, throws an IllegalStateException. The other columns are shifted accordingly.

Parameters:
id - column id
newIndex - new column index

clone

public ColumnsState clone()
Returns deep copy of the object.

Overrides:
clone in class Object
Returns:
ColumnsState instance that is a deep copy of this instance

getVisibleColumns

public <M,I> Collection<IGridColumn<M,I>> getVisibleColumns(Collection<IGridColumn<M,I>> allColumns)
Filters the given IGridColumn collection leaving only the columns with visibility set to true.

Parameters:
allColumns - Collection to be filtered.
Returns:
Collection of columns with visibility set to true.


Copyright © 2007-2012 inMethod s.r.o.. All Rights Reserved.