Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Fasani2015-08-05 09:43:11 +0000
committerMaxime Porhel2015-08-06 06:54:42 +0000
commit73f6363dd011a81e63d989de3e35f0ec2af489db (patch)
treef5466b7640a1f9052aface2519abb56748ab6a00
parent696119d9414623eecd09c7a884314e03c3f23e9f (diff)
downloadorg.eclipse.sirius-73f6363dd011a81e63d989de3e35f0ec2af489db.tar.gz
org.eclipse.sirius-73f6363dd011a81e63d989de3e35f0ec2af489db.tar.xz
org.eclipse.sirius-73f6363dd011a81e63d989de3e35f0ec2af489db.zip
[464269] Keep old default selection behavior
If no graphical elements has been created after a tool execution, the selection keeps unchanged. Bug: 464269 Change-Id: Ic7b0a241b949140d863373fcd7324bf870e271d5 Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html2
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile2
-rw-r--r--plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.html2
-rw-r--r--plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.textile4
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/SelectionAfterToolExecutionTest.java16
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/SelectDRepresentationElementsListener.java9
6 files changed, 26 insertions, 9 deletions
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
index f84cc6ce42..fd119ce7ff 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.html
@@ -42,7 +42,7 @@
<li>
<code>InterpretedExpression Elements to select</code>: Expression to list the elements to select after the execution of the tool. There are four possibilities for the list of elements returned by this expression. In any case, if the default list of elements is not empty, the list of elements returned is filtered with the default selected elements. In case of creation tool, the default list contains newly created elements so, the returned list can contain at most that elements.
<ul>
- <li>Empty expression: The default behavior is applied.</li>
+ <li>Empty expression: The default behavior is applied: if graphical elements has been created, these elements will be selected(excluding the sub elements), else, the selection is unchanged.</li>
<li>List of
<code>DRepresentationElement</code>: All this graphical elements will be selected after the execution of the tool.
</li>
diff --git a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
index 2c7ca90f66..64dc18b85f 100644
--- a/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/specifier/general/ToolsSpecification.textile
@@ -14,7 +14,7 @@ The _Precondition_ of a tool definition can be used to restrict its applicabilit
By default, only the created elements are selected.
* @InterpretedExpression Elements to select@: Expression to list the elements to select after the execution of the tool. There are four possibilities for the list of elements returned by this expression. In any case, if the default list of elements is not empty, the list of elements returned is filtered with the default selected elements. In case of creation tool, the default list contains newly created elements so, the returned list can contain at most that elements.
-** Empty expression: The default behavior is applied.
+** Empty expression: The default behavior is applied: if graphical elements has been created, these elements will be selected(excluding the sub elements), else, the selection is unchanged.
** List of @DRepresentationElement@: All this graphical elements will be selected after the execution of the tool.
** List of semantic elements: All @EObject@ that are not a @DRepresentationElement@ are considered as semantic elements. All graphical elements corresponding to these semantic elements will be selected after the execution of the tool.
** Empty list: Nothing is selected after the execution of the tool.
diff --git a/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.html b/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.html
index 4a79fa62aa..f6d7590836 100644
--- a/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.html
+++ b/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.html
@@ -1 +1 @@
-<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body><h1 id="SiriusEvolutionSpecificationAllowspecifiertochoosetheselectedelementsaftertoolexecution">Sirius Evolution Specification: Allow specifier to choose the selected elements after tool execution</h1><h2 id="Preamble">Preamble</h2><p><em>Summary</em>: Allow specifier to choose the selected elements after tool execution.</p><table><tr><th>Version </th><th>Status </th><th>Date </th><th>Authors </th><th>Changes </th></tr><tr><td>v0.1 </td><td>DRAFT </td><td>2015-04-15 </td><td>lredor </td><td>Initial version. </td></tr><tr><td>v0.2 </td><td>DRAFT </td><td>2015-04-21 </td><td>lredor </td><td>Consider team review. </td></tr><tr><td>v0.3 </td><td>PROPOSAL </td><td>2015-04-22 </td><td>lredor </td><td>Consider team review. </td></tr><tr><td>v0.4 </td><td>PROPOSAL </td><td>2015-04-27 </td><td>lredor </td><td>Clarify variables evaluations. </td></tr><tr><td>v0.5 </td><td>ACCEPTED </td><td>2015-07-01 </td><td>lfasani </td><td>Precise spec on interpreted expression. </td></tr></table><p><em>Relevant tickets</em>:</p><ul><li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=464269">Bug 464269 &#8211; Allow specifier to choose the selected elements after tool execution</a></li><li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=428545">Bug 428545 &#8211; Created item not selected in tree/table editor</a>.</li></ul><h2 id="Introduction">Introduction</h2><p>Currently, after a tool execution, all new graphical elements are selected (in the creation order). The last created graphical element is the primary selection. The primary selection determines the available actions and the scope of these actions.</p><p>This behavior is not always the expected one. For example, just after a creation, the direct edit tool is available on the primary selection (the last created graphical element). If the direct edit tool must operate on the first created graphical element, the user must select the diagram and then select again the first created graphical element to direct edit.</p><p>The goal of this feature is to allow the specifier to choose the selected elements after a tool execution. </p><h2 id="DetailedSpecification">Detailed Specification</h2><p>To allow the specifier to choose the graphical elements to select after a tool execution, some additional data are needed for tools description.<br/>There are 2 cases:</p><ul><li>the tool creates only semantic elements (graphical elements are computing during the refresh according to the mapping and to the new semantic elements)</li><li>the tool creates the semantic elements <strong>and</strong> the graphical elements</li></ul><p>In the first case, the specifier can only fill an expression with the list of semantic elements to select. Depending on the tool, the same semantic element can correspond to several graphical elements. In this case, all the graphical elements corresponding to the semantic element will be selected (with the same current rule: the last created element is the primary selection).<br/>In the second case, we can easily imagine that the specifier fills an expression with the list of graphical elements to select. Indeed, if the tool also creates the graphical elements, they are accessible latter in the tool by using the instance variable name.</p><p><img border="0" src="images/metaModelChanges.jpg"/></p><h3 id="VSM">VSM </h3><p>On the VSM side, two new fields are necessary on <code>AbstractToolDescription</code>:</p><ul><li><code>InterpretedExpression elementsToSelect</code>: Expression to list the elements to select after the execution of the tool. There are 4 possibilities for the list of elements returned by this expression. In any case, if the default list of elements is not empty, the list of elements returned is filtered with the default one. In case of creation tool, the default list contains new created elements so the returned list can contain at most that elements.<ul><li>Empty expression: The default behavior is applied: all the new created graphical elements will be selected after the execution of the tool.</li><li>List of <code>DRepresentationElement</code>: All this graphical elements will be selected after the execution of the tool.</li><li>List of semantic elements: All <code>EObject</code> that are not a <code>DRepresentationElement</code> are considered as semantic elements. All graphical elements corresponding to these semantic elements will be selected after the execution of the tool.</li><li>Empty list: Nothing is selected after the execution of the tool.</li><li>List with only the <code>DRepresentation</code>: It will be considered as empty list.</li><li>List with a mix of <code>DRepresentationElement</code> and non <code>DRepresentationElement</code> is forbidden. A such list will be considered as empty list.</li></ul></li><li><code>EBoolean inverseSelectionOrder</code> : By default, false, the elements are selected in the order of the list or the default list. It is possible to inverse this order by setting this property to true. To be more precise, the meaning of this property depends on the value of elementsToSelectExpression:<ul><li>List of <code>DRepresentationElement</code>: The elements are selected in order of the list (first element is selected in first, second element is selected in second, and so on). The last graphical element of the list will be the primary selection. If <code>inverseSelectionOrder</code> is true, the order is reverted.</li><li>List of semantic elements: The elements are selected in order of the list (the graphical element corresponding to the first semantic element is selected in first, the graphical element corresponding to second semantic element is selected in second, and so on). And if several graphical elements correspond to the same semantic element, they are selected on their default order(Created elements for diagram else empty list). The last element is the primary selection. If <code>inverseSelectionOrder</code> is true, the order is reverted (the order of the list AND the order of several graphical elements corresponding to the same semantic element).</li><li>Empty list or list with only the <code>DRepresentation</code>: The <code>inverseSelectionOrder</code> is ignored in this context.</li></ul></li></ul><h4 id="Completion">Completion</h4><p>List of variables that should be proposed in the completion:</p><ul><li>All sub variables defined directly under the tool. Examples:<ul><li><code>container</code> and <code>containerView</code> for a <code>ContainerCreationDescription</code>, </li><li><code>element</code> and <code>elementView</code> for a <code>ToolDescription</code></li><li><code>root</code>, <code>element</code> and <code>container</code> for a <code>CreateLineTool</code></li></ul></li><li>All variables defined through <code>CreateInstance</code> operations</li><li>All variables defined through <code>CreateView</code> operations</li><li>All variables defined through <code>CreateEdgeView</code> operations</li></ul><p>Technically, the entry point to changes this is in <code>org.eclipse.sirius.tools.api.interpreter.context.SiriusInterpreterContextFactory.createInterpreterContext(EObject, EStructuralFeature)</code> and depending classes, for example in <code>org.eclipse.sirius.diagram.business.internal.dialect.description.DiagramInterpretedExpressionQuery.getAvailableVariables()</code>.</p><h3 id="Runtime">Runtime</h3><p>All above changes, on the VSM side, allow the specifier to configure the expected list of elements to select. Then, new fields are needed in representations file to store this result, used later in a post commit listener (a <code>ResourceSetListenerImpl</code>). Indeed, the tool is not accessible in the post commit listener so these data must be stored in the current modified representation.<br/>A new class <code>UIState</code> will be added in the meta-model to store this computed expression (and also the current <code>inverseSelectionOrder</code>). A new reference, <code>uiState</code> to this <code>UIState</code> will be added in <code>DRepresentation</code>. This reference is a containment reference and is transient. The class <code>UIState</code> allows to store several transient data in <code>DRepresentation</code>. It will be currently used only for this feature but we can imagine to use it in the future instead of specific singleton (<code>ViewLocationHint</code>, <code>ViewSizeHint</code>) or for copy/paste layout capability for example.<br/>This new class has 2 fields:</p><ul><li><code>List&lt;EObject&gt; elementsToSelect</code>: The result of the computation of <code>elementsToSelect</code> interpreted expression of the tool. The expression <code>elementsToSelect</code> is evaluated after the execution of the tool (technically as the current refresh task: <code>org.eclipse.sirius.tools.api.command.AbstractCommandFactory.addRefreshTask(DSemanticDecorator, DCommand, AbstractToolDescription)</code> or <code>org.eclipse.sirius.diagram.tools.internal.command.builders.AbstractDiagramCommandBuilder.addRefreshTask(DDiagram, DCommand, AbstractToolDescription)</code>). The context of evaluation should &#171;be the same as completion&#187;: every variable proposed in the completion should be available and valued in the context of the interpreter during evaluation of the expression. If the existing variables correspond to an expression, they are not evaluated a second time, the values of these variables are already available in the interpreter.</li><li><code>EBoolean inverseSelectionOrder</code>: The value of the <code>inverseSelectionOrder</code> of the tool.</li></ul><p>The <code>uiState</code> will be cleaned just before the next use of it. This leads to a temporary memory leak:</p><ul><li>The elements to select are retained by the <code>uiState.elementsToSelect</code> reference.</li><li>But in theory there are already loaded and available in the semantic resource or in the representation resource.</li></ul><p>This temporary memory leak is accepted as it will be free when the representation is unloaded.</p><p>Currently, the selection is made by <code>SelectCreatedDRepresentationElementsListener</code> for the diagram and not done for table and tree (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=428545">bugzilla 428545</a> for table and tree). The chosen behavior for tree (probably TreeUIUpdater) and table (probably TableUIUpdater) must also consider the new fields of DRepresentation as for <code>SelectCreatedDRepresentationElementsListener</code>.</p><h2 id="BackwardCompatibilityandMigrationPaths">Backward Compatibility and Migration Paths</h2><p>This is a new behavior, so without modification of the VSM, there is no impact. The metamodel is changed but just with new elements.</p><h3 id="MetamodelChanges">Metamodel Changes</h3><p>All the new metamodel elements are in blue.<br/><img border="0" src="images/metaModelChanges.jpg"/></p><p>No validation rule is needed:</p><ul><li><code>AbstractToolDescription.elementsToSelect</code> can be blank (considered as empty): in this case the behavior is the current (all the created elements are selected in the order of the creation).</li><li><code>AbstractToolDescription.inverseSelectionOrder</code> has false as default value</li><li><code>UIState.elementsToSelect</code> can be null: in this case, it is considered as empty and nothing is selected.</li><li><code>UIState.inverseSelectionOrder</code> has false as default value</li></ul><p>No migration is needed for the new elements.</p><h3 id="APIChanges">API Changes</h3><p>The main API changes is for meta-model.<br/>There is probably new API in <code>org.eclipse.sirius.tools.api.command.AbstractCommandFactory</code> to provide default access to the new fields of the tool (evaluation of the expression...).</p><h3 id="UserInterfaceChanges">User Interface Changes</h3><p>In the <em>Properties</em> view of a VSM, the tool have now the new properties defined above.<br/><img border="0" src="images/expectedPropertiesView.png"/></p><h3 id="DocumentationChanges">Documentation Changes</h3><p>Update specifier documentation and release note about this new feature.</p><h2 id="TestsandNonregressionstrategy">Tests and Non-regression strategy</h2><ul><li>Select nothing (expression that returns the representation)</li><li>Empty expression --&gt; current behavior</li><li>Empty expression but inverse order</li><li>Select 2 elements of 3</li><li>Select 2 elements of 3 with inverse order</li><li>Use description of use case of <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=464269#c1">bugzilla 428545</a></li><li>Test at least a tool in a diagram, in a table and in a tree. </li></ul><h2 id="Implementationchoicesandtradeoffs">Implementation choices and tradeoffs</h2><p>The solution to add a new <code>ModelOperation</code> has not been chosen because the specifier has not really the choice. This operation is called at the end of the tool and not in the middle of other <code>ModelOperation</code>. </p></body></html> \ No newline at end of file
+<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body><h1 id="SiriusEvolutionSpecificationAllowspecifiertochoosetheselectedelementsaftertoolexecution">Sirius Evolution Specification: Allow specifier to choose the selected elements after tool execution</h1><h2 id="Preamble">Preamble</h2><p><em>Summary</em>: Allow specifier to choose the selected elements after tool execution.</p><table><tr><th>Version </th><th>Status </th><th>Date </th><th>Authors </th><th>Changes </th></tr><tr><td>v0.1 </td><td>DRAFT </td><td>2015-04-15 </td><td>lredor </td><td>Initial version. </td></tr><tr><td>v0.2 </td><td>DRAFT </td><td>2015-04-21 </td><td>lredor </td><td>Consider team review. </td></tr><tr><td>v0.3 </td><td>PROPOSAL </td><td>2015-04-22 </td><td>lredor </td><td>Consider team review. </td></tr><tr><td>v0.4 </td><td>PROPOSAL </td><td>2015-04-27 </td><td>lredor </td><td>Clarify variables evaluations. </td></tr><tr><td>v0.5 </td><td>ACCEPTED </td><td>2015-07-01 </td><td>lfasani </td><td>Precise spec on interpreted expression. </td></tr></table><p><em>Relevant tickets</em>:</p><ul><li><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=464269">Bug 464269 &#8211; Allow specifier to choose the selected elements after tool execution</a></li></ul><h2 id="Introduction">Introduction</h2><p>Currently, after a tool execution, all new graphical elements are selected (in the creation order). The last created graphical element is the primary selection. The primary selection determines the available actions and the scope of these actions.</p><p>This behavior is not always the expected one. For example, just after a creation, the direct edit tool is available on the primary selection (the last created graphical element). If the direct edit tool must operate on the first created graphical element, the user must select the diagram and then select again the first created graphical element to direct edit.</p><p>The goal of this feature is to allow the specifier to choose the selected elements after a tool execution. </p><h2 id="DetailedSpecification">Detailed Specification</h2><p>To allow the specifier to choose the graphical elements to select after a tool execution, some additional data are needed for tools description.<br/>There are 2 cases:</p><ul><li>the tool creates only semantic elements (graphical elements are computing during the refresh according to the mapping and to the new semantic elements)</li><li>the tool creates the semantic elements <strong>and</strong> the graphical elements</li></ul><p>In the first case, the specifier can only fill an expression with the list of semantic elements to select. Depending on the tool, the same semantic element can correspond to several graphical elements. In this case, all the graphical elements corresponding to the semantic element will be selected (with the same current rule: the last created element is the primary selection).<br/>In the second case, we can easily imagine that the specifier fills an expression with the list of graphical elements to select. Indeed, if the tool also creates the graphical elements, they are accessible latter in the tool by using the instance variable name.</p><p><img border="0" src="images/metaModelChanges.jpg"/></p><h3 id="VSM">VSM </h3><p>On the VSM side, two new fields are necessary on <code>AbstractToolDescription</code>:</p><ul><li><code>InterpretedExpression elementsToSelect</code>: Expression to list the elements to select after the execution of the tool. There are 4 possibilities for the list of elements returned by this expression. In any case, if the default list of elements is not empty, the list of elements returned is filtered with the default one. In case of creation tool, the default list contains new created elements so the returned list can contain at most that elements.<ul><li>Empty expression: The default behavior is applied: if graphical elements has been created, these elements will be selected(excluding the sub elements), else, the selection is unchanged.</li><li>List of <code>DRepresentationElement</code>: All this graphical elements will be selected after the execution of the tool.</li><li>List of semantic elements: All <code>EObject</code> that are not a <code>DRepresentationElement</code> are considered as semantic elements. All graphical elements corresponding to these semantic elements will be selected after the execution of the tool.</li><li>Empty list: Nothing is selected after the execution of the tool.</li><li>List with only the <code>DRepresentation</code>: It will be considered as empty list.</li><li>List with a mix of <code>DRepresentationElement</code> and non <code>DRepresentationElement</code> is forbidden. A such list will be considered as empty list.</li></ul></li><li><code>EBoolean inverseSelectionOrder</code> : By default, false, the elements are selected in the order of the list or the default list. It is possible to inverse this order by setting this property to true. To be more precise, the meaning of this property depends on the value of elementsToSelectExpression:<ul><li>List of <code>DRepresentationElement</code>: The elements are selected in order of the list (first element is selected in first, second element is selected in second, and so on). The last graphical element of the list will be the primary selection. If <code>inverseSelectionOrder</code> is true, the order is reverted.</li><li>List of semantic elements: The elements are selected in order of the list (the graphical element corresponding to the first semantic element is selected in first, the graphical element corresponding to second semantic element is selected in second, and so on). And if several graphical elements correspond to the same semantic element, they are selected on their default order(Created elements for diagram else empty list). The last element is the primary selection. If <code>inverseSelectionOrder</code> is true, the order is reverted (the order of the list AND the order of several graphical elements corresponding to the same semantic element).</li><li>Empty list or list with only the <code>DRepresentation</code>: The <code>inverseSelectionOrder</code> is ignored in this context.</li></ul></li></ul><h4 id="Completion">Completion</h4><p>List of variables that should be proposed in the completion:</p><ul><li>All sub variables defined directly under the tool. Examples:<ul><li><code>container</code> and <code>containerView</code> for a <code>ContainerCreationDescription</code>, </li><li><code>element</code> and <code>elementView</code> for a <code>ToolDescription</code></li><li><code>root</code>, <code>element</code> and <code>container</code> for a <code>CreateLineTool</code></li></ul></li><li>All variables defined through <code>CreateInstance</code> operations</li><li>All variables defined through <code>CreateView</code> operations</li><li>All variables defined through <code>CreateEdgeView</code> operations</li></ul><p>Technically, the entry point to changes this is in <code>org.eclipse.sirius.tools.api.interpreter.context.SiriusInterpreterContextFactory.createInterpreterContext(EObject, EStructuralFeature)</code> and depending classes, for example in <code>org.eclipse.sirius.diagram.business.internal.dialect.description.DiagramInterpretedExpressionQuery.getAvailableVariables()</code>.</p><h3 id="Runtime">Runtime</h3><p>All above changes, on the VSM side, allow the specifier to configure the expected list of elements to select. Then, new fields are needed in representations file to store this result, used later in a post commit listener (a <code>ResourceSetListenerImpl</code>). Indeed, the tool is not accessible in the post commit listener so these data must be stored in the current modified representation.<br/>A new class <code>UIState</code> will be added in the meta-model to store this computed expression (and also the current <code>inverseSelectionOrder</code>). A new reference, <code>uiState</code> to this <code>UIState</code> will be added in <code>DRepresentation</code>. This reference is a containment reference and is transient. The class <code>UIState</code> allows to store several transient data in <code>DRepresentation</code>. It will be currently used only for this feature but we can imagine to use it in the future instead of specific singleton (<code>ViewLocationHint</code>, <code>ViewSizeHint</code>) or for copy/paste layout capability for example.<br/>This new class has 2 fields:</p><ul><li><code>List&lt;EObject&gt; elementsToSelect</code>: The result of the computation of <code>elementsToSelect</code> interpreted expression of the tool. The expression <code>elementsToSelect</code> is evaluated after the execution of the tool (technically as the current refresh task: <code>org.eclipse.sirius.tools.api.command.AbstractCommandFactory.addRefreshTask(DSemanticDecorator, DCommand, AbstractToolDescription)</code> or <code>org.eclipse.sirius.diagram.tools.internal.command.builders.AbstractDiagramCommandBuilder.addRefreshTask(DDiagram, DCommand, AbstractToolDescription)</code>). The context of evaluation should &#171;be the same as completion&#187;: every variable proposed in the completion should be available and valued in the context of the interpreter during evaluation of the expression. If the existing variables correspond to an expression, they are not evaluated a second time, the values of these variables are already available in the interpreter.</li><li><code>EBoolean inverseSelectionOrder</code>: The value of the <code>inverseSelectionOrder</code> of the tool.</li></ul><p>The <code>uiState</code> will be cleaned just before the next use of it. This leads to a temporary memory leak:</p><ul><li>The elements to select are retained by the <code>uiState.elementsToSelect</code> reference.</li><li>But in theory there are already loaded and available in the semantic resource or in the representation resource.</li></ul><p>This temporary memory leak is accepted as it will be free when the representation is unloaded.</p><p>Currently, the selection is made by <code>SelectCreatedDRepresentationElementsListener</code> for the diagram and not done for table and tree (see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=428545">bugzilla 428545</a> for table and tree). The chosen behavior for tree (probably TreeUIUpdater) and table (probably TableUIUpdater) must also consider the new fields of DRepresentation as for <code>SelectCreatedDRepresentationElementsListener</code>.</p><h2 id="BackwardCompatibilityandMigrationPaths">Backward Compatibility and Migration Paths</h2><p>This is a new behavior, so without modification of the VSM, there is no impact. The metamodel is changed but just with new elements.</p><h3 id="MetamodelChanges">Metamodel Changes</h3><p>All the new metamodel elements are in blue.<br/><img border="0" src="images/metaModelChanges.jpg"/></p><p>No validation rule is needed:</p><ul><li><code>AbstractToolDescription.elementsToSelect</code> can be blank (considered as empty): in this case the behavior is the current (all the created elements are selected in the order of the creation).</li><li><code>AbstractToolDescription.inverseSelectionOrder</code> has false as default value</li><li><code>UIState.elementsToSelect</code> can be null: in this case, it is considered as empty and nothing is selected.</li><li><code>UIState.inverseSelectionOrder</code> has false as default value</li></ul><p>No migration is needed for the new elements.</p><h3 id="APIChanges">API Changes</h3><p>The main API changes is for meta-model.<br/>There is probably new API in <code>org.eclipse.sirius.tools.api.command.AbstractCommandFactory</code> to provide default access to the new fields of the tool (evaluation of the expression...).</p><h3 id="UserInterfaceChanges">User Interface Changes</h3><p>In the <em>Properties</em> view of a VSM, the tool have now the new properties defined above.<br/><img border="0" src="images/expectedPropertiesView.png"/></p><h3 id="DocumentationChanges">Documentation Changes</h3><p>Update specifier documentation and release note about this new feature.</p><h2 id="TestsandNonregressionstrategy">Tests and Non-regression strategy</h2><ul><li>Select nothing (expression that returns the representation)</li><li>Empty expression --&gt; current behavior</li><li>Empty expression but inverse order</li><li>Select 2 elements of 3</li><li>Select 2 elements of 3 with inverse order</li><li>Use description of use case of <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=464269#c1">bugzilla 428545</a></li><li>Test at least a tool in a diagram, in a table and in a tree. </li></ul><h2 id="Implementationchoicesandtradeoffs">Implementation choices and tradeoffs</h2><p>The solution to add a new <code>ModelOperation</code> has not been chosen because the specifier has not really the choice. This operation is called at the end of the tool and not in the middle of other <code>ModelOperation</code>. </p></body></html> \ No newline at end of file
diff --git a/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.textile b/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.textile
index 6e1b819488..3573f16596 100644
--- a/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.textile
+++ b/plugins/org.eclipse.sirius.doc/specs/proposal/464269_selectElementsAfterToolExecution/464269.textile
@@ -13,8 +13,6 @@ _Summary_: Allow specifier to choose the selected elements after tool execution.
_Relevant tickets_:
* "Bug 464269 - Allow specifier to choose the selected elements after tool execution":https://bugs.eclipse.org/bugs/show_bug.cgi?id=464269
-* "Bug 428545 - Created item not selected in tree/table editor":https://bugs.eclipse.org/bugs/show_bug.cgi?id=428545.
-
h2. Introduction
Currently, after a tool execution, all new graphical elements are selected (in the creation order). The last created graphical element is the primary selection. The primary selection determines the available actions and the scope of these actions.
@@ -39,7 +37,7 @@ h3. VSM
On the VSM side, two new fields are necessary on @AbstractToolDescription@:
* @InterpretedExpression elementsToSelect@: Expression to list the elements to select after the execution of the tool. There are 4 possibilities for the list of elements returned by this expression. In any case, if the default list of elements is not empty, the list of elements returned is filtered with the default one. In case of creation tool, the default list contains new created elements so the returned list can contain at most that elements.
-** Empty expression: The default behavior is applied: all the new created graphical elements will be selected after the execution of the tool.
+** Empty expression: The default behavior is applied: if graphical elements has been created, these elements will be selected(excluding the sub elements), else, the selection is unchanged.
** List of @DRepresentationElement@: All this graphical elements will be selected after the execution of the tool.
** List of semantic elements: All @EObject@ that are not a @DRepresentationElement@ are considered as semantic elements. All graphical elements corresponding to these semantic elements will be selected after the execution of the tool.
** Empty list: Nothing is selected after the execution of the tool.
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/SelectionAfterToolExecutionTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/SelectionAfterToolExecutionTest.java
index 53418bf4d7..b52f248ebe 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/SelectionAfterToolExecutionTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/tools/SelectionAfterToolExecutionTest.java
@@ -184,8 +184,12 @@ public class SelectionAfterToolExecutionTest extends SiriusDiagramTestCase {
/**
* Test selection when no objects have been notified according to
- * SelectDRepresentationElementsListener filter. In that case the result of
- * interpreted query is taken as is.
+ * SelectDRepresentationElementsListener filter. In that case the selected
+ * elements are
+ * <ul>
+ * <li>the result of interpreted query if provided.</li>
+ * <li>not changed if query expression is empty</li>
+ * </ul>
*/
public void testSelectionAfterDirectEditTool() {
final String tool_Name = "Edit Name";
@@ -200,6 +204,14 @@ public class SelectionAfterToolExecutionTest extends SiriusDiagramTestCase {
// check the selection
checkExpectedElementsInSelection(editorForSelection, Lists.newArrayList("NodeList A1", "NodeList B", "NodeList C"), 3);
+
+ changeSelectionExpression(tool, "", false);
+ TestsUtil.synchronizationWithUIThread();
+ applyDirectEditTool(tool_Name, diagramForSelection, nodeA, "A2");
+ TestsUtil.synchronizationWithUIThread();
+
+ // check the selection is the same than previous
+ checkExpectedElementsInSelection(editorForSelection, Lists.newArrayList("NodeList A2", "NodeList B", "NodeList C"), 3);
}
/**
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/SelectDRepresentationElementsListener.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/SelectDRepresentationElementsListener.java
index c4575d1a69..a648dd8014 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/SelectDRepresentationElementsListener.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/editor/SelectDRepresentationElementsListener.java
@@ -154,7 +154,14 @@ public class SelectDRepresentationElementsListener extends ResourceSetListenerIm
if (elementsToSelectFromUiState != null) {
elementsToSelect = elementsToSelectFromUiState;
} else { // keep default selection and reverse it if necessary
- elementsToSelect = notifiedElements;
+ if (notifiedElements.size() > 0) {
+ // Select created elements
+ elementsToSelect = notifiedElements;
+ } else {
+ // do not change the selection if there is no created
+ // elements
+ elementsToSelect = null;
+ }
}
} else {
// Keep default behavior if change has been done out of a tool

Back to the top