Class EObjectChangeNotifier

java.lang.Object
com.amalgamasimulation.desktop.ui.emf.EObjectChangeNotifier

public class EObjectChangeNotifier extends Object
Observes every change in the containment tree of a root EObject with a single EContentAdapter and notifies listeners once per batch of changes.

A batch ends when no change has arrived for the quiet period, so a burst of changes (moving many objects, removing many objects, a long operation applied in one go) results in one call of each affected listener. Changes are accepted from any thread; listeners are always called on the UI thread.

Typed listeners are called when the batch touches an object of one of the given classes (subclasses included): the changed object, objects added to or removed from its containment features, or the containers of the changed object. References are not traversed.

  • Field Details

    • DEFAULT_QUIET_PERIOD_MS

      public static final int DEFAULT_QUIET_PERIOD_MS
      See Also:
  • Constructor Details

    • EObjectChangeNotifier

      public EObjectChangeNotifier()
  • Method Details

    • observeEObject

      public void observeEObject(org.eclipse.emf.ecore.EObject newRoot)
      Starts observing the given root and stops observing the previous one. Pass null to stop observing.

      Replacing the root counts as a change of every object: all listeners, typed ones included, are called after the quiet period, as for any other batch.

    • addChangeListener

      public void addChangeListener(Set<Class<?>> types, Runnable changeHandler)
      Adds a handler called once per batch that touches an object of any of the given classes or their subclasses.
    • addFeatureChangeListener

      public void addFeatureChangeListener(Set<org.eclipse.emf.ecore.EStructuralFeature> features, Runnable changeHandler)
    • addChangeListener

      public void addChangeListener(Runnable changeHandler)
      Adds a handler called once per batch of any changes.
    • removeChangeListener

      public void removeChangeListener(Runnable changeHandler)
      Removes the handler added by any of the addChangeListener methods.