Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Getting an object from a different session with the Select widget
Getting an object from a different session with the Select widget [message #1850223] Tue, 22 February 2022 07:55 Go to next message
Simon Tulia is currently offline Simon TuliaFriend
Messages: 14
Registered: January 2022
Junior Member
Hello all,

In my graphical model, I am able to create two kinds of items: ActualItem and PointerItem. The PointerItem has a reference to the ActualItem in my metamodel. When the user creates a PointerItem in the editor, a dialog box which includes a selection widget pops up. The user can select any ActualItem as a reference by using the selection widget. The user can also select an ActualItem from a model in a different Session (I will call these ActualItems as remote items from now on). I need to call a service function after selecting the ActualItem for a PointerItem. Until now, everything was OK, but the things started to be a bit complicated during the execution of the service function. I want to save the Session information of the remote item in somewhere in Java code. However, I cannot do it by using the reference attribute of the PointerItem, because it is a clone of the actual object. So, the session information is the information about the current session, not the external one. In short, I cannot access any data about the external Session. I tried to access the remote item by adding operations to the select widget in my .odesign file, but it did not work. Is there any solution or trick that can help me to figure out this problem.

Thanks in advance.
Re: Getting an object from a different session with the Select widget [message #1850243 is a reply to message #1850223] Tue, 22 February 2022 14:36 Go to previous messageGo to next message
Glenn Plouhinec is currently offline Glenn PlouhinecFriend
Messages: 22
Registered: April 2020
Junior Member
Hi Simon,

You can get data from any session using the DialectManager with something like that:
URI uri = org.eclipse.emf.common.util.URI.createPlatformResourceURI("/MyProject/representations.aird", true);
Session session = org.eclipse.sirius.business.api.session.SessionManager.INSTANCE.getSession(uri, new NullProgressMonitor());
List<DDiagram> diagrams = DialectManager.INSTANCE.getAllRepresentations(session).stream().filter(DDiagram.class::isInstance).map(DDiagram.class::cast).collect(Collectors.toList());
for (final DDiagram dDiagram : diagrams) {
    dDiagram.getDiagramElements();
    ...
}

Note that I didn't try this piece of code, I was inspired by org.eclipse.sirius.tests.unit.diagram.session.MultiAirdResourcesSessionTest, if it can help you.
I didn't try to reproduce your exact problem but I hope this helps.

Regards,
Glenn


Glenn Plouhinec - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Getting an object from a different session with the Select widget [message #1850262 is a reply to message #1850243] Wed, 23 February 2022 09:09 Go to previous message
Simon Tulia is currently offline Simon TuliaFriend
Messages: 14
Registered: January 2022
Junior Member
Thank you very much Glenn. Actually, thanks to the code that you sent I can access all elements in an external session. However, my problem is that the reference object in the PointerItem is not the same with the ActualItem. Instead, it is a clone of the ActualItem. Therefore, I cannot find the item with the "==" operator in the for loop. I can find it by comparing every attribute of those two ActualItem objects, but it does not sound reasonable. By the way, if the ActualItem is in the same Session, then "==" operator works because the items are really the same (not clone).
Previous Topic:Having trouble in opening editor in sirus
Next Topic:Loading and accessing resources
Goto Forum:
  


Current Time: Tue Apr 16 17:33:39 GMT 2024

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

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

Back to the top