Search in sources :

Example 1 with ILayerEventHandler

use of org.eclipse.nebula.widgets.nattable.layer.event.ILayerEventHandler in project nebula.widgets.nattable by eclipse.

the class AbstractLayer method handleLayerEvent.

/**
 * Handle layer event notification. Convert it to your context and propagate
 * <i>UP</i>.
 *
 * If you override this method you <strong>MUST NOT FORGET</strong> to raise
 * the event up the layer stack by calling
 * <code>super.fireLayerEvent(event)</code> - unless you plan to eat the
 * event yourself.
 */
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void handleLayerEvent(ILayerEvent event) {
    Map<Class<? extends ILayerEvent>, ILayerEventHandler<? extends ILayerEvent>> currentEventHandlers;
    this.eventHelperLock.readLock().lock();
    try {
        currentEventHandlers = this.eventHandlers;
    } finally {
        this.eventHelperLock.readLock().unlock();
    }
    for (Class<? extends ILayerEvent> eventClass : currentEventHandlers.keySet()) {
        if (eventClass.isInstance(event)) {
            ILayerEventHandler eventHandler = currentEventHandlers.get(eventClass);
            eventHandler.handleLayerEvent(event);
        }
    }
    // Pass on the event to our parent
    if (event.convertToLocal(this)) {
        fireLayerEvent(event);
    }
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) ILayerEventHandler(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEventHandler)

Aggregations

ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 ILayerEventHandler (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEventHandler)1