Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlaas Gadeyne2014-12-09 12:26:43 +0000
committerCamille Letavernier2014-12-09 12:26:43 +0000
commitfc4054121b533e0a59a21ec01a392acbfe8b62c8 (patch)
tree0c9f671f5b4bc8b84530a9480fd1ab8843620494 /plugins/uml/org.eclipse.papyrus.uml.navigation
parent4056ea71e15d6259a6244f7395ce6802416a0e0e (diff)
downloadorg.eclipse.papyrus-fc4054121b533e0a59a21ec01a392acbfe8b62c8.tar.gz
org.eclipse.papyrus-fc4054121b533e0a59a21ec01a392acbfe8b62c8.tar.xz
org.eclipse.papyrus-fc4054121b533e0a59a21ec01a392acbfe8b62c8.zip
453721: [Model Explorer] Support 'go to behaviour' navigation for
CallBehaviorActions https://bugs.eclipse.org/bugs/show_bug.cgi?id=453721 Signed-off-by: Klaas Gadeyne <klaas.gadeyne@gmail.com>
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.navigation')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigableElement.java98
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigationContributor.java42
3 files changed, 146 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
index 96d67cb38f9..a3dc19593a7 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/plugin.xml
@@ -9,6 +9,12 @@
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>
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/contributor/CBANavigableElement.java
new file mode 100644
index 00000000000..8de6f1aaadf
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigableElement.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * 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);
+ }
+}
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/contributor/CBANavigationContributor.java
new file mode 100644
index 00000000000..d9d2c3e1303
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.navigation/src/org/eclipse/papyrus/uml/navigation/contributor/CBANavigationContributor.java
@@ -0,0 +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;
+ }
+} \ No newline at end of file

Back to the top