Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How can I get the instance of the Diagram?
How can I get the instance of the Diagram? [message #217597] Fri, 06 February 2009 16:43 Go to next message
Eclipse UserFriend
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
Re: How can I get the instance of the Diagram? [message #217794 is a reply to message #217597] Mon, 09 February 2009 07:19 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cayla,

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
Re: How can I get the instance of the Diagram? [message #217879 is a reply to message #217794] Mon, 09 February 2009 11:24 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How can I get the instance of the Diagram? [message #217902 is a reply to message #217879] Mon, 09 February 2009 12:26 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Cayla,

> 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
Previous Topic:Compartment layout problem
Next Topic:Changing and saving the value of a label?
Goto Forum:
  


Current Time: Thu Mar 04 13:36:45 GMT 2021

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

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

Back to the top