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
public class RowGroupHeaderLayer<T> extends AbstractLayerTransform
Adds the Row grouping functionality to the row headers. Also persists the state of the row groups whenNatTable.saveState(String, Properties)is invoked. Internally uses theIRowGroupModelto 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
Constructors Constructor Description RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel)RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel, boolean useDefaultConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAllGroups()voidcollapseRowGroupByIndex(int rowIndex)ILayerCellgetCellByPosition(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.intgetColumnCount()intgetColumnIndexByPosition(int columnPosition)Gets the underlying non-transformed column index for the given column position on this layer.intgetColumnPositionByX(int x)Returns the column position that contains the given x coordinate.intgetColumnWidthByPosition(int columnPosition)Returns the width in pixels of the given column.LabelStackgetConfigLabelsByPosition(int columnPosition, int rowPosition)Returns the config labels for the cell at the given coordinates.ObjectgetDataValueByPosition(int columnPosition, int rowPosition)Returns the data value for the cell at the given coordinates.DisplayModegetDisplayModeByPosition(int columnPosition, int rowPosition)Returns the activeDisplayModefor the cell at the given coordinates.IRowGroupModel<T>getModel()intgetPreferredColumnCount()intgetPreferredWidth()Collection<String>getProvidedLabels()LabelStackgetRegionLabelsByXY(int x, int y)Return theLabelStackcontaining the region labels for the cell at the given pixel position.protected intgetRowSpan(int rowPosition)Calculates the span of a cell in a Row Group.intgetStartXOfColumnPosition(int columnPosition)Returns the x offset in pixels of the given column.intgetWidth()Returns the total width in pixels of this layer.booleanisColumnPositionResizable(int columnPosition)Check if the column at the given position is resizable.voidloadState(String prefix, Properties properties)Underlying layers must load state first.intlocalToUnderlyingColumnPosition(int localColumnPosition)Convert a column position to the coordinates of the underlying layer.protected voidregisterCommandHandlers()Layers should use this method to register their command handlers and call it from their constructor.voidsaveState(String prefix, Properties properties)Saves the state to the given Properties using the specified prefix.voidsetColumnWidth(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 Detail
-
RowGroupHeaderLayer
public RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel)
-
RowGroupHeaderLayer
public RowGroupHeaderLayer(ILayer rowHeaderLayer, SelectionLayer selectionLayer, IRowGroupModel<T> rowGroupModel, boolean useDefaultConfiguration)
-
-
Method Detail
-
getModel
public IRowGroupModel<T> getModel()
-
loadState
public void loadState(String prefix, Properties properties)
Description copied from class:AbstractLayerTransformUnderlying layers must load state first. If this is not done,IStructuralChangeEventfrom underlying layers will reset caches after state has been loaded- Specified by:
loadStatein interfaceIPersistable- Overrides:
loadStatein 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
public void saveState(String prefix, Properties properties)
Description copied from interface:IPersistableSaves 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:
saveStatein interfaceIPersistable- Overrides:
saveStatein 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:AbstractLayerLayers 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:
registerCommandHandlersin classAbstractLayer
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCountin interfaceILayer- Overrides:
getColumnCountin classAbstractLayerTransform- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
public int getPreferredColumnCount()
- Specified by:
getPreferredColumnCountin interfaceILayer- Overrides:
getPreferredColumnCountin classAbstractLayerTransform
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition)
Description copied from interface:ILayerGets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPositionin interfaceILayer- Overrides:
getColumnIndexByPositionin 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:ILayerConvert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingColumnPositionin interfaceILayer- Overrides:
localToUnderlyingColumnPositionin 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:ILayerReturns the total width in pixels of this layer.- Specified by:
getWidthin interfaceILayer- Overrides:
getWidthin classAbstractLayerTransform- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth()
- Specified by:
getPreferredWidthin interfaceILayer- Overrides:
getPreferredWidthin classAbstractLayerTransform
-
getColumnWidthByPosition
public int getColumnWidthByPosition(int columnPosition)
Description copied from interface:ILayerReturns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Specified by:
getColumnWidthByPositionin interfaceILayer- Overrides:
getColumnWidthByPositionin 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:ILayerCheck if the column at the given position is resizable.- Specified by:
isColumnPositionResizablein interfaceILayer- Overrides:
isColumnPositionResizablein classAbstractLayerTransform- Parameters:
columnPosition- The column position to check.- Returns:
trueif the column is resizable,falseif not.
-
getColumnPositionByX
public int getColumnPositionByX(int x)
Description copied from interface:ILayerReturns the column position that contains the given x coordinate.- Specified by:
getColumnPositionByXin interfaceILayer- Overrides:
getColumnPositionByXin 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:ILayerReturns the x offset in pixels of the given column.- Specified by:
getStartXOfColumnPositionin interfaceILayer- Overrides:
getStartXOfColumnPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
getCellByPosition
public ILayerCell 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.- Specified by:
getCellByPositionin interfaceILayer- Overrides:
getCellByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the requested cell.rowPosition- The row position of the requested cell.- Returns:
- The
ILayerCellfor the given coordinates in this layer ornullif 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
public DisplayMode getDisplayModeByPosition(int columnPosition, int rowPosition)
Description copied from interface:ILayerReturns the activeDisplayModefor 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.SELECTfor cells that are currently selected.- Specified by:
getDisplayModeByPositionin interfaceILayer- Overrides:
getDisplayModeByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
DisplayModefor the cell at the given coordinates.
-
getConfigLabelsByPosition
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
Description copied from interface:ILayerReturns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry.- Specified by:
getConfigLabelsByPositionin interfaceILayer- Overrides:
getConfigLabelsByPositionin classAbstractLayerTransform- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
- The
LabelStackwith the config labels for the cell at the given coordinates.
-
getDataValueByPosition
public Object getDataValueByPosition(int columnPosition, int rowPosition)
Description copied from interface:ILayerReturns the data value for the cell at the given coordinates.- Specified by:
getDataValueByPositionin interfaceILayer- Overrides:
getDataValueByPositionin 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
public LabelStack getRegionLabelsByXY(int x, int y)
Description copied from interface:ILayerReturn theLabelStackcontaining the region labels for the cell at the given pixel position.- Specified by:
getRegionLabelsByXYin interfaceILayer- Overrides:
getRegionLabelsByXYin 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
public Collection<String> getProvidedLabels()
- Specified by:
getProvidedLabelsin interfaceILayer- Overrides:
getProvidedLabelsin classAbstractLayer- Returns:
- The collection of labels that are provided by this layer.
-
-