View/Open Diagram in a SWT shell [message #1784831] |
Wed, 04 April 2018 14:58 |
Parsa Pourali 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 |
|
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 #1784939 is a reply to message #1784922] |
Fri, 06 April 2018 07:06 |
|
Parsa Pourali wrote on Thu, 05 April 2018 22:20I 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 |
Parsa Pourali 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 ?
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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02825 seconds