Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
index 13dc9132577..22bf5891684 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ClassOperationCreateCommand.java
@@ -68,9 +68,12 @@ public class ClassOperationCreateCommand extends EditElementCommand {
*/
@Override
public boolean canExecute() {
+
EObject target = getElementToEdit();
ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getOperation());
return data.isPermitted();
+
+
}
/**
@@ -78,7 +81,9 @@ public class ClassOperationCreateCommand extends EditElementCommand {
*/
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
Operation newElement = UMLFactory.eINSTANCE.createOperation();
+
EObject target = getElementToEdit();
ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
if (data.isPermitted()) {
@@ -87,14 +92,21 @@ public class ClassOperationCreateCommand extends EditElementCommand {
return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
}
} else {
+
Class qualifiedTarget = (Class) target;
- qualifiedTarget.getOwnedOperations().add(newElement);
+ qualifiedTarget.getOwnedOperations()
+ .add(newElement);
+
}
} else {
return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
}
+
+
ElementInitializers.getInstance().init_Operation_3020(newElement);
+
doConfigure(newElement, monitor, info);
+
((CreateElementRequest) getRequest()).setNewElement(newElement);
return CommandResult.newOKCommandResult(newElement);
}

Back to the top