Package com.pnfsoftware.jeb.util.events
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
Standard implementation for an event source.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate an event source not attached to a parent source.EventSource(EventSource parentSource) Create an event source attached to an optional parent source. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(IEventListener listener) Register a listener.intGet the numbers of objects listening to this event source.Get a copy of the list of listeners.Get the parent source.voidinsertListener(int index, IEventListener listener) Register a listener.voidvoidnotifyListeners(Event e, boolean notifyParent) voidNotify listeners that an event has occurred.static IEventListenerrelay(IEventSource origin, IEventSource proxy) Relay events issued from an origin to the listeners of a proxy.voidremoveListener(IEventListener listener) Unregister a listener.voidsetParentSource(IEventSource parentSource) Set a parent source.
-
Field Details
-
onEventCallCount
-
-
Constructor Details
-
EventSource
public EventSource()Create an event source not attached to a parent source. -
EventSource
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
Description copied from interface:IEventSourceSet a parent source.- Specified by:
setParentSourcein interfaceIEventSource- Parameters:
parentSource- the optional parent source
-
getParentSource
Description copied from interface:IEventSourceGet the parent source.- Specified by:
getParentSourcein interfaceIEventSource- Returns:
- the parent source, or null if none
-
countListeners
public int countListeners()Description copied from interface:IEventSourceGet the numbers of objects listening to this event source.- Specified by:
countListenersin interfaceIEventSource- Returns:
- the number of listeners
-
getListeners
Description copied from interface:IEventSourceGet a copy of the list of listeners.- Specified by:
getListenersin interfaceIEventSource- Returns:
-
addListener
Description copied from interface:IEventSourceRegister a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.- Specified by:
addListenerin interfaceIEventSource- Parameters:
listener- a listener of events generated by this source
-
insertListener
Description copied from interface:IEventSourceRegister a listener. The implementor may allow duplicates.- Specified by:
insertListenerin interfaceIEventSource- Parameters:
index- insertion pointlistener- a listener of events generated by this source
-
removeListener
Description copied from interface:IEventSourceUnregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.- Specified by:
removeListenerin interfaceIEventSource- Parameters:
listener- the listener to be removed
-
notifyListeners
Description copied from interface:IEventSourceNotify listeners that an event has occurred.- Specified by:
notifyListenersin interfaceIEventSource- Parameters:
e- the event to be propagated
-
notifyListeners
-
notifyListeners
-
relay
Relay events issued from an origin to the listeners of a proxy.- Parameters:
origin- events are emitted by this origin event sourceproxy- 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
-