Bug 481481 - Tool OperationAction should provide variable for semantic element.
Summary: Tool OperationAction should provide variable for semantic element.
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 3.1.0   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 525257
  Show dependency tree
 
Reported: 2015-11-05 04:21 EST by Wilbert Alberts CLA
Modified: 2017-09-27 03:49 EDT (History)
3 users (show)

See Also:


Attachments
Minimal example screenshot (26.90 KB, image/png)
2015-11-09 09:24 EST, Wilbert Alberts CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wilbert Alberts CLA 2015-11-05 04:21:26 EST
When you create a OperationAction, a variable ( by default called 'views') is defined that provides the elements on which the OperationAction is to be performed. Actually, the views variable is a set of RepresentationElements (so nodes/edges or anything else on a diagram that has been selected).

Typically, you want the operation to act on the semantic element represented by the  RepresentationElements in view. In general, I do this like:

| Container Views Variable 'views'
| begin
|- For tg // views.target
|- - // do something with tg


So I dereference the views variable by the 'target' property. This property is provided as views typically is a set of DSemanticDecorators. However, when I validate the odesign model, a warning is created stating that 'target' is unknown. A better expression would be: views.oclAsType(DSemanticDecorator).target. This however requires me to add a dependency on the Sirius metamodel.

Why isn't an additional variable created that holds the semantic elements on which the operation is to be invoked? If you have a node creation tool for instance, also two variables exist: one representing the container (as semantic element) and one representing the containerView (the graphical element representing the container). A similar approach for the OperationAction sounds reasonable to me.
Comment 1 Esteban DUGUEPEROUX CLA 2015-11-06 12:04:37 EST
Hi Wilbert,

Could you provide a minimal example to highlight the issue?

Thanks.
Comment 2 Wilbert Alberts CLA 2015-11-09 09:24:25 EST
Created attachment 257827 [details]
Minimal example screenshot

Attached screenshot shows a minimal example. 

Crucial point is the Operation Action RenameClasses. The goal of the operation is to prefix the name of the selected classes with 'Wilbert_'.

The tool defines a variable representing the selected diagram elements. As a result, the expression used in 'for tg' iteration determines the target of the selected elements as shown.

It would have been nice in case the Operation Action would have defined an addition variable called: elements. Then, dereferencing views to find the semantic elements would not be necessary.
Comment 3 Florian Barbin CLA 2016-05-11 04:10:57 EDT
Actually the "container" variable is available (you can see it when performing an auto-completion after var:). 
But we are agree that this variable should also be displayed as available.