diff options
author | Pierre-Charles David | 2017-05-03 08:14:55 +0000 |
---|---|---|
committer | Pierre-Charles David | 2017-05-10 07:43:27 +0000 |
commit | 714d146df15b6b6e3b1696d0cbc0bf5959e0ba7f (patch) | |
tree | 94c677c4108f98a1cf5812adc6bc1271762bca86 | |
parent | 8ab04eb2f312b998006c1ab0fca06be6691ea4e9 (diff) | |
download | org.eclipse.sirius-714d146df15b6b6e3b1696d0cbc0bf5959e0ba7f.tar.gz org.eclipse.sirius-714d146df15b6b6e3b1696d0cbc0bf5959e0ba7f.tar.xz org.eclipse.sirius-714d146df15b6b6e3b1696d0cbc0bf5959e0ba7f.zip |
[495036] Allow tasks to remember the originating tool
This will be used for better error reporting when a tool's effect is
rolled back in case of an error.
Bug: 495036
Change-Id: If6ca787234885e02ca3f6cf5a22f9c260d6e8be8
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
2 files changed, 22 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ModelOperationToTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ModelOperationToTask.java index 26694a2f9f..6d8d9a4bef 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ModelOperationToTask.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ModelOperationToTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2017 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 @@ -13,9 +13,11 @@ package org.eclipse.sirius.business.internal.helper.task; import java.util.Iterator; import java.util.Optional; +import org.eclipse.emf.ecore.EObject; import org.eclipse.sirius.business.api.dialect.DialectManager; import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask; import org.eclipse.sirius.business.api.helper.task.ICommandTask; +import org.eclipse.sirius.business.api.query.EObjectQuery; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.internal.helper.task.operations.AbstractOperationTask; import org.eclipse.sirius.business.internal.helper.task.operations.ChangeContextTask; @@ -34,6 +36,7 @@ import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor; import org.eclipse.sirius.ext.base.Option; import org.eclipse.sirius.tools.api.command.CommandContext; import org.eclipse.sirius.tools.api.command.ui.UICallBack; +import org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription; import org.eclipse.sirius.viewpoint.description.tool.ChangeContext; import org.eclipse.sirius.viewpoint.description.tool.ContainerModelOperation; import org.eclipse.sirius.viewpoint.description.tool.CreateInstance; @@ -49,6 +52,7 @@ import org.eclipse.sirius.viewpoint.description.tool.RemoveElement; import org.eclipse.sirius.viewpoint.description.tool.SetObject; import org.eclipse.sirius.viewpoint.description.tool.SetValue; import org.eclipse.sirius.viewpoint.description.tool.Switch; +import org.eclipse.sirius.viewpoint.description.tool.ToolPackage; import org.eclipse.sirius.viewpoint.description.tool.Unset; import com.google.common.base.Function; @@ -160,7 +164,10 @@ public class ModelOperationToTask implements Function<ModelOperation, ICommandTa task = (AbstractOperationTask) optionalTask.get(); } } - + Option<EObject> opt = new EObjectQuery(op).getFirstAncestorOfType(ToolPackage.Literals.ABSTRACT_TOOL_DESCRIPTION); + if (opt.some()) { + task.setSourceTool((AbstractToolDescription) opt.get()); + } return task; } diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/operations/AbstractOperationTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/operations/AbstractOperationTask.java index 00dab2849e..e6f7396456 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/operations/AbstractOperationTask.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/operations/AbstractOperationTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 THALES GLOBAL SERVICES. + * Copyright (c) 2007, 2017 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 @@ -17,6 +17,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter; import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor; import org.eclipse.sirius.tools.api.command.CommandContext; +import org.eclipse.sirius.viewpoint.description.tool.AbstractToolDescription; /** * An operation specific implementation of ICommandTask. @@ -33,6 +34,9 @@ public abstract class AbstractOperationTask extends AbstractCommandTask { /** The interpreter. */ protected IInterpreter interpreter; + + /** The tool from which this operation is defined. */ + protected AbstractToolDescription sourceTool; /** * Default Constructor. @@ -49,6 +53,14 @@ public abstract class AbstractOperationTask extends AbstractCommandTask { this.extPackage = extPackage; this.interpreter = interpreter; } + + public AbstractToolDescription getSourceTool() { + return sourceTool; + } + + public void setSourceTool(AbstractToolDescription tool) { + this.sourceTool = tool; + } /** * Get the current context. |