Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2017-03-14 22:41:19 +0000
committerFlorian Noyrit2017-03-14 22:41:19 +0000
commitc2ebdbe669efd6c802c15b17402b6f682d1cc48f (patch)
tree35d99b45ca1d9edd194716184ad525f889e8ef08 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common
parent4eef963fdc207e07471446beb5964670896f3de5 (diff)
downloadorg.eclipse.papyrus-c2ebdbe669efd6c802c15b17402b6f682d1cc48f.tar.gz
org.eclipse.papyrus-c2ebdbe669efd6c802c15b17402b6f682d1cc48f.tar.xz
org.eclipse.papyrus-c2ebdbe669efd6c802c15b17402b6f682d1cc48f.zip
Bug 510451 - Fix failing tests related to Architecture Framework
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/ModelCreationCommandBase.java44
1 files changed, 40 insertions, 4 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/ModelCreationCommandBase.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/ModelCreationCommandBase.java
index 8f391aba395..f1b2237277b 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/ModelCreationCommandBase.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/commands/ModelCreationCommandBase.java
@@ -13,10 +13,19 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.commands;
+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.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.papyrus.infra.architecture.commands.IModelCreationCommand;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
/**
@@ -25,14 +34,41 @@ import org.eclipse.papyrus.uml.tools.model.UmlUtils;
public abstract class ModelCreationCommandBase implements IModelCreationCommand {
/**
- * @param modelSet
+ * @see org.eclipse.papyrus.infra.ui.extension.commands.IModelCreationCommand#createModel(org.eclipse.papyrus.infra.core.utils.DiResourceSet)
+ *
+ * @param diResourceSet
*/
@Override
public void createModel(final ModelSet modelSet) {
+ runAsTransaction(modelSet);
+ }
+
+ /**
+ * Run as transaction.
+ *
+ * @param diResourceSet
+ * the di resource set
+ */
+ protected void runAsTransaction(final ModelSet modelSet) {
+ // Get the uml element to which the newly created diagram will be
+ // attached.
+ // Create the diagram
final Resource modelResource = UmlUtils.getUmlResource(modelSet);
- EObject model = getRootElement(modelResource);
- attachModelToResource(model, modelResource);
- initializeModel(model);
+ TransactionalEditingDomain editingDomain = modelSet.getTransactionalEditingDomain();
+
+ AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, "Initialize model", Collections.EMPTY_LIST) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ EObject model = getRootElement(modelResource);
+ attachModelToResource(model, modelResource);
+
+ initializeModel(model);
+ return CommandResult.newOKCommandResult();
+
+ }
+ };
+ editingDomain.getCommandStack().execute(new GMFtoEMFCommandWrapper(command));
}
/**

Back to the top