Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » View/Open Diagram in a SWT shell
View/Open Diagram in a SWT shell [message #1784831] Wed, 04 April 2018 14:58 Go to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Hello all :)

I am trying to view an specific diagram (I have the representation name) in a SWT Shell window. Basically, I need to view a diagram in my own java form as if I am previewing a diagram.

I there a way to do it ? or if not, can I export an snapshot of the diagram and view it in my form ?

Thanks,
Parsa

[Updated on: Wed, 04 April 2018 15:00]

Report message to a moderator

Re: View/Open Diagram in a SWT shell [message #1784835 is a reply to message #1784831] Wed, 04 April 2018 15:33 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 554
Registered: July 2009
Senior Member
Sirius diagrams can currently only be opened inside a full-fledged editor, so not directly inside an arbitrary SWT shell.

You can programmatically export a diagram as an image file, and use that afterwards. You'll need to use DialectManager.INSTANCE.getAllRepresentations(session) to obtain all the existing representations, find the one you're interested in, and then use DialectUIManager.INSTANCE.export() on it to produce the image file.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: View/Open Diagram in a SWT shell [message #1784921 is a reply to message #1784835] Thu, 05 April 2018 18:49 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Thanks Pierre-Charles, I'll try and will let you know how it goes.

Cheers,
Parsa
Re: View/Open Diagram in a SWT shell [message #1784922 is a reply to message #1784921] Thu, 05 April 2018 20:20 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
I have tried exporting as image, but it takes so long and can't really use it. But, in general is there a way to retrieve the IEditorPart for a representation or a semantic target (object) ? I can do representation.openEditor() which returns IEditorPart, but it is shaky and it also opens the editor before returning the IEditorPart which I prefer not.

Thanks,
Parsa
Re: View/Open Diagram in a SWT shell [message #1784939 is a reply to message #1784922] Fri, 06 April 2018 07:06 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 554
Registered: July 2009
Senior Member
Parsa Pourali wrote on Thu, 05 April 2018 22:20
I have tried exporting as image, but it takes so long and can't really use it.


By default we export using the highest possible resolution to get the best looking result, but this can indeed have performance impacts. In the ExportFormat parameter you pass to the export() method, you can specify a ScalingPolicy argument to disable that, and/or a scaling factor for more fine-grained control. See the ExportFormat(ExportDocumentFormat, ImageFileFormat, ScalingPolicy, Integer) constructor. The release notes for 5.1.1 has some more details about this: https://www.eclipse.org/sirius/doc/Release_Notes.html#sirius5.1.1



Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: View/Open Diagram in a SWT shell [message #1785019 is a reply to message #1784939] Sat, 07 April 2018 12:33 Go to previous messageGo to next message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Thanks Pierre-Charles, changing the resolution worked.

However, when I was playing around with the Sirius API , I found that the editor could *somehow* be shown in a shell (see the image). But, the issue is that it will be very small and will not be resized to the parent shell, which I guess is because of the shell layout. But, as you can see in my code, I used openEditor, which opens and returns IEditorPart. Is there any other way to just get the IEditorPart and not opening it ? Have you seen anything like this before ?
index.php/fa/32551/0/

My code is:
IEditorPart editor =  DialectUIManager.INSTANCE.openEditor(session, current_representation, new NullProgressMonitor());

editor.createPartControl(parent); //parent is my created shell

[Updated on: Sat, 07 April 2018 12:40]

Report message to a moderator

Re: View/Open Diagram in a SWT shell [message #1785100 is a reply to message #1785019] Mon, 09 April 2018 13:36 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 554
Registered: July 2009
Senior Member
This seems more like an SWT/JFace issue due to the layout configuration used in the widget hierarchy. Note however that even if you find a way to make the whole editor visible, embedding an IEditor in general, and a Sirius one in particular, inside a plain SWT shell is not supported. It might give the first impression that some parts work, but outside of the normal context of a full Eclipse Workbench a lot of things will probably break more or less obviously.

In short, at this time Sirius representations can only be opened inside full-blown editors, and these must be integrated inside the Eclipse workbench to work correctly. We certainly agree that more flexibility on these aspects would be nice, but working on this is not in our priorities at the moment.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: View/Open Diagram in a SWT shell [message #1785104 is a reply to message #1785100] Mon, 09 April 2018 14:00 Go to previous message
Parsa Pourali is currently offline Parsa PouraliFriend
Messages: 210
Registered: February 2014
Senior Member
Thanks Pierre-Charels. You are right, I noticed that it is not completely functional. I found that it is better to open the editor but maybe in the bottom view (I mean the section at the bottom of the page and not at the top). since I can manually drag the editor from top to bottom, I think it should also be programatically doable. I guess I will ask about the editors in SWT/JFace forums.

Bests,
Parsa
Previous Topic:Is there parallel operation in Sirius?
Next Topic:Hooking into Sirius font changing
Goto Forum:
  


Current Time: Fri Jan 22 04:31:09 GMT 2021

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

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

Back to the top