From 883d26739674e12c06d6e18f549154edd1b7409b Mon Sep 17 00:00:00 2001
From: Simon Barner <barner@fortiss.org>
Date: Wed, 8 Nov 2017 10:19:24 +0000
Subject: [PATCH] Use AnnotationViewPart.setUpdateEnabled() consistently with
 rest of code base

---
 .../sysmodel/arch/af3/AF3SystemModelAdapter.java    |  8 +++++++-
 .../internal/ExplorationTransformationService.java  | 13 ++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java
index a734d77d..68af409e 100644
--- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java
+++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/dse/sysmodel/arch/af3/AF3SystemModelAdapter.java
@@ -27,6 +27,7 @@ import static org.fortiss.af3.exploration.alg.util.ExplorationAlgUtils.getDeploy
 import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getPhysicalPlatformArchitecture;
 import static org.fortiss.af3.platform.utils.PlatformArchitectureUtils.getReferencedElementsWithType;
 import static org.fortiss.af3.schedule.utils.MathUtils.gcdDoubleCollection;
+import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.isUpdateEnabled;
 import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled;
 import static org.fortiss.tooling.kernel.utils.EcoreUtils.getChildrenWithType;
 import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
@@ -111,12 +112,16 @@ public class AF3SystemModelAdapter
 	 */
 	private Collection<IDeployableComponentAdapter<Component>> componentReplacementAdapters;
 
+	// TODO (2x): package access rights are ok? If so, please add /* package */
 	/** Contains informations whether the given AF3 model supports multicast channels. */
 	boolean multicastSupport = false;
 
 	/** References the method which returns the multicast targets (if available). */
 	Method multicastGetTargets;
 
+	/** Cache the Annotation View's update status. */
+	private boolean annotationUpdateEnabled;
+
 	/**
 	 * Constructor.
 	 * 
@@ -147,6 +152,7 @@ public class AF3SystemModelAdapter
 		putInputModel(PlatformArchitecture.class, platformArchitecture);
 
 		// Disable any annotation view update.
+		annotationUpdateEnabled = isUpdateEnabled();
 		setUpdateEnabled(false);
 
 		// Determine the associated hardware platform given the platform architecture is a a model
@@ -210,7 +216,7 @@ public class AF3SystemModelAdapter
 		createAbstractTaskGraphEncoding();
 
 		// Re-enable annotation view updates.
-		setUpdateEnabled(true);
+		setUpdateEnabled(annotationUpdateEnabled);
 	}
 
 	/** Determines whether the current AF3 version supports multicast channels. */
diff --git a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java
index 590e7175..b33e9856 100644
--- a/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java
+++ b/org.fortiss.af3.exploration.alg/trunk/src/org/fortiss/af3/exploration/alg/service/internal/ExplorationTransformationService.java
@@ -270,11 +270,8 @@ public class ExplorationTransformationService<T extends ITransformationModule<?>
 			((ITransformationStrategy<?>)moduleInstance).setModelName(transformedModelName);
 		}
 
-		// Disable any Annotation view update
-		if(isUpdateEnabled()) {
-			annotationUpdateEnabled = true;
-			setUpdateEnabled(false);
-		}
+		annotationUpdateEnabled = isUpdateEnabled();
+		setUpdateEnabled(false);
 
 		SubClassToInstanceMap<U> transformedModels = MutableSubClassToInstanceMap.create();
 		moduleInstance.transform(TransformationState.INITIALIZING, context, baseModels,
@@ -296,10 +293,8 @@ public class ExplorationTransformationService<T extends ITransformationModule<?>
 			((ITransformationStrategy<?>)moduleInstance).addModelToProject(fp, modelContext);
 		}
 
-		// Disable any Annotation view update
-		if(annotationUpdateEnabled) {
-			setUpdateEnabled(true);
-		}
+		// Re-enable Annotation view updates if needed
+		setUpdateEnabled(annotationUpdateEnabled);
 
 		ClassToInstanceMap<U> retModels = MutableClassToInstanceMap.create();
 		for(Class<? extends EObject> retType : transformedModelTypes) {
-- 
GitLab