Interface ILayer
-
- All Superinterfaces:
ILayerListener
,IPersistable
- All Known Subinterfaces:
IUniqueIndexLayer
- All Known Implementing Classes:
_001_Getting_Started.BodyLayerStack
,_001_Getting_Started.ColumnHeaderLayerStack
,_001_Getting_Started.RowHeaderLayerStack
,_804_GlazedListsEditorExample.GlazedListsEditorColumnHeaderLayerStack
,AbstractColumnHideShowLayer
,AbstractIndexLayerTransform
,AbstractLayer
,AbstractLayerTransform
,AbstractRowHideShowLayer
,BaseColumnReorderLayerFixture
,BaseDataLayerFixture
,BaseDataLayerFixture
,BaseRowReorderLayerFixture
,BlinkLayer
,BodyLayerStackFixture
,ColumnGroupBodyLayerStack
,ColumnGroupExpandCollapseLayer
,ColumnGroupExpandCollapseLayer
,ColumnGroupGroupHeaderLayer
,ColumnGroupHeaderLayer
,ColumnGroupHeaderLayer
,ColumnGroupReorderLayer
,ColumnHeaderLayer
,ColumnHeaderLayerFixture
,ColumnHideShowLayer
,ColumnHideShowLayerFixture
,ColumnReorderLayer
,ColumnReorderLayerFixture
,ColumnStructureUpdatesExampleGridLayer
,ComboBoxFilterRowHeaderComposite
,CompositeFreezeLayer
,CompositeLayer
,CompositeLayerFixture
,CornerLayer
,DataChangeLayer
,DataLayer
,DataLayerFixture
,DataLayerFixture
,DefaultBodyLayerStack
,DefaultColumnHeaderDataLayer
,DefaultGridLayer
,DefaultRowHeaderDataLayer
,DetailGlazedListsEventLayer
,DimensionallyDependentIndexLayer
,DimensionallyDependentLayer
,DummyGridLayerStack
,FilterRowDataLayer
,FilterRowExampleGridLayer
,FilterRowHeaderComposite
,FixedSummaryRowHeaderLayer
,FixedSummaryRowLayer
,FreezeLayer
,FullFeaturedBodyLayerStack
,FullFeaturedColumnHeaderLayerStack
,GenericLayerFixture
,GlazedListsColumnHeaderLayerStack
,GlazedListsEventLayer
,GlazedListsGridLayer
,GlazedListsGridLayer
,GlazedListsRowHideShowLayer
,GridLayer
,GridLayerFixture
,GroupByDataLayer
,GroupByHeaderLayer
,HierarchicalTreeLayer
,HoverLayer
,InvertedLayer
,NatTable
,NatTableFixture
,NatTableFixture
,ResizeColumnHideShowLayer
,RowGroupExpandCollapseLayer
,RowGroupExpandCollapseLayer
,RowGroupHeaderLayer
,RowGroupHeaderLayer
,RowHeaderLayer
,RowHideShowLayer
,RowHideShowLayerFixture
,RowIdHideShowLayer
,RowReorderLayer
,RowReorderLayerFixture
,SelectionExampleBodyLayerStack
,SelectionExampleGridLayer
,SelectionLayer
,SortHeaderLayer
,SpanningDataLayer
,StaticFilterExampleGridLayer
,SummaryRowLayer
,TestLayer
,TreeLayer
,ViewportLayer
,ViewportLayerFixture
,ViewportLayerFixture
public interface ILayer extends ILayerListener, IPersistable
A Layer is a rectangular region of grid cells. A layer has methods to access its columns, rows, width and height. A layer can be stacked on top of another layer in order to expose a transformed view of its underlying layer's grid cell structure.
Columns and rows in a layer are referenced either by position or index. The position of a column/row in a layer corresponds to the physical location of the column/row in the layer. The index of a column/row in a layer corresponds to the location of the column/row in the lowest level layer in the layer stack. These concepts are illustrated by the following example:
Hide Layer C 0 1 2 3 4 <- column positions 1 0 3 4 5 <- column indexes Reorder Layer B 0 1 2 3 4 5 <- column positions 2 1 0 3 4 5 <- column indexes Data Layer A 0 1 2 3 4 5 <- column positions 0 1 2 3 4 5 <- column indexes
In the above example, Hide Layer C is stacked on top of Reorder Layer B, which is in turn stacked on top of Data Layer A. The positions in Data Layer A are the same as its indexes, because it is the lowest level layer in the stack. Reorder Layer B reorders column 0 of its underlying layer (Data Layer A) after column 2 of its underlying layer. Hide Layer C hides the first column of its underlying layer (Reorder Layer B).
Layers can also be laterally composed into larger layers. For instance, the standard grid layer is composed of a body layer, column header layer, row header layer, and corner layer:
layer composition corner column header row header body - See Also:
CompositeLayer
-
-
Field Summary
-
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addLayerListener(ILayerListener listener)
Add a generalILayerListener
to handleILayerEvent
s on this layer.void
configure(IConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
Configure this layer, e.g.void
dispose()
Dispose any resource allocated by this layer.boolean
doCommand(ILayerCommand command)
Opportunity to respond to a command as it flows down the stack.void
fireLayerEvent(ILayerEvent event)
Events can be fired to notify other components of the grid.org.eclipse.swt.graphics.Rectangle
getBoundsByPosition(int columnPosition, int rowPosition)
Calculates the bounds in pixel for the given cell position.ILayerCell
getCellByPosition(int columnPosition, int rowPosition)
Returns the cell for the given coordinates on this layer.ICellPainter
getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.IClientAreaProvider
getClientAreaProvider()
int
getColumnCount()
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.LabelStack
getConfigLabelsByPosition(int columnPosition, int rowPosition)
Returns the config labels for the cell at the given coordinates.Object
getDataValueByPosition(int columnPosition, int rowPosition)
Returns the data value for the cell at the given coordinates.DisplayMode
getDisplayModeByPosition(int columnPosition, int rowPosition)
Returns the activeDisplayMode
for the cell at the given coordinates.int
getHeight()
Returns the total height in pixels of this layer.ILayerPainter
getLayerPainter()
int
getPreferredColumnCount()
int
getPreferredHeight()
int
getPreferredRowCount()
int
getPreferredWidth()
default Collection<String>
getProvidedLabels()
LabelStack
getRegionLabelsByXY(int x, int y)
Return theLabelStack
containing the region labels for the cell at the given pixel position.int
getRowCount()
int
getRowHeightByPosition(int rowPosition)
Returns the height in pixels of the given row.int
getRowIndexByPosition(int rowPosition)
Gets the underlying non-transformed row index for the given row position on this layer.int
getRowPositionByY(int y)
Returns the row position that contains the given y coordinate.int
getStartXOfColumnPosition(int columnPosition)
Returns the x offset in pixels of the given column.int
getStartYOfRowPosition(int rowPosition)
Returns the y offset in pixels of the given row.ILayer
getUnderlyingLayerByPosition(int columnPosition, int rowPosition)
Returns the layer that is directly below this layer for the given cell coordinate.Collection<ILayer>
getUnderlyingLayersByColumnPosition(int columnPosition)
Returns the layers that are directly below this layer for the given column position.Collection<ILayer>
getUnderlyingLayersByRowPosition(int rowPosition)
Returns the layers that are directly below this layer for the given row position.int
getWidth()
Returns the total width in pixels of this layer.boolean
hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
Check if anILayerListener
of the given type is registered on this layer or not.boolean
isColumnPositionResizable(int columnPosition)
Check if the column at the given position is resizable.default boolean
isDynamicSizeLayer()
boolean
isRowPositionResizable(int rowPosition)
Check if the row at the given position is resizable.int
localToUnderlyingColumnPosition(int localColumnPosition)
Convert a column position to the coordinates of the underlying layer.int
localToUnderlyingRowPosition(int localRowPosition)
Convert a row position to the coordinates of the underlying layer.void
registerCommandHandler(ILayerCommandHandler<?> commandHandler)
Register anILayerCommandHandler
to handle a command in this layer.void
registerPersistable(IPersistable persistable)
Register anIPersistable
that can write its state to the stateProperties
instance when the layer is persisted.void
removeLayerListener(ILayerListener listener)
Remove the givenILayerListener
from this layer.void
setClientAreaProvider(IClientAreaProvider clientAreaProvider)
int
underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
Transforms the column position relative to the given underlying layer to this layer coordinates.Collection<Range>
underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
Transforms the column position ranges relative to the given underlying layer to this layer coordinates.int
underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
Transforms the row position relative to the given underlying layer to this layer coordinates.Collection<Range>
underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges)
Transforms the row position ranges relative to the given underlying layer to this layer coordinates.void
unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
Unregister theILayerCommandHandler
that is registered for the givenILayerCommand
class.void
unregisterPersistable(IPersistable persistable)
Unregister the givenIPersistable
.-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayerListener
handleLayerEvent
-
Methods inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
loadState, saveState
-
-
-
-
Method Detail
-
dispose
void dispose()
Dispose any resource allocated by this layer.
-
registerPersistable
void registerPersistable(IPersistable persistable)
Register anIPersistable
that can write its state to the stateProperties
instance when the layer is persisted.- Parameters:
persistable
- The persistable that should be registered.
-
unregisterPersistable
void unregisterPersistable(IPersistable persistable)
Unregister the givenIPersistable
.- Parameters:
persistable
- The persistable to unregister.
-
configure
void configure(IConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
Configure 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.- Parameters:
configRegistry
- TheIConfigRegistry
instance owned by theNatTable
this layer is attached to.uiBindingRegistry
- TheUiBindingRegistry
instance owned byNatTable
this layer is attached to.- Since:
- 2.0
-
getRegionLabelsByXY
LabelStack getRegionLabelsByXY(int x, int y)
Return theLabelStack
containing the region labels for the cell at the given pixel position.- Parameters:
x
- the x pixel coordinatey
- the y pixel coordinate- Returns:
- LabelStack containing the region labels for the cell at the given pixel position.
-
doCommand
boolean doCommand(ILayerCommand command)
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)
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
registerCommandHandler
void registerCommandHandler(ILayerCommandHandler<?> commandHandler)
Register anILayerCommandHandler
to handle a command in this layer. Only oneILayerCommandHandler
perILayerCommand
can be registered per layer.- Parameters:
commandHandler
- The command handler to register with this layer.
-
unregisterCommandHandler
void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
Unregister theILayerCommandHandler
that is registered for the givenILayerCommand
class.- Parameters:
commandClass
- TheILayerCommand
class for which theILayerCommandHandler
should be unregistered.
-
fireLayerEvent
void fireLayerEvent(ILayerEvent event)
Events can be fired to notify other components of the grid. Events travel up the layer stack and may cause a repaint.Example: When the contents of the grid change
IVisualChangeEvent
can be fired to notify other layers to refresh their caches etc.- Parameters:
event
- the event to fire
-
addLayerListener
void addLayerListener(ILayerListener listener)
Add a generalILayerListener
to handleILayerEvent
s on this layer.- Parameters:
listener
- TheILayerListener
to add.
-
removeLayerListener
void removeLayerListener(ILayerListener listener)
Remove the givenILayerListener
from this layer.- Parameters:
listener
- TheILayerListener
to remove.
-
hasLayerListener
boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
Check if anILayerListener
of the given type is registered on this layer or not.- Parameters:
layerListenerClass
- The type ofILayerListener
to check for.- Returns:
true
if thisILayer
has aILayerListener
of the specified type registered,false
if there is no such listener registered.
-
getLayerPainter
ILayerPainter getLayerPainter()
- Returns:
- The
ILayerPainter
used to render this layer.
-
getClientAreaProvider
IClientAreaProvider getClientAreaProvider()
- Returns:
- The
IClientAreaProvider
that specifies the rectangular area available on this layer.
-
setClientAreaProvider
void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
- Parameters:
clientAreaProvider
- TheIClientAreaProvider
that specifies the rectangular area available on this layer.
-
getColumnCount
int getColumnCount()
- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
int getPreferredColumnCount()
-
getColumnIndexByPosition
int getColumnIndexByPosition(int columnPosition)
Gets the underlying non-transformed column index for the given column position on this layer.- 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
int localToUnderlyingColumnPosition(int localColumnPosition)
Convert 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
int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition)
Transforms 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
Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
Transforms 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
int getWidth()
Returns the total width in pixels of this layer.- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
int getPreferredWidth()
-
getColumnWidthByPosition
int getColumnWidthByPosition(int columnPosition)
Returns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The width of the column.
-
isColumnPositionResizable
boolean isColumnPositionResizable(int columnPosition)
Check if the column at the given position is resizable.- Parameters:
columnPosition
- The column position to check.- Returns:
true
if the column is resizable,false
if not.
-
getColumnPositionByX
int getColumnPositionByX(int x)
Returns the column position that contains the given x coordinate.- 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
int getStartXOfColumnPosition(int columnPosition)
Returns 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
Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)
Returns 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
null
if this layer has no underlying layers.
-
getRowCount
int getRowCount()
- Returns:
- The number of rows in this layer.
-
getPreferredRowCount
int getPreferredRowCount()
-
getRowIndexByPosition
int getRowIndexByPosition(int rowPosition)
Gets the underlying non-transformed row index for the given row position on this layer.- Parameters:
rowPosition
- 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
int localToUnderlyingRowPosition(int localRowPosition)
Convert 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
int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
Transforms 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
Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges)
Transforms 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
int getHeight()
Returns the total height in pixels of this layer.- Returns:
- The total height in pixels of this layer.
-
getPreferredHeight
int getPreferredHeight()
-
getRowHeightByPosition
int getRowHeightByPosition(int rowPosition)
Returns the height in pixels of the given row. The height of invisible and non-existing rows is 0.- Parameters:
rowPosition
- The row position in this layer.- Returns:
- The height of the row.
-
isRowPositionResizable
boolean isRowPositionResizable(int rowPosition)
Check if the row at the given position is resizable.- Parameters:
rowPosition
- The row position to check.- Returns:
true
if the row is resizable,false
if not.
-
getRowPositionByY
int getRowPositionByY(int y)
Returns the row position that contains the given y coordinate.- Parameters:
y
- a vertical pixel location relative to the pixel boundary of this layer- Returns:
- a row position relative to the associated coordinate system, or -1 if there is no row that contains y
-
getStartYOfRowPosition
int getStartYOfRowPosition(int rowPosition)
Returns 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
Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)
Returns 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
null
if this layer has no underlying layers.
-
getCellByPosition
ILayerCell getCellByPosition(int columnPosition, int rowPosition)
Returns the cell for the given coordinates on this layer.- 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.
-
getBoundsByPosition
org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition, int rowPosition)
Calculates the bounds in pixel for the given cell position.- Parameters:
columnPosition
- the column position of the cellrowPosition
- the row position of the cell- Returns:
- the bounds, or
null
if there are no valid bounds
-
getDisplayModeByPosition
DisplayMode getDisplayModeByPosition(int columnPosition, int rowPosition)
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.- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
DisplayMode
for the cell at the given coordinates.- Since:
- 2.0
-
getConfigLabelsByPosition
LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry
.- 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
Object getDataValueByPosition(int columnPosition, int rowPosition)
Returns the data value for the cell at the given coordinates.- 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.
-
getUnderlyingLayerByPosition
ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition)
Returns 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
null
if this layer has no underlying layers.
-
getCellPainter
ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.cell
- TheILayerCell
for which theICellPainter
is requested.configRegistry
- TheIConfigRegistry
to retrieve the painter from.- Returns:
- The
ICellPainter
for the given cell at the given coordinates ornull
if no painter is configured.
-
isDynamicSizeLayer
default boolean isDynamicSizeLayer()
- Returns:
true
if the layer has a dynamic size (e.g. viewport) or a fixed size.- Since:
- 2.0
-
getProvidedLabels
default Collection<String> getProvidedLabels()
- Returns:
- The collection of labels that are provided by this layer used e.g. for CSS styling.
- Since:
- 2.0
-
-