Class SelectionEventSource<N extends NodeWrapper>

java.lang.Object
org.knime.gateway.impl.service.events.EventSource<N,SelectionEvent>
org.knime.gateway.impl.service.events.SelectionEventSource<N>
Type Parameters:
N -

public final class SelectionEventSource<N extends NodeWrapper> extends EventSource<N,SelectionEvent>
An event source that emits selection events (i.e. hiliting events) to the given event consumer.
Since:
4.5
Author:
Martin Horn, KNIME GmbH, Konstanz, Germany, Marc Bux, KNIME GmbH, Berlin, Germany
  • Constructor Details

    • SelectionEventSource

      public SelectionEventSource(BiConsumer<String,Object> eventConsumer, TableViewManager<N> tableViewManager)
      Parameters:
      eventConsumer - selection events will be forwarded to this consumer
      tableViewManager -
  • Method Details

    • getName

      protected String getName()
      Specified by:
      getName in class EventSource<N extends NodeWrapper,SelectionEvent>
      Returns:
      a name unique to the event source
    • addEventListenerAndGetInitialEventFor

      public Optional<SelectionEvent> addEventListenerAndGetInitialEventFor(N nw)
      Registers a listener with the event source for the specified type of event and optionally returns the very first event to 'catch up' (instead of passing it to the associated event consumer).
      Specified by:
      addEventListenerAndGetInitialEventFor in class EventSource<N extends NodeWrapper,SelectionEvent>
      Returns:
      the very first event or an empty optional if there isn't any (method must not wait for events to arrive - only returns if there is an event at event listener registration time)
    • removeAllEventListeners

      public void removeAllEventListeners()
      Removes all event listeners registered with the event source. After this method, no events will be emitted anymore.
      Specified by:
      removeAllEventListeners in class EventSource<N extends NodeWrapper,SelectionEvent>
    • removeEventListener

      public void removeEventListener(N nw)
      Removes an event listener for a particular event type instance.
      Specified by:
      removeEventListener in class EventSource<N extends NodeWrapper,SelectionEvent>
    • getNumEventListeners

      public int getNumEventListeners()
      The total number of event listener registered for the event source. Mainly for testing purposes.
      Returns:
      the total number of event listeners registered
    • processSelectionEvent

      public static void processSelectionEvent(org.knime.core.node.property.hilite.HiLiteHandler hiLiteHandler, org.knime.core.node.workflow.NodeID nodeId, SelectionEventSource.SelectionEventMode selectionEventMode, boolean async, Set<org.knime.core.data.RowKey> rowKeys)
      Forwards selection events to the given hilite-handler.
      Parameters:
      hiLiteHandler - hilite-handler to use
      nodeId - the id of the node the hilite-handler is associated with
      selectionEventMode - the selection event mode
      async - if true, it will return immediately; if false it will return once the selection has been processed completely (i.e. once all associated nodes have received the selection change, too).
      rowKeys - the keys to be (un-)selected