Class AbstractLayer
java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IPersistable
- Direct Known Subclasses:
AbstractIndexLayerTransform
,AbstractLayerTransform
,CompositeLayer
,DataLayer
,DimensionallyDependentLayer
Base layer implementation with common methods for managing listeners and
caching, etc.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<Class<? extends ILayerCommand>,
ILayerCommandHandler<? extends ILayerCommand>> protected Map<Class<? extends ILayerEvent>,
ILayerEventHandler<? extends ILayerEvent>> protected ReadWriteLock
ReadWriteLock
that is used to ensure that no concurrent modifications happen on event handlingprotected ILayerPainter
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguration
(IConfiguration configuration) void
addLayerListener
(ILayerListener listener) Add a generalILayerListener
to handleILayerEvent
s on this layer.void
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) Pass the event to all theILayerListener
registered on this layer.org.eclipse.swt.graphics.Rectangle
getBoundsByPosition
(int columnPosition, int rowPosition) Calculates the bounds in pixel for the given cell position.getCellByPosition
(int columnPosition, int rowPosition) Returns the cell for the given coordinates on this layer.getCellPainter
(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.getConfigLabelsByPosition
(int columnPosition, int rowPosition) Returns the config labels for the cell at the given coordinates.getDisplayModeByPosition
(int columnPosition, int rowPosition) Returns the activeDisplayMode
for the cell at the given coordinates.getRegionLabelsByXY
(int x, int y) Return theLabelStack
containing the region labels for the cell at the given pixel position.void
handleLayerEvent
(ILayerEvent event) Handle layer event notification.boolean
hasLayerListener
(Class<? extends ILayerListener> layerListenerClass) Check if anILayerListener
of the given type is registered on this layer or not.boolean
void
loadState
(String prefix, Properties properties) Restore the state out of the given Properties identified by the specified prefix.void
registerCommandHandler
(ILayerCommandHandler<?> commandHandler) Register anILayerCommandHandler
to handle a command in this layer.protected void
Layers should use this method to register their command handlers and call it from their constructor.void
registerEventHandler
(ILayerEventHandler<?> eventHandler) 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
saveState
(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.void
setClientAreaProvider
(IClientAreaProvider clientAreaProvider) void
setConfigLabelAccumulator
(IConfigLabelAccumulator cellLabelAccumulator) void
setLayerPainter
(ILayerPainter layerPainter) void
setRegionName
(String regionName) toString()
void
unregisterCommandHandler
(Class<? extends ILayerCommand> commandClass) Unregister theILayerCommandHandler
that is registered for the givenILayerCommand
class.void
unregisterEventHandler
(ILayerEventHandler<?> eventHandler) void
unregisterPersistable
(IPersistable persistable) Unregister the givenIPersistable
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getDataValueByPosition, getHeight, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isRowPositionResizable, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions
-
Field Details
-
layerPainter
-
commandHandlers
protected final Map<Class<? extends ILayerCommand>,ILayerCommandHandler<? extends ILayerCommand>> commandHandlers -
eventHandlers
-
eventHelperLock
ReadWriteLock
that is used to ensure that no concurrent modifications happen on event handling- Since:
- 1.4
-
-
Constructor Details
-
AbstractLayer
public AbstractLayer()
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:ILayer
Dispose any resource allocated by this layer. -
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
- Parameters:
x
- the x pixel coordinatey
- the y pixel coordinate- Returns:
- LabelStack containing the region labels for the cell at the given pixel position.
-
getRegionName
-
setRegionName
-
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
- 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.
-
getConfigLabelAccumulator
-
setConfigLabelAccumulator
-
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
- 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:IPersistable
Restore 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:
loadState
in interfaceIPersistable
- 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.
-
registerPersistable
Description copied from interface:ILayer
Register anIPersistable
that can write its state to the stateProperties
instance when the layer is persisted.- Specified by:
registerPersistable
in interfaceILayer
- Parameters:
persistable
- The persistable that should be registered.
-
unregisterPersistable
Description copied from interface:ILayer
Unregister the givenIPersistable
.- Specified by:
unregisterPersistable
in interfaceILayer
- Parameters:
persistable
- The persistable to unregister.
-
addConfiguration
-
clearConfiguration
public void clearConfiguration() -
configure
Description copied from interface:ILayer
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.- Specified by:
configure
in interfaceILayer
- Parameters:
configRegistry
- TheIConfigRegistry
instance owned by theNatTable
this layer is attached to.uiBindingRegistry
- TheUiBindingRegistry
instance owned byNatTable
this layer is attached to.
-
doCommand
Description copied from interface:ILayer
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)
-
registerCommandHandlers
protected void registerCommandHandlers()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 -
registerCommandHandler
Description copied from interface:ILayer
Register anILayerCommandHandler
to handle a command in this layer. Only oneILayerCommandHandler
perILayerCommand
can be registered per layer.- Specified by:
registerCommandHandler
in interfaceILayer
- Parameters:
commandHandler
- The command handler to register with this layer.
-
unregisterCommandHandler
Description copied from interface:ILayer
Unregister theILayerCommandHandler
that is registered for the givenILayerCommand
class.- Specified by:
unregisterCommandHandler
in interfaceILayer
- Parameters:
commandClass
- TheILayerCommand
class for which theILayerCommandHandler
should be unregistered.
-
addLayerListener
Description copied from interface:ILayer
Add a generalILayerListener
to handleILayerEvent
s on this layer.- Specified by:
addLayerListener
in interfaceILayer
- Parameters:
listener
- TheILayerListener
to add.
-
removeLayerListener
Description copied from interface:ILayer
Remove the givenILayerListener
from this layer.- Specified by:
removeLayerListener
in interfaceILayer
- Parameters:
listener
- TheILayerListener
to remove.
-
hasLayerListener
Description copied from interface:ILayer
Check if anILayerListener
of the given type is registered on this layer or not.- Specified by:
hasLayerListener
in interfaceILayer
- 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.
-
handleLayerEvent
Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by callingsuper.fireLayerEvent(event)
- unless you plan to eat the event yourself.- Specified by:
handleLayerEvent
in interfaceILayerListener
- Parameters:
event
- the event
-
registerEventHandler
-
unregisterEventHandler
-
fireLayerEvent
Pass the event to all theILayerListener
registered on this layer. A cloned copy is passed to each listener.- Specified by:
fireLayerEvent
in interfaceILayer
- Parameters:
event
- the event to fire
-
getLayerPainter
- Specified by:
getLayerPainter
in interfaceILayer
- Returns:
ILayerPainter
. Defaults toGridLineCellLayerPainter
-
setLayerPainter
-
getClientAreaProvider
- Specified by:
getClientAreaProvider
in interfaceILayer
- Returns:
- The
IClientAreaProvider
that specifies the rectangular area available on this layer.
-
setClientAreaProvider
- Specified by:
setClientAreaProvider
in interfaceILayer
- Parameters:
clientAreaProvider
- TheIClientAreaProvider
that specifies the rectangular area available on this layer.
-
toString
-
getCellByPosition
Description copied from interface:ILayer
Returns the cell for the given coordinates on this layer.- Specified by:
getCellByPosition
in interfaceILayer
- 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
public org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition, int rowPosition) Description copied from interface:ILayer
Calculates the bounds in pixel for the given cell position.- Specified by:
getBoundsByPosition
in interfaceILayer
- 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
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
- Parameters:
columnPosition
- The column position of the cell.rowPosition
- The row position of the cell.- Returns:
DisplayMode
for the cell at the given coordinates.
-
getCellPainter
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Description copied from interface:ILayer
Return theICellPainter
for the givenILayerCell
at the given coordinates out of the givenIConfigRegistry
.- Specified by:
getCellPainter
in interfaceILayer
- 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
public boolean isDynamicSizeLayer()- Specified by:
isDynamicSizeLayer
in interfaceILayer
- Returns:
true
if the layer has a dynamic size (e.g. viewport) or a fixed size.- Since:
- 1.4
-
getProvidedLabels
- Specified by:
getProvidedLabels
in interfaceILayer
- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-