Class RowGroupHeaderLayer<T>
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
org.eclipse.nebula.widgets.nattable.group.RowGroupHeaderLayer<T>
- All Implemented Interfaces:
ILayer
,ILayerListener
,IPersistable
Adds the Row grouping functionality to the row headers. Also persists the
state of the row groups when
NatTable.saveState(String, Properties)
is invoked.
Internally uses the IRowGroupModel
to track the row groups.-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
underlyingLayer
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
ConstructorDescriptionRowGroupHeaderLayer
(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel) RowGroupHeaderLayer
(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel, boolean useDefaultConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
collapseRowGroupByIndex
(int rowIndex) getCellByPosition
(int columnPosition, int rowPosition) If a cell belongs to a column group: column position - set to the start position of the group span - set to the width/size of the row group NOTE: gc.setClip() is used in the CompositeLayerPainter to ensure that partially visible Column group header cells are rendered properly.int
int
getColumnIndexByPosition
(int columnPosition) Gets the underlying non-transformed column index for the given column position on this layer.int
getColumnPositionByX
(int x) Returns the column position that contains the given x coordinate.int
getColumnWidthByPosition
(int columnPosition) Returns the width in pixels of the given column.getConfigLabelsByPosition
(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.getDataValueByPosition
(int columnPosition, int rowPosition) Returns the data value for the cell at the given coordinates.getDisplayModeByPosition
(int columnPosition, int rowPosition) Returns the activeDisplayMode
for the cell at the given coordinates.getModel()
int
int
getRegionLabelsByXY
(int x, int y) Return theLabelStack
containing the region labels for the cell at the given pixel position.protected int
getRowSpan
(int rowPosition) Calculates the span of a cell in a Row Group.int
getStartXOfColumnPosition
(int columnPosition) Returns the x offset in pixels of the given column.int
getWidth()
Returns the total width in pixels of this layer.boolean
isColumnPositionResizable
(int columnPosition) Check if the column at the given position is resizable.void
loadState
(String prefix, Properties properties) Underlying layers must load state first.int
localToUnderlyingColumnPosition
(int localColumnPosition) Convert a column position to the coordinates of the underlying layer.protected void
Layers should use this method to register their command handlers and call it from their constructor.void
saveState
(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.void
setColumnWidth
(int columnWidth) Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, doCommand, getCellPainter, getHeight, getLayerPainter, getPreferredHeight, getPreferredRowCount, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, isDynamicSizeLayer, isRowPositionResizable, localToUnderlyingRowPosition, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
-
Constructor Details
-
RowGroupHeaderLayer
public RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel) -
RowGroupHeaderLayer
public RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel, boolean useDefaultConfiguration)
-
-
Method Details
-
getModel
-
loadState
Description copied from class:AbstractLayerTransform
Underlying layers must load state first. If this is not done,IStructuralChangeEvent
from underlying layers will reset caches after state has been loaded- Specified by:
loadState
in interfaceIPersistable
- Overrides:
loadState
in classAbstractLayerTransform
- Parameters:
prefix
- The prefix to use for the state keys. Is also used as the state configuration name.properties
- The Properties instance to load the state from.
-
saveState
Description copied from interface:IPersistable
Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.- Specified by:
saveState
in interfaceIPersistable
- Overrides:
saveState
in classAbstractLayerTransform
- Parameters:
prefix
- The prefix to use for the state keys. Is also used as the state configuration name.properties
- The Properties instance to save the state to.
-
registerCommandHandlers
protected void registerCommandHandlers()Description copied from class:AbstractLayer
Layers should use this method to register their command handlers and call it from their constructor. This allows easy overriding if required of command handlers- Overrides:
registerCommandHandlers
in classAbstractLayer
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceILayer
- Overrides:
getColumnCount
in classAbstractLayerTransform
- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
public int getPreferredColumnCount()- Specified by:
getPreferredColumnCount
in interfaceILayer
- Overrides:
getPreferredColumnCount
in classAbstractLayerTransform
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition) Description copied from interface:ILayer
Gets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPosition
in interfaceILayer
- Overrides:
getColumnIndexByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position relative to this layer.- Returns:
- An underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system.
-
localToUnderlyingColumnPosition
public int localToUnderlyingColumnPosition(int localColumnPosition) Description copied from interface:ILayer
Convert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingColumnPosition
in interfaceILayer
- Overrides:
localToUnderlyingColumnPosition
in classAbstractLayerTransform
- Parameters:
localColumnPosition
- column position in local (the layer's own) coordinates- Returns:
- column position in the underlying layer's coordinates
-
getWidth
public int getWidth()Description copied from interface:ILayer
Returns the total width in pixels of this layer.- Specified by:
getWidth
in interfaceILayer
- Overrides:
getWidth
in classAbstractLayerTransform
- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth()- Specified by:
getPreferredWidth
in interfaceILayer
- Overrides:
getPreferredWidth
in classAbstractLayerTransform
-
getColumnWidthByPosition
public int getColumnWidthByPosition(int columnPosition) Description copied from interface:ILayer
Returns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Specified by:
getColumnWidthByPosition
in interfaceILayer
- Overrides:
getColumnWidthByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The width of the column.
-
setColumnWidth
public void setColumnWidth(int columnWidth) -
isColumnPositionResizable
public boolean isColumnPositionResizable(int columnPosition) Description copied from interface:ILayer
Check if the column at the given position is resizable.- Specified by:
isColumnPositionResizable
in interfaceILayer
- Overrides:
isColumnPositionResizable
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position to check.- Returns:
true
if the column is resizable,false
if not.
-
getColumnPositionByX
public int getColumnPositionByX(int x) Description copied from interface:ILayer
Returns the column position that contains the given x coordinate.- Specified by:
getColumnPositionByX
in interfaceILayer
- Overrides:
getColumnPositionByX
in classAbstractLayerTransform
- Parameters:
x
- A horizontal pixel location relative to the pixel boundary of this layer.- Returns:
- A column position relative to the associated coordinate system, or -1 if there is no column that contains x.
-
getStartXOfColumnPosition
public int getStartXOfColumnPosition(int columnPosition) Description copied from interface:ILayer
Returns the x offset in pixels of the given column.- Specified by:
getStartXOfColumnPosition
in interfaceILayer
- Overrides:
getStartXOfColumnPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
getCellByPosition
If a cell belongs to a column group: column position - set to the start position of the group span - set to the width/size of the row group NOTE: gc.setClip() is used in the CompositeLayerPainter to ensure that partially visible Column group header cells are rendered properly.- Specified by:
getCellByPosition
in interfaceILayer
- Overrides:
getCellByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the requested cell.rowPosition
- The row position of the requested cell.- Returns:
- The
ILayerCell
for the given coordinates in this layer ornull
if the coordinates are invalid on this layer.
-
getRowSpan
protected int getRowSpan(int rowPosition) Calculates the span of a cell in a Row Group. Takes into account collapsing and hidden rows in the group.- Parameters:
rowPosition
- position of any row belonging to the group
-
getDisplayModeByPosition
Description copied from interface:ILayer
Returns the activeDisplayMode
for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
. The default value isDisplayMode.NORMAL
. The SelectionLayer for example overrides this to returnDisplayMode.SELECT
for cells that are currently selected.- Specified by:
getDisplayModeByPosition
in interfaceILayer
- Overrides:
getDisplayModeByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
DisplayMode
for the cell at the given coordinates.
-
getConfigLabelsByPosition
Description copied from interface:ILayer
Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
.- Specified by:
getConfigLabelsByPosition
in interfaceILayer
- Overrides:
getConfigLabelsByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The
LabelStack
with the config labels for the cell at the given coordinates.
-
getDataValueByPosition
Description copied from interface:ILayer
Returns the data value for the cell at the given coordinates.- Specified by:
getDataValueByPosition
in interfaceILayer
- Overrides:
getDataValueByPosition
in classAbstractLayerTransform
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
- The data value for the cell at the given coordinates.
-
getRegionLabelsByXY
Description copied from interface:ILayer
Return theLabelStack
containing the region labels for the cell at the given pixel position.- Specified by:
getRegionLabelsByXY
in interfaceILayer
- Overrides:
getRegionLabelsByXY
in classAbstractLayerTransform
- Parameters:
x
- the x pixel coordinatey
- the y pixel coordinate- Returns:
- LabelStack containing the region labels for the cell at the given pixel position.
-
collapseRowGroupByIndex
public void collapseRowGroupByIndex(int rowIndex) -
clearAllGroups
public void clearAllGroups() -
getProvidedLabels
- Specified by:
getProvidedLabels
in interfaceILayer
- Overrides:
getProvidedLabels
in classAbstractLayer
- Returns:
- The collection of labels that are provided by this layer.
-