Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » In memory model for GMF diagram(Using/generating diagram from an in memory model)
In memory model for GMF diagram [message #759235] Sun, 27 November 2011 23:04 Go to next message
Jeff  is currently offline Jeff
Messages: 7
Registered: November 2011
Junior Member
So, I'm working on a project where we are creating a language using xtext.
One of the things the xtext generator does is generate an ecore model for the language - this is what I'm going to use as the basis for my GMF editor - I've gone through the mind map tutorial, and I'm reasonably confident that that will be ok.

When a program is built in the language we're using, xtext generates an in memory EMF AST model of the classes and so on. What I'm trying to do with GMF is show parts of the EMF model as nodes and relationships, but I'm not sure what the best way of doing this is.

What I'm thinking is that I need to surface an extension point from the language plugin which allows the GMF plugin to listen for the creation of the EMF model. The GMF plugin will then do its stuff and generate the diagram.

As I understand the GMF system currently (and I'm not exactly experienced) there is a domain model file in xml, and a diagram that contains the notation model.
So my question is: Is it possible to replace the domain model file with an in-memory emf model, or should I generate the xml file from my emf model? If so, is there a standard way to do this?

Or is one of my assumptions flawed?
Re: In memory model for GMF diagram [message #759300 is a reply to message #759235] Mon, 28 November 2011 10:08 Go to previous message
Mickael Istria is currently offline Mickael Istria
Messages: 754
Registered: July 2009
Location: Grenoble, France
Senior Member
On 28/11/2011 00:04, Jeff wrote:
> So, I'm working on a project where we are creating a language using xtext.
> One of the things the xtext generator does is generate an ecore model
> for the language - this is what I'm going to use as the basis for my GMF
> editor - I've gone through the mind map tutorial, and I'm reasonably
> confident that that will be ok.

You can also start an Xtext project from an existing Ecore. It will be
probably easier for you to really own and maintain the .ecore.

> When a program is built in the language we're using, xtext generates an
> in memory EMF AST model of the classes and so on. What I'm trying to do
> with GMF is show parts of the EMF model as nodes and relationships, but
> I'm not sure what the best way of doing this is.

The best way to do so is to create a diagram editor with GMF for the
given .ecore, independently of XText. Then you'll write the necessary
code to open your model with GMF too.

> What I'm thinking is that I need to surface an extension point from the
> language plugin which allows the GMF plugin to listen for the creation
> of the EMF model. The GMF plugin will then do its stuff and generate the
> diagram.

That will be quite difficult. GMF Tooling needs more than the .ecore to
perform generation. Listening to Ecore changes won't be enough.
What happens is that with GMF Tooling, you have to maintain the mapping
files the same way you maintain your Xtext grammar. The workflow for
both projects is the same.

> As I understand the GMF system currently (and I'm not exactly
> experienced) there is a domain model file in xml, and a diagram that
> contains the notation model.

The domain file is not necessary XML. With a few tweaks, you can replace
the XMLResource or XMIResource with an Xtext resource; so that you can
directly manipulate your domain model in its XText resource.

> So my question is: Is it possible to replace the domain model file with
> an in-memory emf model, or should I generate the xml file from my emf
> model? If so, is there a standard way to do this?

All models are in-memory; XText, XML or XMI are just serializations that
happen and are only interesting when hitting "Save". At runtime, the way
your model is serialized is not interesting.
I also think that GMF will load the ResourceFactory according to the EMF
Factory Registry, So that if the XText Factory is registered for your
model, GMF will automatically use this one, and XText serialization will
be used.

HTH

--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Previous Topic:how to keep the transitions, permanently?
Next Topic:How to add xxx.xxx_diagram as navigator content in GMF plugin.xml
Goto Forum:
  


Current Time: Wed Sep 17 05:40:29 GMT 2014

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

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