Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java
index 62e253f5e94..09597b832db 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/InterruptibleActivityRegionCreateCommand.java
@@ -25,10 +25,15 @@ import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
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.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.viewpoints.policy.ModelAddData;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.InterruptibleActivityRegion;
import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
/**
* @generated
@@ -38,7 +43,7 @@ public class InterruptibleActivityRegionCreateCommand extends EditElementCommand
/**
* @generated
*/
- private EClass eClass = null;
+ private Diagram diagram = null;
/**
* @generated
@@ -48,24 +53,25 @@ public class InterruptibleActivityRegionCreateCommand extends EditElementCommand
/**
* @generated
*/
- public InterruptibleActivityRegionCreateCommand(CreateElementRequest req, EObject eObject) {
+ public InterruptibleActivityRegionCreateCommand(CreateElementRequest req, EObject eObject, Diagram diagram) {
super(req.getLabel(), null, req);
this.eObject = eObject;
- this.eClass = eObject != null ? eObject.eClass() : null;
+ this.diagram = diagram;
}
/**
* @generated
*/
- public static InterruptibleActivityRegionCreateCommand create(CreateElementRequest req, EObject eObject) {
- return new InterruptibleActivityRegionCreateCommand(req, eObject);
+ public static InterruptibleActivityRegionCreateCommand create(CreateElementRequest req, EObject eObject, Diagram diagram) {
+ return new InterruptibleActivityRegionCreateCommand(req, eObject, diagram);
}
/**
* @generated
*/
- public InterruptibleActivityRegionCreateCommand(CreateElementRequest req) {
+ public InterruptibleActivityRegionCreateCommand(CreateElementRequest req, Diagram diagram) {
super(req.getLabel(), null, req);
+ this.diagram = diagram;
}
/**
@@ -88,7 +94,9 @@ public class InterruptibleActivityRegionCreateCommand extends EditElementCommand
* @generated
*/
public boolean canExecute() {
- return true;
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getInterruptibleActivityRegion());
+ return data.isPermitted();
}
/**
@@ -96,8 +104,19 @@ public class InterruptibleActivityRegionCreateCommand extends EditElementCommand
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
InterruptibleActivityRegion newElement = UMLFactory.eINSTANCE.createInterruptibleActivityRegion();
- Activity owner = (Activity)getElementToEdit();
- owner.getOwnedGroups().add(newElement);
+ EObject target = getElementToEdit();
+ ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
+ if(data.isPermitted()) {
+ if(data.isPathDefined()) {
+ if(!data.execute(target, newElement))
+ return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
+ } else {
+ Activity qualifiedTarget = (Activity)target;
+ qualifiedTarget.getOwnedGroups().add(newElement);
+ }
+ } else {
+ return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
+ }
doConfigure(newElement, monitor, info);
((CreateElementRequest)getRequest()).setNewElement(newElement);
return CommandResult.newOKCommandResult(newElement);

Back to the top