diff options
author | atischenko | 2014-06-11 09:28:56 +0000 |
---|---|---|
committer | Camille Letavernier | 2014-07-07 08:18:32 +0000 |
commit | 5787b36995a4487407f1febf7ba5079e1b14ddb9 (patch) | |
tree | 0a46b79f622d164cd489f62da3dbe3554f0bb86d | |
parent | 9fad372f2000ccd1ec4f4869779e1b36ecc681f6 (diff) | |
download | org.eclipse.papyrus-5787b36995a4487407f1febf7ba5079e1b14ddb9.tar.gz org.eclipse.papyrus-5787b36995a4487407f1febf7ba5079e1b14ddb9.tar.xz org.eclipse.papyrus-5787b36995a4487407f1febf7ba5079e1b14ddb9.zip |
[425578] - Cannot create elements on Activity partitions
Signed-off-by: atischenko <ticher777@gmail.com>
Change-Id: I6b47969c6aba3711bfc40507885eeda7f326c454
11 files changed, 269 insertions, 50 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy.java index 83d0f2f16f6..1377a6f23ea 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy.java @@ -24,6 +24,10 @@ import org.eclipse.papyrus.uml.diagram.activity.activitygroup.IContainerNodeDesc */
public class ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy extends GroupCreationEditPolicy {
+ /**
+ * Elements graphically shown inside partitions are semantically owned by the activity.
+ * So default reparenting check (of different semantic containers) should be skipped for partition contents.
+ */
public ActivityPartitionActivityPartitionContentCompartmentCreationEditPolicy(IContainerNodeDescriptor groupDescriptor) {
super(groupDescriptor);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionCompartmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionCompartmentCreationEditPolicy.java new file mode 100644 index 00000000000..84da5e1dce6 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/editpolicy/ActivityPartitionCompartmentCreationEditPolicy.java @@ -0,0 +1,22 @@ +package org.eclipse.papyrus.uml.diagram.activity.activitygroup.editpolicy; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.PapyrusCreationEditPolicy; +import org.eclipse.uml2.uml.Activity; +import org.eclipse.uml2.uml.ActivityPartition; + + +public class ActivityPartitionCompartmentCreationEditPolicy extends PapyrusCreationEditPolicy{ + + /** + * Elements graphically shown inside partitions are semantically owned by the activity. + * So default reparenting check (of different semantic containers) should be skipped for partition contents. + */ + @Override + protected boolean shouldReparent(EObject element, EObject newContext) { + if (newContext instanceof ActivityPartition && element.eContainer() instanceof Activity) + return element != null && + element != newContext; + return super.shouldReparent(element, newContext); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityParameterNodeInCompartmentCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityParameterNodeInCompartmentCreationEditPolicy.java index a87fb9222f3..8cc08c9009e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityParameterNodeInCompartmentCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityParameterNodeInCompartmentCreationEditPolicy.java @@ -34,6 +34,7 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes;
+import org.eclipse.uml2.uml.Activity;
/**
* This class provide customization of the CreationEditPolicy to support the
@@ -97,4 +98,13 @@ public class ActivityParameterNodeInCompartmentCreationEditPolicy extends Defaul }
return cc.isEmpty() ? null : new ICommandProxy(cc.reduce());
}
+
+
+ @Override
+ protected boolean shouldReparent(EObject element, EObject newContext) {
+ if (element.eContainer() instanceof Activity && newContext instanceof Activity)
+ return element != null &&
+ element != newContext;
+ return super.shouldReparent(element, newContext);
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen index 5e1db257eae..35cbf6297d5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen @@ -3608,6 +3608,7 @@ <behaviour xsi:type="gmfgen:CustomBehaviour" key="EditPolicyRoles.DRAG_DROP_ROLE" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityGroupCustomDragAndDropEditPolicy"/> <behaviour xsi:type="gmfgen:CustomBehaviour" key=""RemoveOrphanView"" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.RemoveOrphanViewPolicy"/> <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.CustomActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy"/> + <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.activitygroup.editpolicy.ActivityPartitionCompartmentCreationEditPolicy"/> </compartments> <compartments visualID="7007" editPartClassName="InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentEditPart" itemSemanticEditPolicyClassName="InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentItemSemanticEditPolicy" notationViewFactoryClassName="InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentViewFactory" canonicalEditPolicyClassName="InterruptibleActivityRegionInterruptibleActivityRegionContentCompartmentCanonicalEditPolicy" childNodes="/0/@diagram/@childNodes.3 /0/@diagram/@childNodes.4 /0/@diagram/@childNodes.5 /0/@diagram/@childNodes.6 /0/@diagram/@childNodes.11 /0/@diagram/@childNodes.16 /0/@diagram/@childNodes.32 /0/@diagram/@childNodes.33 /0/@diagram/@childNodes.34 /0/@diagram/@childNodes.35 /0/@diagram/@childNodes.36 /0/@diagram/@childNodes.37 /0/@diagram/@childNodes.44 /0/@diagram/@childNodes.52 /0/@diagram/@childNodes.54 /0/@diagram/@childNodes.56 /0/@diagram/@childNodes.57 /0/@diagram/@childNodes.60 /0/@diagram/@childNodes.64 /0/@diagram/@childNodes.65 /0/@diagram/@childNodes.70 /0/@diagram/@childNodes.24 /0/@diagram/@childNodes.25 /0/@diagram/@childNodes.26 /0/@diagram/@childNodes.27 /0/@diagram/@childNodes.28 /0/@diagram/@childNodes.29 /0/@diagram/@childNodes.30 /0/@diagram/@childNodes.31 /0/@diagram/@childNodes.73 /0/@diagram/@childNodes.76 /0/@diagram/@childNodes.79 /0/@diagram/@childNodes.83 /0/@diagram/@childNodes.85 /0/@diagram/@childNodes.87 /0/@diagram/@childNodes.90 /0/@diagram/@childNodes.92 /0/@diagram/@childNodes.69 /0/@diagram/@childNodes.93" title="InterruptibleActivityRegionContentCompartment" canCollapse="false" needsTitle="false" node="/0/@diagram/@childNodes.68" listLayout="false"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/parts/ActivityPartitionActivityPartitionContentCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/parts/ActivityPartitionActivityPartitionContentCompartmentEditPart.java index 6edc2ff6440..2dbfb1ee1fc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/parts/ActivityPartitionActivityPartitionContentCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/parts/ActivityPartitionActivityPartitionContentCompartmentEditPart.java @@ -27,6 +27,7 @@ import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.diagram.activity.activitygroup.editpolicy.ActivityPartitionCompartmentCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityGroupCustomDragAndDropEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.CustomActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy;
@@ -90,6 +91,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentEditPart extend installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new ActivityGroupCustomDragAndDropEditPolicy());
installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new ActivityPartitionCompartmentCreationEditPolicy());
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy.java index 77d78a79609..e99600cec79 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivityPartitionActivityPartitionContentCompartmentItemSemanticEditPolicy.java @@ -35,7 +35,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } /** - * @generated + * @generated NOT */ protected Command getCreateCommand(CreateElementRequest req) { IElementType requestElementType = req.getElementType(); @@ -56,7 +56,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.InitialNode_3004 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -65,7 +65,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ActivityFinalNode_3005 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -74,7 +74,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.FlowFinalNode_3006 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -83,7 +83,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.OpaqueAction_3007 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -92,7 +92,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.CallBehaviorAction_3008 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -101,7 +101,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.CallOperationAction_3010 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -110,7 +110,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.DecisionNode_3038 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -119,7 +119,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.MergeNode_3039 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -128,7 +128,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ForkNode_3040 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -137,7 +137,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.JoinNode_3041 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -146,7 +146,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.DataStoreNode_3078 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -155,7 +155,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.SendObjectAction_3042 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -164,7 +164,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.SendSignalAction_3052 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -173,7 +173,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.AcceptEventAction_3063 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -182,7 +182,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ValueSpecificationAction_3076 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -191,7 +191,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ConditionalNode_3069 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_StructuredNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -200,7 +200,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ExpansionRegion_3070 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_StructuredNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -209,7 +209,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.LoopNode_3071 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_StructuredNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -218,7 +218,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.SequenceNode_3073 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_StructuredNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -227,7 +227,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.StructuredActivityNode_3065 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_StructuredNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -236,7 +236,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ReadSelfAction_3081 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -245,7 +245,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ActivityPartition_3067 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedGroup(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Subpartition(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -326,7 +326,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.CreateObjectAction_3086 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -335,7 +335,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ReadStructuralFeatureAction_3088 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -344,7 +344,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.AddStructuralFeatureValueAction_3091 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -353,7 +353,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.DestroyObjectAction_3095 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -362,7 +362,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.ReadVariableAction_3097 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -371,7 +371,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.AddVariableValueAction_3099 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -380,7 +380,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.BroadcastSignalAction_3102 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); @@ -389,7 +389,7 @@ public class ActivityPartitionActivityPartitionContentCompartmentItemSemanticEdi } if(UMLElementTypes.CentralBufferNode_3104 == baseElementType) { // adjust the containment feature - EReference containmentFeature = UMLPackage.eINSTANCE.getActivity_OwnedNode(); + EReference containmentFeature = UMLPackage.eINSTANCE.getActivityPartition_Node(); req.setContainmentFeature(containmentFeature); if(isExtendedType) { return getExtendedTypeCreationCommand(req, (IExtendedHintedElementType)requestElementType); diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml index 28a573980b9..2ffb172c335 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/plugin.xml @@ -114,7 +114,8 @@ <metamodelType id="org.eclipse.papyrus.uml.ActivityPartition" name="UML::ActivityPartition" icon="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/ActivityPartition.gif" eclass="ActivityPartition" - kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" > + kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType" + edithelper="org.eclipse.papyrus.uml.service.types.helper.ActivityPartitionEditHelper"> <param name="semanticHint" value="UML::ActivityPartition"/> </metamodelType> diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/PartitionMoveCommand.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/PartitionMoveCommand.java new file mode 100644 index 00000000000..fee89cfc39e --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/command/PartitionMoveCommand.java @@ -0,0 +1,73 @@ +package org.eclipse.papyrus.uml.service.types.command; + +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.emf.core.util.PackageUtil; +import org.eclipse.gmf.runtime.emf.type.core.commands.MoveElementsCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest; + +/** + * All ActivityPartition semantic children containment Activity. + * Standard command cannot move ActivityPartition children to Activity or + * Activity children to ActivityPartition because command move children + * only from one parent to another. + * + */ +public class PartitionMoveCommand extends MoveElementsCommand { + + /** + * Default constructor + * @param request + */ + public PartitionMoveCommand(MoveRequest request) { + super(request); + } + + /** + * For ability to move children from one container to this same container + * we need to remove this check from base canExecute command + * <code> + * if (container.equals(element.eContainer()) + * && feature == element.eContainmentFeature()) { + * // Don't allow the reparenting + * return false; + * } + * </code> + */ + @Override + public boolean canExecute() { + EObject container = getTargetContainer(); + + if(container == null || getElementsToMove() == null || getElementsToMove().isEmpty()) { + return false; + } + + for(Iterator i = getElementsToMove().keySet().iterator(); i.hasNext();) { + EObject element = (EObject)i.next(); + EReference feature = getTargetFeature(element); + + if(feature == null || !container.eClass().getEAllReferences().contains(feature)) { + // If the target feature doesn't exist in the target container, + // don't allow the move. + return false; + } + + // IF the element is the parent of the target container... + if(EcoreUtil.isAncestor(element, getTargetContainer())) { + // Don't allow the reparenting + return false; + } + + // IF the container can not contain the element... + if(!PackageUtil.canContain(getTargetContainer().eClass(), feature, element.eClass(), false)) { + // Don't allow the reparenting + return false; + } + } + + return true; + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java index 9c62c9ebf47..6531c85180d 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityHelper.java @@ -13,27 +13,17 @@ *****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper;
-import java.util.Collections;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand;
-import org.eclipse.gmf.runtime.emf.type.core.internal.EMFTypePlugin;
-import org.eclipse.gmf.runtime.emf.type.core.internal.l10n.EMFTypeCoreMessages;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+import org.eclipse.papyrus.uml.service.types.command.PartitionMoveCommand;
public class ActivityHelper extends ElementEditHelper {
+
+ @Override
+ protected ICommand getMoveCommand(MoveRequest req) {
+ return new PartitionMoveCommand(req);
+ }
// {
// getDefaultContainmentFeatures().put(UMLPackage.eINSTANCE.getCentralBufferNode(), UMLPackage.eINSTANCE.getActivity_OwnedNode());
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 2bc0bcdc5dc..62fe898886f 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 @@ -19,12 +19,25 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.edit.command.DeleteCommand;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+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.DestroyElementCommand;
+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.ConfigureRequest;
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;
+import org.eclipse.papyrus.uml.service.types.command.PartitionMoveCommand;
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* this is an helper that redirect destroy request to get destroy command from uml plugin
@@ -33,6 +46,12 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; public class ActivityNodeHelper extends ElementEditHelper {
+ /**
+ * Parameter name for {@link ConfigureRequest}
+ * Used to pass the actual partition instance to set {@link ActivityNode#getInPartition()}
+ */
+ public static final String IN_PARTITION = "IN_PARTITION";
+
@Override
protected ICommand getBasicDestroyElementCommand(DestroyElementRequest req) {
ICommand result = new DestroyActivityNode(req);
@@ -40,6 +59,74 @@ public class ActivityNodeHelper extends ElementEditHelper { 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 PartitionMoveCommand(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();
+ }
+
/**
* inner class for the destruction of element
*
@@ -106,5 +193,4 @@ public class ActivityNodeHelper extends ElementEditHelper { return Status.OK_STATUS;
}
}
-
}
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 new file mode 100644 index 00000000000..0d10c304bc5 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/ActivityPartitionEditHelper.java @@ -0,0 +1,30 @@ +package org.eclipse.papyrus.uml.service.types.helper; + +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.uml2.uml.ActivityPartition; + +public class ActivityPartitionEditHelper extends ActivityNodeHelper { + + @Override + protected ICommand getCreateCommand(CreateElementRequest req) { + return super.getCreateCommand(getCreatePartitionChildRequest(req)); + } + + /** + * All elements which created in ActivityPartition is contained in Activity. + * ActivityPartition hasn't containment features. + * That's why we need replace ActivityPartion on Activity. + * + * @return new CreateElementRequest with Activity as a container for new Element. + */ + protected CreateElementRequest getCreatePartitionChildRequest(CreateElementRequest req) { + if (req == null) { + return null; + } + CreateElementRequest result = new CreateElementRequest(req.getEditingDomain(), findActivity(req.getContainer()), req.getElementType()); + result.setParameter(IN_PARTITION, (ActivityPartition)req.getContainer()); + result.setContainmentFeature(findActivityFeature(req.getElementType().getEClass())); + return result; + } +}
\ No newline at end of file |