Package com.inmethod.grid.common
Class ColumnsState
- java.lang.Object
-
- 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
Nested Classes Modifier and Type Class Description static classColumnsState.EntryState entry for single column.
-
Constructor Summary
Constructors Constructor Description ColumnsState(ColumnsState.Entry[] columnStates)Creates newColumnsStateinstance.ColumnsState(Collection<IGridColumn<M,I,S>> columns)Creates newColumnsStateinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ColumnsStateclone()Returns deep copy of the object.Collection<ColumnsState.Entry>getColumnStates()Returns collection ofColumnsState.Entryinstances of thisColumnsState.booleangetColumnVisibility(String id)Returns the visibility of given column.intgetColumnWidth(String id)Returns the width of column with specified id.ColumnsState.EntrygetEntry(String id)Returns theColumnsState.Entryinstance for column with give id, or null if the entry doesn't exist.<M,I,S>
Collection<IGridColumn<M,I,S>>getVisibleColumns(Collection<IGridColumn<M,I,S>> allColumns)Filters the givenIGridColumncollection leaving only the columns with visibility set totrue.voidsetColumnIndex(String id, int newIndex)Moves the column with specified to specified position.voidsetColumnVisibility(String id, boolean newValue)Sets the visibility of column with given id.voidsetColumnWidth(String id, int newWidth)Sets the width of column with specified id.
-
-
-
Constructor Detail
-
ColumnsState
public ColumnsState(Collection<IGridColumn<M,I,S>> columns)
Creates newColumnsStateinstance. The state will be initialized from the specified collection ofIGridColumns.- Parameters:
columns-
-
ColumnsState
public ColumnsState(ColumnsState.Entry[] columnStates)
Creates newColumnsStateinstance. The instance will be initialized from the specifiedColumnsState.Entryarray.- Parameters:
columnStates-
-
-
Method Detail
-
getEntry
public ColumnsState.Entry getEntry(String id)
Returns theColumnsState.Entryinstance 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 idnewWidth- 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 idnewValue-
-
getColumnVisibility
public boolean getColumnVisibility(String id)
Returns the visibility of given column.- Parameters:
id- column id- Returns:
trueif the column is visible,falseotherwise
-
getColumnStates
public Collection<ColumnsState.Entry> getColumnStates()
Returns collection ofColumnsState.Entryinstances of thisColumnsState.- Returns:
- collection of
ColumnsState.Entryinstances
-
setColumnIndex
public void setColumnIndex(String id, int newIndex)
Moves the column with specified to specified position. If the position is out of range throwsIndexOutOfBoundsException. If the column with given id is not found, throws anIllegalStateException. The other columns are shifted accordingly.- Parameters:
id- column idnewIndex- new column index
-
clone
public ColumnsState clone()
Returns deep copy of the object.- Overrides:
clonein classObject- Returns:
ColumnsStateinstance that is a deep copy of this instance
-
getVisibleColumns
public <M,I,S> Collection<IGridColumn<M,I,S>> getVisibleColumns(Collection<IGridColumn<M,I,S>> allColumns)
Filters the givenIGridColumncollection leaving only the columns with visibility set totrue.- Parameters:
allColumns- Collection to be filtered.- Returns:
- Collection of columns with visibility set to
true.
-
-