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
-
Constructor Summary
ConstructorDescriptionCreate 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 TypeMethodDescriptionvoid
addListener
(IEventListener listener) Register a listener.int
Get the numbers of objects listening to this event source.Get a copy of the list of listeners.Get the parent source.void
insertListener
(int index, IEventListener listener) Register a listener.void
void
notifyListeners
(Event e, boolean notifyParent) void
Notify listeners that an event has occurred.static IEventListener
relay
(IEventSource origin, IEventSource proxy) Relay events issued from an origin to the listeners of a proxy.void
removeListener
(IEventListener listener) Unregister a listener.void
setParentSource
(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:IEventSource
Set a parent source.- Specified by:
setParentSource
in interfaceIEventSource
- Parameters:
parentSource
- the optional parent source
-
getParentSource
Description copied from interface:IEventSource
Get the parent source.- Specified by:
getParentSource
in interfaceIEventSource
- 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 interfaceIEventSource
- Returns:
- the number of listeners
-
getListeners
Description copied from interface:IEventSource
Get a copy of the list of listeners.- Specified by:
getListeners
in interfaceIEventSource
- Returns:
-
addListener
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 interfaceIEventSource
- Parameters:
listener
- a listener of events generated by this source
-
insertListener
Description copied from interface:IEventSource
Register a listener. The implementor may allow duplicates.- Specified by:
insertListener
in interfaceIEventSource
- Parameters:
index
- insertion pointlistener
- a listener of events generated by this source
-
removeListener
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 interfaceIEventSource
- Parameters:
listener
- the listener to be removed
-
notifyListeners
Description copied from interface:IEventSource
Notify listeners that an event has occurred.- Specified by:
notifyListeners
in 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
-