Class ChangeBrokerImpl
- java.lang.Object
-
- org.eclipse.emf.ecp.changebroker.internal.ChangeBrokerImpl
-
- All Implemented Interfaces:
ChangeBroker
,NotificationReceiver
public class ChangeBrokerImpl extends java.lang.Object implements ChangeBroker, NotificationReceiver
Implementation of aChangeBroker
. Registers itself as aNotificationReceiver
at allproviders
. Once it gets notified it forwards the notification to all of the brokers notification receivers, as applicable.- Author:
- Jonas, jfaltermeier
-
-
Constructor Summary
Constructors Constructor Description ChangeBrokerImpl()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNotificationProvider(NotificationProvider provider)
Adds a notification provider.boolean
canDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
void
continueNotification()
Notifying theChangeObserver
is started again ifChangeBroker.stopNotification()
was called beforehand.void
continueNotification(java.lang.Object blocker)
Removes ablocker
.java.util.Set<NotificationProvider>
getNotificationProviders()
For testing purposes.java.util.Set<ChangeObserver>
getRegisteredObservers()
For testing purposes.void
notify(org.eclipse.emf.common.notify.Notification notification)
Called whenever there is a newNotification
meant for the receiver.void
notifyPostDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
Called after an element was deleted.void
notifyPreDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
Called before an element gets deleted, after allVetoableDeleteObserver
have returned true and therefore the delete operation is allowed.void
removeNotificationProvider(NotificationProvider provider)
Removes a notification provider.void
stopNotification()
Stops notifying allChangeObserver
.void
stopNotification(java.lang.Object blocker)
Stops notifying allChangeObserver
.void
subscribe(EMFObserver observer)
Adds anChangeObserver
that will receive all notifications.void
subscribeToEClass(ChangeObserver observer, org.eclipse.emf.ecore.EClass eClass)
Adds anChangeObserver
that will receive notifications of notifiers with the given EClass.void
subscribeToFeature(ChangeObserver observer, org.eclipse.emf.ecore.EStructuralFeature feature)
Adds anChangeObserver
that will receive notifications when the given EStructuralFeautre is effected.void
subscribeToTree(ChangeObserver observer, org.eclipse.emf.ecore.EClass eClass)
Adds anChangeObserver
that will receive notifications of notifiers with the given EClass or which are contained (either direct or indirect) in an EObject of the given EClass.void
unsubsribe(EMFObserver receiver)
Removes an observer.
-
-
-
Method Detail
-
addNotificationProvider
public void addNotificationProvider(NotificationProvider provider)
Adds a notification provider.- Parameters:
provider
- the provider
-
removeNotificationProvider
public void removeNotificationProvider(NotificationProvider provider)
Removes a notification provider.- Parameters:
provider
- the provider
-
notify
public void notify(org.eclipse.emf.common.notify.Notification notification)
Called whenever there is a newNotification
meant for the receiver.- Specified by:
notify
in interfaceNotificationReceiver
- Parameters:
notification
- the notification- See Also:
ChangeObserver.handleNotification(org.eclipse.emf.common.notify.Notification)
-
subscribe
public void subscribe(EMFObserver observer)
Adds anChangeObserver
that will receive all notifications. Does nothing if already registered.- Specified by:
subscribe
in interfaceChangeBroker
- Parameters:
observer
- the observer- See Also:
ChangeBroker.subscribe(org.eclipse.emf.ecp.changebroker.spi.EMFObserver)
-
subscribeToEClass
public void subscribeToEClass(ChangeObserver observer, org.eclipse.emf.ecore.EClass eClass)
Adds anChangeObserver
that will receive notifications of notifiers with the given EClass. Does nothing if already registered.- Specified by:
subscribeToEClass
in interfaceChangeBroker
- Parameters:
observer
- the observereClass
- the required EClass of the notifier- See Also:
ChangeBroker.subscribeToEClass(org.eclipse.emf.ecp.changebroker.spi.ChangeObserver, org.eclipse.emf.ecore.EClass)
-
subscribeToTree
public void subscribeToTree(ChangeObserver observer, org.eclipse.emf.ecore.EClass eClass)
Adds anChangeObserver
that will receive notifications of notifiers with the given EClass or which are contained (either direct or indirect) in an EObject of the given EClass. Does nothing if already registered.- Specified by:
subscribeToTree
in interfaceChangeBroker
- Parameters:
observer
- the observereClass
- the required EClass of the notifier or of one of its parents- See Also:
ChangeBroker.subscribeToTree(org.eclipse.emf.ecp.changebroker.spi.ChangeObserver, org.eclipse.emf.ecore.EClass)
-
subscribeToFeature
public void subscribeToFeature(ChangeObserver observer, org.eclipse.emf.ecore.EStructuralFeature feature)
Adds anChangeObserver
that will receive notifications when the given EStructuralFeautre is effected. Does nothing if already registered.- Specified by:
subscribeToFeature
in interfaceChangeBroker
- Parameters:
observer
- the observerfeature
- the feature to receive changes for- See Also:
ChangeBroker.subscribeToFeature(org.eclipse.emf.ecp.changebroker.spi.ChangeObserver, org.eclipse.emf.ecore.EStructuralFeature)
-
unsubsribe
public void unsubsribe(EMFObserver receiver)
Removes an observer. Does nothing if receiver is not registered.- Specified by:
unsubsribe
in interfaceChangeBroker
- Parameters:
receiver
- the receiver- See Also:
ChangeBroker.unsubsribe(org.eclipse.emf.ecp.changebroker.spi.EMFObserver)
-
stopNotification
public void stopNotification()
Stops notifying allChangeObserver
.ReadOnlyEMFObservers
will still be notified.- Specified by:
stopNotification
in interfaceChangeBroker
- See Also:
ChangeBroker.stopNotification()
-
continueNotification
public void continueNotification()
Notifying theChangeObserver
is started again ifChangeBroker.stopNotification()
was called beforehand. Has no effect if the notification process has beenblocked
or ifChangeBroker.stopNotification()
wasn't called before.- Specified by:
continueNotification
in interfaceChangeBroker
- See Also:
ChangeBroker.continueNotification()
-
getNotificationProviders
public java.util.Set<NotificationProvider> getNotificationProviders()
For testing purposes.- Returns:
- all registered providers
-
getRegisteredObservers
public java.util.Set<ChangeObserver> getRegisteredObservers()
For testing purposes.- Returns:
- all registered observers
-
stopNotification
public void stopNotification(java.lang.Object blocker)
Stops notifying allChangeObserver
.ReadOnlyEMFObservers
will still be notified. The notifications will we blocked untilChangeBroker.continueNotification(Object)
has been called with all blocking elements. Using the same blocker multiple times has no effect.- Specified by:
stopNotification
in interfaceChangeBroker
- Parameters:
blocker
- the key object used to block all notifications- See Also:
ChangeBroker.stopNotification(java.lang.Object)
-
continueNotification
public void continueNotification(java.lang.Object blocker)
Removes ablocker
. When all blockers have been removed the notification process will continue. This method callsChangeBroker.continueNotification()
internally in all cases, even if the given blocker object was not used as a blocker beforehand.- Specified by:
continueNotification
in interfaceChangeBroker
- Parameters:
blocker
- the blocker object to remove.- See Also:
ChangeBroker.continueNotification(java.lang.Object)
-
notifyPreDelete
public void notifyPreDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
Description copied from interface:NotificationReceiver
Called before an element gets deleted, after allVetoableDeleteObserver
have returned true and therefore the delete operation is allowed.- Specified by:
notifyPreDelete
in interfaceNotificationReceiver
- Parameters:
toBeDeleted
- TheEObject
to be deleted
-
notifyPostDelete
public void notifyPostDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
Description copied from interface:NotificationReceiver
Called after an element was deleted.- Specified by:
notifyPostDelete
in interfaceNotificationReceiver
- Parameters:
toBeDeleted
- The deletedEObject
-
canDelete
public boolean canDelete(org.eclipse.emf.ecore.EObject toBeDeleted)
- Specified by:
canDelete
in interfaceNotificationReceiver
- Parameters:
toBeDeleted
- TheEObject
to be deleted- Returns:
- if the element can be deleted meaning if no
VetoableDeleteObserver
has returned false
-
-