Class CompositeLayer
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.layer.CompositeLayer
- All Implemented Interfaces:
ILayer,ILayerListener,IPersistable
- Direct Known Subclasses:
ComboBoxFilterRowHeaderComposite,CompositeFreezeLayer,CompositeLayerFixture,FilterRowHeaderComposite,GridLayer
A composite layer is a layer that is made up of a number of underlying child
layers. This class assumes that the child layers are laid out in a regular
grid pattern where the child layers in each composite row all have the same
number of rows and the same height, and the child layers in each composite
column each have the same number of columns and the same width.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainterFields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) Adds the configLabelAccumulator to the existing label accumulators.voidconfigure(IConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry) Configure this layer, e.g.voiddispose()Dispose any resource allocated by this layer.booleandoCommand(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.protected booleandoCommandOnChildLayers(ILayerCommand command) org.eclipse.swt.graphics.RectanglegetBoundsByPosition(int compositeColumnPosition, int compositeRowPosition) Calculates the bounds in pixel for the given cell position.getCellByPosition(int compositeColumnPosition, int compositeRowPosition) Returns the cell for the given coordinates on this layer.getCellPainter(int compositeColumnPosition, int compositeRowPosition, ILayerCell cell, IConfigRegistry configRegistry) Return theICellPainterfor the givenILayerCellat the given coordinates out of the givenIConfigRegistry.getChildLayerByLayoutCoordinate(int layoutX, int layoutY) getChildLayerByRegionName(String regionName) protected ILayer[][]intintgetColumnIndexByPosition(int compositeColumnPosition) 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.protected intgetColumnPositionOffset(int layoutX) intgetColumnWidthByPosition(int column) Returns the width in pixels of the given column.getConfigLabelAccumulatorByRegionName(String regionName) getConfigLabelsByPosition(int compositeColumnPosition, int compositeRowPosition) Returns the config labels for the cell at the given coordinates.getDataValueByPosition(int compositeColumnPosition, int compositeRowPosition) Returns the data value for the cell at the given coordinates.getDisplayModeByPosition(int compositeColumnPosition, int compositeRowPosition) Returns the activeDisplayModefor the cell at the given coordinates.intReturns the total height in pixels of this layer.protected intgetHeightOffset(int layoutY) protected intgetLayoutXByColumnPosition(int compositeColumnPosition) protected intgetLayoutXByPixelX(int x) intprotected org.eclipse.swt.graphics.PointgetLayoutXYByChildLayer(ILayer childLayer) protected org.eclipse.swt.graphics.PointgetLayoutXYByPixelXY(int x, int y) protected org.eclipse.swt.graphics.PointgetLayoutXYByPosition(int compositeColumnPosition, int compositeRowPosition) protected intgetLayoutYByPixelY(int y) protected intgetLayoutYByRowPosition(int compositeRowPosition) intintintintintgetRegionLabelsByXY(int x, int y) Return theLabelStackcontaining the region labels for the cell at the given pixel position.intintgetRowHeightByPosition(int row) Returns the height in pixels of the given row.intgetRowIndexByPosition(int compositeRowPosition) Gets the underlying non-transformed row index for the given row position on this layer.intgetRowPositionByY(int y) Get the row position relative to the layer the containing coordinate y.protected intgetRowPositionOffset(int layoutY) intgetStartXOfColumnPosition(int columnPosition) Returns the x offset in pixels of the given column.intgetStartYOfRowPosition(int rowPosition) Returns the y offset in pixels of the given row.getUnderlyingLayerByPosition(int columnPosition, int rowPosition) Returns the layer that is directly below this layer for the given cell coordinate.getUnderlyingLayersByColumnPosition(int columnPosition) Returns the layers that are directly below this layer for the given column position.getUnderlyingLayersByRowPosition(int rowPosition) Returns the layers that are directly below this layer for the given row position.intgetWidth()Returns the total width in pixels of this layer.protected intgetWidthOffset(int layoutX) booleanisColumnPositionResizable(int compositeColumnPosition) Check if the column at the given position is resizable.booleanbooleanisRowPositionResizable(int compositeRowPosition) Check if the row at the given position is resizable.voidloadState(String prefix, Properties properties) Restore the state out of the given Properties identified by the specified prefix.intlocalToUnderlyingColumnPosition(int localColumnPosition) Convert a column position to the coordinates of the underlying layer.intlocalToUnderlyingRowPosition(int localRowPosition) Convert a row position to the coordinates of the underlying layer.voidsaveState(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.voidsetChildLayer(String regionName, ILayer childLayer, int layoutX, int layoutY) voidsetConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) Sets the IConfigLabelAccumulator for the given named region.intunderlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Transforms the column position relative to the given underlying layer to this layer coordinates.underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) Transforms the column position ranges relative to the given underlying layer to this layer coordinates.intunderlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition) Transforms the row position relative to the given underlying layer to this layer coordinates.underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) Transforms the row position ranges relative to the given underlying layer to this layer coordinates.Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getClientAreaProvider, getConfigLabelAccumulator, getLayerPainter, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setClientAreaProvider, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
-
Constructor Details
-
CompositeLayer
public CompositeLayer(int layoutXCount, int layoutYCount)
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:ILayerDispose any resource allocated by this layer.- Specified by:
disposein interfaceILayer- Overrides:
disposein classAbstractLayer
-
saveState
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 classAbstractLayer- 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.
-
loadState
Description copied from interface:IPersistableRestore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.- Specified by:
loadStatein interfaceIPersistable- Overrides:
loadStatein classAbstractLayer- 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.
-
configure
Description copied from interface:ILayerConfigure this layer, e.g. add any key/mouse bindings and other general configuration.This method is triggered by
NatTable.configure()and executed down the layer stack.- Specified by:
configurein interfaceILayer- Overrides:
configurein classAbstractLayer- Parameters:
configRegistry- TheIConfigRegistryinstance owned by theNatTablethis layer is attached to.uiBindingRegistry- TheUiBindingRegistryinstance owned byNatTablethis layer is attached to.
-
doCommand
Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.Note: Before the layer can process a command it must convert the command to its local coordinates using
ILayerCommand.convertToTargetLayer(ILayer)Handle commands- Specified by:
doCommandin interfaceILayer- Overrides:
doCommandin classAbstractLayer- Parameters:
command- The command to execute.- Returns:
trueif the command has been handled and was therefore consumed,falseotherwise.
-
doCommandOnChildLayers
-
getColumnCount
public int getColumnCount()- Returns:
- total number of columns being displayed Note: Works off the header layers.
-
getPreferredColumnCount
public int getPreferredColumnCount() -
getColumnIndexByPosition
public int getColumnIndexByPosition(int compositeColumnPosition) Description copied from interface:ILayerGets the underlying non-transformed column index for the given column position on this layer.- Parameters:
compositeColumnPosition- Column position in theCompositeLayer- Returns:
- column index in the underlying layer.
-
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.- Parameters:
localColumnPosition- column position in local (the layer's own) coordinates- Returns:
- column position in the underlying layer's coordinates
-
underlyingToLocalColumnPosition
public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Description copied from interface:ILayerTransforms the column position relative to the given underlying layer to this layer coordinates.- Parameters:
sourceUnderlyingLayer- The underlying layer to which the given column position matches.underlyingColumnPosition- The column position in the given underlying layer that should be converted to a local column position.- Returns:
- The given column position transformed to be local to this layer.
-
underlyingToLocalColumnPositions
public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges) Description copied from interface:ILayerTransforms the column position ranges relative to the given underlying layer to this layer coordinates.- Parameters:
sourceUnderlyingLayer- The underlying layer to which the given column positions match.underlyingColumnPositionRanges- The column position ranges relative to the given underlying layer that should be converted to local column positions.- Returns:
- The given column position ranges transformed to this layer.
-
getWidth
public int getWidth()Description copied from interface:ILayerReturns the total width in pixels of this layer.- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth() -
getColumnWidthByPosition
public int getColumnWidthByPosition(int column) Description copied from interface:ILayerReturns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Parameters:
column- The column position in this layer.- Returns:
- The width of the column.
-
isColumnPositionResizable
public boolean isColumnPositionResizable(int compositeColumnPosition) Description copied from interface:ILayerCheck if the column at the given position is resizable.- Parameters:
compositeColumnPosition- 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.- Parameters:
x- pixel position - starts from 0- 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.- Parameters:
columnPosition- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
getUnderlyingLayersByColumnPosition
Description copied from interface:ILayerReturns the layers that are directly below this layer for the given column position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a column.- Parameters:
columnPosition- The column position for which the underlying layers are requested.- Returns:
- The layers that are directly below this layer for the given
column position or
nullif this layer has no underlying layers.
-
getRowCount
public int getRowCount()- Returns:
- The number of rows in this layer.
-
getPreferredRowCount
public int getPreferredRowCount() -
getRowIndexByPosition
public int getRowIndexByPosition(int compositeRowPosition) Description copied from interface:ILayerGets the underlying non-transformed row index for the given row position on this layer.- Parameters:
compositeRowPosition- The row position relative to this layer.- Returns:
- An underlying non-transformed row index, or -1 if the given row position does not exist within this coordinate system.
-
localToUnderlyingRowPosition
public int localToUnderlyingRowPosition(int localRowPosition) Description copied from interface:ILayerConvert a row position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Parameters:
localRowPosition- row position in local (the layer's own) coordinates- Returns:
- row position in the underlying layer's coordinates
-
underlyingToLocalRowPosition
Description copied from interface:ILayerTransforms the row position relative to the given underlying layer to this layer coordinates.- Parameters:
sourceUnderlyingLayer- The underlying layer to which the given row position matches.underlyingRowPosition- The row position in the given underlying layer that should be converted to a local row position.- Returns:
- The given row position transformed to be local to this layer.
-
underlyingToLocalRowPositions
public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges) Description copied from interface:ILayerTransforms the row position ranges relative to the given underlying layer to this layer coordinates.- Parameters:
sourceUnderlyingLayer- The underlying layer to which the given row positions match.underlyingRowPositionRanges- The row position ranges relative to the given underlying layer that should be converted to local row positions.- Returns:
- The given row position ranges transformed to this layer.
-
getHeight
public int getHeight()Description copied from interface:ILayerReturns the total height in pixels of this layer.- Returns:
- The total height in pixels of this layer.
-
getPreferredHeight
public int getPreferredHeight() -
getRowHeightByPosition
public int getRowHeightByPosition(int row) Description copied from interface:ILayerReturns the height in pixels of the given row. The height of invisible and non-existing rows is 0.- Parameters:
row- The row position in this layer.- Returns:
- The height of the row.
-
isRowPositionResizable
public boolean isRowPositionResizable(int compositeRowPosition) Description copied from interface:ILayerCheck if the row at the given position is resizable.- Parameters:
compositeRowPosition- The row position to check.- Returns:
- false if the row position is out of bounds
-
getRowPositionByY
public int getRowPositionByY(int y) Get the row position relative to the layer the containing coordinate y.- Parameters:
y- Mouse event Y position.- Returns:
- a row position relative to the associated coordinate system, or -1 if there is no row that contains y
-
getStartYOfRowPosition
public int getStartYOfRowPosition(int rowPosition) Description copied from interface:ILayerReturns the y offset in pixels of the given row.- Parameters:
rowPosition- the row position in this layer- Returns:
- the y offset of the row, or -1
-
getUnderlyingLayersByRowPosition
Description copied from interface:ILayerReturns the layers that are directly below this layer for the given row position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a row.- Parameters:
rowPosition- The row position for which the underlying layers are requested.- Returns:
- The layers that are directly below this layer for the given row
position or
nullif this layer has no underlying layers.
-
getCellByPosition
Description copied from interface:ILayerReturns the cell for the given coordinates on this layer.- Specified by:
getCellByPositionin interfaceILayer- Overrides:
getCellByPositionin classAbstractLayer- Parameters:
compositeColumnPosition- The column position of the requested cell.compositeRowPosition- The row position of the requested cell.- Returns:
- The
ILayerCellfor the given coordinates in this layer ornullif the coordinates are invalid on this layer.
-
getBoundsByPosition
public org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int compositeColumnPosition, int compositeRowPosition) Description copied from interface:ILayerCalculates the bounds in pixel for the given cell position.- Specified by:
getBoundsByPositionin interfaceILayer- Overrides:
getBoundsByPositionin classAbstractLayer- Parameters:
compositeColumnPosition- the column position of the cellcompositeRowPosition- the row position of the cell- Returns:
- the bounds, or
nullif there are no valid bounds
-
getDisplayModeByPosition
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 classAbstractLayer- Parameters:
compositeColumnPosition- The column position of the cell.compositeRowPosition- The row position of the cell.- Returns:
DisplayModefor the cell at the given coordinates.
-
getConfigLabelsByPosition
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 classAbstractLayer- Parameters:
compositeColumnPosition- The column position of the cell.compositeRowPosition- The row position of the cell.- Returns:
- The
LabelStackwith the config labels for the cell at the given coordinates.
-
getDataValueByPosition
Description copied from interface:ILayerReturns the data value for the cell at the given coordinates.- Parameters:
compositeColumnPosition- The column position of the cell.compositeRowPosition- The row position of the cell.- Returns:
- The data value for the cell at the given coordinates.
-
getCellPainter
public ICellPainter getCellPainter(int compositeColumnPosition, int compositeRowPosition, ILayerCell cell, IConfigRegistry configRegistry) Description copied from interface:ILayerReturn theICellPainterfor the givenILayerCellat the given coordinates out of the givenIConfigRegistry.- Specified by:
getCellPainterin interfaceILayer- Overrides:
getCellPainterin classAbstractLayer- Parameters:
compositeColumnPosition- The column position of the cell.compositeRowPosition- The row position of the cell.cell- TheILayerCellfor which theICellPainteris requested.configRegistry- TheIConfigRegistryto retrieve the painter from.- Returns:
- The
ICellPainterfor the given cell at the given coordinates ornullif no painter is configured.
-
setChildLayer
-
getConfigLabelAccumulatorByRegionName
-
setConfigLabelAccumulatorForRegion
public void setConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) Sets the IConfigLabelAccumulator for the given named region. Replaces any existing IConfigLabelAccumulator.- Parameters:
regionName- the region name.configLabelAccumulator- theIConfigLabelAccumulatorto set.
-
addConfigLabelAccumulatorForRegion
public void addConfigLabelAccumulatorForRegion(String regionName, IConfigLabelAccumulator configLabelAccumulator) Adds the configLabelAccumulator to the existing label accumulators.- Parameters:
regionName- the region name.configLabelAccumulator- theIConfigLabelAccumulatorto add.
-
getChildLayerByLayoutCoordinate
- Parameters:
layoutX- col position in the CompositeLayerlayoutY- row position in the CompositeLayer- Returns:
- child layer according to the Composite Layer Layout
-
getChildLayerByRegionName
- Parameters:
regionName- The region name for which the child layer is requested.- Returns:
- The child layer that is registered for the given region name.
-
getRegionLabelsByXY
Description copied from interface:ILayerReturn theLabelStackcontaining the region labels for the cell at the given pixel position.- Specified by:
getRegionLabelsByXYin interfaceILayer- Overrides:
getRegionLabelsByXYin classAbstractLayer- Parameters:
x- pixel positiony- pixel position- Returns:
- Region which the given position is in
-
getUnderlyingLayerByPosition
Description copied from interface:ILayerReturns the layer that is directly below this layer for the given cell coordinate.- Parameters:
columnPosition- The column position for which the underlying layer is requested.rowPosition- The row position for which the underlying layer is requested.- Returns:
- The layer that is directly below this layer for the given cell
coordinates or
nullif this layer has no underlying layers.
-
getLayoutXYByChildLayer
-
getLayoutXByPixelX
protected int getLayoutXByPixelX(int x) -
getLayoutYByPixelY
protected int getLayoutYByPixelY(int y) -
getLayoutXYByPixelXY
protected org.eclipse.swt.graphics.Point getLayoutXYByPixelXY(int x, int y) -
getLayoutXByColumnPosition
protected int getLayoutXByColumnPosition(int compositeColumnPosition) -
getLayoutYByRowPosition
protected int getLayoutYByRowPosition(int compositeRowPosition) -
getLayoutXYByPosition
protected org.eclipse.swt.graphics.Point getLayoutXYByPosition(int compositeColumnPosition, int compositeRowPosition) -
getColumnPositionOffset
protected int getColumnPositionOffset(int layoutX) -
getWidthOffset
protected int getWidthOffset(int layoutX) -
getRowPositionOffset
protected int getRowPositionOffset(int layoutY) -
getHeightOffset
protected int getHeightOffset(int layoutY) -
getLayoutXCount
public int getLayoutXCount()- Returns:
- The number of column regions in this CompositeLayer.
-
getLayoutYCount
public int getLayoutYCount()- Returns:
- The number of row regions in this CompositeLayer.
-
getChildLayerLayout
- Returns:
- The internal data structure of the layer composition.
- Since:
- 1.6
-
isDynamicSizeLayer
public boolean isDynamicSizeLayer()- Specified by:
isDynamicSizeLayerin interfaceILayer- Overrides:
isDynamicSizeLayerin classAbstractLayer- Returns:
trueif the layer has a dynamic size (e.g. viewport) or a fixed size.
-
getProvidedLabels
- Specified by:
getProvidedLabelsin interfaceILayer- Overrides:
getProvidedLabelsin classAbstractLayer- Returns:
- The collection of labels that are provided by this layer.
-