de.tu_berlin.cs.tfs.muvitorkit.ui.utils
Class MuvitorNotifierService

java.lang.Object
  extended by de.tu_berlin.cs.tfs.muvitorkit.ui.utils.MuvitorNotifierService

public class MuvitorNotifierService
extends Object

In MuvitorKit editors, this purely static service can be used to listen to and process EMF notifications fired by almost all EObject instances even without being registered to these models. Usually, listeners of this service perform checks for correctness conditions and generate problem markers on specific model changes.

This service is hooked into MuvitorKit editors via the adapter edit parts, which by default pass notifications of their models to this service by calling notifyListeners(Notification).

As the default behavior that is this services's main purpose, if MuvitorNotifierService notices that an EObject has been deleted from the model it will take care of closing all MuvitorKit views showing this particular EObject or one of its children.

There are several interfaces for listeners serving different purposes. The most general is MuvitorNotifierService.IChangeListener, which will be notified about all notifications announced via notifyListeners(Notification).

Listeners should use this service carefully with respect to performance issues by reacting on specific notifications only (e.g. by filtering notifications by their featureID) and restricting listeners to their editor contexts if possible (see addListener(IMuvitorListener, MuvitorTreeEditor)).

Rating red

Nested Class Summary
static interface MuvitorNotifierService.IChangeListener
          Listeners implementing this interface will be notified about all occurring notifications.
static interface MuvitorNotifierService.IChangeListenerJob
          This interface is equivalent to MuvitorNotifierService.IChangeListener unless listening jobs will be notified after all other IMuvitorListener so that possible reactions to a notification have completed before.
 
Method Summary
static void addListener(de.tu_berlin.cs.tfs.muvitorkit.ui.utils.MuvitorNotifierService.IMuvitorListener listener, MuvitorTreeEditor editor)
          Adds a listener to the MuvitorNotifierService.
static void clear(MuvitorTreeEditor editor)
          Unregisters all listeners from the MuvitorNotifierService of a specific editor context.
static void notifyListeners(Notification notification)
          This method passes a notification to all listeners registered to the GlobalNotifierService.
static void removeListener(de.tu_berlin.cs.tfs.muvitorkit.ui.utils.MuvitorNotifierService.IMuvitorListener listener)
          Removes a listener from the MuvitorNotifierService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addListener

public static final void addListener(de.tu_berlin.cs.tfs.muvitorkit.ui.utils.MuvitorNotifierService.IMuvitorListener listener,
                                     MuvitorTreeEditor editor)
Adds a listener to the MuvitorNotifierService.

Parameters:
listener - the listener to be added
editor - the editor in whose context notifications will be forwarded to the listener, or null if it should receive all notifications globally

removeListener

public static final void removeListener(de.tu_berlin.cs.tfs.muvitorkit.ui.utils.MuvitorNotifierService.IMuvitorListener listener)
Removes a listener from the MuvitorNotifierService.

Parameters:
listener - the listener to be removed

clear

public static final void clear(MuvitorTreeEditor editor)
Unregisters all listeners from the MuvitorNotifierService of a specific editor context.


notifyListeners

public static final void notifyListeners(Notification notification)
This method passes a notification to all listeners registered to the GlobalNotifierService. This will be done according to the interfaces the listeners implement.

In MuvitorKit editors all edit parts (should) extend the adapter edit parts that by default call this method if their models fire some notification.

If the notification announces that an EObject has been deleted from the model all MuvitorKit views showing this particular EObject or one of its children will be closed.

Parameters:
notification - the notification to distribute to all registered listeners
See Also:
IMuvitorListener, MuvitorNotifierService.IChangeListener, MuvitorNotifierService.IChangeListenerJob, AdapterTreeEditPart, AdapterGraphicalEditPart, AdapterConnectionEditPart