public class EventManagerTableBased extends java.lang.Object implements EventManager
EventManager
interface, using hash tables to quickly dispatch
incoming Notification
s to the sets of registered event listeners
. Uses a single
EContentAdapter
to listen to all changes in those ResourceSet
s for which it is responsible.Modifier and Type | Field and Description |
---|---|
protected java.util.WeakHashMap<org.eclipse.emf.common.notify.Adapter,java.util.Collection<AdapterCapsule>> |
notifierByListener
listeners are not notified directly.
|
Constructor and Description |
---|
EventManagerTableBased() |
EventManagerTableBased(org.eclipse.emf.ecore.resource.ResourceSet set) |
Modifier and Type | Method and Description |
---|---|
void |
addToObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Adds
resourceSet to the resource sets from which this event manager receives notifications
that it dispatches to adapters subscribed to this event manager. |
void |
beginCommand() |
void |
cancelCommand() |
void |
deregister(org.eclipse.emf.common.notify.Adapter listener) |
protected void |
finalize() |
void |
fireChangeEvent(org.eclipse.emf.common.notify.Notification event) |
void |
firePreChangeEvent(org.eclipse.emf.common.notify.Notification event) |
void |
handleEMFEvent(org.eclipse.emf.common.notify.Notification notification)
Initialize the filtering process for a given
Notification , all Adapter registered with a matching filter
will be notified. |
void |
postCommitCommand() |
void |
preCommitCommand() |
void |
registerCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree) |
void |
registerPreChangeListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree) |
void |
registerPreCommitListener(org.eclipse.emf.common.notify.Adapter listener,
AbstractEventFilter eventFilterTree) |
void |
removeFromObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Stops receiving and dispatching notifications coming from
resourceSet . |
void |
setActive(boolean active)
Sometimes it can be convenient to temporarily stop the flow of events.
|
void |
setFireEvents(boolean doFireEventsValue)
|
void |
subscribe(EventFilter eventFilterTree,
org.eclipse.emf.common.notify.Adapter listener)
Register an
Adapter on the EventManager which will be notified for any Notification which matches
the given filter. |
java.lang.String |
toString() |
boolean |
unsubscribe(org.eclipse.emf.common.notify.Adapter caller)
Removes the given
Adapter from the EventManager and the linked AbstractEventFilter , so that the given
Adapter will not be notified anymore |
protected java.util.WeakHashMap<org.eclipse.emf.common.notify.Adapter,java.util.Collection<AdapterCapsule>> notifierByListener
public EventManagerTableBased(org.eclipse.emf.ecore.resource.ResourceSet set)
public EventManagerTableBased()
public void setFireEvents(boolean doFireEventsValue)
doFireEventsValue
- false
to disable Notification
delivery, true
to enablepublic void setActive(boolean active)
EventManager
ResourceSet
and thus removing the
adapter from all objects in the resource set, it is more efficient to just block forwarding the events to the
Adapter
s subscribed with this event manager.
Calling this method with active==false
will stop this event manager from forwarding events to
the Adapter
s subscribed. Calling it with active==true
again will forward events received
after the call again. Events that arrived in between are not forwarded and therefore "lost" for the
subscribers to this event manager.
By default, an event manager starts in the "active" state.
setActive
in interface EventManager
public void subscribe(EventFilter eventFilterTree, org.eclipse.emf.common.notify.Adapter listener)
EventManager
Adapter
on the EventManager
which will be notified for any Notification
which matches
the given filter. If an equal or the same caller
registers multiple times using equal filter
s,
the caller
will get notified as many times as it subscribed.subscribe
in interface EventManager
eventFilterTree
- the AbstractEventFilter
which is used to filter events for the given Adapter
.
Currently, there are still a few limitations as to the filter trees permissible. It is
considered an error if the filter, after conversion into disjunctive normal form,
contains more than one filter of a kind in an "AND" clause. Such filters, passed
to this method, cause an IllegalArgumentException
to be thrown.listener
- the adapter which should receive event which matches the filter. This event manager will only
maintain weak references to the listener which means that the client should hold a strong reference
in order to make sure that notifications will be received. This is a good idea anyhow since for
de-registration using EventManager.unsubscribe(Adapter)
the listener is required as well.public void registerPreChangeListener(org.eclipse.emf.common.notify.Adapter listener, AbstractEventFilter eventFilterTree)
public void registerCommitListener(org.eclipse.emf.common.notify.Adapter listener, AbstractEventFilter eventFilterTree)
public void registerPreCommitListener(org.eclipse.emf.common.notify.Adapter listener, AbstractEventFilter eventFilterTree)
public void deregister(org.eclipse.emf.common.notify.Adapter listener)
public void fireChangeEvent(org.eclipse.emf.common.notify.Notification event)
public void firePreChangeEvent(org.eclipse.emf.common.notify.Notification event)
public void beginCommand()
public void postCommitCommand()
public void preCommitCommand()
public void cancelCommand()
public void handleEMFEvent(org.eclipse.emf.common.notify.Notification notification)
EventManager
Notification
, all Adapter
registered with a matching filter
will be notified. Normally, clients don't have to call this method explicitly. It will be called by the
event manager automatically when an event has been received from any elements in the ResourceSet
for which the event manager has been obtained (see EventManagerFactory.getEventManagerFor(ResourceSet)
).
However, for testing purposes and in case clients want to explicitly send events that have not emerged
from the ResourceSet
to registered clients, they may use this method.handleEMFEvent
in interface EventManager
notification
- Notification
to send to clients whose event filter matches the notificationpublic boolean unsubscribe(org.eclipse.emf.common.notify.Adapter caller)
EventManager
Adapter
from the EventManager
and the linked AbstractEventFilter
, so that the given
Adapter
will not be notified anymoreunsubscribe
in interface EventManager
caller
- the Adapter
to unsubscribetrue
if the adapter was registeredprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public java.lang.String toString()
toString
in class java.lang.Object
public void addToObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
EventManager
resourceSet
to the resource sets from which this event manager receives notifications
that it dispatches to adapters subscribed to this event manager. If this event manager already
does receive notifications from resourceSet
it is not registered a second time. In
particular, it won't receive the same notifications multiple times.addToObservedResourceSets
in interface EventManager
EventManager.removeFromObservedResourceSets(ResourceSet)
public void removeFromObservedResourceSets(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
EventManager
resourceSet
.removeFromObservedResourceSets
in interface EventManager
EventManager.addToObservedResourceSets(ResourceSet)