Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvelten2011-03-08 05:19:39 -0500
committermvelten2011-03-08 05:19:39 -0500
commitea725c62f31b6e1f9e4227654dfa7523f1cc6b9b (patch)
treefbe1e2a40b56b0e7f0bf61df2fd17e75f1dd374c /plugins
parent7584b72eb9399ee151013b8b6a49f24ad07e4d28 (diff)
downloadorg.eclipse.papyrus-ea725c62f31b6e1f9e4227654dfa7523f1cc6b9b.tar.gz
org.eclipse.papyrus-ea725c62f31b6e1f9e4227654dfa7523f1cc6b9b.tar.xz
org.eclipse.papyrus-ea725c62f31b6e1f9e4227654dfa7523f1cc6b9b.zip
REOPENED - bug 334262: [General] Navigation and integration with the creation diagram service
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334262 backport navigation : add navigation plugins
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/.classpath7
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/.project28
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/META-INF/MANIFEST.MF11
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/about.html28
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/build.properties8
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.properties12
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.xml24
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/BehavioredClassifierRule.java75
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/CBARule.java63
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/OperationRule.java59
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/PackageRule.java74
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/StateRule.java76
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/TransitionRule.java59
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLBaseNameSetter.java47
-rw-r--r--plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLRuleHelper.java39
15 files changed, 610 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/.classpath b/plugins/uml/org.eclipse.papyrus.navigation.uml/.classpath
new file mode 100644
index 00000000000..9d5026e8ffd
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/.project b/plugins/uml/org.eclipse.papyrus.navigation.uml/.project
new file mode 100644
index 00000000000..a2cac6cf434
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.navigation.uml</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.navigation.uml/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..57b289eb746
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.papyrus.navigation.uml;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.papyrus.navigation;bundle-version="0.7.3",
+ org.eclipse.uml2.uml,
+ org.eclipse.papyrus.umlutils
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/about.html b/plugins/uml/org.eclipse.papyrus.navigation.uml/about.html
new file mode 100644
index 00000000000..82d49bf5f81
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/build.properties b/plugins/uml/org.eclipse.papyrus.navigation.uml/build.properties
new file mode 100644
index 00000000000..30e2cedf44d
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ about.html
+src.includes = about.html
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.properties b/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.properties
new file mode 100644
index 00000000000..fd3fcfebe47
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.properties
@@ -0,0 +1,12 @@
+#################################################################################
+# Copyright (c) 2010 Atos Origin.
+# 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:
+# Atos Origin - Initial API and Implementation
+##################################################################################
+pluginName=Papyrus UML navigation (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.xml b/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.xml
new file mode 100644
index 00000000000..9c5a0673191
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/plugin.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.papyrus.navigation.navigationRule">
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.BehavioredClassifierRule"></navigationRule>
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.CBARule">
+ </navigationRule>
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.OperationRule">
+ </navigationRule>
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.PackageRule">
+ </navigationRule>
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.StateRule">
+ </navigationRule>
+ <navigationRule
+ rule="org.eclipse.papyrus.navigation.uml.TransitionRule"></navigationRule>
+ </extension>
+
+</plugin>
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/BehavioredClassifierRule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/BehavioredClassifierRule.java
new file mode 100644
index 00000000000..5a40fed1993
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/BehavioredClassifierRule.java
@@ -0,0 +1,75 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.BehavioredClassifier;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class BehavioredClassifierRule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof BehavioredClassifier &&
+ // forbid Behavior to avoid infinite loop
+ !(element instanceof Behavior);
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ EStructuralFeature classifierBehaviorFeature = UMLPackage.Literals.BEHAVIORED_CLASSIFIER__CLASSIFIER_BEHAVIOR;
+
+ final BehavioredClassifier behavioredClassifier = (BehavioredClassifier)currentNavElement.getElement();
+
+ Behavior classifierBehavior = behavioredClassifier.getClassifierBehavior();
+ if(classifierBehavior != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(classifierBehavior, classifierBehaviorFeature));
+ }
+
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, classifierBehaviorFeature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ behavioredClassifier.setClassifierBehavior((Behavior)toLink);
+ }
+ });
+
+ EStructuralFeature ownedBehaviorFeature = UMLPackage.Literals.BEHAVIORED_CLASSIFIER__OWNED_BEHAVIOR;
+
+ for(Behavior ownedBehavior : behavioredClassifier.getOwnedBehaviors()) {
+ if(ownedBehavior != null && !ownedBehavior.equals(classifierBehavior)) {
+ nextPossibleElements.add(new ExistingNavigableElement(ownedBehavior, ownedBehaviorFeature));
+ }
+ }
+
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, ownedBehaviorFeature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ behavioredClassifier.getOwnedBehaviors().add((Behavior)toLink);
+ }
+ });
+
+ return nextPossibleElements;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/CBARule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/CBARule.java
new file mode 100644
index 00000000000..a6838487134
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/CBARule.java
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class CBARule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof CallBehaviorAction;
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ EStructuralFeature feature = UMLPackage.Literals.CALL_BEHAVIOR_ACTION__BEHAVIOR;
+
+ final CallBehaviorAction cba = (CallBehaviorAction)currentNavElement.getElement();
+ // two cases here :
+ // if the behavior is defined we want the possibility to navigate to it
+ // otherwise we want the possibility to create either an interaction or an activity as a behavior
+ if(cba.getBehavior() != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(cba.getBehavior(), feature));
+ } else {
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, feature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ // TODO ask for container ?
+ org.eclipse.uml2.uml.Package owner = cba.getActivity().getNearestPackage();
+ owner.getPackagedElements().add((PackageableElement)toLink);
+ cba.setBehavior((Behavior)toLink);
+ }
+ });
+ }
+
+ return nextPossibleElements;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/OperationRule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/OperationRule.java
new file mode 100644
index 00000000000..069e8198e82
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/OperationRule.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class OperationRule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof Operation;
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ EStructuralFeature feature = UMLPackage.Literals.BEHAVIORAL_FEATURE__METHOD;
+
+ final Operation op = (Operation)currentNavElement.getElement();
+ for(Behavior b : op.getMethods()) {
+ nextPossibleElements.add(new ExistingNavigableElement(b, feature));
+ }
+
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, feature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ // TODO ask for container ?
+ org.eclipse.uml2.uml.Class owner = op.getClass_();
+ owner.getOwnedBehaviors().add((Behavior)toLink);
+ op.getMethods().add((Behavior)toLink);
+ }
+ });
+
+ return nextPossibleElements;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/PackageRule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/PackageRule.java
new file mode 100644
index 00000000000..618b3cf73aa
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/PackageRule.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.CreatedNavigableElement;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Collaboration;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class PackageRule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof Package;
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ EStructuralFeature packagedFeature = UMLPackage.Literals.PACKAGE__PACKAGED_ELEMENT;
+
+ final Package pack = (Package)currentNavElement.getElement();
+
+ for(PackageableElement element : pack.getPackagedElements()) {
+ if(element instanceof Collaboration) {
+ nextPossibleElements.add(new ExistingNavigableElement(element, packagedFeature));
+ }
+ }
+
+ Collaboration collab = UMLFactory.eINSTANCE.createCollaboration();
+ nextPossibleElements.add(new CreatedNavigableElement(collab, currentNavElement, packagedFeature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ pack.getPackagedElements().add((PackageableElement)toLink);
+ }
+ }, UMLBaseNameSetter.instance));
+
+ // provide the possibility to create behavior in package as structural element :
+ // this allows to easily share behavior between elements using a package as library
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, UMLPackage.Literals.ELEMENT__OWNED_ELEMENT, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ pack.getPackagedElements().add((Behavior)toLink);
+ }
+ });
+
+ return nextPossibleElements;
+ }
+
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/StateRule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/StateRule.java
new file mode 100644
index 00000000000..725a87a5358
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/StateRule.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class StateRule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof State;
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ final State state = (State)currentNavElement.getElement();
+
+ if(state.getDoActivity() != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(state.getDoActivity(), UMLPackage.Literals.STATE__DO_ACTIVITY));
+ } else {
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, UMLPackage.Literals.STATE__DO_ACTIVITY, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ state.setDoActivity((Behavior)toLink);
+ }
+ });
+ }
+
+ if(state.getEntry() != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(state.getEntry(), UMLPackage.Literals.STATE__ENTRY));
+ } else {
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, UMLPackage.Literals.STATE__ENTRY, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ state.setEntry((Behavior)toLink);
+ }
+ });
+ }
+
+ if(state.getExit() != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(state.getExit(), UMLPackage.Literals.STATE__EXIT));
+ } else {
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, UMLPackage.Literals.STATE__EXIT, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ state.setExit((Behavior)toLink);
+ }
+ });
+ }
+
+ return nextPossibleElements;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/TransitionRule.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/TransitionRule.java
new file mode 100644
index 00000000000..bec17905289
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/TransitionRule.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.ExistingNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.INavigationRule;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Transition;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class TransitionRule implements INavigationRule {
+
+ public boolean handle(EObject element) {
+ return element instanceof Transition;
+ }
+
+ public List<NavigableElement> getNextPossibleElements(NavigableElement currentNavElement) {
+ List<NavigableElement> nextPossibleElements = new LinkedList<NavigableElement>();
+
+ EStructuralFeature feature = UMLPackage.Literals.TRANSITION__EFFECT;
+
+ final Transition transition = (Transition)currentNavElement.getElement();
+ // two cases here :
+ // if the effect is defined we want the possibility to navigate to it
+ // otherwise we want the possibility to create either an interaction or an activity as an effect
+ if(transition.getEffect() != null) {
+ nextPossibleElements.add(new ExistingNavigableElement(transition.getEffect(), feature));
+ } else {
+ UMLRuleHelper.addBehaviorCreatedNavigableElements(nextPossibleElements, currentNavElement, feature, new IModelLinker() {
+
+ public void linkToModel(EObject toLink) {
+ transition.setEffect((Behavior)toLink);
+ }
+ });
+ }
+
+ return nextPossibleElements;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLBaseNameSetter.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLBaseNameSetter.java
new file mode 100644
index 00000000000..909ef8dcb60
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLBaseNameSetter.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.navigation.IBaseNameSetter;
+import org.eclipse.papyrus.umlutils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+
+
+public class UMLBaseNameSetter implements IBaseNameSetter {
+
+ public static final UMLBaseNameSetter instance = new UMLBaseNameSetter();
+
+ private UMLBaseNameSetter() {
+ }
+
+ public void setBaseName(String base, EObject toName) {
+ if(toName instanceof NamedElement) {
+ NamedElement namedElement = (NamedElement)toName;
+
+ List<EObject> contents;
+ if(namedElement.eContainer() != null) {
+ contents = namedElement.eContainer().eContents();
+ } else {
+ contents = Collections.EMPTY_LIST;
+ }
+
+ namedElement.setName(NamedElementUtil.getDefaultNameWithIncrement(base, namedElement, contents));
+ }
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLRuleHelper.java b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLRuleHelper.java
new file mode 100644
index 00000000000..9255b329e32
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.navigation.uml/src/org/eclipse/papyrus/navigation/uml/UMLRuleHelper.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * 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:
+ * Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.navigation.uml;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.navigation.CreatedNavigableElement;
+import org.eclipse.papyrus.navigation.IModelLinker;
+import org.eclipse.papyrus.navigation.NavigableElement;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+
+public class UMLRuleHelper {
+
+ private static final EClass[] possibleBehaviors = { UMLPackage.Literals.INTERACTION, UMLPackage.Literals.ACTIVITY, UMLPackage.Literals.STATE_MACHINE };
+
+ public static void addBehaviorCreatedNavigableElements(List<NavigableElement> navElements, NavigableElement currentNavElement, EStructuralFeature feature, final IModelLinker modelLinker) {
+ for(EClass behaviorClass : possibleBehaviors) {
+ final EObject behavior = UMLFactory.eINSTANCE.create(behaviorClass);
+ navElements.add(new CreatedNavigableElement(behavior, currentNavElement, feature, modelLinker, UMLBaseNameSetter.instance));
+ }
+ }
+
+}

Back to the top