How to export model data to formats other than XML/XMI [message #428365] |
Wed, 18 March 2009 08:23  |
Eclipse User |
|
|
|
Hi all,
this is going to be a rather general enquiry, so I won't go into the gory
details of the format I am trying to write. I am looking for a way to
export to another file format when model data is saved. I do not need an
import of this format, for this I am relying on the originally produced
ecore internal view of the saved resources.
When generating the model and edit code from the Genmodel, I selected
"Basic" as the resource type. Subsequently, a corresponding subclass of
ResourceImpl is generated into the .util package (along with the Factory
etc etc). The idea now is to override the doSave method to write the model
contents into another format - I can simply traverse the resources in the
resourceSet and translate that to whatever I need in my output.
Now here is the issue: After generating the code and then plugging it all
into the GMF I have succeeded in producing a rather usable editor and the
model is stored and restored consistently. But I cannot get the system to
use the "Basic"ResourceImpl implementation to write my own format when
saving. Where in the world do I have to register the subclassed
ResourceImpl to write my format?
What do I need to do and most importantly, where do I have to do it in
order to conserve the original model data (as generated by the EMF edit
and GMF editor code) and also output my own file alongside of them...?
Thanks much for your help! Best regards,
Jens.
|
|
|
Re: How to export model data to formats other than XML/XMI [message #428370 is a reply to message #428365] |
Wed, 18 March 2009 10:29  |
Eclipse User |
|
|
|
OK, I once again was a victim of not looking at my plugin.xml...
Since I had already generated the plugin prior to changing the "Resource
Type" setting to something other than "none" in the genmodel, the
plugin.xml was filled with the generic reference to the standard
GMFResourceFactory
(org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFacto ry). When
changing to "Basic" (or XMI/XML), the code to override the doSave/doLoad
methods in the ResourceImpl was generated, but the plugin.xml was still
referencing the ResourceFactory as stated above.
Most probably, I will start by going to the "XMI" Resource Type, which
should lead to a generated ResourceFactoryImpl in my .util package with a
more or less exact copy of the platform edition as included before. The
difference no is that I can use the hook and overrid whatever parts I need
and thus can (hopefully) produce a new output stream for my intended
format. Loading will still occur using the original format - in a second
step, I can perhaps serialize/deserialize into just one file if I can get
all information stored in that format...
So for now, I figure this is alright for me - but I still appreciate the
newsgroup as I (and a colleague of mine) can find this kind of info after
reasonable searching...
Cheers, Jens.
(source of the reference
http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03958.html)
|
|
|
Powered by
FUDForum. Page generated in 0.03119 seconds