Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2013-10-28 04:57:45 -0400
committerCamille Letavernier2013-10-28 04:57:45 -0400
commit8be72fef63089c63158c73894a032b2cfb1183a7 (patch)
treec8f9b372e6dcd94e72674ea4bd8303ed7b5fd9e9 /plugins
parent3b137be84f2f4cea30252962688c51555fb94e5a (diff)
downloadorg.eclipse.papyrus-8be72fef63089c63158c73894a032b2cfb1183a7.tar.gz
org.eclipse.papyrus-8be72fef63089c63158c73894a032b2cfb1183a7.tar.xz
org.eclipse.papyrus-8be72fef63089c63158c73894a032b2cfb1183a7.zip
417673: [Hyperlinks] Cannot easily navigate to nested diagrams.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=417673
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml9
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java83
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java73
4 files changed, 167 insertions, 1 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
index 2ba7a506016..c29d62f3384 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.1",
org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="0.10.1",
- org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1"
+ org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.services.navigation;bundle-version="0.10.1"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.hyperlink,
org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies,
org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
index 7c6419322c3..c2e965c397e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/plugin.xml
@@ -23,5 +23,14 @@
</specificHyperLink>
</extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.navigation.navigationContributor">
+ <contributor
+ contributor="org.eclipse.papyrus.infra.gmfdiag.hyperlink.navigation.DiagramNavigationProvider"
+ description="Navigates to the current element&apos;s diagram(s)"
+ id="org.eclipse.papyrus.infra.gmfdiag.hyperlink.diagram"
+ label="Automatic Diagram Navigation">
+ </contributor>
+ </extension>
</plugin>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java
new file mode 100644
index 00000000000..c3bbaf2cee3
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.hyperlink.navigation;
+
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.hyperlink.Activator;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.swt.graphics.Image;
+
+
+public class DiagramNavigableElement implements NavigableElement {
+
+ protected Diagram targetDiagram;
+
+ public DiagramNavigableElement(Diagram target) {
+ this.targetDiagram = target;
+ }
+
+ public String getLabel() {
+ return "Navigate to diagram " + targetDiagram.getName();
+ }
+
+ public String getDescription() {
+ return String.format("Navigates to the %s %s", targetDiagram.getType(), targetDiagram.getName());
+ }
+
+ public boolean navigate(NavigationTarget navigationContext) {
+ try {
+ final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(targetDiagram);
+ if(pageManager.isOpen(targetDiagram)) {
+ pageManager.selectPage(targetDiagram);
+ } else {
+ TransactionalEditingDomain domain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(targetDiagram);
+
+ RecordingCommand command = new RecordingCommand(domain, "Open diagram") {
+
+ @Override
+ protected void doExecute() {
+ pageManager.openPage(targetDiagram);
+ }
+ };
+
+ domain.getCommandStack().execute(command);
+ }
+
+ return true;
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+
+ return false;
+ }
+
+ @Deprecated
+ public void navigate(IRevealSemanticElement revealSemanticElement) {
+ }
+
+ public Image getImage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return targetDiagram != null;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java
new file mode 100644
index 00000000000..0fb614a3b48
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.hyperlink.navigation;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
+
+
+public class DiagramNavigationProvider implements NavigationContributor {
+
+ public List<NavigableElement> getNavigableElements(Object fromElement) {
+ if(fromElement instanceof IAdaptable) {
+ //Find pages under the element (isPageContainer)
+ //Alt1: Find diagrams under the element (+ all Tables in a separate provider)
+
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+
+
+ for(Diagram diagram : getOwnedDiagrams(fromElement)) {
+ navigableElements.add(new DiagramNavigableElement(diagram));
+ }
+ return navigableElements;
+ }
+ return null;
+ }
+
+ protected List<Diagram> getOwnedDiagrams(Object fromElement) {
+ EObject eObject = EMFHelper.getEObject(fromElement);
+ if(eObject instanceof View || eObject == null) {
+ return Collections.emptyList();
+ }
+
+ try {
+ List<Diagram> ownedDiagrams = new LinkedList<Diagram>();
+
+ IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(eObject);
+ for(Object pageObject : pageManager.allPages()) {
+ if(pageObject instanceof Diagram) {
+ Diagram diagram = (Diagram)pageObject;
+ if(diagram.getElement() == eObject) {
+ ownedDiagrams.add(diagram);
+ }
+ }
+ }
+
+ return ownedDiagrams;
+ } catch (ServiceException ex) {
+ return Collections.emptyList();
+ }
+ }
+
+}

Back to the top