Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Creating a representation file externally(Xtext + Sirius combo)
Creating a representation file externally [message #1791287] Wed, 27 June 2018 16:03 Go to next message
Urban Leben is currently offline Urban LebenFriend
Messages: 4
Registered: June 2018
Junior Member
I am developing eclipse plugin. So far I have successfully implemented Sirius + Xtext combination.

What I would like to do is to enable user to view diagram of his opened file (xtext syntax) automatically.

This would be achieved by creating external representation file and opening the diagram view in the active workbench.

Basically I would like to allow user to observe diagram representation of his code.

Is this concept possible?

If yes: I struggle to create external representation programatically. How does one go about this?

All help & guidelines very appreciated.

Thanks!
Re: Creating a representation file externally [message #1791596 is a reply to message #1791287] Mon, 02 July 2018 16:53 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 388
Registered: May 2011
Senior Member
Hello,

I have not created a Session from scratch lately but off the top of my head this is how I would proceed:
- First you will need to create a session programmatically using SessionFactory.INSTANCE.createSession and then open it (using the open method).
- Next you can add your semantic resources to your new session using org.eclipse.sirius.business.api.session.Session.addSemanticResource(URI, IProgressMonitor).
- Now, that you have the needed resources in your session, you will want to activate the Viewpoint you designed on your session. You can wrap your session in UserSession and use the selectViewpoints method or directly execute the command ChangeViewpointSelectionCommand.
- Finally, you can create a representation using the API DialectManager.INSTANCE.createRepresentation.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Creating a representation file externally [message #1792818 is a reply to message #1791596] Tue, 24 July 2018 12:15 Go to previous messageGo to next message
Urban Leben is currently offline Urban LebenFriend
Messages: 4
Registered: June 2018
Junior Member
Hello Steve,

thank you for your reply, it confirmed my prototyping.

I managed to come the step 2 (adding semantic resource) by myself.

Will let you know of the final result.

Regards,
Urban.
Re: Creating a representation file externally [message #1792827 is a reply to message #1791596] Tue, 24 July 2018 13:57 Go to previous messageGo to next message
Urban Leben is currently offline Urban LebenFriend
Messages: 4
Registered: June 2018
Junior Member
Steve Monnier wrote on Mon, 02 July 2018 16:53

- Finally, you can create a representation using the API DialectManager.INSTANCE.createRepresentation.


I got stuck on the last step. I don't know what to pass as 2nd and 3rd argument to create representation method.

DialectManager.INSTANCE.createRepresentation(String name, EObject semantic, RepresentationDescription description, Session session, IProgressMonitor monitor);

Thanks for your help,
Urban.
Re: Creating a representation file externally [message #1792864 is a reply to message #1792827] Wed, 25 July 2018 08:51 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 388
Registered: May 2011
Senior Member
Hello Urban,

The second argument is the semantic root that will be used to create the new representation. For example, when you create a new representation manually, it is the element of the model you right-click on to create the new representation.
The third argument is the representation description specified in your VSM (.odesign), that will be used to create the new representation concerning the semantic root you choose. You can access to the RepresentationDescription element from the Viewpoint reference "getOwnedRepresentations()". You should already have the Viewpoint thanks to step 3, but you can also access the active viewpoints from the session using the reference getSelectedViewpoints(boolean).

For example, you can take a look to the JUnit and SWTBot tests we have, many of them uses this API.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Creating a representation file externally [message #1796243 is a reply to message #1792864] Mon, 08 October 2018 18:20 Go to previous messageGo to next message
Urban Leben is currently offline Urban LebenFriend
Messages: 4
Registered: June 2018
Junior Member
Dear Steve,

I would like to thank you. With your answers, I have managed to successfully implement all the things I asked about.

Br,
Urban
Re: Creating a representation file externally [message #1796251 is a reply to message #1796243] Tue, 09 October 2018 08:16 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 388
Registered: May 2011
Senior Member
Hello Urban

Great news. Thank you very much for your feadback.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Set: The AQL query for enumeration
Next Topic:changes to the metamodel
Goto Forum:
  


Current Time: Sat Nov 17 11:51:45 GMT 2018

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

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

Back to the top