Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShuai Li2015-05-06 12:03:34 +0000
committerGerrit Code Review @ Eclipse.org2015-11-18 10:01:35 +0000
commit5c6b9f2134605509211bcf3ef271799e1554d5f2 (patch)
treecc7b4e8625597e82c1a1d02f3a77b2b7dc06ddd0 /plugins/uml
parent7dbaf8867e0b3e43d606caa8f2d342dbf479d3d6 (diff)
downloadorg.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.tar.gz
org.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.tar.xz
org.eclipse.papyrus-5c6b9f2134605509211bcf3ef271799e1554d5f2.zip
Bug 463589 - [Navigation] Alt Menu
- Add navigation menu on alt+hover over a navigable element (in diagram or model explorer) - Move hyperlinks to this navigation menu - First version of navigation extension framework to contribute navigation menu buttons to the menu. These contributors are handled by the navigation service. - Current contributors are: parents, children, types, views, targets, sources - Add NamedElement navigable element - Add method to chose navigation target provider in navigation service - Add method to get semantic element from navigable element - Change some navigable element labels - Rm DiagramNavigationProvider because views where the element appears are already shown. - Add PopupBarEditPolicyProvider to edit policy extensions Patch set 20: Architecture changes: - oep.views.navigation is deleted and its content moved to oep.infra.gmfdiag.navigation. Several changes were made beforehand: - Remove dependency on oep.uml.tools - Remove useless import of org.eclipse.uml.uml2 - Remove dependencies on uml and nattable - Move oep.views.navigation.contributor oep.uml.navigation.menuContributor - Remove useless imports of navigation menu button package elsewhere - Delete oep.views.navigation[.feature] and remove from main pom Feature changes: - In oep.infra.gmfdiag.navigation, added OwnedDiagramButton menu contributor, which will show diagrams owned by the hovered element Other changes: - Contribute DiagramOfViewLabelProvider extension in context of "oep.infra.services.navigation.menu.labelprovider" - Add ViewerSearchService to DefaultNavigationMenu. This replaces getViewsToSelect and getClosedViewsToSelect methods. - Rename oep.uml.navigation.contributor to navigableElement - Remove old navigation contributors from oep.infra.gmfdiag.navigation (not contributed through extensions anyway) Change-Id: I895ea3923b1e5612b3bba4d3296a91176b7c2b94 Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/META-INF/MANIFEST.MF39
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml84
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ChildrenButton.java70
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ParentsButton.java66
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/SourcesButton.java71
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TargetsButton.java71
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TypesButton.java74
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigableElement.java (renamed from plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigableElement.java)214
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigationContributor.java (renamed from plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigationContributor.java)82
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedElementNavigationContributor.java42
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedNavigableElement.java115
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/OperationTypeNavigableElement.java (renamed from plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java)74
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedElementNavigationContributor.java (renamed from plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java)88
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedNavigableElement.java (renamed from plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java)210
14 files changed, 945 insertions, 355 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.navigation/META-INF/MANIFEST.MF
index 301f7558c53..79d67725a67 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/META-INF/MANIFEST.MF
@@ -1,19 +1,20 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.papyrus.infra.services.navigation;bundle-version="1.2.0",
- org.eclipse.uml2.uml;bundle-version="4.1.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.2.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0"
-Bundle-Vendor: Eclipse Modeling Project
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.2.0.qualifier
-Bundle-Name: UML Navigation
-Bundle-Activator: org.eclipse.papyrus.uml.navigation.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.navigation;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.papyrus.infra.services.navigation;bundle-version="1.2.0",
+ org.eclipse.uml2.uml;bundle-version="4.1.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.2.0",
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="1.2.0"
+Bundle-Vendor: Eclipse Modeling Project
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Name: UML Navigation
+Bundle-Activator: org.eclipse.papyrus.uml.navigation.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.uml.navigation;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
index a3dc19593a7..6f4c0c3a116 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
@@ -1,20 +1,64 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.papyrus.infra.services.navigation.navigationContributor">
- <contributor
- contributor="org.eclipse.papyrus.uml.navigation.contributor.TypedElementNavigationContributor"
- description="Navigates to the type of the current UML Element"
- id="org.eclipse.papyrus.uml.navigation.typedElement"
- label="UML Typed Element navigation">
- </contributor>
- <contributor
- contributor="org.eclipse.papyrus.uml.navigation.contributor.CBANavigationContributor"
- description="Navigates to the Behavior linked to the current UML CallBehaviourAction"
- id="org.eclipse.papyrus.uml.navigation.callBehaviorAction"
- label="UML Call Behavior Action navigation">
- </contributor>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.infra.services.navigation.navigationContributor">
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.navigableElement.TypedElementNavigationContributor"
+ description="Navigates to the type of the current UML Element"
+ id="org.eclipse.papyrus.uml.navigation.typedElement"
+ label="UML Typed Element navigation">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.navigableElement.CBANavigationContributor"
+ description="Navigates to the behavior linked to the current UML CallBehaviourAction"
+ id="org.eclipse.papyrus.uml.navigation.callBehaviorAction"
+ label="UML Call Behavior Action navigation">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.navigableElement.NamedElementNavigationContributor"
+ description="Navigates to the current UML Named Element"
+ id="org.eclipse.papyrus.uml.navigation.namedElement"
+ label="UML Named Element navigation">
+ </contributor>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.navigation.navigationMenuContributor">
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.ParentsButton"
+ description="Navigate to parents of an element"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.parentsButton"
+ label="Parents">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.ChildrenButton"
+ description="Navigate to children of an element"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.childrenButton"
+ label="Children">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.TypesButton"
+ description="Navigate to elements typed by selected element"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.typesButton"
+ label="Types">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.TargetsButton"
+ description="Navigate to targets of relationships for which the selected element is a source"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.targetsButton"
+ label="Targets">
+ </contributor>
+ <contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.SourcesButton"
+ description="Navigate to sources of relationships for which the selected element is a target"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.sourcesButton"
+ label="Sources">
+ </contributor>
+ <!--<contributor
+ contributor="org.eclipse.papyrus.uml.navigation.menuContributor.ViewsButton"
+ description="Views button"
+ id="org.eclipse.papyrus.uml.navigation.menuContributor.viewsButton"
+ label="Views button">
+ </contributor>-->
+ </extension>
+</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ChildrenButton.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ChildrenButton.java
new file mode 100644
index 00000000000..3bfab6b14df
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ChildrenButton.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.navigation.menuContributor;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.NavigationSubMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
+import org.eclipse.papyrus.uml.navigation.Activator;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Generalization;
+import org.eclipse.uml2.uml.Relationship;
+
+public class ChildrenButton implements NavigationMenuContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor#getButtons(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<NavigationMenuButton> getButtons(Object fromElement) {
+ List<NavigationMenuButton> buttons = new LinkedList<NavigationMenuButton>();
+
+ if (fromElement instanceof Classifier) {
+ try {
+ NavigationService navigationService = ServiceUtilsForEObject.getInstance().getService(NavigationService.class, (Classifier) fromElement);
+
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+ for (Relationship relationship : ((Element) fromElement).getRelationships()) {
+ if (relationship instanceof Generalization) {
+ Generalization generalization = (Generalization) relationship;
+ if (generalization.getGeneral() == fromElement) {
+ Classifier specific = generalization.getSpecific();
+ if (specific != null) {
+ navigableElements.addAll(navigationService.getNavigableElements(specific));
+ }
+ }
+ }
+ }
+
+ if (!navigableElements.isEmpty()) {
+ buttons.add(new NavigationSubMenuButton("Children...", null, "Show children classes", navigableElements));
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return buttons;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ParentsButton.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ParentsButton.java
new file mode 100644
index 00000000000..3c647d4b45a
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/ParentsButton.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.navigation.menuContributor;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.NavigationSubMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
+import org.eclipse.papyrus.uml.navigation.Activator;
+import org.eclipse.uml2.uml.Classifier;
+
+/**
+ * The navigation menu contributor returns a navigation menu button that contains
+ * the parents of the element that is clicked on.
+ *
+ */
+public class ParentsButton implements NavigationMenuContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor#getButtons(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<NavigationMenuButton> getButtons(Object fromElement) {
+ List<NavigationMenuButton> buttons = new LinkedList<NavigationMenuButton>();
+
+ if (fromElement instanceof Classifier) {
+ try {
+ NavigationService navigationService = ServiceUtilsForEObject.getInstance().getService(NavigationService.class, (Classifier) fromElement);
+ // Parents
+ if (!((Classifier) fromElement).parents().isEmpty()) {
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+ for (Classifier parent : ((Classifier) fromElement).parents()) {
+ navigableElements.addAll(navigationService.getNavigableElements(parent));
+ }
+
+ if (!navigableElements.isEmpty()) {
+ buttons.add(new NavigationSubMenuButton("Parents...", null, "Show parent classes", navigableElements));
+ }
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return buttons;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/SourcesButton.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/SourcesButton.java
new file mode 100644
index 00000000000..2b9534c1977
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/SourcesButton.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.navigation.menuContributor;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.NavigationSubMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
+import org.eclipse.papyrus.uml.navigation.Activator;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * The navigation menu contributor returns a navigation menu button that contains
+ * the sources of the element that is clicked on.
+ *
+ */
+public class SourcesButton implements NavigationMenuContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor#getButtons(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<NavigationMenuButton> getButtons(Object fromElement) {
+ List<NavigationMenuButton> buttons = new LinkedList<NavigationMenuButton>();
+
+ if (fromElement instanceof Element) {
+ try {
+ NavigationService navigationService = ServiceUtilsForEObject.getInstance().getService(NavigationService.class, (Element) fromElement);
+
+ List<DirectedRelationship> relationships = ((Element) fromElement).getTargetDirectedRelationships();
+
+ if (!relationships.isEmpty()) {
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+ for (DirectedRelationship relationship : relationships) {
+ for (Element source : relationship.getSources()) {
+ navigableElements.addAll(navigationService.getNavigableElements(source));
+ }
+ }
+
+ if (!navigableElements.isEmpty()) {
+ buttons.add(new NavigationSubMenuButton("Sources...", null, "Show sources", navigableElements));
+ }
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return buttons;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TargetsButton.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TargetsButton.java
new file mode 100644
index 00000000000..0933470cc63
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TargetsButton.java
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.navigation.menuContributor;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.NavigationSubMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
+import org.eclipse.papyrus.uml.navigation.Activator;
+import org.eclipse.uml2.uml.DirectedRelationship;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * The navigation menu contributor returns a navigation menu button that contains
+ * the targets of the element that is clicked on.
+ *
+ */
+public class TargetsButton implements NavigationMenuContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor#getButtons(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<NavigationMenuButton> getButtons(Object fromElement) {
+ List<NavigationMenuButton> buttons = new LinkedList<NavigationMenuButton>();
+
+ if (fromElement instanceof Element) {
+ try {
+ NavigationService navigationService = ServiceUtilsForEObject.getInstance().getService(NavigationService.class, (Element) fromElement);
+
+ List<DirectedRelationship> relationships = ((Element) fromElement).getSourceDirectedRelationships();
+
+ if (!relationships.isEmpty()) {
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+ for (DirectedRelationship relationship : relationships) {
+ for (Element target : relationship.getTargets()) {
+ navigableElements.addAll(navigationService.getNavigableElements(target));
+ }
+ }
+
+ if (!navigableElements.isEmpty()) {
+ buttons.add(new NavigationSubMenuButton("Targets...", null, "Show targets", navigableElements));
+ }
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return buttons;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TypesButton.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TypesButton.java
new file mode 100644
index 00000000000..ff828cd23e1
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/menuContributor/TypesButton.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * Shuai Li (CEA LIST) <shuai.li@cea.fr> - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.navigation.menuContributor;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.gmfdiag.navigation.menu.button.NavigationSubMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuButton;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationService;
+import org.eclipse.papyrus.uml.navigation.Activator;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.TypedElement;
+
+public class TypesButton implements NavigationMenuContributor {
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigationMenuContributor#getButtons(java.lang.Object)
+ *
+ * @param fromElement
+ * @return
+ */
+ public List<NavigationMenuButton> getButtons(Object fromElement) {
+ List<NavigationMenuButton> buttons = new LinkedList<NavigationMenuButton>();
+
+ if (fromElement instanceof Type) {
+ try {
+ NavigationService navigationService = ServiceUtilsForEObject.getInstance().getService(NavigationService.class, (Classifier) fromElement);
+ List<NavigableElement> navigableElements = new LinkedList<NavigableElement>();
+
+ List<Element> elements = ((Element) fromElement).getModel().allOwnedElements();
+ for (Element element : elements) {
+ if (element instanceof TypedElement) {
+ if (((TypedElement) element).getType() == fromElement) {
+ List<NavigableElement> typesNavigableElements = navigationService.getNavigableElements(element);
+ for (NavigableElement typesNavigableElement : typesNavigableElements) {
+ if (!typesNavigableElement.getClass().getSimpleName().equalsIgnoreCase("TypedNavigableElement")
+ && !typesNavigableElement.getClass().getSimpleName().equalsIgnoreCase("OperationTypeNavigableElement")) {
+ navigableElements.add(typesNavigableElement);
+ }
+ }
+ }
+ }
+ }
+
+ if (!navigableElements.isEmpty()) {
+ buttons.add(new NavigationSubMenuButton("Types...", null, "Show other elements typed by this element", navigableElements));
+ }
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ return buttons;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigableElement.java
index 8de6f1aaadf..1004d012a1d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigableElement.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigableElement.java
@@ -1,98 +1,116 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST, 2014 Flanders' Make.
- *
- * 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
- * Klaas Gadeyne (Flanders' Make) klaas.gadeyne@flandersmake.be - Extended for CallBehaviorActions,
- * see bug 453721
- *****************************************************************************/
-package org.eclipse.papyrus.uml.navigation.contributor;
-
-import java.util.Collections;
-
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.Behavior;
-
-/**
- * Navigates from a CallBehaviorAction to its Behavior declaration
- *
- * @author Klaas Gadeyne
- */
-public class CBANavigableElement implements NavigableElement {
-
- protected final Behavior behavior;
-
- /**
- *
- * @param type
- * The Type to navigate to. May be null.
- */
- public CBANavigableElement(Behavior behavior) {
- this.behavior = behavior;
- }
-
- public String getLabel() {
- String label = "Go to behavior" + getCBALabel();
- return label;
- }
-
- public String getDescription() {
- return "Go to the Behavior linked with to this CallBehaviorAction" + getCBALabel();
- }
-
- protected String getCBALabel() {
- if (behavior == null) {
- return " (Undefined)";
- } else {
- return " (" + behavior.getName() + ")";
- }
- }
-
- @Deprecated
- public void navigate(IRevealSemanticElement navigationContext) {
- if (!isEnabled()) {
- return;
- }
-
- navigationContext.revealSemanticElement(Collections.singletonList(behavior));
- }
-
- public Image getImage() {
- if (behavior == null) {
- return null;
- }
-
- try {
- return ServiceUtilsForEObject.getInstance().getServiceRegistry(behavior).getService(LabelProviderService.class).getLabelProvider().getImage(behavior);
- } catch (Exception ex) {
- return null;
- }
- }
-
- /**
- * Enabled when the behavior is defined
- */
- public boolean isEnabled() {
- return behavior != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean navigate(NavigationTarget navigationContext) {
- if (!isEnabled()) {
- return false;
- }
- return navigationContext.revealElement(behavior);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST, 2014 Flanders' Make.
+ *
+ * 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
+ * Klaas Gadeyne (Flanders' Make) klaas.gadeyne@flandersmake.be - Extended for CallBehaviorActions,
+ * see bug 453721
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.navigation.navigableElement;
+
+import java.util.Collections;
+
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.navigation.service.ExtendedNavigableElement;
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * Navigates from a CallBehaviorAction to its Behavior declaration
+ *
+ * @author Klaas Gadeyne
+ */
+public class CBANavigableElement implements ExtendedNavigableElement {
+
+ protected final Behavior behavior;
+
+ /**
+ *
+ * @param type
+ * The Type to navigate to. May be null.
+ */
+ public CBANavigableElement(Behavior behavior) {
+ this.behavior = behavior;
+ }
+
+ public String getLabel() {
+ String label = "Go to behavior" + getCBALabel();
+ return label;
+ }
+
+ public String getDescription() {
+ return "Go to the Behavior linked with to this CallBehaviorAction" + getCBALabel();
+ }
+
+ protected String getCBALabel() {
+ if (behavior == null) {
+ return " (Undefined)";
+ } else {
+ return " (" + behavior.getName() + ")";
+ }
+ }
+
+ @Deprecated
+ public void navigate(IRevealSemanticElement navigationContext) {
+ if (!isEnabled()) {
+ return;
+ }
+
+ navigationContext.revealSemanticElement(Collections.singletonList(behavior));
+ }
+
+ public Image getImage() {
+ if (behavior == null) {
+ return null;
+ }
+
+ try {
+ return ServiceUtilsForEObject.getInstance().getServiceRegistry(behavior).getService(LabelProviderService.class).getLabelProvider().getImage(behavior);
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+ /**
+ * Enabled when the behavior is defined
+ */
+ public boolean isEnabled() {
+ return behavior != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean navigate(NavigationTarget navigationContext) {
+ if (!isEnabled()) {
+ return false;
+ }
+ return navigationContext.revealElement(behavior);
+ }
+
+ /**
+ * Returns the behavior (UML Element) of the CBANavigableElement
+ * @return behavior
+ */
+ public Element getBehavior() {
+ return behavior;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigableElement#getSemanticElement()
+ *
+ * @return
+ */
+ public Object getSemanticElement() {
+ return getBehavior();
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigationContributor.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigationContributor.java
index d9d2c3e1303..9799b9d42e2 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigationContributor.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/CBANavigationContributor.java
@@ -1,42 +1,42 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST, 2014 Flanders' Make.
- *
- * 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
- * Klaas Gadeyne (Flanders' Make) klaas.gadeyne@flandersmake.be - Extended for CallBehaviorActions,
- * see bug 453721
- *****************************************************************************/
-package org.eclipse.papyrus.uml.navigation.contributor;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.CallBehaviorAction;
-
-/**
- * NavigationContributor to navigate from a CallBehaviorAction to its Behavior declaration
- *
- * @author Klaas Gadeyne
- *
- */
-public class CBANavigationContributor implements NavigationContributor {
-
- public List<NavigableElement> getNavigableElements(Object fromElement) {
- List<NavigableElement> result = new LinkedList<NavigableElement>();
-
- Element element = UMLUtil.resolveUMLElement(fromElement);
- if (element instanceof CallBehaviorAction) {
- result.add(new CBANavigableElement(((CallBehaviorAction) element).getBehavior()));
- }
- return result;
- }
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST, 2014 Flanders' Make.
+ *
+ * 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
+ * Klaas Gadeyne (Flanders' Make) klaas.gadeyne@flandersmake.be - Extended for CallBehaviorActions,
+ * see bug 453721
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.navigation.navigableElement;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+
+/**
+ * NavigationContributor to navigate from a CallBehaviorAction to its Behavior declaration
+ *
+ * @author Klaas Gadeyne
+ *
+ */
+public class CBANavigationContributor implements NavigationContributor {
+
+ public List<NavigableElement> getNavigableElements(Object fromElement) {
+ List<NavigableElement> result = new LinkedList<NavigableElement>();
+
+ Element element = UMLUtil.resolveUMLElement(fromElement);
+ if (element instanceof CallBehaviorAction) {
+ result.add(new CBANavigableElement(((CallBehaviorAction) element).getBehavior()));
+ }
+ return result;
+ }
} \ No newline at end of file
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedElementNavigationContributor.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedElementNavigationContributor.java
new file mode 100644
index 00000000000..4e2ccc1a993
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedElementNavigationContributor.java
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * 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
+ * Shuai Li (CEA LIST) shuai.li@cea.fr - Creation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.navigation.navigableElement;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * NavigationContributor to navigate from TypedElement to their Type
+ *
+ * @author Shuai Li
+ *
+ */
+public class NamedElementNavigationContributor implements NavigationContributor {
+
+ public List<NavigableElement> getNavigableElements(Object fromElement) {
+ List<NavigableElement> result = new LinkedList<NavigableElement>();
+
+ Element element = UMLUtil.resolveUMLElement(fromElement);
+ if (element instanceof NamedElement) {
+ result.add(new NamedNavigableElement(((NamedElement) element)));
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedNavigableElement.java
new file mode 100644
index 00000000000..8946f3df3b4
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/NamedNavigableElement.java
@@ -0,0 +1,115 @@
+/*****************************************************************************
+ * 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
+ * Shuai Li (CEA LIST) shuai.li@cea.fr - Creation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.navigation.navigableElement;
+
+import java.util.Collections;
+
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.navigation.service.ExtendedNavigableElement;
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ * Navigates from a NamedElementdElement to its NamedElement declaration
+ *
+ * @author Shuai Li
+ */
+public class NamedNavigableElement implements ExtendedNavigableElement {
+
+ protected final NamedElement element;
+
+ /**
+ *
+ * @param element
+ * The NamedElement to navigate to. May be null.
+ */
+ public NamedNavigableElement(NamedElement element) {
+ this.element = element;
+ }
+
+ public String getLabel() {
+ String label = "Go to element" + getNamedElementLabel() + "...";
+ return label;
+ }
+
+ public String getDescription() {
+ return "Go to the element declaration of this NamedElement" + getNamedElementLabel();
+ }
+
+ protected String getNamedElementLabel() {
+ if (element == null) {
+ return " (Undefined)";
+ } else {
+ return " (" + element.getName() + ")";
+ }
+ }
+
+ @Deprecated
+ public void navigate(IRevealSemanticElement navigationContext) {
+ if (!isEnabled()) {
+ return;
+ }
+
+ navigationContext.revealSemanticElement(Collections.singletonList(element));
+ }
+
+ public Image getImage() {
+ if (element == null) {
+ return null;
+ }
+
+ try {
+ return ServiceUtilsForEObject.getInstance().getServiceRegistry(element).getService(LabelProviderService.class).getLabelProvider().getImage(element);
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+ /**
+ * Enabled when the element is defined
+ */
+ public boolean isEnabled() {
+ return element != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean navigate(NavigationTarget navigationContext) {
+ if (!isEnabled()) {
+ return false;
+ }
+ return navigationContext.revealElement(element);
+ }
+
+ /**
+ * Returns the element (UML Element) of the NamedElementdNavigableElement
+ * @return element
+ */
+ public Element getNamedElement() {
+ return this.element;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigableElement#getSemanticElement()
+ *
+ * @return
+ */
+ public Object getSemanticElement() {
+ return getNamedElement();
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/OperationTypeNavigableElement.java
index fd52df2b4d2..037a21614fe 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/OperationTypeNavigableElement.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/OperationTypeNavigableElement.java
@@ -1,37 +1,37 @@
-/*****************************************************************************
- * 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.uml.navigation.contributor;
-
-import org.eclipse.uml2.uml.Operation;
-
-/**
- * Navigates from an Operation to it's return type declaration
- *
- * @author CL228098
- *
- */
-public class OperationTypeNavigableElement extends TypedNavigableElement {
-
- public OperationTypeNavigableElement(Operation operation) {
- super(operation.getType());
- }
-
- @Override
- public String getLabel() {
- return "Go to return Type" + getTypeLabel();
- }
-
- @Override
- public String getDescription() {
- return "Go to the return type declaration of this Operation" + getTypeLabel();
- }
-}
+/*****************************************************************************
+ * 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.uml.navigation.navigableElement;
+
+import org.eclipse.uml2.uml.Operation;
+
+/**
+ * Navigates from an Operation to it's return type declaration
+ *
+ * @author CL228098
+ *
+ */
+public class OperationTypeNavigableElement extends TypedNavigableElement {
+
+ public OperationTypeNavigableElement(Operation operation) {
+ super(operation.getType());
+ }
+
+ @Override
+ public String getLabel() {
+ return "Go to return type" + getTypeLabel() + "...";
+ }
+
+ @Override
+ public String getDescription() {
+ return "Go to the return type declaration of this Operation" + getTypeLabel();
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedElementNavigationContributor.java
index 42bf705e7ae..0ae43d449ca 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedElementNavigationContributor.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedElementNavigationContributor.java
@@ -1,44 +1,44 @@
-/*****************************************************************************
- * 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.uml.navigation.contributor;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
-import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Operation;
-import org.eclipse.uml2.uml.TypedElement;
-
-/**
- * NavigationContributor to navigate from TypedElement to their Type
- *
- * @author Camille Letavernier
- *
- */
-public class TypedElementNavigationContributor implements NavigationContributor {
-
- public List<NavigableElement> getNavigableElements(Object fromElement) {
- List<NavigableElement> result = new LinkedList<NavigableElement>();
-
- Element element = UMLUtil.resolveUMLElement(fromElement);
- if (element instanceof TypedElement) {
- result.add(new TypedNavigableElement(((TypedElement) element).getType()));
- } else if (element instanceof Operation) {
- result.add(new OperationTypeNavigableElement((Operation) element));
- }
-
- return result;
- }
-}
+/*****************************************************************************
+ * 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.uml.navigation.navigableElement;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.services.navigation.service.NavigableElement;
+import org.eclipse.papyrus.infra.services.navigation.service.NavigationContributor;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.TypedElement;
+
+/**
+ * NavigationContributor to navigate from TypedElement to their Type
+ *
+ * @author Camille Letavernier
+ *
+ */
+public class TypedElementNavigationContributor implements NavigationContributor {
+
+ public List<NavigableElement> getNavigableElements(Object fromElement) {
+ List<NavigableElement> result = new LinkedList<NavigableElement>();
+
+ Element element = UMLUtil.resolveUMLElement(fromElement);
+ if (element instanceof TypedElement && ((TypedElement) element).getType() != null) {
+ result.add(new TypedNavigableElement(((TypedElement) element).getType()));
+ } else if (element instanceof Operation && ((Operation) element).getType() != null) {
+ result.add(new OperationTypeNavigableElement((Operation) element));
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedNavigableElement.java
index cf9d286fde8..3e856a98319 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/TypedNavigableElement.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/navigableElement/TypedNavigableElement.java
@@ -1,96 +1,114 @@
-/*****************************************************************************
- * 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.uml.navigation.contributor;
-
-import java.util.Collections;
-
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-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;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.Type;
-
-/**
- * Navigates from a TypedElement to its Type declaration
- *
- * @author Camille Letavernier
- */
-public class TypedNavigableElement implements NavigableElement {
-
- protected final Type type;
-
- /**
- *
- * @param type
- * The Type to navigate to. May be null.
- */
- public TypedNavigableElement(Type type) {
- this.type = type;
- }
-
- public String getLabel() {
- String label = "Go to type" + getTypeLabel();
- return label;
- }
-
- public String getDescription() {
- return "Go to the type declaration of this TypedElement" + getTypeLabel();
- }
-
- protected String getTypeLabel() {
- if (type == null) {
- return " (Undefined)";
- } else {
- return " (" + type.getName() + ")";
- }
- }
-
- @Deprecated
- public void navigate(IRevealSemanticElement navigationContext) {
- if (!isEnabled()) {
- return;
- }
-
- navigationContext.revealSemanticElement(Collections.singletonList(type));
- }
-
- public Image getImage() {
- if (type == null) {
- return null;
- }
-
- try {
- return ServiceUtilsForEObject.getInstance().getServiceRegistry(type).getService(LabelProviderService.class).getLabelProvider().getImage(type);
- } catch (Exception ex) {
- return null;
- }
- }
-
- /**
- * Enabled when the type is defined
- */
- public boolean isEnabled() {
- return type != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean navigate(NavigationTarget navigationContext) {
- if (!isEnabled()) {
- return false;
- }
- return navigationContext.revealElement(type);
- }
-}
+/*****************************************************************************
+ * 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.uml.navigation.navigableElement;
+
+import java.util.Collections;
+
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.services.navigation.service.ExtendedNavigableElement;
+import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement;
+import org.eclipse.papyrus.infra.widgets.util.NavigationTarget;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Type;
+
+/**
+ * Navigates from a TypedElement to its Type declaration
+ *
+ * @author Camille Letavernier
+ */
+public class TypedNavigableElement implements ExtendedNavigableElement {
+
+ protected final Type type;
+
+ /**
+ *
+ * @param type
+ * The Type to navigate to. May be null.
+ */
+ public TypedNavigableElement(Type type) {
+ this.type = type;
+ }
+
+ public String getLabel() {
+ String label = "Go to type" + getTypeLabel() + "...";
+ return label;
+ }
+
+ public String getDescription() {
+ return "Go to the type declaration of this TypedElement" + getTypeLabel();
+ }
+
+ protected String getTypeLabel() {
+ if (type == null) {
+ return " (Undefined)";
+ } else {
+ return " (" + type.getName() + ")";
+ }
+ }
+
+ @Deprecated
+ public void navigate(IRevealSemanticElement navigationContext) {
+ if (!isEnabled()) {
+ return;
+ }
+
+ navigationContext.revealSemanticElement(Collections.singletonList(type));
+ }
+
+ public Image getImage() {
+ if (type == null) {
+ return null;
+ }
+
+ try {
+ return ServiceUtilsForEObject.getInstance().getServiceRegistry(type).getService(LabelProviderService.class).getLabelProvider().getImage(type);
+ } catch (Exception ex) {
+ return null;
+ }
+ }
+
+ /**
+ * Enabled when the type is defined
+ */
+ public boolean isEnabled() {
+ return type != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean navigate(NavigationTarget navigationContext) {
+ if (!isEnabled()) {
+ return false;
+ }
+ return navigationContext.revealElement(type);
+ }
+
+ /**
+ * Returns the type (UML Element) of the TypedNavigableElement
+ * @return type
+ */
+ public Element getType() {
+ return this.type;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.navigation.service.NavigableElement#getSemanticElement()
+ *
+ * @return
+ */
+ public Object getSemanticElement() {
+ return getType();
+ }
+}

Back to the top