Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Programmatically generate diagram contents
Programmatically generate diagram contents [message #236215] Wed, 15 July 2009 12:27 Go to next message
Tobias Lingemann is currently offline Tobias LingemannFriend
Messages: 11
Registered: July 2009
Junior Member
Hi,

I'm working on a graphical editor, that will be additional to an existing
tree-view based editor working on the same data (but not simultanously).
To be exactly it's a bit more complex, so let's just say I want to import
information. So the thing is, I have to load existing data and create the
elements into the graphical representation.

My plan is to initially add all elements invisible somewhere into the
canvas and the user makes them visible over the context menu of the
outline (I'm using the model oriented outline).
Show or hide the elements is not the big deal, but I really don't have a
good idea how to add the elements to the canvas.

I can create the domain models via the
EditorFactory.eINSTANCE.createMyNode() but the visual representation is
still missing.
According to
http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg00894.html
I need to create the notational view, but the topic in the linked post is
more how to create additional nodes by graphically creating one node.
All the talking about the different EditPolicies and CreateCommands are
confusing me.

Currently I'm opening the editor and create an empty new file. So what is
the normal way to add programmatically new nodes with their visual
representation to a canvas?

Best regards,
Tobias
Re: Programmatically generate diagram contents [message #236292 is a reply to message #236215] Thu, 16 July 2009 13:47 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 125
Registered: July 2009
Senior Member
I'm not sure if I understand your question correctly.

But if you are trying to generate a diagram based on some external data,
why don't you simply pass it in as XML in the same format that your
diagram creates and load it up?

You would just need to use XSLT to transform your XML (from the external
form) to a suitable form then load it up as a diagram file.

Hope this helps answer your question!
Re: Programmatically generate diagram contents [message #236299 is a reply to message #236215] Thu, 16 July 2009 14:18 Go to previous messageGo to next message
Tobias Lingemann is currently offline Tobias LingemannFriend
Messages: 11
Registered: July 2009
Junior Member
I think the part of the tutorial about custom actions is usefull for this
(http://wiki.eclipse.org/GMF_Tutorial_Part_3#Custom_Actions).
The only thing is that I dont want to use these popups for it. It just
should run whenever I want it, like before saving, after clicking a button
or in my use case during initialization.
But the example is totally based on the selectedElement item, which I dont
know how to get.

So how could I use this?
I think the selectionChanged-method has to be called, but I dont know how
and where as it wants an ISelection and IAction.

Any ideas?

Best regards,
Tobias
Re: Programmatically generate diagram contents [message #236306 is a reply to message #236292] Thu, 16 July 2009 14:29 Go to previous messageGo to next message
Tobias Lingemann is currently offline Tobias LingemannFriend
Messages: 11
Registered: July 2009
Junior Member
Hm, that could really work for me.
But I'm still wondering if there isnt any more elegant way, because it
could be a lot more easier (if the framework would do the work).

Anyway, thanks a lot for your answer. I'm trying that way.

Best regards,
Tobias

Gary wrote:

> I'm not sure if I understand your question correctly.

> But if you are trying to generate a diagram based on some external data,
> why don't you simply pass it in as XML in the same format that your
> diagram creates and load it up?

> You would just need to use XSLT to transform your XML (from the external
> form) to a suitable form then load it up as a diagram file.

> Hope this helps answer your question!
Re: Programmatically generate diagram contents [message #236503 is a reply to message #236299] Mon, 20 July 2009 12:27 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Tobias,

> But the example is totally based on the selectedElement item, which I
> dont
> know how to get.
> So how could I use this?
It probably depends on a place you are calling this code (clicking a button/saving)...
You can either get current selection from Editor/IWorkbenchWindow.getSelectionService()
or just use corresponsing selection available in popup action (by "clicking
a button" you probably mean some action..)

-----------------
Alex Shatalin
Previous Topic:Problem with super and sub-diagram
Next Topic:Cusotmize New Wizard Category
Goto Forum:
  


Current Time: Fri Apr 19 19:50:50 GMT 2024

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

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

Back to the top