Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-08-18 07:31:24 -0400
committerGerrit Code Review @ Eclipse.org2014-08-18 07:31:24 -0400
commit1b7ecb84d83a6a1e9db116d46621b1c1c94e2bb2 (patch)
treeaf5c2c221cf32cc237aed7f10f0a6e3f48a99282 /plugins
parent575546624b85c525a9b0acf3679ca31f35d29497 (diff)
parent4528d2b08b5558930a5db103917d718d1389415f (diff)
downloadorg.eclipse.papyrus-1b7ecb84d83a6a1e9db116d46621b1c1c94e2bb2.tar.gz
org.eclipse.papyrus-1b7ecb84d83a6a1e9db116d46621b1c1c94e2bb2.tar.xz
org.eclipse.papyrus-1b7ecb84d83a6a1e9db116d46621b1c1c94e2bb2.zip
Merge "[440276] - Activity node created in partition does not have InPartition feature set"
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java71
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java84
2 files changed, 85 insertions, 70 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
index c6bd8c158bb..a4ca22a391f 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java
@@ -62,75 +62,10 @@ public class ActivityNodeHelper extends ElementEditHelper {
}
@Override
- protected ICommand getMoveCommand(MoveRequest req) {
- if (req != null) {
- if (req.getTargetContainer() instanceof ActivityPartition) {
- ActivityPartition partition = (ActivityPartition)req.getTargetContainer();
- CompositeCommand result = new CompositeCommand("Move elements in Partition");
- MoveElementsCommand moveCommand = new NotContainmentMoveCommand(createMoveToPartitionRequest(req));
- result.add(moveCommand);
- for (Object o: req.getElementsToMove().keySet()) {
- result.add(new SetValueCommand(new SetRequest(partition, UMLPackage.eINSTANCE.getActivityPartition_Node(), o)));
- }
- return result;
- }
- }
- return super.getMoveCommand(req);
- }
-
- /**
- * @param base move request in which target container is ActivityPartition
- * @return MoveRequest in which replaced Partition container on Activity and replaced containment features for it.
- */
- private MoveRequest createMoveToPartitionRequest(MoveRequest baseReq) {
- if (baseReq == null) {
- return null;
- }
- MoveRequest result = new MoveRequest(baseReq.getEditingDomain(), findActivity(baseReq.getTargetContainer()), baseReq.getElementsToMove());
- for (Object o : baseReq.getElementsToMove().keySet()) {
- if (o instanceof ActivityNode) {
- ActivityNode node = (ActivityNode)o;
- result.setTargetFeature(node ,findActivityFeature(node.eClass()));
- }
- }
- return result;
- }
-
- /**
- * Find parent Activity.
- *
- * @param editElement ActivitiyPartition element
- * @return null if Activity not found.
- */
- protected Activity findActivity(EObject editElement) {
- if (editElement instanceof ActivityPartition) {
- ActivityPartition partition = (ActivityPartition) editElement;
- if (partition.eContainer() instanceof Activity) {
- return (Activity)partition.eContainer();
- } else {
- return findActivity(partition.eContainer());
- }
- }
- return null;
- }
-
- /**
- * Find Activity feature appropriate to ActivityPartition feature.
- *
- * @return Appropriate feature. If feature not found return partitionFeature param
- */
- protected EReference findActivityFeature(EClass eClass) {
- if (UMLPackage.eINSTANCE.getActivityPartition().isSuperTypeOf(eClass)) {
- return UMLPackage.eINSTANCE.getActivity_StructuredNode();
- }
- if (UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(eClass)) {
- return UMLPackage.eINSTANCE.getActivity_StructuredNode();
- }
- return UMLPackage.eINSTANCE.getActivity_OwnedNode();
- }
-
- @Override
protected ICommand getConfigureCommand(ConfigureRequest req) {
+ if (req.getParameter(IN_PARTITION) != null) {
+ return new SetValueCommand(new SetRequest((EObject)req.getParameter(IN_PARTITION),UMLPackage.eINSTANCE.getActivityPartition_Node(), req.getElementToConfigure()));
+ }
if (req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION) != null) {
return new SetValueCommand(new SetRequest((EObject)req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION),UMLPackage.eINSTANCE.getInterruptibleActivityRegion_Node(), req.getElementToConfigure()));
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
index 0d10c304bc5..2b725ce76fb 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java
@@ -1,10 +1,22 @@
package org.eclipse.papyrus.uml.service.types.helper;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.papyrus.uml.service.types.command.NotContainmentMoveCommand;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.UMLPackage;
-public class ActivityPartitionEditHelper extends ActivityNodeHelper {
+public class ActivityPartitionEditHelper extends ActivityGroupHelper {
@Override
protected ICommand getCreateCommand(CreateElementRequest req) {
@@ -23,8 +35,76 @@ public class ActivityPartitionEditHelper extends ActivityNodeHelper {
return null;
}
CreateElementRequest result = new CreateElementRequest(req.getEditingDomain(), findActivity(req.getContainer()), req.getElementType());
- result.setParameter(IN_PARTITION, (ActivityPartition)req.getContainer());
+ result.setParameter(ActivityNodeHelper.IN_PARTITION, (ActivityPartition)req.getContainer());
result.setContainmentFeature(findActivityFeature(req.getElementType().getEClass()));
return result;
}
+
+ @Override
+ protected ICommand getMoveCommand(MoveRequest req) {
+ if (req != null) {
+ if (req.getTargetContainer() instanceof ActivityPartition) {
+ ActivityPartition partition = (ActivityPartition)req.getTargetContainer();
+ CompositeCommand result = new CompositeCommand("Move elements in Partition");
+ MoveElementsCommand moveCommand = new NotContainmentMoveCommand(createMoveToPartitionRequest(req));
+ result.add(moveCommand);
+ for (Object o: req.getElementsToMove().keySet()) {
+ result.add(new SetValueCommand(new SetRequest(partition, UMLPackage.eINSTANCE.getActivityPartition_Node(), o)));
+ }
+ return result;
+ }
+ }
+ return super.getMoveCommand(req);
+ }
+
+ /**
+ * @param base move request in which target container is ActivityPartition
+ * @return MoveRequest in which replaced Partition container on Activity and replaced containment features for it.
+ */
+ private MoveRequest createMoveToPartitionRequest(MoveRequest baseReq) {
+ if (baseReq == null) {
+ return null;
+ }
+ MoveRequest result = new MoveRequest(baseReq.getEditingDomain(), findActivity(baseReq.getTargetContainer()), baseReq.getElementsToMove());
+ for (Object o : baseReq.getElementsToMove().keySet()) {
+ if (o instanceof ActivityNode) {
+ ActivityNode node = (ActivityNode)o;
+ result.setTargetFeature(node ,findActivityFeature(node.eClass()));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Find parent Activity.
+ *
+ * @param editElement ActivitiyPartition element
+ * @return null if Activity not found.
+ */
+ protected Activity findActivity(EObject editElement) {
+ if (editElement instanceof ActivityPartition) {
+ ActivityPartition partition = (ActivityPartition) editElement;
+ if (partition.eContainer() instanceof Activity) {
+ return (Activity)partition.eContainer();
+ } else {
+ return findActivity(partition.eContainer());
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find Activity feature appropriate to ActivityPartition feature.
+ *
+ * @return Appropriate feature. If feature not found return partitionFeature param
+ */
+ protected EReference findActivityFeature(EClass eClass) {
+ if (UMLPackage.eINSTANCE.getActivityPartition().isSuperTypeOf(eClass)) {
+ return UMLPackage.eINSTANCE.getActivity_StructuredNode();
+ }
+ if (UMLPackage.eINSTANCE.getStructuredActivityNode().isSuperTypeOf(eClass)) {
+ return UMLPackage.eINSTANCE.getActivity_StructuredNode();
+ }
+ return UMLPackage.eINSTANCE.getActivity_OwnedNode();
+ }
} \ No newline at end of file

Back to the top