Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2015-04-30 15:24:41 +0000
committerEsteban DUGUEPEROUX2015-07-08 08:16:39 +0000
commit0820dd70e7bd9757787d3df2bdb1965f4c010e13 (patch)
tree1ad8a2d71eae391e495e526163c54c81d62b54d0
parente40557bdf344909723b364679a276d3d1c4ebebc (diff)
downloadorg.eclipse.sirius-0820dd70e7bd9757787d3df2bdb1965f4c010e13.tar.gz
org.eclipse.sirius-0820dd70e7bd9757787d3df2bdb1965f4c010e13.tar.xz
org.eclipse.sirius-0820dd70e7bd9757787d3df2bdb1965f4c010e13.zip
[465955] Remove useless IUndoableCommand
- Remove IUndoableCommand interface. - Remove TaskExecutor.undo()/redo() methods. - Remove SiriusCommand.doUndo()/doRedo() methods. - Remove ICommandTask.undo()/redo() methods. - Updated Release Notes. Bug: 465955 Change-Id: Ic9783b572fac240a88eca86c0ddec5647ab77e8a Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/command/GMFCommandWrapper.java40
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html21
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile6
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/tools/internal/command/TableCommandFactory.java135
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/AbstractCommandTask.java23
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/ICommandTask.java19
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskExecutor.java72
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/DCommand.java4
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/IUndoableCommand.java32
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/SiriusCommand.java29
10 files changed, 97 insertions, 284 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/command/GMFCommandWrapper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/command/GMFCommandWrapper.java
index 254fdd676b..b1ffe23e3e 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/command/GMFCommandWrapper.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/command/GMFCommandWrapper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES.
* 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
@@ -13,12 +13,10 @@ package org.eclipse.sirius.diagram.ui.tools.api.command;
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.emf.common.command.Command;
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.sirius.tools.api.command.IUndoableCommand;
/**
* Wrap an EMF command into a GMF command.
@@ -104,40 +102,4 @@ public class GMFCommandWrapper extends AbstractTransactionalCommand {
return CommandResult.newOKCommandResult();
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doUndo(org.eclipse.core.runtime.IProgressMonitor,
- * org.eclipse.core.runtime.IAdaptable)
- */
- @Override
- protected IStatus doUndo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- final IStatus status = super.doUndo(monitor, info);
- if (this.emfCommand instanceof IAdaptable) {
- final Object adapter = ((IAdaptable) this.emfCommand).getAdapter(IUndoableCommand.class);
- if (adapter != null) {
- ((IUndoableCommand) adapter).doUndo();
- }
- }
- return status;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doRedo(org.eclipse.core.runtime.IProgressMonitor,
- * org.eclipse.core.runtime.IAdaptable)
- */
- @Override
- protected IStatus doRedo(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- final IStatus status = super.doRedo(monitor, info);
- if (this.emfCommand instanceof IAdaptable) {
- final Object adapter = ((IAdaptable) this.emfCommand).getAdapter(IUndoableCommand.class);
- if (adapter != null) {
- ((IUndoableCommand) adapter).doRedo();
- }
- }
- return status;
- }
-
}
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index 8e622a2d17..2c9cc4b88d 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -78,6 +78,21 @@
<code>org.eclipse.sirius.ext.gef.query.EditPartQuery</code> has been added. It allows to retrieve all children of the current part.
</li>
</ul>
+ <h4 id="Changesinorg.eclipse.sirius">Changes in
+ <code>org.eclipse.sirius</code>
+ </h4>
+ <ul>
+ <li>
+ <code>org.eclipse.sirius.business.api.helper.task.ICommandTask.undo()/redo()</code> methods removed because they are useless since undo/redo is managed by EMF Transaction.
+ </li>
+ <li>
+ <code>org.eclipse.sirius.tools.api.command.IUndoableCommand</code> interface removed because it is useless since undo/redo is managed by EMF Transaction.
+ </li>
+ <li>
+ <code>org.eclipse.sirius.tools.api.command.DCommand</code> no more inherits of
+ <code>IUndoableCommand</code> because useless since undo/redo is managed by EMF Transaction.
+ </li>
+ </ul>
<h4 id="Changesinorg.eclipse.sirius.tests.swtbot.support">Changes in
<code>org.eclipse.sirius.tests.swtbot.support</code>
</h4>
@@ -405,7 +420,7 @@
<code>org.eclipse.sirius.common.ui.ext</code>.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius">Changes in
+ <h4 id="Changesinorg.eclipse.sirius2">Changes in
<code>org.eclipse.sirius</code>
</h4>
<ul>
@@ -1116,7 +1131,7 @@
<li>&#171;Lozenge&#187; is replaced by &#171;Diamond&#187; in diagram style.</li>
</ul>
<h3 id="APIChanges">API Changes</h3>
- <h4 id="Changesinorg.eclipse.sirius2">Changes in
+ <h4 id="Changesinorg.eclipse.sirius3">Changes in
<code>org.eclipse.sirius</code>
</h4>
<ul>
@@ -1479,4 +1494,4 @@
</li>
</ul>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index e254b3f64d..c651e7772c 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -17,6 +17,12 @@ h4. Changes in @org.eclipse.sirius.ext.gef@
* <span class="label label-success">Added</span> The new class @org.eclipse.sirius.ext.gef.query.EditPartQuery@ has been added. It allows to retrieve all children of the current part.
+h4. Changes in @org.eclipse.sirius@
+
+* @org.eclipse.sirius.business.api.helper.task.ICommandTask.undo()/redo()@ methods removed because they are useless since undo/redo is managed by EMF Transaction.
+* @org.eclipse.sirius.tools.api.command.IUndoableCommand@ interface removed because it is useless since undo/redo is managed by EMF Transaction.
+* @org.eclipse.sirius.tools.api.command.DCommand@ no more inherits of @IUndoableCommand@ because useless since undo/redo is managed by EMF Transaction.
+
h4. Changes in @org.eclipse.sirius.tests.swtbot.support@
* <span class="label label-success">Added</span> The methods @closePerspective(String)@, @closeSiriusPerspective()@ and @closeModelingPerspective()@ have been added in class @org.eclipse.sirius.tests.swtbot.support.api.perspective.DesignerPerspectives@ to allow the closing of perspectives.
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/tools/internal/command/TableCommandFactory.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/tools/internal/command/TableCommandFactory.java
index cd0b08d6c2..d94630d1cb 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/tools/internal/command/TableCommandFactory.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/tools/internal/command/TableCommandFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES and others.
* 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
@@ -112,6 +112,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* {@link DTargetColumn}).
* @return a command that can delete the specified element.
*/
+ @Override
public Command buildDeleteTableElement(final DTableElement element) {
Command cmd = UnexecutableCommand.INSTANCE;
if (element instanceof DLine || element instanceof DTargetColumn) {
@@ -153,6 +154,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @return a command able to create the line and putting it in the
* container, corresponding to the {@link CreateTool}.
*/
+ @Override
public Command buildCreateLineCommandFromTool(final LineContainer lineContainer, final EObject semanticCurrentElement, final CreateTool tool) {
Command result = UnexecutableCommand.INSTANCE;
if (!getPermissionAuthority().canEditInstance(lineContainer)) {
@@ -180,6 +182,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @return a command able to create the line and putting it in the
* container, corresponding to the {@link CreateTool}.
*/
+ @Override
public Command buildCreateColumnCommandFromTool(final DTable containerView, final EObject semanticCurrentElement, final CreateTool tool) {
Command result = UnexecutableCommand.INSTANCE;
if (!getPermissionAuthority().canEditInstance(containerView)) {
@@ -433,6 +436,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @param modelAccessor
* the modelAccessor to set
*/
+ @Override
public void setModelAccessor(final ModelAccessor modelAccessor) {
this.modelAccessor = modelAccessor;
commandTaskHelper = new TaskHelper(modelAccessor, uiCallBack);
@@ -451,6 +455,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* {@link org.eclipse.sirius.table.metamodel.table.description.CreateCellTool
* CreateCellTool}.
*/
+ @Override
public Command buildSetCellValueFromTool(final DCell editedCell, final Object newValue) {
Command result = UnexecutableCommand.INSTANCE;
if (!getPermissionAuthority().canEditInstance(editedCell)) {
@@ -473,6 +478,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* org.eclipse.sirius.table.metamodel.table.DTargetColumn,
* java.lang.Object)
*/
+ @Override
public Command buildCreateCellFromTool(DLine line, DTargetColumn column, Object newValue) {
Command result = UnexecutableCommand.INSTANCE;
if (!getPermissionAuthority().canEditInstance(line)) {
@@ -528,52 +534,32 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @see org.eclipse.sirius.table.tools.api.command.ITableCommandFactory#buildSetValue(org.eclipse.emf.ecore.EObject,
* java.lang.String, java.lang.Object)
*/
+ @Override
public Command buildSetValue(final EObject instance, final String name, final Object value) {
if (getPermissionAuthority().canEditInstance(instance)) {
final SiriusCommand result = new SiriusCommand(domain);
- try {
- result.getTasks().add(new AbstractCommandTask() {
- private final Object oldValue = getModelAccessor().eGet(instance, name);
-
- private final Object newValue = value;
-
- @Override
- public void undo() {
- try {
- if (!getModelAccessor().eGet(instance, name).equals(oldValue)) {
- getModelAccessor().eSet(instance, name, oldValue);
- }
- } catch (final LockedInstanceException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- } catch (final FeatureNotFoundException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- }
- }
+ result.getTasks().add(new AbstractCommandTask() {
- @Override
- public void redo() {
- try {
- if (!getModelAccessor().eGet(instance, name).equals(newValue)) {
- getModelAccessor().eSet(instance, name, newValue);
- }
- } catch (final LockedInstanceException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- } catch (final FeatureNotFoundException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- }
- }
+ private final Object newValue = value;
- public String getLabel() {
- return "Set " + name + " value";
- }
+ @Override
+ public String getLabel() {
+ return "Set " + name + " value";
+ }
- public void execute() {
- redo();
+ @Override
+ public void execute() {
+ try {
+ if (!getModelAccessor().eGet(instance, name).equals(newValue)) {
+ getModelAccessor().eSet(instance, name, newValue);
+ }
+ } catch (final LockedInstanceException e) {
+ SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
+ } catch (final FeatureNotFoundException e) {
+ SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
}
- });
- } catch (final FeatureNotFoundException e1) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e1);
- }
+ }
+ });
return result;
} else {
return new InvalidPermissionCommand(domain, instance);
@@ -587,39 +573,27 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @see org.eclipse.sirius.table.tools.api.command.ITableCommandFactory#buildAddValue(org.eclipse.emf.ecore.EObject,
* java.lang.String, java.lang.Object)
*/
+ @Override
public Command buildAddValue(final EObject instance, final String name, final Object value) {
if (getPermissionAuthority().canEditInstance(instance)) {
final SiriusCommand result = new SiriusCommand(domain);
result.getTasks().add(new AbstractCommandTask() {
- private final Object addedValue = value;
@Override
- public void undo() {
- try {
- getModelAccessor().eRemove(instance, name, addedValue);
- } catch (final LockedInstanceException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- }
+ public String getLabel() {
+ return "Add " + name + " value";
}
@Override
- public void redo() {
+ public void execute() {
try {
- getModelAccessor().eAdd(instance, name, addedValue);
+ getModelAccessor().eAdd(instance, name, value);
} catch (final LockedInstanceException e) {
SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
} catch (final FeatureNotFoundException e) {
SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
}
}
-
- public String getLabel() {
- return "Add " + name + " value";
- }
-
- public void execute() {
- redo();
- }
});
return result;
} else {
@@ -633,45 +607,27 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* @see org.eclipse.sirius.table.tools.api.command.ITableCommandFactory#buildClearValue(org.eclipse.emf.ecore.EObject,
* java.lang.String, java.lang.Object)
*/
+ @Override
public Command buildClearValue(final EObject instance, final String name) {
if (getPermissionAuthority().canEditInstance(instance)) {
final SiriusCommand result = new SiriusCommand(domain);
- try {
- result.getTasks().add(new AbstractCommandTask() {
- private final Object oldValues = getModelAccessor().eGet(instance, name);
-
- @Override
- public void undo() {
- try {
- getModelAccessor().eSet(instance, name, oldValues);
- } catch (final LockedInstanceException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- } catch (final FeatureNotFoundException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- }
- }
-
- @Override
- public void redo() {
- try {
- getModelAccessor().eClear(instance, name);
- } catch (final LockedInstanceException e) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
- }
- }
+ result.getTasks().add(new AbstractCommandTask() {
- public String getLabel() {
- return "Clear " + name;
- }
+ @Override
+ public String getLabel() {
+ return "Clear " + name;
+ }
- public void execute() {
- redo();
+ @Override
+ public void execute() {
+ try {
+ getModelAccessor().eClear(instance, name);
+ } catch (final LockedInstanceException e) {
+ SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e);
}
- });
- } catch (final FeatureNotFoundException e1) {
- SiriusPlugin.getDefault().error(IInterpreterMessages.EVALUATION_ERROR_ON_MODEL_MODIFICATION, e1);
- }
+ }
+ });
return result;
} else {
return new InvalidPermissionCommand(domain, instance);
@@ -685,6 +641,7 @@ public class TableCommandFactory extends AbstractCommandFactory implements ITabl
* org.eclipse.sirius.viewpoint.description.tool.RepresentationCreationDescription,
* java.lang.String)
*/
+ @Override
public AbstractCommand buildDoExecuteDetailsOperation(final DSemanticDecorator target, final RepresentationCreationDescription desc, final String newRepresentationName) {
final SiriusCommand cmd = new SiriusCommand(domain);
final Map<AbstractVariable, Object> variables = new HashMap<AbstractVariable, Object>();
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/AbstractCommandTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/AbstractCommandTask.java
index b4019bcba5..edd9394d94 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/AbstractCommandTask.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/AbstractCommandTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -28,6 +28,7 @@ public abstract class AbstractCommandTask implements ICommandTask {
*
* @see org.eclipse.sirius.business.api.helper.task.ICommandTask#getChildrenTasks()
*/
+ @Override
public List<ICommandTask> getChildrenTasks() {
return childrenTasks;
}
@@ -37,34 +38,18 @@ public abstract class AbstractCommandTask implements ICommandTask {
*
* @see org.eclipse.sirius.business.api.helper.task.ICommandTask#canExecute()
*/
+ @Override
public boolean canExecute() {
return true;
}
/**
- * {@inheritDoc} Do nothing as it should be done by emft.
- *
- * @see org.eclipse.sirius.business.api.helper.task.ICommandTask#undo()
- */
- public void undo() {
- // do nothing
- }
-
- /**
- * {@inheritDoc} Do nothing as it should be done by emft.
- *
- * @see org.eclipse.sirius.business.api.helper.task.ICommandTask#redo()
- */
- public void redo() {
- // do nothing
- }
-
- /**
* {@inheritDoc} Return false. Subclass if you need to execute children
* tasks yourself
*
* @see org.eclipse.sirius.business.api.helper.task.ICommandTask#executeMyselfChildrenTasks()
*/
+ @Override
public boolean executeMyselfChildrenTasks() {
return false;
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/ICommandTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/ICommandTask.java
index 06b1052384..ff3d071f8c 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/ICommandTask.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/ICommandTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -62,21 +62,4 @@ public interface ICommandTask {
*/
boolean canExecute();
- /**
- * Undo the task. By default it will not undo the children tasks.
- *
- * @deprecated is no more useful since undo/redo is managed by EMF
- * Transaction.
- */
- @Deprecated
- void undo();
-
- /**
- * Redo the task. By default it will not redo the children tasks.
- *
- * @deprecated is no more useful since undo/redo is managed by EMF
- * Transaction.
- */
- @Deprecated
- void redo();
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskExecutor.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskExecutor.java
index 15e5f68864..bad831c6a9 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskExecutor.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskExecutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -24,12 +24,6 @@ import org.eclipse.sirius.viewpoint.SiriusPlugin;
*/
public final class TaskExecutor {
- private static final int KIND_EXECUTE = 0;
-
- private static final int KIND_UNDO = 1;
-
- private static final int KIND_REDO = 2;
-
/**
* Avoid instanciation.
*/
@@ -62,64 +56,18 @@ public final class TaskExecutor {
* the tasks list to execute
*/
public static void execute(final List<ICommandTask> tasks) {
- TaskExecutor.operation(tasks, KIND_EXECUTE);
- }
-
- /**
- * Undo a list of tasks.
- *
- * @param tasks
- * the tasks list to undo
- *
- * @deprecated is no more useful since undo/redo is managed by EMF
- * Transaction.
- */
- @Deprecated
- public static void undo(final List<ICommandTask> tasks) {
- TaskExecutor.operation(tasks, KIND_UNDO);
- }
-
- /**
- * Redo a list of tasks.
- *
- * @param tasks
- * the tasks list to redo
- *
- * @deprecated is no more useful since undo/redo is managed by EMF
- * Transaction.
- */
- @Deprecated
- public static void redo(final List<ICommandTask> tasks) {
- TaskExecutor.operation(tasks, KIND_REDO);
- }
-
- private static void operation(final List<ICommandTask> tasks, final int kind) {
final Iterator<ICommandTask> it = tasks.iterator();
while (it.hasNext()) {
final ICommandTask task = it.next();
- switch (kind) {
- case KIND_EXECUTE:
- try {
- task.execute();
- } catch (MetaClassNotFoundException e) {
- SiriusPlugin.getDefault().error("Error while modifying model", e);
- } catch (FeatureNotFoundException e) {
- SiriusPlugin.getDefault().error("Error while modifying model", e);
- }
- if (!task.executeMyselfChildrenTasks()) {
- TaskExecutor.operation(task.getChildrenTasks(), kind);
- }
- break;
- case KIND_UNDO:
- task.undo();
- TaskExecutor.operation(task.getChildrenTasks(), kind);
- break;
- case KIND_REDO:
- task.redo();
- TaskExecutor.operation(task.getChildrenTasks(), kind);
- break;
- default:
- break;
+ try {
+ task.execute();
+ } catch (MetaClassNotFoundException e) {
+ SiriusPlugin.getDefault().error("Error while modifying model", e);
+ } catch (FeatureNotFoundException e) {
+ SiriusPlugin.getDefault().error("Error while modifying model", e);
+ }
+ if (!task.executeMyselfChildrenTasks()) {
+ TaskExecutor.execute(task.getChildrenTasks());
}
}
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/DCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/DCommand.java
index 308dfae751..cf4c4af913 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/DCommand.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/DCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -23,7 +23,7 @@ import org.eclipse.sirius.viewpoint.DRepresentationElement;
*
* @author ymortier
*/
-public interface DCommand extends Command, IUndoableCommand {
+public interface DCommand extends Command {
/**
* Get the task list to execute.
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/IUndoableCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/IUndoableCommand.java
deleted file mode 100644
index 2391acefe4..0000000000
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/IUndoableCommand.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 THALES GLOBAL SERVICES.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.tools.api.command;
-
-/**
- * An Undoable command.
- *
- * @deprecated is no more useful since undo/redo is managed by EMF Transaction.
- * @author mchauvin
- */
-@Deprecated
-public interface IUndoableCommand {
-
- /**
- * called on an undo operation.
- */
- void doUndo();
-
- /**
- * called on a redo operation.
- */
- void doRedo();
-
-}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/SiriusCommand.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/SiriusCommand.java
index 0cd552f1f1..fae84827f2 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/SiriusCommand.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/tools/api/command/SiriusCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES.
* 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
@@ -30,7 +30,7 @@ import org.eclipse.sirius.viewpoint.DRepresentationElement;
*
* @author mchauvin
*/
-public class SiriusCommand extends RecordingCommand implements DCommand, IUndoableCommand {
+public class SiriusCommand extends RecordingCommand implements DCommand {
private static final int CREATED_OBJECTS = 0;
@@ -91,28 +91,11 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
}
/**
- * Undo some task not related to transactional. {@inheritDoc}
- *
- * @see org.eclipse.sirius.tools.api.command.common.ui.tool.api.graphical.command.IUndoableCommand#doUndo()
- */
- public void doUndo() {
- TaskExecutor.undo(this.tasks);
- }
-
- /**
- * Redo some task not related to transactional. {@inheritDoc}
- *
- * @see org.eclipse.sirius.tools.api.command.common.ui.tool.api.graphical.command.IUndoableCommand#doRedo()
- */
- public void doRedo() {
- TaskExecutor.redo(this.tasks);
- }
-
- /**
* Get the tasks list.
*
* @return the tasks list
*/
+ @Override
public List<ICommandTask> getTasks() {
return this.tasks;
}
@@ -172,6 +155,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getCreatedObjects()
*/
+ @Override
public Collection<EObject> getCreatedObjects() {
return getOperationsObject(CREATED_OBJECTS);
}
@@ -181,6 +165,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getCreatedRepresentationElements()
*/
+ @Override
public Collection<DRepresentationElement> getCreatedRepresentationElements() {
final Collection<EObject> objects = getOperationsObject(CREATED_VIEWS);
final Collection<DRepresentationElement> elements = new ArrayList<DRepresentationElement>(objects.size());
@@ -198,6 +183,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getDeletedObjects()
*/
+ @Override
public Collection<EObject> getDeletedObjects() {
return getOperationsObject(DELETED_OBJECTS);
}
@@ -207,6 +193,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getCreatedReferences()
*/
+ @Override
public Collection<EObject> getCreatedReferences() {
return getOperationsObject(CREATED_REFERENCES);
}
@@ -216,6 +203,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getAffectedElements()
*/
+ @Override
public Collection<EObject> getAffectedElements() {
return getOperationsObject(AFFECTED_ELEMENTS);
}
@@ -225,6 +213,7 @@ public class SiriusCommand extends RecordingCommand implements DCommand, IUndoab
*
* @see org.eclipse.sirius.tools.api.command.DCommand#getCreatedElement()
*/
+ @Override
public EObject getCreatedElement() {
return getCreatedRepresentationElements().isEmpty() ? null : (EObject) getCreatedRepresentationElements().iterator().next();
}

Back to the top