diff options
author | jeremie.tatibouet | 2015-11-13 17:22:26 +0000 |
---|---|---|
committer | jeremie.tatibouet | 2015-11-24 15:20:38 +0000 |
commit | ba766b2e20ecd1ece737c21909b1f6311b26be6a (patch) | |
tree | c3b6eb6fe6ab33a38b7a941f1cf97882267c8133 | |
parent | 235ec77206d641bddca1b98879d026904bd8de2b (diff) | |
download | org.eclipse.papyrus-moka-ba766b2e20ecd1ece737c21909b1f6311b26be6a.tar.gz org.eclipse.papyrus-moka-ba766b2e20ecd1ece737c21909b1f6311b26be6a.tar.xz org.eclipse.papyrus-moka-ba766b2e20ecd1ece737c21909b1f6311b26be6a.zip |
1 - Separate animation framework from oep.moka.ui
2 - Refactor animation framework code
3 - Fix deadlock introduced by fUML services
Change-Id: I292d78f8a5d110ecffadefbf01933788516dae78
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
30 files changed, 851 insertions, 675 deletions
diff --git a/org.eclipse.papyrus.moka.animation/.classpath b/org.eclipse.papyrus.moka.animation/.classpath new file mode 100644 index 00000000..b862a296 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.papyrus.moka.animation/.project b/org.eclipse.papyrus.moka.animation/.project new file mode 100644 index 00000000..298628fe --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.moka.animation</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF b/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF new file mode 100644 index 00000000..502fdedc --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/META-INF/MANIFEST.MF @@ -0,0 +1,28 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Moka animation framework +Bundle-SymbolicName: org.eclipse.papyrus.moka.animation;singleton:=true +Bundle-Version: 1.2.0.qualifier +Bundle-Activator: org.eclipse.papyrus.moka.animation.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.emf.ecore, + org.eclipse.papyrus.infra.services.markerlistener, + org.eclipse.gmf.runtime.notation.edit, + org.eclipse.papyrus.infra.core, + org.eclipse.papyrus.moka, + org.eclipse.emf.transaction, + org.eclipse.papyrus.infra.emf, + org.eclipse.gef, + org.eclipse.debug.core, + org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0", + org.eclipse.uml2.uml, + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0", + org.eclipse.core.jobs, + org.eclipse.jface, + org.eclipse.ui.workbench, + org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="1.2.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-ActivationPolicy: lazy +Export-Package: org.eclipse.papyrus.moka.animation, + org.eclipse.papyrus.moka.animation.engine diff --git a/org.eclipse.papyrus.moka.animation/build.properties b/org.eclipse.papyrus.moka.animation/build.properties new file mode 100644 index 00000000..6f20375d --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/build.properties @@ -0,0 +1,5 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/org.eclipse.papyrus.moka.animation/plugin.xml b/org.eclipse.papyrus.moka.animation/plugin.xml new file mode 100644 index 00000000..06ee524d --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/plugin.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.css.markertopseudoselectormappingprovider">
+ <provider
+ class="org.eclipse.papyrus.moka.animation.css.AnimationPseudoSelectorMappingProvider">
+ </provider>
+ </extension>
+ <extension
+ id="org.eclipse.papyrus.moka.animation.suspendedmarker"
+ name="SUSPENDED MARKER"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.papyrus.modelmarker">
+ </super>
+ <persistent
+ value="false">
+ </persistent>
+ </extension>
+ <extension
+ id="org.eclipse.papyrus.moka.animation.animatedmarker"
+ name="ANIMATED MARKER"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.papyrus.modelmarker">
+ </super>
+ <persistent
+ value="false">
+ </persistent>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.css.theme">
+ <themeContribution
+ id="org.eclipse.papyrus.css.papyrus_theme">
+ <stylesheet
+ stylesheetPath="theme/defaultAnimationTheme.css">
+ </stylesheet>
+ </themeContribution>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.papyrus.moka.animation/pom.xml b/org.eclipse.papyrus.moka.animation/pom.xml new file mode 100644 index 00000000..406e52fd --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/pom.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.papyrus.moka.parent</artifactId> + <groupId>org.eclipse.papyrus.moka</groupId> + <version>1.2.0-SNAPSHOT</version> + </parent> + <artifactId>org.eclipse.papyrus.moka.animation</artifactId> + <packaging>eclipse-plugin</packaging> + <name>org.eclipse.papyrus.moka.animation</name> +</project>
\ No newline at end of file diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/Activator.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/Activator.java new file mode 100644 index 00000000..eb42d733 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.papyrus.moka.animation;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.moka.animation"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/css/AnimationPseudoSelectorMappingProvider.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/css/AnimationPseudoSelectorMappingProvider.java new file mode 100644 index 00000000..519ef163 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/css/AnimationPseudoSelectorMappingProvider.java @@ -0,0 +1,30 @@ +package org.eclipse.papyrus.moka.animation.css;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.papyrus.infra.gmfdiag.css.service.IMarkerToPseudoSelectorMappingProvider;
+import org.eclipse.papyrus.moka.animation.utils.AnimationUtils;
+
+public class AnimationPseudoSelectorMappingProvider implements IMarkerToPseudoSelectorMappingProvider {
+
+ protected Map<String, String> mappings;
+
+ public final static String BREAKPOINT_MARKER_PSEUDO_SELECTOR = "breakpoint";
+
+ public final static String SUSPENDED_MARKER_PSEUDO_SELECTOR = "suspended";
+
+ public final static String ANIMATION_MARKER_PSEUDO_SELECTOR = "animated";
+
+ public AnimationPseudoSelectorMappingProvider() {}
+
+ public Map<String, String> getMappings() {
+ if (this.mappings == null) {
+ this.mappings = new HashMap<String, String>();
+ // Adds pseudo selectors for 'suspended' and 'animation' markers
+ this.mappings.put(AnimationUtils.SUSPENDED_MARKER_ID, SUSPENDED_MARKER_PSEUDO_SELECTOR);
+ this.mappings.put(AnimationUtils.ANIMATED_MARKER_ID, ANIMATION_MARKER_PSEUDO_SELECTOR);
+ }
+ return this.mappings;
+ }
+}
diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimatedDiagramManager.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimatedDiagramManager.java new file mode 100644 index 00000000..62910a13 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimatedDiagramManager.java @@ -0,0 +1,148 @@ +package org.eclipse.papyrus.moka.animation.engine;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Model;
+
+public class AnimatedDiagramManager {
+
+ // The set of diagrams identified for a given model
+ protected HashSet<Diagram> modelDiagrams;
+
+ // The cache linking a model element to the of diagram in which it appears
+ protected HashMap<EObject, HashSet<Diagram>> modelDiagramMapping;
+
+ public AnimatedDiagramManager(){
+ this.modelDiagrams = new HashSet<Diagram>();
+ this.modelDiagramMapping = new HashMap<EObject, HashSet<Diagram>>();
+ }
+
+ public AnimatedDiagramManager(Model model){
+ this();
+ this.init(model);
+ }
+
+ /**
+ * Initialize the animated diagrams manager. The initialize process consist in:
+ * 1 - Identifying diagrams located in a model
+ * 2 - Build a cache linking a model element to a list of diagrams in which it appears
+ *
+ * @param modelElement - the model element used as a starting point for the initialization
+ */
+ public void init(EObject modelElement){
+ if(modelElement instanceof Element){
+ // Find all diagrams available in this model
+ Job diagramsLoading = new InitiliazeDiagramManagerJob(((Element)modelElement).getModel());
+ diagramsLoading.schedule();
+ try {
+ diagramsLoading.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("here");
+ }
+ }
+
+ /**
+ * Find the set of diagrams in which in the given model element appears
+ *
+ * @param modelElement - the model element for which the diagrams are searched
+ *
+ * @param notationResource - the resource (.notation) in which the associated diagrams can be found
+ *
+ * @return associatedDiagrams - the list of diagrams associated to the given model element
+ */
+ private List<Diagram> getAssociatedDiagrams(EObject modelElement, Resource notationResource){
+ List<Diagram> associatedDiagrams = new ArrayList<Diagram>();
+ if(notationResource!=null && modelElement!=null){
+ return DiagramUtils.getAssociatedDiagramsFromNotationResource(modelElement, notationResource);
+ }
+ return associatedDiagrams;
+ }
+
+ /**
+ * Identify all diagrams that are available in a model. The unique place from which this operation
+ * is called is the job in charge of executing the search.
+ *
+ * @param model - The model in which the diagrams should identified
+ *
+ * @param monitor - The monitor used to report progress of our search
+ */
+ private void searchDiagrams(Model model, IProgressMonitor monitor){
+ // Initialization
+ Resource resource = model.eResource();
+ ResourceSet resourceSet = resource.getResourceSet();
+ // Load the resource corresponding to the notation
+ final String resourceNotationURI = model.eResource().getURI().toString().replaceAll("\\.uml$", ".notation");
+ Resource notationResource = resourceSet.getResource(URI.createURI(resourceNotationURI), true);
+ // Iterate over all model elements in order to discover all diagrams
+ Iterator<EObject> modelContentIterator = model.eAllContents();
+ while(modelContentIterator.hasNext()){
+ EObject currentModelElement = modelContentIterator.next();
+ // Find the associated diagrams
+ List<Diagram> diagrams = this.getAssociatedDiagrams(currentModelElement, notationResource);
+ // Build the cache to relate the model element the set of diagrams where it is shown
+ if(!diagrams.isEmpty()){
+ if(this.modelDiagramMapping.get(currentModelElement)==null){
+ HashSet<Diagram> setOfDiagrams = new HashSet<Diagram>();
+ setOfDiagrams.addAll(diagrams);
+ this.modelDiagramMapping.put(currentModelElement, setOfDiagrams);
+ }else{
+ this.modelDiagramMapping.get(currentModelElement).addAll(diagrams);
+ }
+ // Add newly found diagrams to the set
+ this.modelDiagrams.addAll(diagrams);
+ }
+ monitor.worked(1);
+ }
+ }
+
+ /**
+ * The diagrams search is executed in a separate job.
+ */
+ class InitiliazeDiagramManagerJob extends Job{
+
+ private Model model;
+
+ public InitiliazeDiagramManagerJob(Model model) {
+ super("Diagrams lookup");
+ this.model = model;
+ this.setUser(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Diagrams lookup", IProgressMonitor.UNKNOWN);
+ AnimatedDiagramManager.this.searchDiagrams(this.model, monitor);
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ /**
+ * A model element is considered as being "renderable" if it has diagrams in which it appears
+ *
+ * @param modelElement - the model element that we assess as being renderable
+ *
+ * @return true if the the element is present in the cache; false otherwise
+ */
+ public boolean isRenderable(EObject modelElement){
+ return this.modelDiagramMapping.get(modelElement)!=null;
+ }
+}
diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationKind.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationKind.java new file mode 100644 index 00000000..ad7bceae --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationKind.java @@ -0,0 +1,6 @@ +package org.eclipse.papyrus.moka.animation.engine;
+
+public enum AnimationKind {
+ ANIMATED,
+ SUSPENDED,
+}
diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationManager.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationManager.java new file mode 100644 index 00000000..49718cd7 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/AnimationManager.java @@ -0,0 +1,232 @@ +/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.moka.animation.engine; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EValidator; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker; +import org.eclipse.papyrus.infra.services.markerlistener.PapyrusMarkerAdapter; +import org.eclipse.papyrus.moka.animation.utils.AnimationUtils; + +/** + * Some facilities to manage animation in diagrams. + * + */ +public class AnimationManager implements IAnimationManager{ + + // The diagram manager handles every action done by the animation regarding diagrams + AnimatedDiagramManager diagramManager; + + // The static instance for this class + protected static AnimationManager eInstance = null; + + // Maintain a map of model elements having makers + // The only purpose of this map is too avoid a to global search in diagrams at some points of the execution + protected Map<EObject, List<IPapyrusMarker>> modelElementMarkers = new HashMap<EObject, List<IPapyrusMarker>>(); + + + private AnimationManager() { + this.diagramManager = new AnimatedDiagramManager(); + this.modelElementMarkers = new HashMap<EObject, List<IPapyrusMarker>>(); + } + + private boolean hasMarker(EObject modelElement, AnimationKind kind){ + if(modelElement==null){ + return false; + } + List<IPapyrusMarker> markers = this.modelElementMarkers.get(modelElement); + if(markers==null || markers.isEmpty()){ + return false; + } + boolean found = false; + int i = 0; + while(!found && i < markers.size()){ + IPapyrusMarker marker = markers.get(i); + String type = ""; + try { + type = marker.getType(); + } catch (CoreException e) { + e.printStackTrace(); + } + if(kind==AnimationKind.ANIMATED){ + found = type.equals(AnimationUtils.ANIMATED_MARKER_ID); + }else if(kind==AnimationKind.SUSPENDED){ + found = type.equals(AnimationUtils.SUSPENDED_MARKER_ID); + } + i++; + } + return found; + } + + @SuppressWarnings("unchecked") + private IPapyrusMarker createMarker(final EObject modelElement, final String markerID, @SuppressWarnings("rawtypes") Map attributes){ + IPapyrusMarker marker = null; + // Assert that the model element is usable + if(modelElement==null || modelElement.eResource()==null){ + return null; + } + final String uri = EcoreUtil.getURI(modelElement).toString(); + if(uri==null || uri.isEmpty()){ + return null; + } + // Assert we are able to access the resource on which the marker will be placed + IResource resource = this.getWorkspaceResource(modelElement); + if(resource!=null && resource.exists()){ + IMarker newMarker = null; + try { + newMarker = resource.createMarker(markerID); + newMarker.setAttributes(attributes); + } catch (CoreException e) { + e.printStackTrace(); + } + if(newMarker!=null){ + // Place the Papyrus marker + marker = PapyrusMarkerAdapter.wrap(modelElement.eResource(), newMarker, attributes); + } + } + return marker; + } + + private IResource getWorkspaceResource(final EObject modelElement){ + IResource resource = null; + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + if(workspace!=null){ + resource = workspace.getRoot().getFile(new Path(modelElement.eResource().getURI().toPlatformString(true))); + } + return resource; + } + + /** + * Returns an instance of AnimationManager. Guarantees that AnimationManager is instantiated only once. + * + * @return An instance of AnimationManagers + */ + public static AnimationManager getInstance() { + if (eInstance == null) { + eInstance = new AnimationManager(); + } + return eInstance; + } + + /** + * Initialize the animation manager + * + * @param modelElement + */ + public void init(EObject modelElement){ + // Triggers diagrams search when called + this.diagramManager.init(modelElement); + } + + @Override + public void startRendering(EObject modelElement, AnimationKind animationKind) { + // A marker is only registered on a model element if + // this latter has not already a marker applied on it + // and if so this marker is not of the kind of the requested + // marker + if(!this.hasMarker(modelElement, animationKind)){ + IPapyrusMarker marker = null; + // Build attributes + Map<String, String> attributes = new HashMap<String, String>(); + attributes.put(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(modelElement).toString()); + // Defined which type of animation is expected + if(animationKind.equals(AnimationKind.ANIMATED)){ + marker = this.createMarker(modelElement, AnimationUtils.ANIMATED_MARKER_ID, attributes); + }else if(animationKind.equals(AnimationKind.SUSPENDED)){ + marker = this.createMarker(modelElement, AnimationUtils.SUSPENDED_MARKER_ID, attributes); + }else{ + System.err.println("[startRendering] - animation kind not recognized"); + } + // Update map of applied markers + List<IPapyrusMarker> markerList = this.modelElementMarkers.get(modelElement); + if(markerList==null){ + markerList = new ArrayList<IPapyrusMarker>(); + markerList.add(marker); + this.modelElementMarkers.put(modelElement, markerList); + }else{ + markerList.add(marker); + } + } + } + + @Override + public void render(EObject modelElement, AnimationKind animationKind, int renderingDuration) { + // Place the marker to trigger the user view to change + this.startRendering(modelElement, animationKind); + // The duration for which the marker is in place + try { + Thread.sleep(renderingDuration); + } catch (InterruptedException e) { + e.printStackTrace(); + } + // Remove the marker to trigger the user view to change + this.stopRendering(modelElement, animationKind); + } + + @Override + public void stopRendering(EObject modelElement, AnimationKind kind) { + // A + if(this.hasMarker(modelElement, kind)){ + List<IPapyrusMarker> markers = this.modelElementMarkers.get(modelElement); + Iterator<IPapyrusMarker> markersIterator = markers.iterator(); + IPapyrusMarker marker = null; + while(marker==null && markersIterator.hasNext()){ + IPapyrusMarker currentMarker = markersIterator.next(); + String markerType=""; + try { + markerType = currentMarker.getType(); + } catch (CoreException e) { + e.printStackTrace(); + } + if(kind==AnimationKind.ANIMATED){ + marker = markerType.equals(AnimationUtils.ANIMATED_MARKER_ID) ? currentMarker : null; + }else if(kind==AnimationKind.SUSPENDED){ + marker = markerType.equals(AnimationUtils.SUSPENDED_MARKER_ID) ? currentMarker : null; + } + } + if(marker!=null){ + this.modelElementMarkers.get(modelElement).remove(marker); + try { + marker.delete(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + } + + public void stopRendering(EObject modelElement){ + + } + + @Override + public boolean isRenderable(EObject modelElement) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/IAnimationManager.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/IAnimationManager.java new file mode 100644 index 00000000..f705a2e5 --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/engine/IAnimationManager.java @@ -0,0 +1,15 @@ +package org.eclipse.papyrus.moka.animation.engine;
+
+import org.eclipse.emf.ecore.EObject;
+
+public interface IAnimationManager {
+
+ public void startRendering(EObject modelElement, AnimationKind animationKind);
+
+ public void render(EObject modelElement, AnimationKind animationKind, int renderingDuration);
+
+ public void stopRendering(EObject modelElement, AnimationKind animationKind);
+
+ public boolean isRenderable(EObject modelElement);
+
+}
diff --git a/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/utils/AnimationUtils.java b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/utils/AnimationUtils.java new file mode 100644 index 00000000..042ceb6e --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/src/org/eclipse/papyrus/moka/animation/utils/AnimationUtils.java @@ -0,0 +1,13 @@ +package org.eclipse.papyrus.moka.animation.utils;
+
+public class AnimationUtils {
+
+ // Declares the ID of the suspended marker
+ // NOTE: this ID is the same that the one used to declare the marker in the extensions
+ public static String SUSPENDED_MARKER_ID = "org.eclipse.papyrus.moka.animation.suspendedmarker";
+
+ // Declares the ID of the animated marker
+ // NOTE: this ID is the same that the one used to declare the marker in the extensions
+ public static String ANIMATED_MARKER_ID = "org.eclipse.papyrus.moka.animation.animatedmarker";
+
+}
diff --git a/org.eclipse.papyrus.moka.animation/theme/defaultAnimationTheme.css b/org.eclipse.papyrus.moka.animation/theme/defaultAnimationTheme.css new file mode 100644 index 00000000..77ececff --- /dev/null +++ b/org.eclipse.papyrus.moka.animation/theme/defaultAnimationTheme.css @@ -0,0 +1,17 @@ +:animated{
+ /*Edge of the shape affected by the pseudo selector*/
+ lineColor: #92d050;
+ lineWidth: 2px;
+ /*Content of the shape affected by the pseudo selector*/
+ fillColor: #0070c0;
+ bold: true;
+}
+
+:suspended{
+ /*Edge of the shape affected by the pseudo selector*/
+ lineColor: #c00000;
+ lineWidth: 2px;
+ /*Content of the shape affected by the pseudo selector*/
+ fillColor: #fab953;
+ bold: true;
+}
\ No newline at end of file diff --git a/org.eclipse.papyrus.moka.async.fuml/META-INF/MANIFEST.MF b/org.eclipse.papyrus.moka.async.fuml/META-INF/MANIFEST.MF index eef2e448..f7cfecd6 100644 --- a/org.eclipse.papyrus.moka.async.fuml/META-INF/MANIFEST.MF +++ b/org.eclipse.papyrus.moka.async.fuml/META-INF/MANIFEST.MF @@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.moka.fuml.standardlibrary;bundle-version="1.2.0", org.eclipse.ui.console, org.apache.commons.lang, - org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.2.0" + org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.2.0", + org.eclipse.papyrus.moka.animation Export-Package: org.eclipse.papyrus.moka.async.fuml, org.eclipse.papyrus.moka.async.fuml.Semantics.Classes.Kernel, org.eclipse.papyrus.moka.async.fuml.Semantics.CommonBehaviors.Communications, diff --git a/org.eclipse.papyrus.moka.async.fuml/src/org/eclipse/papyrus/moka/async/fuml/debug/AsyncControlDelegate.java b/org.eclipse.papyrus.moka.async.fuml/src/org/eclipse/papyrus/moka/async/fuml/debug/AsyncControlDelegate.java index 72374b88..1306d4a6 100644 --- a/org.eclipse.papyrus.moka.async.fuml/src/org/eclipse/papyrus/moka/async/fuml/debug/AsyncControlDelegate.java +++ b/org.eclipse.papyrus.moka.async.fuml/src/org/eclipse/papyrus/moka/async/fuml/debug/AsyncControlDelegate.java @@ -24,6 +24,8 @@ import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.emf.ecore.EObject; import org.eclipse.papyrus.infra.core.Activator; import org.eclipse.papyrus.moka.MokaConstants; +import org.eclipse.papyrus.moka.animation.engine.AnimationKind; +import org.eclipse.papyrus.moka.animation.engine.AnimationManager; import org.eclipse.papyrus.moka.async.fuml.Semantics.CommonBehaviors.Communications.AsyncObjectActivation; import org.eclipse.papyrus.moka.communication.event.Start_Event; import org.eclipse.papyrus.moka.communication.event.isuspendresume.Resume_Event; @@ -47,7 +49,6 @@ import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.Communications.Ob import org.eclipse.papyrus.moka.fuml.debug.ControlDelegate; import org.eclipse.papyrus.moka.fuml.debug.FUMLThread; import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils; -import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils; import org.eclipse.uml2.uml.AcceptEventAction; // TODO: Auto-generated Javadoc @@ -208,7 +209,7 @@ public class AsyncControlDelegate extends ControlDelegate { this.terminateRequestByClient = true; for (List<AcceptEventAction> waitingOn : this.objectActivationToWaitingAcceptEventActions.values()) { for (EObject o : waitingOn) { - AnimationUtils.getInstance().removeAnimationMarker(o); + //AnimationManager.getInstance().removeAnimationMarker(o); } } /**********/ @@ -234,7 +235,7 @@ public class AsyncControlDelegate extends ControlDelegate { synchronized (this) { notifyAll(); } - AnimationUtils.getInstance().removeAllAnimationMarker(); + //AnimationManager.getInstance().removeAllAnimationMarker(); } /** @@ -417,7 +418,7 @@ public class AsyncControlDelegate extends ControlDelegate { if (eventAccepter instanceof AcceptEventActionEventAccepter) { AcceptEventAction action = (AcceptEventAction) ((AcceptEventActionEventAccepter) eventAccepter).actionActivation.node; waitingAcceptEventActions.add(action); - AnimationUtils.getInstance().addAnimationMarker(action); + AnimationManager.getInstance().startRendering(action, AnimationKind.ANIMATED); } } objectActivationToWaitingAcceptEventActions.put(asyncObjectActivation, waitingAcceptEventActions); @@ -451,7 +452,7 @@ public class AsyncControlDelegate extends ControlDelegate { } objectActivationToWaitingAcceptEventActions.put(asyncObjectActivation, waitingAcceptEventActions); if (action != null) { - AnimationUtils.getInstance().removeAnimationMarker(action); + AnimationManager.getInstance().stopRendering(action); } } } diff --git a/org.eclipse.papyrus.moka.feature/feature.xml b/org.eclipse.papyrus.moka.feature/feature.xml index 49ff8ff2..b0fa54ab 100644 --- a/org.eclipse.papyrus.moka.feature/feature.xml +++ b/org.eclipse.papyrus.moka.feature/feature.xml @@ -1,6 +1,11 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?><feature id="org.eclipse.papyrus.moka.feature" label="%featureName" provider-name="%providerName" version="1.2.0.qualifier"> - - <description url="http://www.example.com/description"> +<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.papyrus.moka.feature"
+ label="%featureName"
+ version="1.2.0.qualifier"
+ provider-name="%providerName">
+
+ <description url="http://www.example.com/description">
MOKA is a framework for executing/simulating debugging fUML models. It implements: 1 - The execution semantics of Foundational UML @@ -8,37 +13,89 @@ It provides the following possibilities: 1 - Execute models built from the UML subset considered by fUML (i.e. Classes, Actions, Activities, Composite Structures, Parts, Ports and Connectors) 2 - At runtime models are animated (i.e. current executed nodes are hilighted in a specific way) - 3 - At runtime models can be debugged. According to breakpoints placed on a model, the execution engines stops and the UI provides variables snapshops which are presented to the user. - </description> - - <copyright url="http://www.example.com/copyright"> + 3 - At runtime models can be debugged. According to breakpoints placed on a model, the execution engines stops and the UI provides variables snapshops which are presented to the user.
+ </description>
+
+ <copyright url="http://www.example.com/copyright">
Copyright (c) 2013 CEA LIST. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License - v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html - </copyright> - - <license url="%licenseURL"> - %license - </license> - - <plugin download-size="0" id="org.eclipse.papyrus.moka" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.async.fuml" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.composites" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.fuml" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.fuml.assertionlibrary" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.fuml.standardlibrary" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.ui" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.composites.utils" install-size="0" unpack="false" version="0.0.0"/> - - <plugin download-size="0" id="org.eclipse.papyrus.moka.doc" install-size="0" unpack="false" version="0.0.0"/> - -</feature>
\ No newline at end of file + v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
+ </copyright>
+
+ <license url="%licenseURL">
+ %license
+ </license>
+
+ <plugin
+ id="org.eclipse.papyrus.moka"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.async.fuml"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.composites"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.fuml"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.fuml.assertionlibrary"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.fuml.standardlibrary"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.composites.utils"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.doc"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.eclipse.papyrus.moka.animation"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardInputChannelImpl.java b/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardInputChannelImpl.java index 7f992478..9c095b14 100644 --- a/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardInputChannelImpl.java +++ b/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardInputChannelImpl.java @@ -9,7 +9,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * Jeremie Tatibouet (CEA LIST) - Align service code with abstract service *****************************************************************************/ package org.eclipse.papyrus.moka.fuml.standardlibrary.library.io; @@ -22,7 +22,6 @@ import java.util.List; import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StringValue; import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value; -import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution; import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue; import org.eclipse.papyrus.moka.fuml.debug.Debug; import org.eclipse.papyrus.moka.fuml.registry.service.framework.AbstractService; @@ -37,16 +36,17 @@ public class StandardInputChannelImpl extends AbstractService { public StandardInputChannelImpl(Class service) { super(service); - this.types.add(service); this.in = StandardOutputChannelImpl.getConsole().getInputStream(); } - + @Override - public Execution dispatch(Operation operation) { - if (operation.getName().equals("readLine")) { - return new ReadLineExecution(operation); + public void doOperationExecutionMapping() { + Class type = this.types.get(0); + for(Operation operation : type.getOwnedOperations()){ + if (operation.getName().equals("readLine")) { + this.operationExecution.put(operation, new ReadLineExecution(operation)); + } } - return null; } protected class ReadLineExecution extends AbstractService.ServiceOperationExecution { diff --git a/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardOutputChannelImpl.java b/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardOutputChannelImpl.java index e11d1670..fa801228 100644 --- a/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardOutputChannelImpl.java +++ b/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/io/StandardOutputChannelImpl.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.StringValue; import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value; -import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution; import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue; import org.eclipse.papyrus.moka.fuml.debug.Debug; import org.eclipse.papyrus.moka.fuml.registry.service.framework.AbstractService; @@ -51,16 +50,17 @@ public class StandardOutputChannelImpl extends AbstractService { super(service); this.out = getConsole().newOutputStream(); } - + @Override - public Execution dispatch(Operation operation) { - if (operation.getName().equals("writeLine")) { - return new WriteLineExecution(operation); - } else if (operation.getName().equals("write")) { - return new Write(operation); + public void doOperationExecutionMapping() { + Class type = this.types.get(0); + for(Operation operation : type.getOwnedOperations()){ + if (operation.getName().equals("writeLine")) { + this.operationExecution.put(operation, new WriteLineExecution(operation)); + } else if (operation.getName().equals("write")) { + this.operationExecution.put(operation, new Write(operation)); + } } - // TODO complete with other operations - return null; } protected class WriteLineExecution extends AbstractService.ServiceOperationExecution { diff --git a/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF b/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF index 175ad596..3680f54f 100644 --- a/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF +++ b/org.eclipse.papyrus.moka.fuml/META-INF/MANIFEST.MF @@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui, org.apache.commons.lang;bundle-version="2.6.0", org.eclipse.emf.ecore, org.eclipse.emf.codegen;bundle-version="2.9.0", - org.eclipse.uml2.codegen.ecore;bundle-version="1.9.0" + org.eclipse.uml2.codegen.ecore;bundle-version="1.9.0", + org.eclipse.papyrus.moka.animation Export-Package: org.eclipse.papyrus.moka.fuml;uses:="org.eclipse.ui.plugin, org.osgi.framework", org.eclipse.papyrus.moka.fuml.Semantics.Actions.BasicActions, diff --git a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngineForMoka.java b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngineForMoka.java index 02301832..c603a527 100644 --- a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngineForMoka.java +++ b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/FUMLExecutionEngineForMoka.java @@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.papyrus.infra.core.Activator; import org.eclipse.papyrus.moka.MokaConstants; +import org.eclipse.papyrus.moka.animation.engine.AnimationManager; import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request; import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request; import org.eclipse.papyrus.moka.communication.request.iterminate.Terminate_Request; @@ -37,7 +38,6 @@ import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value; import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue; import org.eclipse.papyrus.moka.fuml.debug.ControlDelegate; import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils; -import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils; import org.eclipse.swt.widgets.Display; import org.eclipse.uml2.uml.Behavior; import org.eclipse.uml2.uml.Parameter; @@ -68,7 +68,7 @@ public class FUMLExecutionEngineForMoka extends FUMLExecutionEngine { this.debugTarget = debugTarget; this.debugTarget.setName("FUML Execution Engine"); FUMLPresentationUtils.init(eObjectToExecute); - AnimationUtils.init(eObjectToExecute); + AnimationManager.getInstance().init(eObjectToExecute); FUMLExecutionEngine.eInstance = this; } } diff --git a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/debug/ControlDelegate.java b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/debug/ControlDelegate.java index 05e10fce..d5aa8373 100644 --- a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/debug/ControlDelegate.java +++ b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/debug/ControlDelegate.java @@ -23,6 +23,8 @@ import org.eclipse.debug.core.model.IThread; import org.eclipse.emf.ecore.EObject; import org.eclipse.papyrus.infra.core.Activator; import org.eclipse.papyrus.moka.MokaConstants; +import org.eclipse.papyrus.moka.animation.engine.AnimationKind; +import org.eclipse.papyrus.moka.animation.engine.AnimationManager; import org.eclipse.papyrus.moka.communication.event.isuspendresume.Suspend_Event; import org.eclipse.papyrus.moka.communication.request.isuspendresume.Resume_Request; import org.eclipse.papyrus.moka.communication.request.isuspendresume.Suspend_Request; @@ -34,7 +36,6 @@ import org.eclipse.papyrus.moka.engine.AbstractExecutionEngine; import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityEdgeInstance; import org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities.ActivityNodeActivation; import org.eclipse.papyrus.moka.fuml.presentation.FUMLPresentationUtils; -import org.eclipse.papyrus.moka.ui.presentation.AnimationUtils; import org.eclipse.uml2.uml.ActivityEdge; import org.eclipse.uml2.uml.Pin; @@ -46,6 +47,11 @@ public class ControlDelegate { protected AbstractExecutionEngine engine; /** + * The animation manager that is attached to this delegate + */ + protected AnimationManager manager; + + /** * The list of threads implied by current execution */ protected List<FUMLThread> threads; @@ -91,7 +97,7 @@ public class ControlDelegate { EObject modelElement = breakpoint.getModelElement(); if (modelElement != null) { if (modelElement.eIsProxy()) { - modelElement = AnimationUtils.resolve(modelElement); + //modelElement = AnimationManager.resolve(modelElement); } this.elementsWithBreakpoints.add(modelElement); } @@ -107,7 +113,7 @@ public class ControlDelegate { EObject modelElement = breakpoint.getModelElement(); if (modelElement != null) { if (modelElement.eIsProxy()) { - modelElement = AnimationUtils.resolve(modelElement); + //modelElement = AnimationManager.resolve(modelElement); } this.elementsWithBreakpoints.remove(modelElement); } @@ -261,28 +267,26 @@ public class ControlDelegate { } protected void animate(EObject element) { - try { // If the element is an activity edge, // Also animates the source, in the case where it is a pin if (element instanceof ActivityEdge) { ActivityEdge edge = (ActivityEdge) element; if (edge.getSource() instanceof Pin) { - if (AnimationUtils.getInstance().diagramsExistFor(edge.getSource())) { - AnimationUtils.getInstance().addAnimationMarker(edge.getSource()); + //if (AnimationManager.getInstance().diagramsExistFor(edge.getSource())) { + /*AnimationManager.getInstance().addAnimationMarker(edge.getSource()); Thread.sleep(MokaConstants.MOKA_ANIMATION_DELAY); - AnimationUtils.getInstance().removeAnimationMarker(edge.getSource()); - } + AnimationManager.getInstance().removeAnimationMarker(edge.getSource());*/ + AnimationManager.getInstance().render(edge.getSource(), AnimationKind.ANIMATED, MokaConstants.MOKA_ANIMATION_DELAY); + //} } } // Animates the element - if ((AnimationUtils.getInstance().diagramsExistFor(element))) { - AnimationUtils.getInstance().addAnimationMarker(element); + //if ((AnimationManager.getInstance().diagramsExistFor(element))) { + /*AnimationManager.getInstance().addAnimationMarker(element); Thread.sleep(MokaConstants.MOKA_ANIMATION_DELAY); - AnimationUtils.getInstance().removeAnimationMarker(element); - } - } catch (InterruptedException e) { - Activator.log.error(e); - } + AnimationManager.getInstance().removeAnimationMarker(element);*/ + AnimationManager.getInstance().render(element, AnimationKind.ANIMATED, MokaConstants.MOKA_ANIMATION_DELAY); + //} } public void waitForTermination() { diff --git a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/registry/service/framework/AbstractService.java b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/registry/service/framework/AbstractService.java index 9c5b0434..080cbd80 100644 --- a/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/registry/service/framework/AbstractService.java +++ b/org.eclipse.papyrus.moka.fuml/src/org/eclipse/papyrus/moka/fuml/registry/service/framework/AbstractService.java @@ -1,76 +1,69 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.moka.fuml.registry.service.framework; - -import java.util.HashMap; -import java.util.List; - -import org.apache.commons.lang.NotImplementedException; -import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_; -import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value; -import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution; -import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.OpaqueBehaviorExecution; -import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue; -import org.eclipse.papyrus.moka.fuml.registry.SystemServicesRegistryUtils; -import org.eclipse.uml2.uml.Behavior; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.OpaqueBehavior; -import org.eclipse.uml2.uml.Operation; - -public abstract class AbstractService extends Object_ { - - protected HashMap<Operation, OpaqueBehavior> ownedOperation; - - protected HashMap<Operation, Execution> operationExecution; - - private void initializeOperations(Class classifier) { - this.ownedOperation = new HashMap<Operation, OpaqueBehavior>(); - for (Operation op : classifier.getAllOperations()) { - this.ownedOperation.put(op, SystemServicesRegistryUtils.getInstance().generateOpaqueBehaviorSignature(op)); - } - } - - public AbstractService(Class service) { - super(); - this.types.add(service); - this.initializeOperations(service); - this.operationExecution = new HashMap<Operation, Execution>(); - } - - @Override - public Execution dispatch(Operation operation) { - if (this.operationExecution.containsKey(operation)) { - return this.operationExecution.get(operation); - } - throw new NotImplementedException("Not any ServiceOperationExecution implemented/registered for this operation"); - } - - public abstract class ServiceOperationExecution extends OpaqueBehaviorExecution { - - protected Operation operation; - - public ServiceOperationExecution(Operation operation) { - this.operation = operation; - } - - @Override - public Behavior getBehavior() { - return AbstractService.this.ownedOperation.get(this.operation); - } - - @Override - public abstract void doBody(List<ParameterValue> inputParameters, List<ParameterValue> outputParameters); - - @Override - public abstract Value new_(); - } -} +/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Jeremie Tatibouet (CEA LIST) - Refine service code to avoid deadlocks when model execution starts
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.registry.service.framework;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Object_;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.Execution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.OpaqueBehaviorExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.eclipse.papyrus.moka.fuml.registry.SystemServicesRegistryUtils;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Operation;
+
+public abstract class AbstractService extends Object_ {
+
+ protected HashMap<Operation, Execution> operationExecution;
+
+ public AbstractService(Class service) {
+ super();
+ this.types.add(service);
+ this.operationExecution = new HashMap<Operation, Execution>();
+ this.doOperationExecutionMapping();
+ }
+
+ @Override
+ public Execution dispatch(Operation operation) {
+ if (this.operationExecution.containsKey(operation)) {
+ return this.operationExecution.get(operation);
+ }
+ throw new NotImplementedException("Not any ServiceOperationExecution implemented/registered for this operation");
+ }
+
+ public abstract void doOperationExecutionMapping();
+
+ public abstract class ServiceOperationExecution extends OpaqueBehaviorExecution {
+
+ protected Operation operation;
+
+ public ServiceOperationExecution(Operation operation) {
+ this.operation = operation;
+ }
+
+ @Override
+ public Behavior getBehavior() {
+ return SystemServicesRegistryUtils.getInstance().generateOpaqueBehaviorSignature(operation);
+ }
+
+ @Override
+ public abstract void doBody(List<ParameterValue> inputParameters, List<ParameterValue> outputParameters);
+
+ @Override
+ public abstract Value new_();
+ }
+}
diff --git a/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF b/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF index 0b723ba9..db3323b2 100644 --- a/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.papyrus.moka.ui/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.infra.services.markerlistener;bundle-version="1.2.0", org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0", org.eclipse.papyrus.uml.extensionpoints;bundle-version="1.2.0", - org.eclipse.uml2.uml;bundle-version="4.1.0" + org.eclipse.uml2.uml;bundle-version="4.1.0", + org.eclipse.papyrus.moka.animation;bundle-version="1.2.0" Export-Package: org.eclipse.papyrus.moka.ui.launch, org.eclipse.papyrus.moka.ui.presentation Bundle-Vendor: Eclipse Modeling Project diff --git a/org.eclipse.papyrus.moka.ui/plugin.xml b/org.eclipse.papyrus.moka.ui/plugin.xml index 4d69aed4..65c24882 100644 --- a/org.eclipse.papyrus.moka.ui/plugin.xml +++ b/org.eclipse.papyrus.moka.ui/plugin.xml @@ -170,32 +170,6 @@ </client> </extension> <extension - id="org.eclipse.papyrus.moka.ui.suspendedmarker" - point="org.eclipse.core.resources.markers"> - <super - type="org.eclipse.papyrus.modelmarker"> - </super> - <persistent - value="false"> - </persistent> - </extension> - <extension - id="org.eclipse.papyrus.moka.ui.animationmarker" - point="org.eclipse.core.resources.markers"> - <super - type="org.eclipse.papyrus.modelmarker"> - </super> - <persistent - value="false"> - </persistent> - </extension> - <extension - point="org.eclipse.papyrus.infra.gmfdiag.css.markertopseudoselectormappingprovider"> - <provider - class="org.eclipse.papyrus.moka.ui.presentation.DebugMarkerMappingToPseudoSelector"> - </provider> - </extension> - <extension point="org.eclipse.ui.perspectiveExtensions"> <perspectiveExtension targetID="org.eclipse.debug.ui.DebugPerspective"> @@ -221,14 +195,5 @@ name="Animation Configuration"> </view> </extension> - <extension - point="org.eclipse.papyrus.infra.gmfdiag.css.theme"> - <themeContribution - id="org.eclipse.papyrus.css.papyrus_theme"> - <stylesheet - stylesheetPath="theme/defaultAnimationTheme.css"> - </stylesheet> - </themeContribution> - </extension> </plugin> diff --git a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java b/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java deleted file mode 100644 index 5e1a841c..00000000 --- a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/AnimationUtils.java +++ /dev/null @@ -1,417 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2013 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.moka.ui.presentation; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IThread; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature.Setting; -import org.eclipse.emf.ecore.EValidator; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.RootEditPart; -import org.eclipse.gef.ui.parts.GraphicalEditor; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.core.Activator; -import org.eclipse.papyrus.infra.core.resource.ModelSet; -import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.core.services.ServicesRegistry; -import org.eclipse.papyrus.infra.core.utils.ServiceUtils; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.services.markerlistener.IPapyrusMarker; -import org.eclipse.papyrus.infra.services.markerlistener.PapyrusMarkerAdapter; -import org.eclipse.papyrus.moka.MokaConstants; -import org.eclipse.papyrus.moka.debug.MokaBreakpoint; -import org.eclipse.papyrus.moka.launch.EditorUtils; -import org.eclipse.ui.IEditorPart; - -/** - * Some facilities to manage animation in diagrams. - * - */ -public class AnimationUtils { - - /** - * The static instance for this class - */ - protected static AnimationUtils eInstance = null; - - /** - * An EObject -> 'Suspended' marker map - */ - protected static Map<EObject, IPapyrusMarker> eObjectToSuspendedMarker = new ConcurrentHashMap<EObject, IPapyrusMarker>(); - - /** - * An EObject -> 'Animation' marker map - */ - protected static Map<EObject, IPapyrusMarker> eObjectToAnimationMarker = new ConcurrentHashMap<EObject, IPapyrusMarker>(); - - /** - * An EObject -> List<Diagram> map - */ - protected static Map<EObject, List<Diagram>> eObjectToDiagrams = new ConcurrentHashMap<EObject, List<Diagram>>(); - - private AnimationUtils() { - - } - - public static void init() { - // Reinitializes hash maps - eObjectToAnimationMarker = new ConcurrentHashMap<EObject, IPapyrusMarker>(); - eObjectToSuspendedMarker = new ConcurrentHashMap<EObject, IPapyrusMarker>(); - eObjectToDiagrams = new ConcurrentHashMap<EObject, List<Diagram>>(); - } - - public static void init(EObject eobject) { - init(); - getInstance().getDiagrams(eobject); - } - - /** - * Typically called on engine termination. This methods removes all - * markers used to enable semantic elements animation at runtime - */ - public synchronized void removeAllAnimationMarker() { - for (EObject animatedObject : eObjectToAnimationMarker.keySet()) { - this.removeAnimationMarker(animatedObject); - } - } - - /** - * Returns an instance of AnimationUtils. Guarantees that AnimationUtils is instantiated only once. - * - * @return An instance of AnimationUtils - */ - public static AnimationUtils getInstance() { - if (eInstance == null) { - eInstance = new AnimationUtils(); - } - return eInstance; - } - - /** - * Retrieves all diagrams in which the given model element has a graphical representation - * - * @param modelElement - * The model element for which diagrams where it appears have to be retrieved - * @return all diagrams in which the given model element has a graphical representation - */ - public synchronized List<Diagram> getDiagrams(EObject modelElement) { - List<Diagram> matchingDiagrams = eObjectToDiagrams.get(modelElement); - if (matchingDiagrams != null) { - return matchingDiagrams; - } - - Resource resource = modelElement.eResource(); - if (!resource.getURI().isPlatformResource()) { - matchingDiagrams = new ArrayList<Diagram>(); - eObjectToDiagrams.put(modelElement, new ArrayList<Diagram>()); - return matchingDiagrams; - } - ResourceSet resourceSet = resource.getResourceSet(); - - final String resourceNotationURI = modelElement.eResource().getURI().toString().replaceAll("\\.uml$", ".notation"); - @SuppressWarnings("unused") - Resource notationResource = resourceSet.getResource(URI.createURI(resourceNotationURI), true); - List<EObject> matchingObjects = new ArrayList<EObject>(); - matchingObjects.add(modelElement); - - Map<EObject, Collection<Setting>> maps = EcoreUtil.UsageCrossReferencer.findAll(matchingObjects, resourceSet); - matchingDiagrams = new ArrayList<Diagram>(); - - for (Object key : maps.keySet()) { - for (Setting setting : maps.get(key)) { - if (setting.getEObject() instanceof View) { - Diagram diagram = ((View) setting.getEObject()).getDiagram(); - if (!matchingDiagrams.contains(diagram)) { - matchingDiagrams.add(diagram); - } - // For optimization purposes, - // Add mapping entries for other semantic elements - // having a representation in this diagram - for (Iterator<EObject> i = diagram.eAllContents(); i.hasNext();) { - EObject cddView = i.next(); - if (cddView instanceof View) { - EObject element = ((View) cddView).getElement(); - if (element != modelElement && element != null) { - List<Diagram> diags = eObjectToDiagrams.get(element); - if (diags == null) { - diags = new ArrayList<Diagram>(); - } else if (!diags.contains(diagram)) { - diags.add(diagram); - } - eObjectToDiagrams.put(element, diags); - } - } - } - } - } - } - - eObjectToDiagrams.put(modelElement, matchingDiagrams); - - return matchingDiagrams; - } - - /** - * Returns true if some diagrams with graphical representation of the given model element exist, false otherwise - * - * @param modelElement - * @return true if some diagrams with graphical representation of the given model element exist, false otherwise - */ - public boolean diagramsExistFor(EObject modelElement) { - return !this.getDiagrams(modelElement).isEmpty(); - } - - /** - * In the case where the list of diagrams for the given modelElement has already been retrieved, - * resets this list - * - * @param modelElement - * The model element for which the list of diagrams has to be reset - */ - public void resetDiagrams(EObject modelElement) { - eObjectToDiagrams.remove(modelElement); - } - - /** - * Opens the given diagram (or puts focus on diagram if this diagram is already opened) in the current active papyrus editor. - * By construction, the active papyrus editor is supposed to be opened with the appropriate .di file. - * openDiagram is called by MokaDebugModelPresentation.addAnnotations(), which is always called after MokaDebugModelPresentation.getEditorInput() - * is called. - * MokaDebugModelPresentation.getEditorInput() returns a FileEditorInput for the .di model to which the given Diagram belongs. - * - * @param diagram - * The diagram to be opened. - */ - public void openDiagram(final Diagram diagram, boolean closeOpenedDiagrams) { - IEditorPart part = EditorUtils.getEditorPart(diagram); - ServicesRegistry servicesRegistry = (ServicesRegistry) part.getAdapter(ServicesRegistry.class); - try { - final IPageManager pageMngr = ServiceUtils.getInstance().getIPageManager(servicesRegistry); - try { - if (pageMngr.isOpen(diagram)) { - pageMngr.selectPage(diagram); - } else { - TransactionalEditingDomain domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(diagram); - OpenDiagramCommand updateCommand = new OpenDiagramCommand(diagram, pageMngr, domain); - domain.getCommandStack().execute(updateCommand); - } - } catch (Exception e) { - Activator.log.error(e); - } - } catch (ServiceException e1) { - Activator.log.error(e1); - } - } - - /** - * A convenience method for retrieving the diagram edit part corresponding to a graphical editor. - * - * @return the diagram edit part corresponding to the given editor - */ - public RootEditPart getRootEditPart(GraphicalEditor editor) { - return (RootEditPart) editor.getAdapter(EditPart.class); - } - - /** - * Adds a "Suspended" marker to the given semantic element - * - * @param semanticElement - * The semantic element to which a "Suspended" marker has to be attached - * @param thread - * The context thread in which this marker is attached - */ - public void addSuspendedMarker(EObject semanticElement) { - if (eObjectToSuspendedMarker.get(semanticElement) != null) { - // Marker already exists - return; - } - if (semanticElement.eIsProxy()) { - semanticElement = resolve(semanticElement); - } - IResource iresource = MokaBreakpoint.getIResource(semanticElement.eResource()); - try { - if (iresource != null) { - String uriOfSemanticElement = EcoreUtil.getURI(semanticElement).toString(); - IMarker marker = iresource.createMarker(MokaConstants.MOKA_SUSPENDED_MARKER_ID); - marker.setAttribute(EValidator.URI_ATTRIBUTE, uriOfSemanticElement); - eObjectToSuspendedMarker.put(semanticElement, PapyrusMarkerAdapter.wrap(semanticElement.eResource(), marker)); - } - } catch (CoreException ce) { - Activator.log.error(ce); - } - } - - /** - * Removes the "Suspended" marker for all semantic elements suspended in the context of the given thread - * - * @param thread - * The thread for which "Suspend" markers have to be removed from suspended semantic elements - */ - public void removeSuspendedMarker(IThread thread) { - for (EObject key : eObjectToSuspendedMarker.keySet()) { - IPapyrusMarker stackFrameMarker = eObjectToSuspendedMarker.get(key); - try { - stackFrameMarker.delete(); - } catch (CoreException e) { - Activator.log.error(e); - } - } - eObjectToSuspendedMarker.clear(); - } - - /** - * Adds an "Animation" marker to the given semantic element - * - * @param semanticElement - * The semantic element to which an "Animation" marker has to be attached - */ - public void addAnimationMarker(EObject semanticElement) { - if (eObjectToAnimationMarker.get(semanticElement) != null) { - // Marker already exists - return; - } - if (semanticElement.eIsProxy()) { - semanticElement = resolve(semanticElement); - } - IResource iresource = MokaBreakpoint.getIResource(semanticElement.eResource()); - try { - if (iresource != null) { - String uriOfSemanticElement = EcoreUtil.getURI(semanticElement).toString(); - if (MokaConstants.MOKA_OPEN_DIAGRAM_IN_AUTOMATIC_ANIMATION) { - List<Diagram> diagrams = getDiagrams(semanticElement); - for (Diagram d : diagrams) { - openDiagram(d, false); - } - } - IMarker marker = iresource.createMarker(MokaConstants.MOKA_ANIMATION_MARKER_ID); - marker.setAttribute(EValidator.URI_ATTRIBUTE, uriOfSemanticElement); - eObjectToAnimationMarker.put(semanticElement, PapyrusMarkerAdapter.wrap(semanticElement.eResource(), marker)); - } - } catch (CoreException ce) { - Activator.log.error(ce); - } - } - - /** - * Removes the "Animation" marker associated with the given semantic element, if any - * - * @param semanticElement - * The semantic element to which an "Animation" marker has to be attached - */ - public void removeAnimationMarker(EObject semanticElement) { - if (semanticElement.eIsProxy()) { - semanticElement = resolve(semanticElement); - } - IPapyrusMarker animationFrameMarker = eObjectToAnimationMarker.get(semanticElement); - if (animationFrameMarker != null) { - try { - animationFrameMarker.delete(); - eObjectToAnimationMarker.remove(semanticElement); - } catch (CoreException e) { - Activator.log.error(e); - } - } - } - - /** - * Resolve the given semantic element in the case where it is a proxy. - * This is supposed to happen only when, in the course of execution, - * the editor for the model being executed is closed. - * This may imply re-creation of a new IEditorPart. - * - * @param semanticElement - * The semantic element that needs to be resolved - * @return the resolved semantic element - */ - public static EObject resolve(EObject semanticElement) { - if (semanticElement.eIsProxy()) { - getInstance().resetDiagrams(semanticElement); - IEditorPart part = EditorUtils.getEditorPart(semanticElement); - ServicesRegistry registry = (ServicesRegistry) part.getAdapter(ServicesRegistry.class); - ResourceSet resourceSet = null; - try { - resourceSet = registry.getService(ModelSet.class); - } catch (ServiceException e) { - resourceSet = new ResourceSetImpl(); - } - semanticElement = EcoreUtil.resolve(semanticElement, resourceSet); - } - return semanticElement; - } - - public boolean isAnimationMarkerApplied(EObject element) { - return eObjectToAnimationMarker.get(element) != null; - } - - /** - * A command for opening a diagram - * - */ - protected class OpenDiagramCommand extends RecordingCommand { - - protected Diagram diagram; - - protected IPageManager pageMngr; - - /** - * Constructor for the OpenDiagramCommand. - * - * @param diagram - * The diagram to be opened - * @param pageMngr - * The page manager to be used for opening the diagram - * @param domain - * The editing domain in which the command will be executed - */ - public OpenDiagramCommand(Diagram diagram, IPageManager pageMngr, TransactionalEditingDomain domain) { - super(domain); - this.diagram = diagram; - this.pageMngr = pageMngr; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor - * , org.eclipse.core.runtime.IAdaptable) - */ - @Override - protected void doExecute() { - this.pageMngr.openPage(diagram); - this.pageMngr.selectPage(diagram); - } - - } - -} diff --git a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java b/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java deleted file mode 100644 index 30685763..00000000 --- a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/DebugMarkerMappingToPseudoSelector.java +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2013 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * CEA LIST - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.moka.ui.presentation; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.papyrus.infra.gmfdiag.css.service.IMarkerToPseudoSelectorMappingProvider; -import org.eclipse.papyrus.moka.MokaConstants; - -/** - * A mapping between markers defined by Moka, - * a corresponding CSS pseudo selectors. - * These pseudo selectors can be used in CSS styles, - * in order to attach a specific style with one of these markers. - * - */ -public class DebugMarkerMappingToPseudoSelector implements IMarkerToPseudoSelectorMappingProvider { - - protected Map<String, String> mappings; - - protected final static String BREAKPOINT_MARKER_PSEUDO_SELECTOR = "breakpoint"; - - protected final static String SUSPENDED_MARKER_PSEUDO_SELECTOR = "suspended"; - - protected final static String ANIMATION_MARKER_PSEUDO_SELECTOR = "animation"; - - public DebugMarkerMappingToPseudoSelector() { - // Do nothing - } - - public Map<String, String> getMappings() { - if (this.mappings == null) { - this.mappings = new HashMap<String, String>(); - // Adds pseudo selectors for 'breakpoint', 'suspended' and 'animation' markers - this.mappings.put(MokaConstants.MOKA_BREAKPOINT_MARKER_ID, BREAKPOINT_MARKER_PSEUDO_SELECTOR); - this.mappings.put(MokaConstants.MOKA_SUSPENDED_MARKER_ID, SUSPENDED_MARKER_PSEUDO_SELECTOR); - this.mappings.put(MokaConstants.MOKA_ANIMATION_MARKER_ID, ANIMATION_MARKER_PSEUDO_SELECTOR); - } - return this.mappings; - } - -} diff --git a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java b/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java index 9c34b715..0b626a39 100644 --- a/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java +++ b/org.eclipse.papyrus.moka.ui/src/org/eclipse/papyrus/moka/ui/presentation/MokaDebugModelPresentation.java @@ -13,8 +13,6 @@ *****************************************************************************/ package org.eclipse.papyrus.moka.ui.presentation; -import java.util.List; - import org.eclipse.debug.core.model.IStackFrame; import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IValue; @@ -25,12 +23,13 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.papyrus.infra.core.resource.ModelSet; import org.eclipse.papyrus.infra.core.services.ServiceException; import org.eclipse.papyrus.infra.core.services.ServicesRegistry; import org.eclipse.papyrus.moka.MokaConstants; +import org.eclipse.papyrus.moka.animation.engine.AnimationKind; +import org.eclipse.papyrus.moka.animation.engine.AnimationManager; import org.eclipse.papyrus.moka.debug.MokaBreakpoint; import org.eclipse.papyrus.moka.debug.MokaStackFrame; import org.eclipse.papyrus.moka.launch.EditorUtils; @@ -170,7 +169,7 @@ public class MokaDebugModelPresentation implements IDebugModelPresentation, IDeb MokaStackFrame stackFrame = (MokaStackFrame) frame; EObject modelElement = stackFrame.getModelElement(); if (modelElement.eIsProxy()) { - AnimationUtils.getInstance().resetDiagrams(modelElement); + //AnimationUtils.getInstance().resetDiagrams(modelElement); ServicesRegistry servicesRegistry = (ServicesRegistry) editorPart.getAdapter(ServicesRegistry.class); ResourceSet resourceSet = null; try { @@ -180,11 +179,11 @@ public class MokaDebugModelPresentation implements IDebugModelPresentation, IDeb } modelElement = (EcoreUtil.resolve(modelElement, resourceSet)); } - List<Diagram> diagrams = AnimationUtils.getInstance().getDiagrams(modelElement); + /*List<Diagram> diagrams = AnimationUtils.getInstance().getDiagrams(modelElement); for (Diagram diagram : diagrams) { AnimationUtils.getInstance().openDiagram(diagram, false); - } - AnimationUtils.getInstance().addSuspendedMarker(modelElement); + }*/ + AnimationManager.getInstance().startRendering(modelElement, AnimationKind.SUSPENDED); return true; } return false; @@ -196,7 +195,7 @@ public class MokaDebugModelPresentation implements IDebugModelPresentation, IDeb * @see org.eclipse.debug.ui.IDebugEditorPresentation#removeAnnotations(org.eclipse.ui.IEditorPart, org.eclipse.debug.core.model.IThread) */ public void removeAnnotations(IEditorPart editorPart, IThread thread) { - AnimationUtils.getInstance().removeSuspendedMarker(thread); + //AnimationUtils.getInstance().removeSuspendedMarker(thread); } } diff --git a/org.eclipse.papyrus.moka.ui/theme/defaultAnimationTheme.css b/org.eclipse.papyrus.moka.ui/theme/defaultAnimationTheme.css index 95bdcc18..e69de29b 100644 --- a/org.eclipse.papyrus.moka.ui/theme/defaultAnimationTheme.css +++ b/org.eclipse.papyrus.moka.ui/theme/defaultAnimationTheme.css @@ -1,10 +0,0 @@ -:animation{ - lineColor: red; - fillColor: #56f99b; - font-weight: bold; -} - -:suspended{ - lineColor: #ff0315; - fillColor: #fab953; -}
\ No newline at end of file @@ -18,6 +18,7 @@ <module>org.eclipse.papyrus.moka.composites</module> <module>org.eclipse.papyrus.moka.async.fuml</module> <!-- moka utils --> + <module>org.eclipse.papyrus.moka.animation</module> <module>org.eclipse.papyrus.moka.fuml.validation</module> <module>org.eclipse.papyrus.moka.composites.utils</module> <module>org.eclipse.papyrus.moka.fuml.activeobjectcontrollerlibrary</module> |