Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-06-04 04:19:05 -0400
committerNicolas FAUVERGUE2019-06-17 06:22:28 -0400
commit1fb6853103e6b85bccaa5acd2050d50f00c1d759 (patch)
treebc826cbcf998706c9e50ea44ebce6467eabbbe13
parent34058d3dc1cc3d2ed9ac64a309cf0a399784975d (diff)
downloadorg.eclipse.papyrus-1fb6853103e6b85bccaa5acd2050d50f00c1d759.tar.gz
org.eclipse.papyrus-1fb6853103e6b85bccaa5acd2050d50f00c1d759.tar.xz
org.eclipse.papyrus-1fb6853103e6b85bccaa5acd2050d50f00c1d759.zip
Bug 494514: [ActivityDiagram] Activity edge created in partition does
not have inPartition feature set Manage the control flow and object flow edit helper for in partition feature value. + Manage InPartition feature for sub elements in InPartition Element Change-Id: I1c88ea554e4bf8fd9f1e57c70df901d293b5dfb6 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityNodeHelper.java90
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java86
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java86
3 files changed, 239 insertions, 23 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 b71ad612ce5..c61199a9b3c 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012, 2015 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2012, 2015, 2019 CEA LIST, Christian W. Damus, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,10 +12,12 @@
* 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
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
+import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -25,6 +27,7 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
@@ -39,7 +42,7 @@ import org.eclipse.uml2.uml.UMLPackage;
/**
* A customization of the destroy and configure commands for activity nodes to account for
* the bizarre {@link Element#getOwnedElements() Element::ownedElement} override in {@link Activity} that has {@code node} and {@code group} subsetting {@code ownedElement} instead of {@code ownedNode} and {@code ownedGroup}.
- *
+ *
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=463177
*/
public class ActivityNodeHelper extends ElementEditHelper {
@@ -55,6 +58,18 @@ public class ActivityNodeHelper extends ElementEditHelper {
public static final String OUT_FROM_INTERRUPTIBLE_REGION = "OUT_FROM_REGION";
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.helper.DefaultEditHelper#getCreateCommand(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest)
+ */
+ @Override
+ protected ICommand getCreateCommand(final CreateElementRequest req) {
+ // Manage the InPartitions and the InInterruptibleRegions features
+ fillRequestWithInPartitionsAndInInterruptibleRegions(req);
+ return super.getCreateCommand(req);
+ }
+
@Override
protected ICommand getBasicDestroyElementCommand(DestroyElementRequest req) {
ICommand result = req.getBasicDestroyCommand();
@@ -70,20 +85,56 @@ public class ActivityNodeHelper extends ElementEditHelper {
return result;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.uml.service.types.helper.ElementEditHelper#getConfigureCommand(org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest)
+ */
@Override
- protected ICommand getConfigureCommand(ConfigureRequest req) {
+ protected ICommand getConfigureCommand(final ConfigureRequest req) {
if (req.getParameter(IN_PARTITION) != null) {
- return new SetValueCommand(new SetRequest((EObject) req.getParameter(IN_PARTITION), UMLPackage.eINSTANCE.getActivityPartition_Node(), req.getElementToConfigure()));
+ final Object parameterValue = req.getParameter(IN_PARTITION);
+
+ // Manage some commands if this is a collection
+ if (parameterValue instanceof Collection) {
+ final CompositeCommand compositeCommand = new CompositeCommand("Set ActivityPartitions Nodes"); //$NON-NLS-1$
+ for (final Object entryValue : (Collection<?>) parameterValue) {
+ if (entryValue instanceof EObject) {
+ compositeCommand.add(new SetValueCommand(new SetRequest((EObject) entryValue, UMLPackage.eINSTANCE.getActivityPartition_Node(), req.getElementToConfigure())));
+ }
+ }
+ return compositeCommand;
+
+ // Else, just return the correct set command
+ } else if (parameterValue instanceof EObject) {
+ return new SetValueCommand(new SetRequest((EObject) parameterValue, 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()));
+
+ final Object parameterValue = req.getParameter(IN_INTERRUPTIBLE_ACTIVITY_REGION);
+
+ // Manage some commands if this is a collection
+ if (parameterValue instanceof Collection) {
+ final CompositeCommand compositeCommand = new CompositeCommand("Set InterruptibleActivityRegions Nodes"); //$NON-NLS-1$
+ for (final Object entryValue : (Collection<?>) parameterValue) {
+ if (entryValue instanceof EObject) {
+ compositeCommand.add(new SetValueCommand(new SetRequest((EObject) entryValue, UMLPackage.eINSTANCE.getInterruptibleActivityRegion_Node(), req.getElementToConfigure())));
+ }
+ }
+ return compositeCommand;
+
+ // Else, just return the correct set command
+ } else if (parameterValue instanceof EObject) {
+ return new SetValueCommand(new SetRequest((EObject) parameterValue, UMLPackage.eINSTANCE.getInterruptibleActivityRegion_Node(), req.getElementToConfigure()));
+ }
}
return super.getConfigureCommand(req);
}
/**
* Basic destruction command for owned elements of activities.
- *
+ *
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=463177
*/
static class DestroyActivityOwnedElementCommand extends DestroyElementCommand {
@@ -105,6 +156,29 @@ public class ActivityNodeHelper extends ElementEditHelper {
}
}
+ /**
+ * This allows to fill the create element request with in partitions if needed.
+ *
+ * @param createRequest
+ * The create element request.
+ */
+ public static void fillRequestWithInPartitionsAndInInterruptibleRegions(final CreateElementRequest createRequest) {
+ final EObject container = createRequest.getContainer();
+ if (container instanceof ActivityNode) {
+ // Manage the InPartition if needed
+ final Collection<ActivityPartition> inPartitions = ((ActivityNode) container).getInPartitions();
+ if (!inPartitions.isEmpty()) {
+ createRequest.setParameter(ActivityNodeHelper.IN_PARTITION, inPartitions);
+ }
+
+ // Manage the InInterruptibleRegions if needed
+ final Collection<InterruptibleActivityRegion> inInterruptibleRegions = ((ActivityNode) container).getInInterruptibleRegions();
+ if (!inInterruptibleRegions.isEmpty()) {
+ createRequest.setParameter(ActivityNodeHelper.IN_INTERRUPTIBLE_ACTIVITY_REGION, inInterruptibleRegions);
+ }
+ }
+ }
+
public static ICommand getMoveOutFromPartitionCommand(MoveRequest req) {
if (req.getParameter(OUT_FROM_PARTITION) != null) {
CompositeCommand cc = new CompositeCommand("Move Out From Parition");//$NON-NLS-1$
@@ -114,7 +188,7 @@ public class ActivityNodeHelper extends ElementEditHelper {
continue;
}
ActivityNode node = (ActivityNode) elementToMove;
- List<ActivityPartition> inPartitions = new LinkedList<ActivityPartition>(node.getInPartitions());
+ List<ActivityPartition> inPartitions = new LinkedList<>(node.getInPartitions());
if (inPartitions.contains(outFromPartition)) {
inPartitions.remove(outFromPartition);
cc.add(new SetValueCommand(new SetRequest(node, UMLPackage.eINSTANCE.getActivityNode_InPartition(), inPartitions)));
@@ -134,7 +208,7 @@ public class ActivityNodeHelper extends ElementEditHelper {
continue;
}
ActivityNode node = (ActivityNode) elementToMove;
- List<InterruptibleActivityRegion> inRegion = new LinkedList<InterruptibleActivityRegion>(node.getInInterruptibleRegions());
+ 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)));
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
index f5f066ee82c..1a95c8fc85e 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ControlFlowEditHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011-2012 CEA LIST.
+ * Copyright (c) 2011-2012, 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,12 +9,15 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- *
- * CEA LIST - Initial API and implementation
+ * CEA LIST - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 494514
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -26,17 +29,21 @@ import org.eclipse.gmf.runtime.common.core.command.IdentityCommand;
import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.CreateRelationshipCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.service.types.command.ControlFlowReorientCommand;
import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
import org.eclipse.papyrus.uml.tools.utils.ActivityEdgeUtil;
import org.eclipse.papyrus.uml.tools.utils.ControlFlowUtil;
import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ActivityPartition;
import org.eclipse.uml2.uml.ControlFlow;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* Edit helper class for binary {@link ControlFlow}
@@ -48,12 +55,32 @@ public class ControlFlowEditHelper extends ElementEditHelper {
*/
@Override
protected ICommand getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- return new ControlFlowReorientCommand(req);
+ ICommand resultCommand = new ControlFlowReorientCommand(req);
+
+ // Get the control flow
+ final ControlFlow controlFlow = (ControlFlow) req.getRelationship();
+
+ // Get if this is a source re-orient or the target
+ final boolean isReorientSource = req.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE;
+
+ // Get the source and target from controlFlow and request for needed one
+ final Object source = isReorientSource ? req.getNewRelationshipEnd() : controlFlow.getSource();
+ final Object target = isReorientSource ? controlFlow.getTarget() : req.getNewRelationshipEnd();
+
+ if ((null == source || source instanceof ActivityNode) && (null == target || target instanceof ActivityNode)) {
+ // Get the command to update the InPartition feature
+ final ICommand updatePartitionsCommand = getInPartitionUpdateCommand(controlFlow, (ActivityNode) source, (ActivityNode) target);
+ if (null != updatePartitionsCommand) {
+ resultCommand = CompositeCommand.compose(resultCommand, updatePartitionsCommand);
+ }
+ }
+
+ return resultCommand;
}
/**
* Test if the relationship creation is allowed.
- *
+ *
* @param source
* the relationship source can be null
* @param target
@@ -117,6 +144,7 @@ public class ControlFlowEditHelper extends ElementEditHelper {
ICommand configureCommand = new ConfigureElementCommand(req) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
ControlFlow element = (ControlFlow) req.getElementToConfigure();
@@ -129,6 +157,17 @@ public class ControlFlowEditHelper extends ElementEditHelper {
element.setTarget(target);
}
+ // Manage InPartitions
+ if (null != source && null != target) {
+
+ // Get the source InPartitions
+ final List<ActivityPartition> partitions = new ArrayList<>(source.getInPartitions());
+ // Keep the InPartitions contained in the source and target to add it into the control flow
+ partitions.retainAll(target.getInPartitions());
+
+ element.getInPartitions().addAll(partitions);
+ }
+
return CommandResult.newOKCommandResult(element);
}
};
@@ -136,10 +175,9 @@ public class ControlFlowEditHelper extends ElementEditHelper {
return CompositeCommand.compose(configureCommand, super.getConfigureCommand(req));
}
-
/**
* This method provides the object to be use as source.
- *
+ *
* @return the source value
*/
protected ActivityNode getSourceObject(ConfigureRequest req) {
@@ -149,7 +187,7 @@ public class ControlFlowEditHelper extends ElementEditHelper {
/**
* This method provides the object to be used as target.
- *
+ *
* @return the target value
*/
protected ActivityNode getTargetObject(ConfigureRequest req) {
@@ -176,4 +214,36 @@ public class ControlFlowEditHelper extends ElementEditHelper {
return ControlFlowUtil.canExistControlFlow(container, null, (ActivityNode) source, (ActivityNode) target);
}
+ /**
+ * This allows to get the command to update the InPartition feature if needed.
+ *
+ * @param controlFlow
+ * The control flow to update.
+ * @param source
+ * The source activity node.
+ * @param target
+ * The target activity node.
+ * @return The command to update the InPartition feature (can be <code>null</code>).
+ */
+ protected ICommand getInPartitionUpdateCommand(final ControlFlow controlFlow, final ActivityNode source, final ActivityNode target) {
+ List<ActivityPartition> partitions = new ArrayList<>();
+ if (null != source && null != target) {
+ // Get the source InPartitions
+ partitions = new ArrayList<>(source.getInPartitions());
+ // Keep the in partitions contained in the source and target to add it into the control flow
+ partitions.retainAll(target.getInPartitions());
+
+ if (!partitions.isEmpty()) {
+ return new SetValueCommand(new SetRequest(controlFlow, UMLPackage.eINSTANCE.getActivityEdge_InPartition(), partitions));
+ }
+ }
+
+ // If the partitions found are empty and the control flow InPartitions are not, clear this
+ if (partitions.isEmpty() && !controlFlow.getInPartitions().isEmpty()) {
+ return new SetValueCommand(new SetRequest(controlFlow, UMLPackage.eINSTANCE.getActivityEdge_InPartition(), partitions));
+ }
+
+ return null;
+ }
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
index 7067aea1218..a1a92d62df0 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ObjectFlowEditHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011-2012 CEA LIST.
+ * Copyright (c) 2011-2012, 2019 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,12 +9,15 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- *
- * CEA LIST - Initial API and implementation
+ * CEA LIST - Initial API and implementation
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 494514
*
*****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -26,17 +29,21 @@ import org.eclipse.gmf.runtime.common.core.command.IdentityCommand;
import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand;
import org.eclipse.gmf.runtime.emf.type.core.commands.CreateRelationshipCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.service.types.command.ObjectFlowReorientCommand;
import org.eclipse.papyrus.uml.service.types.utils.RequestParameterUtils;
import org.eclipse.papyrus.uml.tools.utils.ActivityEdgeUtil;
import org.eclipse.papyrus.uml.tools.utils.ObjectFlowUtil;
import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ActivityPartition;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.ObjectFlow;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* Edit helper class for binary {@link ObjectFlow}
@@ -48,12 +55,32 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
*/
@Override
protected ICommand getReorientRelationshipCommand(ReorientRelationshipRequest req) {
- return new ObjectFlowReorientCommand(req);
+ ICommand resultCommand = new ObjectFlowReorientCommand(req);
+
+ // Get the object flow
+ final ObjectFlow objectFlow = (ObjectFlow) req.getRelationship();
+
+ // Get if this is a source re-orient or the target
+ final boolean isReorientSource = req.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE;
+
+ // Get the source and target from objectFlow and request for needed one
+ final Object source = isReorientSource ? req.getNewRelationshipEnd() : objectFlow.getSource();
+ final Object target = isReorientSource ? objectFlow.getTarget() : req.getNewRelationshipEnd();
+
+ if ((null == source || source instanceof ActivityNode) && (null == target || target instanceof ActivityNode)) {
+ // Get the command to update the InPartition feature
+ final ICommand updatePartitionsCommand = getInPartitionUpdateCommand(objectFlow, (ActivityNode) source, (ActivityNode) target);
+ if (null != updatePartitionsCommand) {
+ resultCommand = CompositeCommand.compose(resultCommand, updatePartitionsCommand);
+ }
+ }
+
+ return resultCommand;
}
/**
* Test if the relationship creation is allowed.
- *
+ *
* @param source
* the relationship source can be null
* @param target
@@ -109,6 +136,7 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
protected ICommand getConfigureCommand(final ConfigureRequest req) {
ICommand configureCommand = new ConfigureElementCommand(req) {
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
ObjectFlow element = (ObjectFlow) req.getElementToConfigure();
ActivityNode source = getSourceObject(req);
@@ -119,6 +147,18 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
if (target != null) {
element.setTarget(target);
}
+
+ // Manage InPartitions
+ if (null != source && null != target) {
+
+ // Get the source InPartitions
+ final List<ActivityPartition> partitions = new ArrayList<>(source.getInPartitions());
+ // Keep the InPartitions contained in the source and target to add it into the control flow
+ partitions.retainAll(target.getInPartitions());
+
+ element.getInPartitions().addAll(partitions);
+ }
+
return CommandResult.newOKCommandResult(element);
}
};
@@ -127,7 +167,7 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
/**
* This method provides the object to be use as source.
- *
+ *
* @return the source value
*/
protected ActivityNode getSourceObject(ConfigureRequest req) {
@@ -137,7 +177,7 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
/**
* This method provides the object to be used as target.
- *
+ *
* @return the target value
*/
protected ActivityNode getTargetObject(ConfigureRequest req) {
@@ -162,4 +202,36 @@ public class ObjectFlowEditHelper extends ElementEditHelper {
}
return ObjectFlowUtil.canExistObjectFlow(container, null, (ActivityNode) source, (ActivityNode) target);
}
+
+ /**
+ * This allows to get the command to update the InPartition feature if needed.
+ *
+ * @param objectFlow
+ * The object flow to update.
+ * @param source
+ * The source activity node.
+ * @param target
+ * The target activity node.
+ * @return The command to update the InPartition feature (can be <code>null</code>).
+ */
+ protected ICommand getInPartitionUpdateCommand(final ObjectFlow objectFlow, final ActivityNode source, final ActivityNode target) {
+ List<ActivityPartition> partitions = new ArrayList<>();
+ if (null != source && null != target) {
+ // Get the source InPartitions
+ partitions = new ArrayList<>(source.getInPartitions());
+ // Keep the in partitions contained in the source and target to add it into the object flow
+ partitions.retainAll(target.getInPartitions());
+
+ if (!partitions.isEmpty()) {
+ return new SetValueCommand(new SetRequest(objectFlow, UMLPackage.eINSTANCE.getActivityEdge_InPartition(), partitions));
+ }
+ }
+
+ // If the partitions found are empty and the object flow InPartitions are not, clear this
+ if (partitions.isEmpty() && !objectFlow.getInPartitions().isEmpty()) {
+ return new SetValueCommand(new SetRequest(objectFlow, UMLPackage.eINSTANCE.getActivityEdge_InPartition(), partitions));
+ }
+
+ return null;
+ }
}

Back to the top