Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow can I get the instance of the Diagram?
https://www.eclipse.org/forums/index.php/mv/msg/69452/217597/#msg_217597
Originally posted by: cayla_sha.gmx.net
Hello!
I`m inside of an Wizard and I want to calculate the width and the height
of the whole diagram.
I already found out, that I can calculate the size with this method:
org.eclipse.gmf.runtime.diagram.ui.render.clipboard.DiagramG enerator.calculateImageRectangle(java.util.List
editparts)
But for this method I need the list of all editparts. And for that List
I need somehow the instance of the diagram.
The only thing what I have in the wizard is the workbench. I tried
something like
workbench.getActiveWorkbenchWindow().getActivePage().getActi veEditor()
but that led nowhere.
I also tried ShapesDiagram.eINSTANCE, but this don`t work.
EditorPackage.eINSTANCE.getShapesDiagram() doesn`t return the right
thing...
Any ideas?
Thanks in advance!
Best wishes
Julia]]>2009-02-06T16:43:51-00:00Re: How can I get the instance of the Diagram?
https://www.eclipse.org/forums/index.php/mv/msg/69452/217794/#msg_217794
You can use current selection to interact with the Eclipse from your wizard.
BTW, “workbench.getActiveWorkbenchWindow().getActivePage().getA ctiveEditor()”
should be working too if you have appropriate diagram editor open in this
moment.
-----------------
Alex Shatalin]]>Alexander Shatalin2009-02-09T07:19:09-00:00Re: How can I get the instance of the Diagram?
https://www.eclipse.org/forums/index.php/mv/msg/69452/217879/#msg_217879
Originally posted by: cayla_sha.gmx.net
Hello Alex,
the current selection is the file in the Navigator-View, because the
Wizard is an Export Wizard. The user right-clicks on the gmf-file in the
Navigator-View, chooses "Export" and then my Export-Wizard. So there`s
nothing selected in my Diagram.
So the current selection is useless here.
workbench.getActiveWorkbenchWindow().getActivePage().getActi veEditor()
doesn`t work, because when I call:
WorkbenchWindow workbenchWindow =
(WorkbenchWindow)workbench.getActiveWorkbenchWindow();
then workbenchWindow is null.
This is a bit strange, because when I look at workbench during debugging
it has an active WorkbenchWindow and the activeWorkbenchWindow has an
activePage and the activePage has an activeEditor. But I can dig as deep
as I want, I can`t find any EditPart or my ShapesDiagram. So it doesn`t
matter why getActiveWorkbenchWindow() returns null, because nowhere
inside of workbench is something that would help me.
So the workbench is useless, too.
Isn`t there a class where I can get the Instance and then call something
like getShapesDiagram()?
If not, I could also calculate the width and height myself, I think.
Because during the export I parse the whole gmf-file and so I get all
the EditParts, so I think, I just can remember the highest x- and y-Value.
But first I`ll ask my client what he exactly means, when he wants the
width and the height of the diagram :)
Thanks so far!
Best wishes
Julia]]>2009-02-09T11:24:35-00:00Re: How can I get the instance of the Diagram?
https://www.eclipse.org/forums/index.php/mv/msg/69452/217902/#msg_217902
> Navigator-View, chooses "Export" and then my Export-Wizard. So there`s
> nothing selected in my Diagram.
I suggest you to load diagram file and get Diagram instance from there. Then
you can calculate diagram size using Notation model elements (diagram children).
-----------------
Alex Shatalin]]>Alexander Shatalin2009-02-09T12:26:58-00:00