Skip to main content



      Home
Home » Eclipse Projects » Sirius » Creating a representation file externally(Xtext + Sirius combo)
Creating a representation file externally [message #1791287] Wed, 27 June 2018 12:03 Go to next message
Eclipse UserFriend
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 12:53 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Creating a representation file externally [message #1792818 is a reply to message #1791596] Tue, 24 July 2018 08:15 Go to previous messageGo to next message
Eclipse UserFriend
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 09:57 Go to previous messageGo to next message
Eclipse UserFriend
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 04:51 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Creating a representation file externally [message #1796243 is a reply to message #1792864] Mon, 08 October 2018 14:20 Go to previous messageGo to next message
Eclipse UserFriend
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 04:16 Go to previous message
Eclipse UserFriend
Hello Urban

Great news. Thank you very much for your feadback.

Regards,
Steve
Previous Topic:Set: The AQL query for enumeration
Next Topic:changes to the metamodel
Goto Forum:
  


Current Time: Mon Mar 17 15:11:40 EDT 2025

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

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

Back to the top