Bug 551976 - [Moka] Open diagram feature should not open a notation
editor

Change-Id: I6e7b45476ee567506f12e896a05084d8a1100e74
Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
diff --git a/plugins/org.eclipse.papyrus.moka.kernel.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java b/plugins/org.eclipse.papyrus.moka.kernel.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
index ef85da4..e8912cf 100644
--- a/plugins/org.eclipse.papyrus.moka.kernel.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
+++ b/plugins/org.eclipse.papyrus.moka.kernel.animation/src/org/eclipse/papyrus/moka/animation/engine/rendering/DiagramHandler.java
@@ -11,6 +11,7 @@
  * Contributors:
  *  CEA LIST Initial API and implementation
  *  CEA LIST - Bug 551917 
+ *  CEA LIST - Bug 551976 
  *****************************************************************************/
 package org.eclipse.papyrus.moka.animation.engine.rendering;
 
@@ -237,7 +238,8 @@
 			Iterator<Diagram> diagramIterator = diagramSet.iterator();
 			while (!opened && diagramIterator.hasNext()) {
 				Diagram diagram = diagramIterator.next();
-				IEditorPart editorPart = EditorUtils.getEditorPart(diagram);
+				final String resourceDiURI = diagram.eResource().getURI().toString().replaceAll("\\.notation$", ".di");
+				IEditorPart editorPart = EditorUtils.getEditorPart(resourceDiURI);
 				ServicesRegistry servicesRegistry = (ServicesRegistry) editorPart.getAdapter(ServicesRegistry.class);
 				IPageManager pageManager = null;
 				try {
@@ -258,7 +260,8 @@
 		HashSet<Diagram> diagrams = this.modelDiagramMapping.get(modelElement);
 		if (!diagrams.isEmpty()) {
 			for (Diagram diagram : diagrams) {
-				IEditorPart editorPart = EditorUtils.getEditorPart(diagram);
+				final String resourceDiURI = diagram.eResource().getURI().toString().replaceAll("\\.notation$", ".di");
+				IEditorPart editorPart = EditorUtils.getEditorPart(resourceDiURI);
 				ServicesRegistry servicesRegistry = (ServicesRegistry) editorPart.getAdapter(ServicesRegistry.class);
 				IPageManager pageManager = null;
 				try {
@@ -274,6 +277,27 @@
 		}
 	}
 
+	public void selectDiagrams(EObject modelElement) {
+		// Select every diagrams on which the specify on which this model element appear
+		HashSet<Diagram> diagrams = this.modelDiagramMapping.get(modelElement);
+		if (!diagrams.isEmpty()) {
+			for (Diagram diagram : diagrams) {
+				final String resourceDiURI = diagram.eResource().getURI().toString().replaceAll("\\.notation$", ".di");
+				IEditorPart editorPart = EditorUtils.getEditorPart(resourceDiURI);
+				ServicesRegistry servicesRegistry = (ServicesRegistry) editorPart.getAdapter(ServicesRegistry.class);
+				IPageManager pageManager = null;
+				try {
+					pageManager = ServiceUtils.getInstance().getIPageManager(servicesRegistry);
+				} catch (ServiceException e) {
+					e.printStackTrace();
+				}
+				if (pageManager != null) {
+					pageManager.selectPage(diagram);
+				}
+			}
+		}
+	}
+
 	public boolean isRenderable(EObject modelElement) {
 		// A model element can be rendered as soon as it exists a diagram in which it
 		// appear in the model