Sirius Evolution Specification: Allow specifier to choose the selected elements after tool execution

Preamble

Summary: Allow specifier to choose the selected elements after tool execution.

Version Status Date Authors Changes
v0.1 DRAFT 2015-04-15 lredor Initial version.
v0.2 DRAFT 2015-04-21 lredor Consider team review.
v0.3 PROPOSAL 2015-04-22 lredor Consider team review.

Relevant tickets:

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.

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.

The goal of this feature is to allow the specifier to choose the selected elements after a tool execution.

Detailed Specification

To allow the specifier to choose the graphical elements to select after a tool execution, some additional data are needed for tools description.
There are 2 cases:

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).
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.

VSM

On the VSM side, two new fields are necessary on AbstractToolDescription:

Completion

List of variables that should be proposed in the completion:

Technically, the entry point to changes this is in org.eclipse.sirius.tools.api.interpreter.context.SiriusInterpreterContextFactory.createInterpreterContext(EObject, EStructuralFeature) and depending classes, for example in org.eclipse.sirius.diagram.business.internal.dialect.description.DiagramInterpretedExpressionQuery.getAvailableVariables().

Runtime

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 ResourceSetListenerImpl). Indeed, the tool is not accessible in the post commit listener so these data must be stored in the current modified representation.
A new class UIState will be added in the meta-model to store this computed expression (and also the current inverseSelectionOrder). A new reference, uiState to this UIState will be added in DRepresentation. This reference is a containment reference and is transient. The class UIState allows to store several transient data in DRepresentation. It will be currently used only for this feature but we can imagine to use it in the future instead of specific singleton (ViewLocationHint, ViewSizeHint) or for copy/paste layout capability for example.
This new class has 2 fields:

The uiState will be cleaned just before the next use of it. This leads to a temporary memory leak:

This temporary memory leak is accepted as it will be free when the representation is unloaded.

Currently, the selection is made by SelectCreatedDRepresentationElementsListener for the diagram and not done for table and tree (see bugzilla 428545 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 SelectCreatedDRepresentationElementsListener.

Backward Compatibility and Migration Paths

This is a new behavior, so without modification of the VSM, there is no impact. The metamodel is changed but just with new elements.

Metamodel Changes

All the new metamodel elements are in blue.

No validation rule is needed:

No migration is needed for the new elements.

API Changes

The main API changes is for meta-model.
There is probably new API in org.eclipse.sirius.tools.api.command.AbstractCommandFactory to provide default access to the new fields of the tool (evaluation of the expression...).

User Interface Changes

In the Properties view of a VSM, the tool have now the new properties defined above.

Documentation Changes

Update specifier documentation and release note about this new feature.

Tests and Non-regression strategy

Implementation choices and tradeoffs

The solution to add a new ModelOperation 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 ModelOperation.