org.eclipse.nebula.widgets.nattable.layer
Class AbstractLayer

java.lang.Object
  extended by 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 Summary
protected  Map<Class<? extends ILayerCommand>,ILayerCommandHandler<? extends ILayerCommand>> commandHandlers
           
protected  Map<Class<? extends ILayerEvent>,ILayerEventHandler<? extends ILayerEvent>> eventHandlers
           
protected  ILayerPainter layerPainter
           
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
AbstractLayer()
           
 
Method Summary
 void addConfiguration(IConfiguration configuration)
           
 void addLayerListener(ILayerListener listener)
           
 void clearConfiguration()
           
 void configure(ConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
          Every layer gets this call back, starting at the top of the stack.
 void dispose()
           
 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 the ILayerListener registered on this layer.
 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)
           
 ICellPainter getCellPainter(int columnPosition, int rowPosition, ILayerCell cell, IConfigRegistry configRegistry)
           
 IClientAreaProvider getClientAreaProvider()
           
 IConfigLabelAccumulator getConfigLabelAccumulator()
           
 LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
           
 String getDisplayModeByPosition(int columnPosition, int rowPosition)
           
 ILayerPainter getLayerPainter()
           
 LabelStack getRegionLabelsByXY(int x, int y)
          Layer can apply its own labels to any cell it wishes.
 String getRegionName()
           
 void handleLayerEvent(ILayerEvent event)
          Handle layer event notification.
 boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
           
 void loadState(String prefix, Properties properties)
          Restore the state out of the given Properties identified by the specified prefix.
 void registerCommandHandler(ILayerCommandHandler<?> commandHandler)
           
protected  void registerCommandHandlers()
          Layers should use this method to register their command handlers and call it from their constructor.
 void registerEventHandler(ILayerEventHandler<?> eventHandler)
           
 void registerPersistable(IPersistable persistable)
          Persistables registered with a layer will have a chance to write their data out to the Properties instance when the layer is persisted.
 void removeLayerListener(ILayerListener listener)
           
 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)
           
 String toString()
           
 void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
           
 void unregisterEventHandler(ILayerEventHandler<?> eventHandler)
           
 void unregisterPersistable(IPersistable persistable)
           
 
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 Detail

layerPainter

protected ILayerPainter layerPainter

commandHandlers

protected final Map<Class<? extends ILayerCommand>,ILayerCommandHandler<? extends ILayerCommand>> commandHandlers

eventHandlers

protected final Map<Class<? extends ILayerEvent>,ILayerEventHandler<? extends ILayerEvent>> eventHandlers
Constructor Detail

AbstractLayer

public AbstractLayer()
Method Detail

dispose

public void dispose()
Specified by:
dispose in interface ILayer

getRegionLabelsByXY

public LabelStack getRegionLabelsByXY(int x,
                                      int y)
Description copied from interface: ILayer
Layer can apply its own labels to any cell it wishes.

Specified by:
getRegionLabelsByXY in interface ILayer
Parameters:
x - the x pixel coordinate
y - the y pixel coordinate
Returns:
a 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)
Specified by:
getConfigLabelsByPosition in interface ILayer

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
Persistables registered with a layer will have a chance to write their data out to the Properties instance when the layer is persisted.

Specified by:
registerPersistable in interface ILayer
Parameters:
persistable - the persistable to be registered

unregisterPersistable

public void unregisterPersistable(IPersistable persistable)
Specified by:
unregisterPersistable in interface ILayer

addConfiguration

public void addConfiguration(IConfiguration configuration)

clearConfiguration

public void clearConfiguration()

configure

public void configure(ConfigRegistry configRegistry,
                      UiBindingRegistry uiBindingRegistry)
Description copied from interface: ILayer
Every layer gets this call back, starting at the top of the stack. This is triggered by the NatTable.configure() method. This is an opportunity to add any key/mouse bindings and other general configuration.

Specified by:
configure in interface ILayer
Parameters:
configRegistry - instance owned by NatTable
uiBindingRegistry - instance owned by NatTable

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 co-ordinates using ILayerCommand.convertToTargetLayer(ILayer)

Specified by:
doCommand in interface ILayer
Parameters:
command - the command to perform
Returns:
true if the command has been handled, 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)
Specified by:
registerCommandHandler in interface ILayer

unregisterCommandHandler

public void unregisterCommandHandler(Class<? extends ILayerCommand> commandClass)
Specified by:
unregisterCommandHandler in interface ILayer

addLayerListener

public void addLayerListener(ILayerListener listener)
Specified by:
addLayerListener in interface ILayer

removeLayerListener

public void removeLayerListener(ILayerListener listener)
Specified by:
removeLayerListener in interface ILayer

hasLayerListener

public boolean hasLayerListener(Class<? extends ILayerListener> layerListenerClass)
Specified by:
hasLayerListener in interface ILayer
Parameters:
layerListenerClass - The type of ILayerListener to check for existence
Returns:
true if this ILayer has a ILayerListener registered for the specified type, false if there is no such listener registered already

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

setClientAreaProvider

public void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
Specified by:
setClientAreaProvider in interface ILayer

toString

public String toString()
Overrides:
toString in class Object

getCellByPosition

public ILayerCell getCellByPosition(int columnPosition,
                                    int rowPosition)
Specified by:
getCellByPosition in interface ILayer

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 String getDisplayModeByPosition(int columnPosition,
                                       int rowPosition)
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 position. The DisplayMode affects the settings out of the ConfigRegistry. Display mode is NORMAL by default.

Example: SelectionLayer overrides this to return the SELECT label for cells which are selected.


getCellPainter

public ICellPainter getCellPainter(int columnPosition,
                                   int rowPosition,
                                   ILayerCell cell,
                                   IConfigRegistry configRegistry)
Specified by:
getCellPainter in interface ILayer


Copyright © 2015. All rights reserved.