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/ModelCreateCommandTN.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java59
1 files changed, 22 insertions, 37 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
index 9dcbfe97968..7a2425853ad 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/commands/ModelCreateCommandTN.java
@@ -1,22 +1,21 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
+/*
+ * Copyright (c) 2014 CEA LIST.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
+ *
+ *
+ */
package org.eclipse.papyrus.uml.diagram.profile.edit.commands;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -34,40 +33,18 @@ import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.UMLPackage;
+
+
/**
* @generated
*/
public class ModelCreateCommandTN extends EditElementCommand {
- /**
- * @generated
- */
private Diagram diagram = null;
/**
* @generated
*/
- private EObject eObject = null;
-
- /**
- * @generated
- */
- public ModelCreateCommandTN(CreateElementRequest req, EObject eObject, Diagram diagram) {
- super(req.getLabel(), null, req);
- this.eObject = eObject;
- this.diagram = diagram;
- }
-
- /**
- * @generated
- */
- public static ModelCreateCommandTN create(CreateElementRequest req, EObject eObject, Diagram diagram) {
- return new ModelCreateCommandTN(req, eObject, diagram);
- }
-
- /**
- * @generated
- */
public ModelCreateCommandTN(CreateElementRequest req, Diagram diagram) {
super(req.getLabel(), null, req);
this.diagram = diagram;
@@ -75,7 +52,6 @@ public class ModelCreateCommandTN extends EditElementCommand {
/**
* FIXME: replace with setElementToEdit()
- *
* @generated
*/
protected EObject getElementToEdit() {
@@ -83,26 +59,28 @@ public class ModelCreateCommandTN extends EditElementCommand {
if(container instanceof View) {
container = ((View)container).getElement();
}
- if(container != null) {
- return container;
- }
- return eObject;
+ return container;
}
/**
* @generated
*/
public boolean canExecute() {
+
EObject target = getElementToEdit();
ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target.eClass(), UMLPackage.eINSTANCE.getModel());
return data.isPermitted();
+
+
}
/**
* @generated
*/
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
Model newElement = UMLFactory.eINSTANCE.createModel();
+
EObject target = getElementToEdit();
ModelAddData data = PolicyChecker.getCurrent().getChildAddData(diagram, target, newElement);
if(data.isPermitted()) {
@@ -110,14 +88,20 @@ public class ModelCreateCommandTN extends EditElementCommand {
if(!data.execute(target, newElement))
return CommandResult.newErrorCommandResult("Failed to follow the policy-specified for the insertion of the new element");
} else {
+
Package qualifiedTarget = (Package)target;
qualifiedTarget.getPackagedElements().add(newElement);
+
}
} else {
return CommandResult.newErrorCommandResult("The active policy restricts the addition of this element");
}
+
+
ElementInitializers.getInstance().init_Model_2005(newElement);
+
doConfigure(newElement, monitor, info);
+
((CreateElementRequest)getRequest()).setNewElement(newElement);
return CommandResult.newOKCommandResult(newElement);
}
@@ -135,4 +119,5 @@ public class ModelCreateCommandTN extends EditElementCommand {
configureCommand.execute(monitor, info);
}
}
+
}

Back to the top