Class EventSource

java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
All Implemented Interfaces:
IEventSource
Direct Known Subclasses:
AbstractContext, AbstractTableDocument, AbstractTextDocument, AbstractTreeDocument, ItemHistory, PropertyManager, SimplePropertyManager

@Ser public class EventSource extends Object implements IEventSource
Standard implementation for an event source.
  • Field Details

    • onEventCallCount

      public static final AtomicInteger onEventCallCount
  • Constructor Details

    • EventSource

      public EventSource()
      Create an event source not attached to a parent source.
    • EventSource

      public EventSource(EventSource parentSource)
      Create an event source attached to an optional parent source. If present, events generated by this source will be propagated to its listeners as well as the parent source's listeners.
      Parameters:
      parentSource - optional parent source
  • Method Details

    • setParentSource

      public void setParentSource(IEventSource parentSource)
      Description copied from interface: IEventSource
      Set a parent source.
      Specified by:
      setParentSource in interface IEventSource
      Parameters:
      parentSource - the optional parent source
    • getParentSource

      public IEventSource getParentSource()
      Description copied from interface: IEventSource
      Get the parent source.
      Specified by:
      getParentSource in interface IEventSource
      Returns:
      the parent source, or null if none
    • countListeners

      public int countListeners()
      Description copied from interface: IEventSource
      Get the numbers of objects listening to this event source.
      Specified by:
      countListeners in interface IEventSource
      Returns:
      the number of listeners
    • getListeners

      public List<IEventListener> getListeners()
      Description copied from interface: IEventSource
      Get a copy of the list of listeners.
      Specified by:
      getListeners in interface IEventSource
      Returns:
    • addListener

      public void addListener(IEventListener listener)
      Description copied from interface: IEventSource
      Register a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.
      Specified by:
      addListener in interface IEventSource
      Parameters:
      listener - a listener of events generated by this source
    • insertListener

      public void insertListener(int index, IEventListener listener)
      Description copied from interface: IEventSource
      Register a listener. The implementor may allow duplicates.
      Specified by:
      insertListener in interface IEventSource
      Parameters:
      index - insertion point
      listener - a listener of events generated by this source
    • removeListener

      public void removeListener(IEventListener listener)
      Description copied from interface: IEventSource
      Unregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.
      Specified by:
      removeListener in interface IEventSource
      Parameters:
      listener - the listener to be removed
    • notifyListeners

      public void notifyListeners(IEvent e)
      Description copied from interface: IEventSource
      Notify listeners that an event has occurred.
      Specified by:
      notifyListeners in interface IEventSource
      Parameters:
      e - the event to be propagated
    • notifyListeners

      public void notifyListeners(Event e)
    • notifyListeners

      public void notifyListeners(Event e, boolean notifyParent)
    • relay

      public static IEventListener relay(IEventSource origin, IEventSource proxy)
      Relay events issued from an origin to the listeners of a proxy.
      Parameters:
      origin - events are emitted by this origin event source
      proxy - events will be relayed by this proxy event source
      Returns:
      the event listener/relayer object, which should be disposed by the caller after the origin is destroyed