Add the capability to redefine an animator
Change-Id: Ie75bb431c5b204e3e684516f80d0a36d672a9d05
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF b/bundles/core/services/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF
index 8e50d3b..88b6c78 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF
@@ -29,6 +29,7 @@
org.eclipse.papyrus.moka.animation.css;x-internal:=true,
org.eclipse.papyrus.moka.animation.engine,
org.eclipse.papyrus.moka.animation.engine.animators,
+ org.eclipse.papyrus.moka.animation.engine.animators.actions,
org.eclipse.papyrus.moka.animation.engine.rendering,
org.eclipse.papyrus.moka.animation.presentation.control;x-internal:=true,
org.eclipse.papyrus.moka.animation.presentation.data;x-internal:=true,
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/schema/animator.exsd b/bundles/core/services/org.eclipse.papyrus.moka.animation/schema/animator.exsd
index a9332e3..12bdfba 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/schema/animator.exsd
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/schema/animator.exsd
@@ -77,6 +77,16 @@
</documentation>
</annotation>
</attribute>
+ <attribute name="redefined" type="string">
+ <annotation>
+ <documentation>
+ Identify an existing animator that is redefined by this animator. This animator will replace at runtime the redefined animator.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.papyrus.moka.animation.engine.animators.Animator:"/>
+ </appinfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/AnimatorExtensionEvaluator.java b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/AnimatorExtensionEvaluator.java
index db64a36..0ba28bb 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/AnimatorExtensionEvaluator.java
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/AnimatorExtensionEvaluator.java
@@ -12,7 +12,9 @@
package org.eclipse.papyrus.moka.animation.engine.animators;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -25,6 +27,8 @@
private static final String ANIMATOR_ID = "org.eclipse.papyrus.moka.animation.animator";
+ private static final String REDEFINED_ATTR = "redefined";
+
private static final String PRIORITY_ATTR = "priority";
private static final String CLASS_ATTR = "class";
@@ -32,23 +36,52 @@
private static final String DERIVED_ACTIONS_ATTR = "derivedAnimationAction";
public static List<Animator> evaluateAnimators(AnimationEngine engine){
- // Evaluate all contributions to the ANIMATOR extension points. The evaluation
- // process includes the instantiation of the contributed animator classes as
- // well as the association each animator to its specified priority.
+ // Evaluate all contributions to the ANIMATOR extension points
List<Animator> animators = new ArrayList<Animator>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] configuration = registry.getConfigurationElementsFor(ANIMATOR_ID);
- for(int i=0; i < configuration.length; i++){
- IConfigurationElement contribution = configuration[i];
- Animator animator = null;
+ IConfigurationElement[] configurations = registry.getConfigurationElementsFor(ANIMATOR_ID);
+ if(configurations.length > 0) {
+ Set<String> redefinedAnimator = getRedefinedAnimator(configurations);
+ for(IConfigurationElement configuration : configurations){
+ String clazz = configuration.getAttribute(CLASS_ATTR);
+ if(!redefinedAnimator.contains(clazz)) {
+ animators.add(createAnimator(configuration, engine));
+ }
+ }
+ }
+ return animators;
+ }
+
+ private static Set<String> getRedefinedAnimator(IConfigurationElement[] configurations){
+ // Build the set of animators that are redefined and that shall
+ // no be instantiated
+ Set<String> redefinedAnimator = new HashSet<String>();
+ for(IConfigurationElement configuration : configurations) {
+ String redefined = configuration.getAttribute(REDEFINED_ATTR);
+ if(redefined != null && !redefined.isEmpty()) {
+ redefinedAnimator.add(redefined);
+ }
+ }
+ return redefinedAnimator;
+ }
+
+ private static Animator createAnimator(IConfigurationElement configuration, AnimationEngine engine) {
+ // Instantiate the animator based on the information provided in the contribution
+ // to the extension point.
+ // 1] The class defining the animator is instantiated
+ // 2] If no priority is given to the animator then it has the default priority (i.e. 0)
+ // 3] If the animator is provided with derived animation actions then they
+ // are attached to the animator
+ Animator animator = null;
+ if(configuration != null) {
try {
- animator = (Animator) contribution.createExecutableExtension(CLASS_ATTR);
+ animator = (Animator) configuration.createExecutableExtension(CLASS_ATTR);
animator.setAnimationEngine(engine);
} catch (CoreException e) {
e.printStackTrace();
}
if(animator != null){
- String prioritySpecification = contribution.getAttribute(PRIORITY_ATTR);
+ String prioritySpecification = configuration.getAttribute(PRIORITY_ATTR);
if(prioritySpecification != null && !prioritySpecification.isEmpty()){
int priority = 0;
try{
@@ -60,14 +93,15 @@
}else{
animator.setPriority(0);
}
- animator.setDerivedAnimationAction(evaluateDerivedActions(contribution.getChildren(DERIVED_ACTIONS_ATTR)));
- animators.add(animator);
+ animator.setDerivedAnimationAction(evaluateDerivedActions(configuration.getChildren(DERIVED_ACTIONS_ATTR)));
}
}
- return animators;
+ return animator;
}
+
private static List<DerivedAnimationAction> evaluateDerivedActions(final IConfigurationElement[] contributions){
+ // Instantiate derived animation actions specified for an animator
List<DerivedAnimationAction> derivedActions = new ArrayList<DerivedAnimationAction>();
for(IConfigurationElement contribution : contributions) {
DerivedAnimationAction derivedAction = null;
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/StructuralAnimator.java b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/StructuralAnimator.java
index 4fd5612..d361128 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/StructuralAnimator.java
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/StructuralAnimator.java
@@ -47,16 +47,10 @@
AnimationKind.VISITED, MokaConstants.MOKA_ANIMATION_DELAY);
} else if (nodeVisitor instanceof IFeatureValueWrapper) {
// If the visited element is a structural feature newly associated to values
- // then two different animation behavior can occur:
- // 1] The structural feature has a type that is an active class then the feature
- // is marked as being animated (i.e., it is currently executed).
- // 2] The structural feature is not typed by an active class then the feature is
- // marked as being visited (i.e., it is not currently executing)
+ // then the structural feature is marked as being visited
IFeatureValueWrapper featureValue = (IFeatureValueWrapper) nodeVisitor;
Type type = featureValue.getFeature().getType();
- if (type instanceof Class && ((Class) type).isActive()) {
- this.engine.renderAs(featureValue.getFeature(), featureValue.getContext(), AnimationKind.ANIMATED);
- } else {
+ if (type instanceof Class) {
this.engine.renderAs(featureValue.getFeature(), featureValue.getContext(), AnimationKind.VISITED);
}
}
@@ -74,12 +68,7 @@
// while if it is passive it remains in the VISITED state
IObject_ object = (IObject_) value;
for (Classifier classifier : object.getTypes()) {
- Class clazz = (Class) classifier;
- if (clazz.isActive()) {
- this.engine.renderAs(clazz, object, AnimationKind.ANIMATED);
- } else {
- this.engine.renderAs(clazz, object, AnimationKind.VISITED);
- }
+ this.engine.renderAs((Class) classifier, object, AnimationKind.VISITED);
}
}
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/actions/composite/FeatureValueTypeDerivedAnimation.java b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/actions/composite/FeatureValueTypeDerivedAnimation.java
index 9b0855a..930d2a2 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/actions/composite/FeatureValueTypeDerivedAnimation.java
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/animators/actions/composite/FeatureValueTypeDerivedAnimation.java
@@ -26,9 +26,7 @@
// Enable the animation of the type of the new value
org.eclipse.papyrus.moka.fuml.Profiling.Semantics.Kernel.Classes.IFeatureValueWrapper featureValue = (IFeatureValueWrapper) visitor;
Type type = featureValue.getFeature().getType();
- if(type instanceof Class && ((Class)type).isActive()) {
- engine.renderAs(type, featureValue.getContext(), AnimationKind.ANIMATED);
- }else {
+ if(type instanceof Class) {
engine.renderAs(type, featureValue.getContext(), AnimationKind.VISITED);
}
}
diff --git a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
index f332543..0838793 100644
--- a/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
+++ b/bundles/core/services/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
@@ -79,7 +79,11 @@
// 2 - Build a cache linking a model element to a list of diagrams in which it appears
if (modelElement instanceof Element) {
// Find all diagrams available in this model
- Job diagramsLoading = new InitiliazeDiagramManagerJob(((Element) modelElement).getModel());
+ Element owner = ((Element)modelElement).getOwner();
+ while(owner.getOwner() != null) {
+ owner = owner.getOwner();
+ }
+ Job diagramsLoading = new InitiliazeDiagramManagerJob(owner.getModel());
diagramsLoading.schedule();
try {
diagramsLoading.join();