Runtime

## org.eclipse.gmf.runtime.diagram.core.listener
Class DiagramEventBroker

    java.lang.Object
      org.eclipse.emf.transaction.ResourceSetListenerImpl
          org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker

All Implemented Interfaces:
  java.util.EventListener, org.eclipse.emf.transaction.ResourceSetListener

    public class DiagramEventBroker

extends org.eclipse.emf.transaction.ResourceSetListenerImpl

A model server listener that broadcast EObject events to all registered listeners.

Nested Class Summary
`static interface` `DiagramEventBroker.DiagramEventBrokerFactory` Factory interface that can be used to create overrides of the DiagramEventBroker class
`class` `DiagramEventBroker.NotifierToKeyToListenersSetMap` Utility class representing a Map of Notifier to a Map of Keys to a Set of listener

Constructor Summary
`protected` `DiagramEventBroker()` Creates a `DiagramEventBroker` that listens to all `EObject` notifications for the given editing domain.

Method Summary
`void` `addNotificationListener(org.eclipse.emf.ecore.EObject target, org.eclipse.emf.ecore.EStructuralFeature key, NotificationListener listener)` Add the supplied `listener` to the listener list.
`void` `addNotificationListener(org.eclipse.emf.ecore.EObject target, org.eclipse.emf.ecore.EStructuralFeature key, NotificationPreCommitListener listener)` Add the supplied `listener` to the listener list.
`void` `addNotificationListener(org.eclipse.emf.ecore.EObject target, NotificationListener listener)` Add the supplied `listener` to the listener list.
`void` `addNotificationListener(org.eclipse.emf.ecore.EObject target, NotificationPreCommitListener listener)` Add the supplied `listener` to the listener list.
`protected void` `fireNotification(org.eclipse.emf.common.notify.Notification event)` Forward the supplied event to all listeners listening on the supplied target element.
`static DiagramEventBroker` `getInstance(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)` Gets the diagmam event broker instance for the editing domain passed in.
`protected java.util.Set` `getInterestedNotificationListeners(org.eclipse.emf.common.notify.Notification event, DiagramEventBroker.NotifierToKeyToListenersSetMap listeners)` gets a subset of all the registered listeners who are interested in receiving the supplied event.
`protected DiagramEventBroker.NotifierToKeyToListenersSetMap` `getPostCommitListenersMap()` returns the post commit listeners map
`protected DiagramEventBroker.NotifierToKeyToListenersSetMap` `getPreCommitListenersMap()` returns the pre commit listeners map
`protected void` `handleNotificationOnAddedElement(org.eclipse.emf.transaction.ResourceSetChangeEvent event)` This method allows clients to customize the Diagram event broker behavior when it comes to handling events on added objects.
`protected void` `handleNotificationOnDeletedElement(org.eclipse.emf.transaction.ResourceSetChangeEvent event)` This method allows clients to customize the Diagram event broker behavior when it comes to handling events on deleted objects.
`boolean` `isAggregatePrecommitListener()`
`protected boolean` `isDeleted(java.util.Set deletedObjects, org.eclipse.emf.ecore.EObject notifier)` decide if the passed object is deleted or not; the decision is done by checking is the passed notifier or any of its ancestors exists in the passed deletedObjects Set, if it find the obnject to be deleted it will add it to the deleted objects set.
`static void` `registerDiagramEventBrokerFactory(DiagramEventBroker.DiagramEventBrokerFactory newDebFactory)`
`void` `removeNotificationListener(org.eclipse.emf.ecore.EObject target, NotificationListener listener)` remove the supplied `listener` from the listener list.
`void` `removeNotificationListener(org.eclipse.emf.ecore.EObject target, NotificationPreCommitListener listener)` remove the supplied `listener` from the listener list.
`void` `removeNotificationListener(org.eclipse.emf.ecore.EObject target, java.lang.Object key, NotificationListener listener)` remove the supplied `listener` from the listener list.
`void` `removeNotificationListener(org.eclipse.emf.ecore.EObject target, java.lang.Object key, NotificationPreCommitListener listener)` remove the supplied `listener` from the listener list.
`void` `resourceSetChanged(org.eclipse.emf.transaction.ResourceSetChangeEvent event)`
`protected boolean` `shouldIgnoreNotification(org.eclipse.emf.common.notify.Notification notification)` determine if the passed notification can be ignored or not the default implementation will ignore touch event if it is not a resolve event, also it will ignore the mutable feature events
`static void` `startListening(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)` Creates a new diagram event broker instance for the editing domain passed in only if the editing domain does not already have a diagram event broker.
`static void` `stopListening(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)`
`org.eclipse.emf.common.command.Command` `transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent event)`

Methods inherited from class org.eclipse.emf.transaction.ResourceSetListenerImpl
`getFilter, isPostcommitOnly, isPrecommitOnly`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DiagramEventBroker

    protected DiagramEventBroker()

  Creates a `DiagramEventBroker` that listens to all `EObject` notifications for the given editing domain.

Method Detail

### getPreCommitListenersMap

    protected DiagramEventBroker.NotifierToKeyToListenersSetMap getPreCommitListenersMap()

  returns the pre commit listeners map

  Returns:
    pre commit listeners map

### getPostCommitListenersMap

    protected DiagramEventBroker.NotifierToKeyToListenersSetMap getPostCommitListenersMap()

  returns the post commit listeners map

  Returns:
    post commit listeners map

### getInstance

    public static DiagramEventBroker getInstance(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)

  Gets the diagmam event broker instance for the editing domain passed in. There is one diagram event broker per editing domain.

  Parameters:
    `editingDomain` -
  Returns:
    Returns the diagram event broker.

### startListening

    public static void startListening(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)

  Creates a new diagram event broker instance for the editing domain passed in only if the editing domain does not already have a diagram event broker. There is one diagram event broker per editing domain. Adds the diagram event broker instance as a listener to the editing domain.

  Parameters:
    `editingDomain` -

### registerDiagramEventBrokerFactory

    public static void registerDiagramEventBrokerFactory(DiagramEventBroker.DiagramEventBrokerFactory newDebFactory)

  Parameters:
    `newDebFactory` -

### stopListening

    public static void stopListening(org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain)

  Parameters:
    `editingDomain` -

### transactionAboutToCommit

    public org.eclipse.emf.common.command.Command transactionAboutToCommit(org.eclipse.emf.transaction.ResourceSetChangeEvent event)

  Specified by:
    `transactionAboutToCommit` in interface `org.eclipse.emf.transaction.ResourceSetListener`
  Overrides:
    `transactionAboutToCommit` in class `org.eclipse.emf.transaction.ResourceSetListenerImpl`

### resourceSetChanged

    public void resourceSetChanged(org.eclipse.emf.transaction.ResourceSetChangeEvent event)

  Specified by:
    `resourceSetChanged` in interface `org.eclipse.emf.transaction.ResourceSetListener`
  Overrides:
    `resourceSetChanged` in class `org.eclipse.emf.transaction.ResourceSetListenerImpl`

### handleNotificationOnAddedElement

    protected void handleNotificationOnAddedElement(org.eclipse.emf.transaction.ResourceSetChangeEvent event)

  This method allows clients to customize the Diagram event broker behavior when it comes to handling events on added objects. The default behavior will just ignore them

  Parameters:
    `event` - being handled

### handleNotificationOnDeletedElement

    protected void handleNotificationOnDeletedElement(org.eclipse.emf.transaction.ResourceSetChangeEvent event)

  This method allows clients to customize the Diagram event broker behavior when it comes to handling events on deleted objects. The default behavior will just ignore them

  Parameters:
    `event` - event being handled

### isDeleted

    protected boolean isDeleted(java.util.Set deletedObjects,
                                org.eclipse.emf.ecore.EObject notifier)

  decide if the passed object is deleted or not; the decision is done by checking is the passed notifier or any of its ancestors exists in the passed deletedObjects Set, if it find the obnject to be deleted it will add it to the deleted objects set.

  Parameters:
    `deletedObjects` -
    `notifier` -
  Returns:

### shouldIgnoreNotification

    protected boolean shouldIgnoreNotification(org.eclipse.emf.common.notify.Notification notification)

  determine if the passed notification can be ignored or not the default implementation will ignore touch event if it is not a resolve event, also it will ignore the mutable feature events

  Parameters:
    `notification` - the notification to check
  Returns:
    true if the notification should be ignored, otherwise false

### fireNotification

    protected void fireNotification(org.eclipse.emf.common.notify.Notification event)

  Forward the supplied event to all listeners listening on the supplied target element.

  Note, for the MSL migration effort, each listener will be forwarded 2 events. First, a MSL complient Notification event followed by an ElementEvent (for backwards compatibility). The ElementEvent will be removed one the MSL migration is complete.

### addNotificationListener

    public void addNotificationListener(org.eclipse.emf.ecore.EObject target,
                                        NotificationPreCommitListener listener)

  Add the supplied `listener` to the listener list.

  Parameters:
    `target` - the traget to listen to
    `listener` - the listener

### addNotificationListener

    public void addNotificationListener(org.eclipse.emf.ecore.EObject target,
                                        NotificationListener listener)

  Add the supplied `listener` to the listener list.

  Parameters:
    `target` - the traget to listen to
    `listener` - the listener

### addNotificationListener

    public void addNotificationListener(org.eclipse.emf.ecore.EObject target,
                                        org.eclipse.emf.ecore.EStructuralFeature key,
                                        NotificationPreCommitListener listener)

  Add the supplied `listener` to the listener list.

  Parameters:
    `target` - the traget to listen to
    `key` - the key for the listener
    `listener` - the listener

### addNotificationListener

    public void addNotificationListener(org.eclipse.emf.ecore.EObject target,
                                        org.eclipse.emf.ecore.EStructuralFeature key,
                                        NotificationListener listener)

  Add the supplied `listener` to the listener list.

  Parameters:
    `target` - the traget to listen to
    `key` - the key for the listener
    `listener` - the listener

### removeNotificationListener

    public void removeNotificationListener(org.eclipse.emf.ecore.EObject target,
                                           NotificationPreCommitListener listener)

  remove the supplied `listener` from the listener list.

  Parameters:
    `target` - the traget to listen to
    `listener` - the listener

### removeNotificationListener

    public void removeNotificationListener(org.eclipse.emf.ecore.EObject target,
                                           NotificationListener listener)

  remove the supplied `listener` from the listener list.

  Parameters:
    `target` - the traget to listen to
    `listener` - the listener

### removeNotificationListener

    public void removeNotificationListener(org.eclipse.emf.ecore.EObject target,
                                           java.lang.Object key,
                                           NotificationPreCommitListener listener)

  remove the supplied `listener` from the listener list.

  Parameters:
    `target` - the traget to listen to
    `key` - the key for the listener
    `listener` - the listener

### removeNotificationListener

    public void removeNotificationListener(org.eclipse.emf.ecore.EObject target,
                                           java.lang.Object key,
                                           NotificationListener listener)

  remove the supplied `listener` from the listener list.

  Parameters:
    `target` - the traget to listen to
    `key` - the key for the listener
    `listener` - the listener

### getInterestedNotificationListeners

    protected java.util.Set getInterestedNotificationListeners(org.eclipse.emf.common.notify.Notification event,
                                                               DiagramEventBroker.NotifierToKeyToListenersSetMap listeners)

  gets a subset of all the registered listeners who are interested in receiving the supplied event.

  Parameters:
    `event` - the event to use
  Returns:
    the interested listeners in the event

### isAggregatePrecommitListener

    public boolean isAggregatePrecommitListener()

  Specified by:
    `isAggregatePrecommitListener` in interface `org.eclipse.emf.transaction.ResourceSetListener`
  Overrides:
    `isAggregatePrecommitListener` in class `org.eclipse.emf.transaction.ResourceSetListenerImpl`

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.