org.eclipse.nebula.widgets.nattable.extension.glazedlists
Class GlazedListsEventLayer<T>

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
      extended by org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
          extended by org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer<T>
Type Parameters:
T - Type of the bean in the backing list.
All Implemented Interfaces:
ca.odell.glazedlists.event.ListEventListener<T>, PropertyChangeListener, EventListener, ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class GlazedListsEventLayer<T>
extends AbstractLayerTransform
implements IUniqueIndexLayer, ca.odell.glazedlists.event.ListEventListener<T>, PropertyChangeListener

This layer acts as the event listener for:

  1. GlazedLists events - ListEvent
  2. Bean updates - PropertyChangeEvent(s)
GlazedLists events are conflated at a 100ms interval i.e a single RowStructuralRefreshEvent is fired for any number of GlazedLists events received during that interval.

PropertyChangeEvent(s) are propagated immediately as a PropertyUpdateEvent.


Field Summary
 
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, layerPainter
 
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
 
Constructor Summary
GlazedListsEventLayer(IUniqueIndexLayer underlyingLayer, ca.odell.glazedlists.EventList<T> eventList)
           
 
Method Summary
 void activate()
          Activates the handling of GlazedLists events.
 void deactivate()
          Deactivates the handling of GlazedLists events.
 boolean doCommand(ILayerCommand command)
          Opportunity to respond to a command as it flows down the stack.
protected  void fireEventFromSWTDisplayThread(ILayerEvent event)
          These update events are likely to cause a repaint on NatTable.
 int getColumnPositionByIndex(int columnIndex)
           
protected  Runnable getEventNotifier()
          Fires a NatTable refresh event, if any glazed list events have occurred.
 int getRowPositionByIndex(int rowIndex)
           
 boolean isActive()
           
 boolean isDisposed()
           
 void listChanged(ca.odell.glazedlists.event.ListEvent<T> event)
          Glazed list event handling.
 void propertyChange(PropertyChangeEvent event)
          Object property updated event
 void setEventList(ca.odell.glazedlists.EventList<T> newEventList)
           
 void setTestMode(boolean testMode)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform
configure, dispose, getCellByPosition, getCellPainter, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, isColumnPositionResizable, isRowPositionResizable, loadState, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
 
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
addLayerListener, configure, dispose, fireLayerEvent, getBoundsByPosition, getCellByPosition, getCellPainter, getClientAreaProvider, getColumnCount, getColumnIndexByPosition, getColumnPositionByX, getColumnWidthByPosition, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getHeight, getLayerPainter, getPreferredColumnCount, getPreferredHeight, getPreferredRowCount, getPreferredWidth, getRegionLabelsByXY, getRowCount, getRowHeightByPosition, getRowIndexByPosition, getRowPositionByY, getStartXOfColumnPosition, getStartYOfRowPosition, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, getWidth, hasLayerListener, isColumnPositionResizable, isRowPositionResizable, localToUnderlyingColumnPosition, localToUnderlyingRowPosition, registerCommandHandler, registerPersistable, removeLayerListener, setClientAreaProvider, underlyingToLocalColumnPosition, underlyingToLocalColumnPositions, underlyingToLocalRowPosition, underlyingToLocalRowPositions, unregisterCommandHandler, unregisterPersistable
 
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
 

Constructor Detail

GlazedListsEventLayer

public GlazedListsEventLayer(IUniqueIndexLayer underlyingLayer,
                             ca.odell.glazedlists.EventList<T> eventList)
Method Detail

getEventNotifier

protected Runnable getEventNotifier()
Fires a NatTable refresh event, if any glazed list events have occurred.


listChanged

public void listChanged(ca.odell.glazedlists.event.ListEvent<T> event)
Glazed list event handling.

Specified by:
listChanged in interface ca.odell.glazedlists.event.ListEventListener<T>

propertyChange

public void propertyChange(PropertyChangeEvent event)
Object property updated event

Specified by:
propertyChange in interface PropertyChangeListener

fireEventFromSWTDisplayThread

protected void fireEventFromSWTDisplayThread(ILayerEvent event)
These update events are likely to cause a repaint on NatTable. If these are not thrown from the SWT Display thread, SWT will throw an Exception. Painting can only be triggered from the SWT Display thread.


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
Overrides:
doCommand in class AbstractLayerTransform
Parameters:
command - the command to perform
Returns:
true if the command has been handled, false otherwise

isDisposed

public boolean isDisposed()

setEventList

public void setEventList(ca.odell.glazedlists.EventList<T> newEventList)
Parameters:
newEventList - the EventList to listen on.

setTestMode

public void setTestMode(boolean testMode)

activate

public void activate()
Activates the handling of GlazedLists events. By activating on receiving GlazedLists change events, there will be NatTable events fired to indicate that re-rendering is necessary.

This is usually necessary to perform huge updates of the data model to avoid concurrency issues. By default the GlazedListsEventLayer is activated. You can deactivate it prior performing bulk updates and activate it again after the update is finished for a better event handling.


deactivate

public void deactivate()
Deactivates the handling of GlazedLists events. By deactivating there will be no NatTable events fired on GlazedLists change events.

This is usually necessary to perform huge updates of the data model to avoid concurrency issues. By default the GlazedListsEventLayer is activated. You can deactivate it prior performing bulk updates and activate it again after the update is finished for a better event handling.


isActive

public boolean isActive()
Returns:
Whether this GlazedListsEventLayer will propagate ListEvents into NatTable or not.

getColumnPositionByIndex

public int getColumnPositionByIndex(int columnIndex)
Specified by:
getColumnPositionByIndex in interface IUniqueIndexLayer

getRowPositionByIndex

public int getRowPositionByIndex(int rowIndex)
Specified by:
getRowPositionByIndex in interface IUniqueIndexLayer


Copyright © 2015. All rights reserved.