Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-01-12 09:17:08 +0000
committerPierre-Charles David2016-01-12 09:22:06 +0000
commit914b0cc0476b7c58b6508ec799abae898eee7ecf (patch)
tree4d1a3a479a9e0a263ca13d24aea19f1ab878237f
parent69e931e4fd0bbe7ec4e668f69492cc1beb9a7ce9 (diff)
downloadorg.eclipse.sirius-914b0cc0476b7c58b6508ec799abae898eee7ecf.tar.gz
org.eclipse.sirius-914b0cc0476b7c58b6508ec799abae898eee7ecf.tar.xz
org.eclipse.sirius-914b0cc0476b7c58b6508ec799abae898eee7ecf.zip
[482528] Support execution of ModelOperations outside of a DRepresentation
Add a variant of TaskHelper.buildTaskFromModelOperation() which does not require a DRepresentation as part of the context information. This allows the execution of ModelOperations in more contexts. In particular, it allows SiriusToolsService to invoke callbacks specified as ModelOperations for changes happening inside property views, even if only given a semantic element (and not a DSemanticDecorator). Bug: 482528 Change-Id: I95d23b6760534c5b219337df2102ca99f388ceed Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java29
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.html45
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile3
-rw-r--r--plugins/org.eclipse.sirius/plugin.properties1
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskHelper.java15
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ExecuteToolOperationTask.java23
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java3
7 files changed, 74 insertions, 45 deletions
diff --git a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
index 1078f1063d..6e8807bab7 100644
--- a/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
+++ b/incubation/org.eclipse.sirius.ui.properties/src/org/eclipse/sirius/ui/properties/internal/SiriusToolServices.java
@@ -15,9 +15,6 @@ import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.sirius.business.api.helper.task.ICommandTask;
import org.eclipse.sirius.business.api.helper.task.TaskHelper;
import org.eclipse.sirius.business.api.query.EObjectQuery;
@@ -25,35 +22,13 @@ import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
import org.eclipse.sirius.tools.api.command.SiriusCommand;
import org.eclipse.sirius.tools.api.command.ui.NoUICallback;
-import org.eclipse.sirius.viewpoint.DRepresentation;
-import org.eclipse.sirius.viewpoint.DSemanticDecorator;
import org.eclipse.sirius.viewpoint.description.Viewpoint;
import org.eclipse.sirius.viewpoint.description.tool.InitialOperation;
import org.eclipse.sirius.viewpoint.description.tool.ModelOperation;
public class SiriusToolServices {
public void run(EObject eObject, Object selection, String initialCommandUri) {
- DRepresentation representation = null;
-
- EObject semanticElement = null;
- if (selection instanceof GraphicalEditPart) {
- semanticElement = ((GraphicalEditPart) selection).resolveSemanticElement();
- } else if (selection instanceof ConnectionEditPart) {
- semanticElement = ((Edge) ((ConnectionEditPart) selection).getModel()).getElement();
- } else if (selection instanceof DSemanticDecorator) {
- semanticElement = ((DSemanticDecorator) selection).getTarget();
- }
- if (semanticElement instanceof DSemanticDecorator) {
- DSemanticDecorator dSemanticDecorator = (DSemanticDecorator) semanticElement;
- EObjectQuery eObjectQuery = new EObjectQuery(dSemanticDecorator);
- org.eclipse.sirius.ext.base.Option<DRepresentation> oRepresentation = eObjectQuery.getRepresentation();
- if (oRepresentation.some()) {
- representation = oRepresentation.get();
- }
- }
-
Session session = new EObjectQuery(eObject).getSession();
-
ModelAccessor modelAccessor = session.getModelAccessor();
TaskHelper taskHelper = new TaskHelper(modelAccessor, new NoUICallback());
@@ -70,8 +45,8 @@ public class SiriusToolServices {
}
}
- if (representation != null && modelOperation != null) {
- ICommandTask task = taskHelper.buildTaskFromModelOperation(representation, eObject, modelOperation);
+ if (modelOperation != null) {
+ ICommandTask task = taskHelper.buildTaskFromModelOperation(eObject, modelOperation);
SiriusCommand command = new SiriusCommand(session.getTransactionalEditingDomain(), "SiriusToolServices#run");
command.getTasks().add(task);
session.getTransactionalEditingDomain().getCommandStack().execute(command);
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
index c523b2e9dd..e6941878fa 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.html
@@ -111,6 +111,17 @@
<code>org.eclipse.sirius.diagram.bundledImageShape</code> extension-point. See the developer documentation for more details.
</li>
</ul>
+ <h4 id="Changesinorg.eclipse.sirius.ui">Changes in
+ <code>org.eclipse.sirius.ui</code>
+ </h4>
+ <ul>
+ <li><span class="label label-success">Added</span> A new variant of
+ <code>org.eclipse.sirius.business.api.helper.task.TaskHelper.buildTaskFromModelOperation(EObject, ModelOperation)</code> has been added, which does not require to specify a
+ <code>DRepresentation</code> in the context. It allows the creation of a task which executes a behavior specified by
+ <code>ModelOperations</code> outside of the context of a specific representation, provided the
+ <code>ModelOperations</code> work in that context.
+ </li>
+ </ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
@@ -139,7 +150,7 @@
<code>org.eclipse.sirius.ext.emf.ui.properties.ExtensiblePropertySource.collector</code> field is now in protected visibility to be modifiable and accessible by subclass.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.ui">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.ui2">Changes in
<code>org.eclipse.sirius.ui</code>
</h4>
<ul>
@@ -265,7 +276,7 @@
</ul>
<h3 id="DeveloperVisibleChanges3">Developer-Visible Changes</h3>
<h4 id="Partialsupportforinternationalization">Partial support for internationalization</h4>
- <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#8220;language packs&#8221; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
+ <p>Sirius 3.1 introduces partial support for internationalization: all literal strings from the runtime part of Sirius are now externalized and can be localized by third parties by providing the appropriate &#171;language packs&#187; as OSGi fragments. Note that this does not concern the VSM editor&#8217;s UI, the VSMs themselves, or the parts of the UI inherited from Eclipse/EMF/GEF/GMF and other libraries and frameworks used by Sirius.</p>
<p>Some API changes were required to enable this. While technically breaking changes if interpreting strictly the OSGi versioning rules, the major version number of the impacted bundles was not incremented as the changes only concern classes that should not impact the vast majority of users. Most breaking changes concern the plug-in/activator classes from each bundle. They are:</p>
<ul>
<li><span class="label label-success">Added</span>
@@ -534,7 +545,7 @@
<code>org.eclipse.sirius.tools.api.command.IUndoableCommand</code> interface removed because it is useless since undo/redo is managed by EMF Transaction.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.ui2">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.ui3">Changes in
<code>org.eclipse.sirius.ui</code>
</h4>
<ul>
@@ -734,7 +745,7 @@
</li>
<li><span class="label label-success">Added</span> On diagrams, it is now possible to set a custom background image on list containers.</li>
<li><span class="label label-info">Modified</span> In the
- <em>Viewpoint Selection</em> dialog and wizard page, the &#8220;plug-in&#8221; decorator for viewpoints loaded from plug-ins is removed, and a &#8220;Folder&#8221; decorator for viewpoints loaded from the current workspace has been added. This makes the icons more visible in the most common where viewpoints come from installed plug-ins.
+ <em>Viewpoint Selection</em> dialog and wizard page, the &#171;plug-in&#187; decorator for viewpoints loaded from plug-ins is removed, and a &#171;Folder&#187; decorator for viewpoints loaded from the current workspace has been added. This makes the icons more visible in the most common where viewpoints come from installed plug-ins.
</li>
</ul>
<h3 id="SpecifierVisibleChanges4">Specifier-Visible Changes</h3>
@@ -757,12 +768,12 @@
<li><span class="label label-success">Added</span> Compressed SVG images (
<code>*.svgz</code>) are now supported everywhere normal SVG images were supported.
</li>
- <li><span class="label label-success">Added</span> When developing a modeler in &#8220;live mode&#8221;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
+ <li><span class="label label-success">Added</span> When developing a modeler in &#171;live mode&#187;, with the VSM in the same workspace as the sample session(s) which use it, VSM expressions which use
<code>service:</code> or
<code>aql:</code> can now invoke Java services which are defined in the workspace (with no need to launch a separate runtime).
</li>
<li><span class="label label-success">Added</span> A quick outline is now accessible in the VSM editor by using the shortcut <kbd>Ctrl+o</kbd>. It supports filtering on both an element&#8217;s name and properties for quick, keyboard-only navigation in complex VSMs.</li>
- <li><span class="label label-success">Added</span> The &#8220;hide label by default capability&#8221; has been added to the container styles.</li>
+ <li><span class="label label-success">Added</span> The &#171;hide label by default capability&#187; has been added to the container styles.</li>
<li><span class="label label-success">Added</span> In addition to
<em>Bold</em> and
<em>Italic</em>,
@@ -795,7 +806,7 @@
</li>
<li><span class="label label-success">Improved</span> The precision of the VSM validation, especially regarding the typing of computed expressions, has been greatly improved. Other validation rules like static image paths have also been added or improved.</li>
<li><span class="label label-info">Modified</span> In the VSM editor, the context menu entries (categories and items) have been reorganized to put most common actions/items first.</li>
- <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#8220;Lozenge&#8221; is now called &#8220;Diamond&#8221;.</li>
+ <li><span class="label label-info">Modified</span> In diagrams, the style previously named &#171;Lozenge&#187; is now called &#171;Diamond&#187;.</li>
<li><span class="label label-info">Modified</span> In the
<em>Open</em> menu on a representation, the menu is computed from the navigation tool&#8217;s label instead of its name/id.
</li>
@@ -1149,7 +1160,7 @@
<code>org.eclipse.sirius.viewpoint.DContainer</code> has been removed.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.ui3">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.ui4">Changes in
<code>org.eclipse.sirius.ui</code>
</h4>
<ul>
@@ -1678,13 +1689,13 @@
<img border="0" src="images/containerResize-changedBehavior.gif"/>
</p>
<ul>
- <li>The &#8220;snap to shapes&#8221; is now enabled by default (see
+ <li>The &#171;snap to shapes&#187; is now enabled by default (see
<em>Sirius &gt; Sirius Diagram &gt; Rulers and Grid</em> preference page). This is true only for new diagrams. The existing diagrams are not impacted.
</li>
- <li>The &#8220;Navigate&#8221; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
+ <li>The &#171;Navigate&#187; top-level contextual menu entry with mixed actions for creating new representations and opening existing ones has been changed by two top-level menus:
<ul>
- <li>One named &#8220;New&#8221;, which lists only the available actions to create new representations on the selected element.</li>
- <li>One named &#8220;Open&#8221;, which lists only the existing representations on the selected element. </li>
+ <li>One named &#171;New&#187;, which lists only the available actions to create new representations on the selected element.</li>
+ <li>One named &#171;Open&#187;, which lists only the existing representations on the selected element. </li>
</ul>
</li>
<li>When a shape is resized (no matter the direction), the edge(s) connection location (toward or from this one) is kept. Before that, edges connections moved according to the ratio of the resizing.</li>
@@ -1709,19 +1720,19 @@
<li>Distribute centers vertically</li>
</ul>
</li>
- <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#8220;Remove Bend-points&#8221; or by using the shortcut &#8220;Ctrl&#8221; + &#8220;Shift&#8221; + &#8220;-&#8221;.</li>
+ <li>The end user can now remove all bend-points between the two edge ends. This action is available on edge context menu &#171;Remove Bend-points&#187; or by using the shortcut &#171;Ctrl&#187; + &#171;Shift&#187; + &#171;-&#187;.</li>
<li>Reconnection of an edge will only now move the minimum necessary bendpoints instead of reseting it to default.</li>
<li>A new action has been added to reset the diagram (or container) origin: the diagram (or container) bounds (the rectangle formed by the highest, the leftmost, the lowest and the rightmost children elements) can have a negative origin or can be shifted toward the bottom-right with a blank zone at the top-left. This action aims to move all diagram (or container) elements so that the it retrieves its origin while keeping elements layout.</li>
</ul>
<h3 id="SpecifierVisibleChanges5">Specifier-Visible Changes</h3>
<ul>
- <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#8220;advance&#8221; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
+ <li>The specifier can now choose to hold the edge ends toward the center of the source, target or both. New fields within the &#171;advance&#187; tab of EdgeStyle description have been added to choose for which source or target mappings an edge should be centered. See
<a href="specifier/diagrams/Diagrams.html#edges_styles">Edges Styles &gt; Edge Centering</a> in the specifier manual for more details.
</li>
<li>When creating a new Viewpoint Specification Project using the supplied wizard:
- <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#8220;design&#8221;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
+ <em>New &gt; Viewpoint Specification Project</em>, the VSM name is now given according to the project name. If the project name is suffixed with &#171;design&#187;, the VSM name is provided by the last word before this suffix. Otherwise, the VSM name is given by the last word of the project name.
</li>
- <li>&#8220;Lozenge&#8221; is replaced by &#8220;Diamond&#8221; in diagram style.</li>
+ <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.sirius4">Changes in
@@ -1799,7 +1810,7 @@
<code>org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter</code>. However considering the way Sirius uses GMF, this adapter is not needed.
</li>
</ul>
- <h4 id="Changesinorg.eclipse.sirius.ui4">Changes in
+ <h4 id="Changesinorg.eclipse.sirius.ui5">Changes in
<code>org.eclipse.sirius.ui</code>
</h4>
<ul>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
index 61c1e2acde..75eae934bc 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release_Notes.textile
@@ -23,6 +23,9 @@ h3. Developer-Visible Changes
* <span class="label label-success">Added</span> It is now possible to provide a full customized tab-bar by implementing the @ITabbarContributor@ through the @org.eclipse.sirius.diagram.ui.tabbarContributor@ extension-point. See the developer documentation for more details.
* <span class="label label-success">Added</span> It is now possible to provide new shapes for basic shape styles through the @org.eclipse.sirius.diagram.bundledImageShape@ extension-point. See the developer documentation for more details.
+h4. Changes in @org.eclipse.sirius.ui@
+
+* <span class="label label-success">Added</span> A new variant of @org.eclipse.sirius.business.api.helper.task.TaskHelper.buildTaskFromModelOperation(EObject, ModelOperation)@ has been added, which does not require to specify a @DRepresentation@ in the context. It allows the creation of a task which executes a behavior specified by @ModelOperations@ outside of the context of a specific representation, provided the @ModelOperations@ work in that context.
h4. Changes in @org.eclipse.sirius.diagram.ui@
diff --git a/plugins/org.eclipse.sirius/plugin.properties b/plugins/org.eclipse.sirius/plugin.properties
index 043f22d127..5be84f84ca 100644
--- a/plugins/org.eclipse.sirius/plugin.properties
+++ b/plugins/org.eclipse.sirius/plugin.properties
@@ -142,6 +142,7 @@ ElementsToSelectTask_label = Get result of Elements To Select interpreted expres
EmptyAppliedOnListConstraint_errorMsg = This customization has no style to customize.
TaskExecutor_errorModifyingModelMsg = Error while modifying model
ExecuteToolOperationTask_label = the main tool operation task
+ExecuteToolOperationTask_sessionNotFound = Unable to obtain the session from the given arguments
ExternalJavaActionDescriptor_actionCreationErrorMsg = Impossible to create the action {0}
ExternalJavaActionTask_label = Execute external java action "{0}"
FeatureContributor_targetObject = Target object
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskHelper.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskHelper.java
index e8d9a4be91..f92ab05095 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskHelper.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/api/helper/task/TaskHelper.java
@@ -67,6 +67,21 @@ public class TaskHelper {
this.modelAccessor = modelAccessor;
this.uiCallback = uiCallback;
}
+
+ /**
+ * Create an {@link ExecuteToolOperationTask} with the specified context and
+ * operation.
+ *
+ * @param target
+ * the context.
+ * @param op
+ * the operation.
+ * @return the created {@link ExecuteToolOperationTask}.
+ * @since 4.0.0
+ */
+ public ICommandTask buildTaskFromModelOperation(final EObject target, final ModelOperation op) {
+ return new ExecuteToolOperationTask(modelAccessor, target, op, uiCallback);
+ }
/**
* Create an {@link ExecuteToolOperationTask} with the specified context and
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ExecuteToolOperationTask.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ExecuteToolOperationTask.java
index 69cdf041a0..5bcad64b37 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ExecuteToolOperationTask.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/helper/task/ExecuteToolOperationTask.java
@@ -30,6 +30,8 @@ import org.eclipse.sirius.viewpoint.SiriusPlugin;
import org.eclipse.sirius.viewpoint.description.tool.ContainerModelOperation;
import org.eclipse.sirius.viewpoint.description.tool.ModelOperation;
+import com.google.common.base.Preconditions;
+
/**
* The main task for operations of a tool.
*
@@ -55,6 +57,24 @@ public class ExecuteToolOperationTask extends AbstractCommandTask {
* the extended package
* @param target
* the target
+ * @param op
+ * the operation
+ *
+ * @param uiCallback
+ * the {@link UICallBack}
+ * @since 4.0.0
+ */
+ public ExecuteToolOperationTask(final ModelAccessor extPackage, final EObject target, final ModelOperation op, final UICallBack uiCallback) {
+ this(extPackage, target, null, op, uiCallback);
+ }
+
+ /**
+ * Default constructor.
+ *
+ * @param extPackage
+ * the extended package
+ * @param target
+ * the target
* @param representation
* current representation
* @param op
@@ -67,9 +87,10 @@ public class ExecuteToolOperationTask extends AbstractCommandTask {
this.extPackage = extPackage;
this.uiCallback = uiCallback;
this.session = new EObjectQuery(target).getSession();
- if (session == null) {
+ if (session == null && representation != null) {
this.session = new EObjectQuery(representation).getSession();
}
+ Preconditions.checkArgument(session != null, Messages.ExecuteToolOperationTask_sessionNotFound);
final CommandContext context = new CommandContext(target, representation);
this.rootOperationTask = createTask(op, context);
// for task creates children tasks at runtime
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java
index 34867c4a20..c3af6c8cb2 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/viewpoint/Messages.java
@@ -247,6 +247,9 @@ public final class Messages {
@TranslatableMessage
public static String ExecuteToolOperationTask_label;
+
+ @TranslatableMessage
+ public static String ExecuteToolOperationTask_sessionNotFound;
@TranslatableMessage
public static String ExternalJavaActionDescriptor_actionCreationErrorMsg;

Back to the top