Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Set reference to existing class instance with tool
Set reference to existing class instance with tool [message #1843206] Tue, 20 July 2021 08:17 Go to next message
Aron S is currently offline Aron SFriend
Messages: 4
Registered: June 2021
Junior Member
Hey,

simplified i have the meta model below:

index.php/fa/40775/0/

I already have a tool to create instances of Class_B.

Now I want to create a second tool which creates an instance of Class_A, an instance of Child_A, let the user choose a corresponding class_b from allB and sets the reference.

How can i achieve this?

I tried two approaches using the Open Dialog:

1. The Reference widget (https://www.eclipse.org/sirius/doc/specifier/properties/Properties_View_Description.html#reference) seems to do exactly what i want, but i couldn't get it to work. It does not appear in the dialog at all.
2. I used the Radio widget. With aql:container.allB as Candidate Expression the dialog shows all available instances of Class_B, but it doesn't create the Child_A instance (and the reference of course neither).

The corresponding .odesign configuration:

index.php/fa/40776/0/

And i attached the example project.

Best regards,
Aron
  • Attachment: project.zip
    (Size: 169.57KB, Downloaded 30 times)
  • Attachment: metaModel.png
    (Size: 15.44KB, Downloaded 175 times)
  • Attachment: odesign.png
    (Size: 17.40KB, Downloaded 181 times)
Re: Set reference to existing class instance with tool [message #1843582 is a reply to message #1843206] Mon, 09 August 2021 13:02 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 570
Registered: May 2011
Senior Member
Hello,

Concerning your questions about the Open dialog approach:
1. You need to change the semantic candidate expression in Default Page/Group in order to display the list of Class_B element that should be displayed in the dialog. On the sample it is set on var:self that is the newly created Class_A element.
2. You need to move the model operations you placed under Default Group to be placed under the "OK" button element so the variable with the selection will be valued at this point.

Note that you can have the same result without needing a dialog, by using the "classB" mapping as an extra mapping (tab "Advanced") of the node creation tool. This will allow you to click on a Class_B element when you want to create a Class_A element. In your tool, you will need to start with a if to check if the variable container is an instance of Class_B, but from there you can create ClassA, ChildA and link it to Class_B.

Best regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Set reference to existing class instance with tool [message #1843845 is a reply to message #1843582] Fri, 20 August 2021 11:22 Go to previous message
Aron S is currently offline Aron SFriend
Messages: 4
Registered: June 2021
Junior Member
Hey,
thanks for the reply!

Regarding the second approach: But how can i access the instance which corresponds to the selected radio button?
According to the documentary (https://www.eclipse.org/sirius/doc/specifier/properties/Properties_View_Description.html#radio_group) I can use the variable "newValue" underneath the "Begin" element of the radio.
To me it seems like the variable is not accessible under the "OK" button.

Regarding the extra mapping approach you suggested: In my actual editor Class_A will be crated in a container, so the extra mapping have to be used to select the target container.


Best Regards,
Aron
Previous Topic:Sirus Web Creating elements programmatically
Next Topic:Diagram Has Red Xs Everywhere, But No Problems Reported
Goto Forum:
  


Current Time: Wed Sep 28 16:47:43 GMT 2022

Powered by FUDForum. Page generated in 0.02182 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top