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
FieldsModifier and TypeFieldDescriptionprotected final Map<Class<? extends ILayerCommand>,ILayerCommandHandler<? extends ILayerCommand>> protected Map<Class<? extends ILayerEvent>,ILayerEventHandler<? extends ILayerEvent>> protected ReadWriteLockReadWriteLockthat is used to ensure that no concurrent modifications happen on event handlingprotected ILayerPainterFields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfiguration(IConfiguration configuration) voidaddLayerListener(ILayerListener listener) Add a generalILayerListenerto handleILayerEvents on this layer.voidvoidconfigure(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.voidfireLayerEvent(ILayerEvent event) Pass the event to all theILayerListenerregistered on this layer.org.eclipse.swt.graphics.RectanglegetBoundsByPosition(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 theICellPainterfor the givenILayerCellat 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 activeDisplayModefor the cell at the given coordinates.getRegionLabelsByXY(int x, int y) Return theLabelStackcontaining the region labels for the cell at the given pixel position.voidhandleLayerEvent(ILayerEvent event) Handle layer event notification.booleanhasLayerListener(Class<? extends ILayerListener> layerListenerClass) Check if anILayerListenerof the given type is registered on this layer or not.booleanvoidloadState(String prefix, Properties properties) Restore the state out of the given Properties identified by the specified prefix.voidregisterCommandHandler(ILayerCommandHandler<?> commandHandler) Register anILayerCommandHandlerto handle a command in this layer.protected voidLayers should use this method to register their command handlers and call it from their constructor.voidregisterEventHandler(ILayerEventHandler<?> eventHandler) voidregisterPersistable(IPersistable persistable) Register anIPersistablethat can write its state to the statePropertiesinstance when the layer is persisted.voidremoveLayerListener(ILayerListener listener) Remove the givenILayerListenerfrom this layer.voidsaveState(String prefix, Properties properties) Saves the state to the given Properties using the specified prefix.voidsetClientAreaProvider(IClientAreaProvider clientAreaProvider) voidsetConfigLabelAccumulator(IConfigLabelAccumulator cellLabelAccumulator) voidsetLayerPainter(ILayerPainter layerPainter) voidsetRegionName(String regionName) toString()voidunregisterCommandHandler(Class<? extends ILayerCommand> commandClass) Unregister theILayerCommandHandlerthat is registered for the givenILayerCommandclass.voidunregisterEventHandler(ILayerEventHandler<?> eventHandler) voidunregisterPersistable(IPersistable persistable) Unregister the givenIPersistable.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
ReadWriteLockthat 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:ILayerDispose any resource allocated by this layer. -
getRegionLabelsByXY
Description copied from interface:ILayerReturn theLabelStackcontaining the region labels for the cell at the given pixel position.- Specified by:
getRegionLabelsByXYin 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:ILayerReturns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of theIConfigRegistry.- Specified by:
getConfigLabelsByPositionin interfaceILayer- 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.
-
getConfigLabelAccumulator
-
setConfigLabelAccumulator
-
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- 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- 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:ILayerRegister anIPersistablethat can write its state to the statePropertiesinstance when the layer is persisted.- Specified by:
registerPersistablein interfaceILayer- Parameters:
persistable- The persistable that should be registered.
-
unregisterPersistable
Description copied from interface:ILayerUnregister the givenIPersistable.- Specified by:
unregisterPersistablein interfaceILayer- Parameters:
persistable- The persistable to unregister.
-
addConfiguration
-
clearConfiguration
public void clearConfiguration() -
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- Parameters:
configRegistry- TheIConfigRegistryinstance owned by theNatTablethis layer is attached to.uiBindingRegistry- TheUiBindingRegistryinstance owned byNatTablethis layer is attached to.
-
doCommand
Description copied from interface:ILayerOpportunity 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:ILayerRegister anILayerCommandHandlerto handle a command in this layer. Only oneILayerCommandHandlerperILayerCommandcan be registered per layer.- Specified by:
registerCommandHandlerin interfaceILayer- Parameters:
commandHandler- The command handler to register with this layer.
-
unregisterCommandHandler
Description copied from interface:ILayerUnregister theILayerCommandHandlerthat is registered for the givenILayerCommandclass.- Specified by:
unregisterCommandHandlerin interfaceILayer- Parameters:
commandClass- TheILayerCommandclass for which theILayerCommandHandlershould be unregistered.
-
addLayerListener
Description copied from interface:ILayerAdd a generalILayerListenerto handleILayerEvents on this layer.- Specified by:
addLayerListenerin interfaceILayer- Parameters:
listener- TheILayerListenerto add.
-
removeLayerListener
Description copied from interface:ILayerRemove the givenILayerListenerfrom this layer.- Specified by:
removeLayerListenerin interfaceILayer- Parameters:
listener- TheILayerListenerto remove.
-
hasLayerListener
Description copied from interface:ILayerCheck if anILayerListenerof the given type is registered on this layer or not.- Specified by:
hasLayerListenerin interfaceILayer- Parameters:
layerListenerClass- The type ofILayerListenerto check for.- Returns:
trueif thisILayerhas aILayerListenerof the specified type registered,falseif 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:
handleLayerEventin interfaceILayerListener- Parameters:
event- the event
-
registerEventHandler
-
unregisterEventHandler
-
fireLayerEvent
Pass the event to all theILayerListenerregistered on this layer. A cloned copy is passed to each listener.- Specified by:
fireLayerEventin interfaceILayer- Parameters:
event- the event to fire
-
getLayerPainter
- Specified by:
getLayerPainterin interfaceILayer- Returns:
ILayerPainter. Defaults toGridLineCellLayerPainter
-
setLayerPainter
-
getClientAreaProvider
- Specified by:
getClientAreaProviderin interfaceILayer- Returns:
- The
IClientAreaProviderthat specifies the rectangular area available on this layer.
-
setClientAreaProvider
- Specified by:
setClientAreaProviderin interfaceILayer- Parameters:
clientAreaProvider- TheIClientAreaProviderthat specifies the rectangular area available on this layer.
-
toString
-
getCellByPosition
Description copied from interface:ILayerReturns the cell for the given coordinates on this layer.- Specified by:
getCellByPositionin interfaceILayer- 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.
-
getBoundsByPosition
public org.eclipse.swt.graphics.Rectangle getBoundsByPosition(int columnPosition, int rowPosition) Description copied from interface:ILayerCalculates the bounds in pixel for the given cell position.- Specified by:
getBoundsByPositionin interfaceILayer- Parameters:
columnPosition- the column position of the cellrowPosition- 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- Parameters:
columnPosition- The column position of the cell.rowPosition- The row position of the cell.- Returns:
DisplayModefor the cell at the given coordinates.
-
getCellPainter
public ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry) Description copied from interface:ILayerReturn theICellPainterfor the givenILayerCellat the given coordinates out of the givenIConfigRegistry.- Specified by:
getCellPainterin interfaceILayer- Parameters:
columnPosition- The column position of the cell.rowPosition- 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.
-
isDynamicSizeLayer
public boolean isDynamicSizeLayer()- Specified by:
isDynamicSizeLayerin interfaceILayer- Returns:
trueif the layer has a dynamic size (e.g. viewport) or a fixed size.- Since:
- 1.4
-
getProvidedLabels
- Specified by:
getProvidedLabelsin interfaceILayer- Returns:
- The collection of labels that are provided by this layer.
- Since:
- 1.4
-