Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigableElement.java11
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/navigation/DiagramNavigationProvider.java10
2 files changed, 19 insertions, 2 deletions
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
index c3bbaf2cee3..daa8c5734ac 100644
--- 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
@@ -14,10 +14,12 @@ 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.jface.viewers.ILabelProvider;
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.labelprovider.service.LabelProviderService;
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;
@@ -72,7 +74,14 @@ public class DiagramNavigableElement implements NavigableElement {
}
public Image getImage() {
- // TODO Auto-generated method stub
+ if(targetDiagram != null) {
+ try {
+ ILabelProvider labelProvider = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, targetDiagram).getLabelProvider();
+ return labelProvider.getImage(targetDiagram);
+ } catch (ServiceException ex) {
+ return null;
+ }
+ }
return 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
index 0fb614a3b48..569424e6b5b 100644
--- 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
@@ -23,6 +23,7 @@ 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.gmfdiag.common.helper.NotationHelper;
import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
@@ -46,7 +47,8 @@ public class DiagramNavigationProvider implements NavigationContributor {
}
protected List<Diagram> getOwnedDiagrams(Object fromElement) {
- EObject eObject = EMFHelper.getEObject(fromElement);
+ EObject eObject = EMFHelper.getEObject(fromElement); //Should not be null (Otherwise, return=)
+ View currentView = NotationHelper.findView(fromElement); //May be null (e.g. Selection from the ModelExplorer)
if(eObject instanceof View || eObject == null) {
return Collections.emptyList();
}
@@ -58,6 +60,12 @@ public class DiagramNavigationProvider implements NavigationContributor {
for(Object pageObject : pageManager.allPages()) {
if(pageObject instanceof Diagram) {
Diagram diagram = (Diagram)pageObject;
+
+ //Avoid navigation to the current diagram
+ if(currentView != null && currentView.getDiagram() == diagram) {
+ continue;
+ }
+
if(diagram.getElement() == eObject) {
ownedDiagrams.add(diagram);
}

Back to the top