Community
Participate
Working Groups
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.
Hi Wilbert, Could you provide a minimal example to highlight the issue? Thanks.
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.
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.