diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java')
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java index ee786f70733..9c651aa5d20 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.navigation/src/org/eclipse/papyrus/uml/diagram/navigation/CBARule.java @@ -1,66 +1,66 @@ -/*****************************************************************************
- * 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.uml.diagram.navigation;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.infra.gmfdiag.navigation.ExistingNavigableElement;
-import org.eclipse.papyrus.infra.gmfdiag.navigation.IModelLinker;
-import org.eclipse.papyrus.infra.gmfdiag.navigation.INavigationRule;
-import org.eclipse.papyrus.infra.gmfdiag.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 {
-
- @Override
- public boolean handle(EObject element) {
- return element instanceof CallBehaviorAction;
- }
-
- @Override
- 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() {
-
- @Override
- 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;
- }
-
-}
+/***************************************************************************** + * 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.uml.diagram.navigation; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.infra.gmfdiag.navigation.ExistingNavigableElement; +import org.eclipse.papyrus.infra.gmfdiag.navigation.IModelLinker; +import org.eclipse.papyrus.infra.gmfdiag.navigation.INavigationRule; +import org.eclipse.papyrus.infra.gmfdiag.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 { + + @Override + public boolean handle(EObject element) { + return element instanceof CallBehaviorAction; + } + + @Override + 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() { + + @Override + 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; + } + +} |