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

public abstract class AbstractLayer extends Object implements ILayer
Base layer implementation with common methods for managing listeners and caching, etc.
  • Field Details

  • Constructor Details

    • AbstractLayer

      public AbstractLayer()
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: ILayer
      Dispose any resource allocated by this layer.
      Specified by:
      dispose in interface ILayer
    • getRegionLabelsByXY

      public LabelStack getRegionLabelsByXY(int x, int y)
      Description copied from interface: ILayer
      Return the LabelStack containing the region labels for the cell at the given pixel position.
      Specified by:
      getRegionLabelsByXY in interface ILayer
      Parameters:
      x - the x pixel coordinate
      y - the y pixel coordinate
      Returns:
      LabelStack containing the region labels for the cell at the given pixel position.
    • getRegionName

      public String getRegionName()
    • setRegionName

      public void setRegionName(String regionName)
    • getConfigLabelsByPosition

      public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
      Specified by:
      getConfigLabelsByPosition in interface ILayer
      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

      public IConfigLabelAccumulator getConfigLabelAccumulator()
    • setConfigLabelAccumulator

      public void setConfigLabelAccumulator(IConfigLabelAccumulator cellLabelAccumulator)
    • saveState

      public void saveState(String prefix, Properties properties)
      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 interface IPersistable
      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

      public void loadState(String prefix, Properties properties)
      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 interface IPersistable
      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

      public void registerPersistable(IPersistable persistable)
      Description copied from interface: ILayer
      Register an IPersistable that can write its state to the state Properties instance when the layer is persisted.
      Specified by:
      registerPersistable in interface ILayer
      Parameters:
      persistable - The persistable that should be registered.
    • unregisterPersistable

      public void unregisterPersistable(IPersistable persistable)
      Description copied from interface: ILayer
      Unregister the given IPersistable.
      Specified by:
      unregisterPersistable in interface ILayer
      Parameters:
      persistable - The persistable to unregister.
    • addConfiguration

      public void addConfiguration(IConfiguration configuration)
    • clearConfiguration

      public void clearConfiguration()
    • configure

      public void configure(IConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
      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 interface ILayer
      Parameters:
      configRegistry - The IConfigRegistry instance owned by the NatTable this layer is attached to.
      uiBindingRegistry - The UiBindingRegistry instance owned by NatTable this layer is attached to.
    • doCommand

      public boolean doCommand(ILayerCommand command)
      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)

      Specified by:
      doCommand in interface ILayer
      Parameters:
      command - The command to execute.
      Returns:
      true if the command has been handled and was therefore consumed, false otherwise.
    • 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

      public void registerCommandHandler(ILayerCommandHandler<?> commandHandler)
      Description copied from interface: ILayer
      Register an ILayerCommandHandler to handle a command in this layer. Only one ILayerCommandHandler per ILayerCommand can be registered per layer.
      Specified by:
      registerCommandHandler in interface ILayer
      Parameters:
      commandHandler - The command handler to register with this layer.
    • unregisterCommandHandler

      public void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
      Description copied from interface: ILayer
      Unregister the ILayerCommandHandler that is registered for the given ILayerCommand class.
      Specified by:
      unregisterCommandHandler in interface ILayer
      Parameters:
      commandClass - The ILayerCommand class for which the ILayerCommandHandler should be unregistered.
    • addLayerListener

      public void addLayerListener(ILayerListener listener)
      Description copied from interface: ILayer
      Add a general ILayerListener to handle ILayerEvents on this layer.
      Specified by:
      addLayerListener in interface ILayer
      Parameters:
      listener - The ILayerListener to add.
    • removeLayerListener

      public void removeLayerListener(ILayerListener listener)
      Description copied from interface: ILayer
      Remove the given ILayerListener from this layer.
      Specified by:
      removeLayerListener in interface ILayer
      Parameters:
      listener - The ILayerListener to remove.
    • hasLayerListener

      public boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
      Description copied from interface: ILayer
      Check if an ILayerListener of the given type is registered on this layer or not.
      Specified by:
      hasLayerListener in interface ILayer
      Parameters:
      layerListenerClass - The type of ILayerListener to check for.
      Returns:
      true if this ILayer has a ILayerListener of the specified type registered, false if there is no such listener registered.
    • handleLayerEvent

      public void handleLayerEvent(ILayerEvent event)
      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 calling super.fireLayerEvent(event) - unless you plan to eat the event yourself.
      Specified by:
      handleLayerEvent in interface ILayerListener
      Parameters:
      event - the event
    • registerEventHandler

      public void registerEventHandler(ILayerEventHandler<?> eventHandler)
    • unregisterEventHandler

      public void unregisterEventHandler(ILayerEventHandler<?> eventHandler)
    • fireLayerEvent

      public void fireLayerEvent(ILayerEvent event)
      Pass the event to all the ILayerListener registered on this layer. A cloned copy is passed to each listener.
      Specified by:
      fireLayerEvent in interface ILayer
      Parameters:
      event - the event to fire
    • getLayerPainter

      public ILayerPainter getLayerPainter()
      Specified by:
      getLayerPainter in interface ILayer
      Returns:
      ILayerPainter. Defaults to GridLineCellLayerPainter
    • setLayerPainter

      public void setLayerPainter(ILayerPainter layerPainter)
    • getClientAreaProvider

      public IClientAreaProvider getClientAreaProvider()
      Specified by:
      getClientAreaProvider in interface ILayer
      Returns:
      The IClientAreaProvider that specifies the rectangular area available on this layer.
    • setClientAreaProvider

      public void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
      Specified by:
      setClientAreaProvider in interface ILayer
      Parameters:
      clientAreaProvider - The IClientAreaProvider that specifies the rectangular area available on this layer.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCellByPosition

      public ILayerCell getCellByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the cell for the given coordinates on this layer.
      Specified by:
      getCellByPosition in interface ILayer
      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 or null 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 interface ILayer
      Parameters:
      columnPosition - the column position of the cell
      rowPosition - the row position of the cell
      Returns:
      the bounds, or null if there are no valid bounds
    • getDisplayModeByPosition

      public DisplayMode getDisplayModeByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the active DisplayMode for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry. The default value is DisplayMode.NORMAL. The SelectionLayer for example overrides this to return DisplayMode.SELECT for cells that are currently selected.
      Specified by:
      getDisplayModeByPosition in interface ILayer
      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 the ICellPainter for the given ILayerCell at the given coordinates out of the given IConfigRegistry.
      Specified by:
      getCellPainter in interface ILayer
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      cell - The ILayerCell for which the ICellPainter is requested.
      configRegistry - The IConfigRegistry to retrieve the painter from.
      Returns:
      The ICellPainter for the given cell at the given coordinates or null if no painter is configured.
    • isDynamicSizeLayer

      public boolean isDynamicSizeLayer()
      Specified by:
      isDynamicSizeLayer in interface ILayer
      Returns:
      true if the layer has a dynamic size (e.g. viewport) or a fixed size.
      Since:
      1.4
    • getProvidedLabels

      public Collection<String> getProvidedLabels()
      Specified by:
      getProvidedLabels in interface ILayer
      Returns:
      The collection of labels that are provided by this layer.
      Since:
      1.4