diff options
2 files changed, 63 insertions, 7 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityCompartmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityCompartmentCreationEditPolicy.java index 7a7b93785ca..7c5a87fb49b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityCompartmentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityCompartmentCreationEditPolicy.java @@ -1,6 +1,6 @@ /***************************************************************************** * 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 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.activity.edit.policies; @@ -69,9 +69,21 @@ public class ActivityCompartmentCreationEditPolicy extends DefaultCreationEditPo EObject currentParentSemantic = ((IGraphicalEditPart) gep.getParent()).resolveSemanticElement(); if (currentParentSemantic instanceof ActivityPartition) { req.setParameter(ActivityNodeHelper.OUT_FROM_PARTITION, currentParentSemantic); + if (context instanceof ActivityPartition) { + req.setParameter(ActivityNodeHelper.IN_PARTITION, context); + } + if (context instanceof InterruptibleActivityRegion) { + req.setParameter(ActivityNodeHelper.IN_INTERRUPTIBLE_ACTIVITY_REGION, context); + } } if (currentParentSemantic instanceof InterruptibleActivityRegion) { req.setParameter(ActivityNodeHelper.OUT_FROM_INTERRUPTIBLE_REGION, currentParentSemantic); + if (context instanceof ActivityPartition) { + req.setParameter(ActivityNodeHelper.IN_PARTITION, context); + } + if (context instanceof InterruptibleActivityRegion) { + req.setParameter(ActivityNodeHelper.IN_INTERRUPTIBLE_ACTIVITY_REGION, context); + } } Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(req)); 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 c61199a9b3c..25b7b2e65fe 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 @@ -12,7 +12,7 @@ * Contributors: * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation * Christian W. Damus - bug 462979 - * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 494514 + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bugs 494514, 533248 * *****************************************************************************/ package org.eclipse.papyrus.uml.service.types.helper; @@ -189,10 +189,32 @@ public class ActivityNodeHelper extends ElementEditHelper { } ActivityNode node = (ActivityNode) elementToMove; List<ActivityPartition> inPartitions = new LinkedList<>(node.getInPartitions()); + boolean change = false; if (inPartitions.contains(outFromPartition)) { inPartitions.remove(outFromPartition); + change = true; + } + // We know we have to remove the out inPartition, but we maybe have to add another inPartition + if (req.getParameter(IN_PARTITION) != null) { + ActivityPartition inPartition = (ActivityPartition) req.getParameter(IN_PARTITION); + if (!inPartitions.contains(inPartition)) { + inPartitions.add(inPartition); + change = true; + } + } + if (change) { cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InPartition(), inPartitions))); } + + // We know we have to remove the out inPartition, but maybe the inInterruptibleRegion must be filled + if (req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION) != null) { + InterruptibleActivityRegion inRegion = (InterruptibleActivityRegion) req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION); + List<InterruptibleActivityRegion> inRegions = new LinkedList<>(node.getInInterruptibleRegions()); + if (!inRegions.contains(inRegion)) { + inRegions.add(inRegion); + cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InInterruptibleRegion(), inRegions))); + } + } } return cc.isEmpty() ? null : cc.reduce(); } @@ -208,10 +230,32 @@ public class ActivityNodeHelper extends ElementEditHelper { continue; } ActivityNode node = (ActivityNode) elementToMove; - List<InterruptibleActivityRegion> inRegion = new LinkedList<>(node.getInInterruptibleRegions()); - if (inRegion.contains(outFromRegion)) { - inRegion.remove(outFromRegion); - cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InInterruptibleRegion(), inRegion))); + List<InterruptibleActivityRegion> inRegions = new LinkedList<>(node.getInInterruptibleRegions()); + boolean change = false; + if (inRegions.contains(outFromRegion)) { + inRegions.remove(outFromRegion); + change = true; + } + // We know we have to remove the out inInterruptibleRegion, but we maybe have to add another inInterruptibleRegion + if (req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION) != null) { + InterruptibleActivityRegion inRegion = (InterruptibleActivityRegion) req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION); + if (!inRegions.contains(inRegion)) { + inRegions.add(inRegion); + change = true; + } + } + if (change) { + cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InInterruptibleRegion(), inRegions))); + } + + // We know we have to remove the out inInterruptibleRegion, but maybe the inPartition must be filled + if (req.getParameter(IN_PARTITION) != null) { + ActivityPartition inPartition = (ActivityPartition) req.getParameter(IN_PARTITION); + List<ActivityPartition> inPartitions = new LinkedList<>(node.getInPartitions()); + if (!inPartitions.contains(inPartition)) { + inPartitions.add(inPartition); + cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InPartition(), inPartitions))); + } } } return cc.isEmpty() ? null : cc.reduce(); |