Bug 509598 - [Model Editor] refreshOnSave seems to be called for all
saves

Change-Id: I8ab01a0ea146233a7346ea463672af7c7a70fe7d
Signed-off-by: Olivier Prouvost <olivier.prouvost@opcoach.com>
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index b672ace..0c9706c 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -27,6 +27,7 @@
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
+import javax.inject.Named;
 
 import org.eclipse.core.databinding.ObservablesManager;
 import org.eclipse.core.databinding.observable.IObservable;
@@ -170,6 +171,7 @@
 import org.eclipse.e4.ui.model.fragment.MModelFragments;
 import org.eclipse.e4.ui.model.fragment.impl.FragmentPackageImpl;
 import org.eclipse.e4.ui.model.internal.ModelUtils;
+import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.e4.ui.workbench.UIEvents;
 import org.eclipse.e4.ui.workbench.UIEvents.EventTags;
 import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
@@ -342,6 +344,10 @@
 	@Optional
 	private IModelExtractor modelExtractor;
 
+	@Inject
+	@Optional
+	MPart currentPart;
+
 	private final ObservablesManager obsManager;
 
 	private final IResourcePool resourcePool;
@@ -1998,9 +2004,15 @@
 	@Inject
 	@Optional
 	public void refreshOnSave(
-			@UIEventTopic(UIEvents.Dirtyable.TOPIC_DIRTY) org.osgi.service.event.Event event) {
+			@UIEventTopic(UIEvents.Dirtyable.TOPIC_DIRTY) org.osgi.service.event.Event event,
+			@Named(IServiceConstants.ACTIVE_PART) MPart part) {
 		// If the application model is saved (-> becomes undirty) we must
 		// refresh tree (bug 472706)
+		// Must react only if editor is the current one... (bug 509598)
+		if (part != currentPart) {
+			return;
+		}
+
 		final Object type = event.getProperty(EventTags.TYPE);
 		final Object newValue = event.getProperty(EventTags.NEW_VALUE);