|Re: In memory model for GMF diagram [message #759300 is a reply to message #759235]
||Mon, 28 November 2011 10:08
|| Mickael Istria
Registered: July 2009
Location: Grenoble, France
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
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
Powered by FUDForum
. Page generated in 0.01535 seconds