From fe4c4952b2b7f106acb19f00ec24e3e8fd3c659a Mon Sep 17 00:00:00 2001
From: Simon Barner <barner@fortiss.org>
Date: Mon, 1 Sep 2014 07:39:23 +0000
Subject: [PATCH] DerivedAnnotationBase -> IDerivedAnnotation<T>  - Change
 return type of getValue() to T  - This allows for more type safe
 implementation of the underlying calculations  - The former abstract base
 class DerivedAnnotationBase used Object as a return type for getValue() to
 due an EMF code generation bug for generics if the base class is located in a
 different .ecore file than the concrete class. For interfaces, this bug is
 not triggered.

refs 1841
---
 .../DerivedAnnotationValueProviderBase.java   |  8 +++----
 .../view/AnnotationViewPartBase.java          |  5 +++--
 .../trunk/model/base.ecore                    | 21 +++++++++----------
 .../trunk/model/base.genmodel                 |  7 ++++---
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/DerivedAnnotationValueProviderBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/DerivedAnnotationValueProviderBase.java
index ef9ae195a..d83fac55e 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/DerivedAnnotationValueProviderBase.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/valueprovider/DerivedAnnotationValueProviderBase.java
@@ -21,24 +21,24 @@ import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.EFactory;
 import org.eclipse.jface.viewers.ColumnViewer;
 import org.eclipse.jface.viewers.EditingSupport;
-import org.fortiss.tooling.base.model.base.DerivedAnnotationBase;
 import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
+import org.fortiss.tooling.base.model.element.IDerivedAnnotation;
 
 /**
  * Base class for {@link IAnnotationValueProvider} for derived annotations (i.e., based on
- * {@link DerivedAnnotationBase}).
+ * {@link IDerivedAnnotation}).
  * 
  * @author barner
  * @author $Author$
  * @version $Rev$
  * @ConQAT.Rating RED Hash:
  */
-public abstract class DerivedAnnotationValueProviderBase<T extends DerivedAnnotationBase> extends
+public abstract class DerivedAnnotationValueProviderBase<T extends IDerivedAnnotation<?>> extends
 		ValueProviderBase<T> {
 
 	/**
 	 * Constructs a {@link IAnnotationValueProvider} for derived annotations (i.e., based on
-	 * {@link DerivedAnnotationBase}).
+	 * {@link IDerivedAnnotation}).
 	 */
 	public DerivedAnnotationValueProviderBase(EClass annotatedSpecificationEClass,
 			EFactory annotationFactory) {
diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java
index 4e42219f5..6e31d43a7 100644
--- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java
+++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java
@@ -64,8 +64,9 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
 	Set<IModelElement> watchedModelElements = new HashSet<IModelElement>();
 
 	/**
-	 * {@link Adapter} to watch for the addition or removal of model elements to/from elements
-	 * visible in this {@link AnnotationViewPartBase} (to trigger according updates).
+	 * {@link Adapter} to watch for the addition, removal or value change of model elements
+	 * to/from/in elements visible in this {@link AnnotationViewPartBase} (to trigger according
+	 * updates).
 	 */
 	private final Adapter changeListener = new AdapterImpl() {
 		@Override
diff --git a/org.fortiss.tooling.base/trunk/model/base.ecore b/org.fortiss.tooling.base/trunk/model/base.ecore
index 4339ba1f6..58c9f1626 100644
--- a/org.fortiss.tooling.base/trunk/model/base.ecore
+++ b/org.fortiss.tooling.base/trunk/model/base.ecore
@@ -152,6 +152,16 @@
         <details key="documentation" value="An array of model element specifications."/>
       </eAnnotations>
     </eClassifiers>
+    <eClassifiers xsi:type="ecore:EClass" name="IDerivedAnnotation" abstract="true"
+        interface="true" eSuperTypes="#//element/IAnnotatedSpecification #//element/IHiddenSpecification">
+      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+        <details key="documentation" value="Base class for {@link IAnnotationSpecification}s that are derived from the state of other annotations and/or model elements.&#xD;&#xA;&#xD;&#xA;&lt;ul>&#xD;&#xA;&lt;li>Concrete specifications must provide a specialized getValue() {@link EOperation}s that perform the required calculation. Example: Calculation of {@link Component} WCET for current deployment (if available) based on {@link Component} instruction count and performance (e.g., MIPS) of {@link ExecutionUnit}, some warning indicator otherwise. &lt;/li>&#xD;&#xA;&lt;li>Concrete specifications may provide additional {@link EOperation} that provide an advanced query interface to the annoation. Example: WCET for an explicitly specified {@link ExecutionUnit}. This can be used e.g. in a DSE to explore different deployments.&lt;/li>&#xD;&#xA;&lt;li>The corresponding {@link IAnnotationValueProvider} should be based on {@link DerivedAnnotationValueProviderBase}.&#xD;&#xA;&lt;/ul>"/>
+      </eAnnotations>
+      <eTypeParameters name="T"/>
+      <eOperations name="getValue">
+        <eGenericType eTypeParameter="#//element/IDerivedAnnotation/T"/>
+      </eOperations>
+    </eClassifiers>
   </eSubpackages>
   <eSubpackages name="layout" nsURI="http://www.fortiss.org/tooling/base/model/layout"
       nsPrefix="org-fortiss-tooling-base-model-layout">
@@ -294,16 +304,5 @@
         </eAnnotations>
       </eOperations>
     </eClassifiers>
-    <eClassifiers xsi:type="ecore:EClass" name="DerivedAnnotationBase" abstract="true"
-        eSuperTypes="#//element/IAnnotatedSpecification #//element/IHiddenSpecification">
-      <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
-        <details key="documentation" value="Base class for {@link IAnnotationSpecification}s that are derived from the state of other annotations and/or model elements.&#xD;&#xA;&#xD;&#xA;&lt;ul>&#xD;&#xA;&lt;li>Concrete specifications must provide a specialized getValue() {@link EOperation}s that perform the required calculation. Example: Calculation of {@link Component} WCET for current deployment (if available) based on {@link Component} instruction count and performance (e.g., MIPS) of {@link ExecutionUnit}, some warning indicator otherwise. &lt;/li>&#xD;&#xA;&lt;li>Concrete specifications may provide additional {@link EOperation} that provide an advanced query interface to the annoation. Example: WCET for an explicitly specified {@link ExecutionUnit}. This can be used e.g. in a DSE to explore different deployments.&lt;/li>&#xD;&#xA;&lt;li>The corresponding {@link IAnnotationValueProvider} should be based on {@link DerivedAnnotationValueProviderBase}.&#xD;&#xA;&lt;/ul>"/>
-      </eAnnotations>
-      <eOperations name="getValue" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EJavaObject">
-        <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
-          <details key="body" value="return null;"/>
-        </eAnnotations>
-      </eOperations>
-    </eClassifiers>
   </eSubpackages>
 </ecore:EPackage>
diff --git a/org.fortiss.tooling.base/trunk/model/base.genmodel b/org.fortiss.tooling.base/trunk/model/base.genmodel
index ea8a322df..f21f947c8 100644
--- a/org.fortiss.tooling.base/trunk/model/base.genmodel
+++ b/org.fortiss.tooling.base/trunk/model/base.genmodel
@@ -48,6 +48,10 @@
       </genClasses>
       <genClasses image="false" ecoreClass="base.ecore#//element/IHiddenSpecification"/>
       <genClasses ecoreClass="base.ecore#//element/IAnnotatedSpecification"/>
+      <genClasses image="false" ecoreClass="base.ecore#//element/IDerivedAnnotation">
+        <genTypeParameters ecoreTypeParameter="base.ecore#//element/IDerivedAnnotation/T"/>
+        <genOperations ecoreOperation="base.ecore#//element/IDerivedAnnotation/getValue"/>
+      </genClasses>
     </nestedGenPackages>
     <nestedGenPackages prefix="Layout" basePackage="org.fortiss.tooling.base.model"
         disposableProviderFactory="true" ecorePackage="base.ecore#//layout">
@@ -97,9 +101,6 @@
         <genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getURI"/>
         <genOperations ecoreOperation="base.ecore#//base/LibraryElementBase/getName"/>
       </genClasses>
-      <genClasses image="false" ecoreClass="base.ecore#//base/DerivedAnnotationBase">
-        <genOperations ecoreOperation="base.ecore#//base/DerivedAnnotationBase/getValue"/>
-      </genClasses>
     </nestedGenPackages>
   </genPackages>
 </genmodel:GenModel>
-- 
GitLab