Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to create own loader of model for GMF-based editor
How to create own loader of model for GMF-based editor [message #531180] Tue, 04 May 2010 06:23 Go to next message
Alexander Maltsev is currently offline Alexander MaltsevFriend
Messages: 1
Registered: May 2010
Junior Member
Hello everybody,

I'm not very experienced in GMF/EMF that's why I want to ask about good solution for my task.
I've generated a GMF diagram editor from EMF model. It loads model from XMI file and saves it to XMI file. My task is to load it from database and save it to database. I guess firstly, I need to create my own loader which will obtain information from database and collect model.
There is a StatemachinesDocumentProvider with setDocumentContent() method. I've tried to create my own diagram instance and set it as document content. Is it right way?
Anyway it does not work now. After many hacks it stopped to cause error because of missing preferences but EditPartService.createEditPart() causes NullPointerException because TransactionUtil.getEditingDomain(model) can't get resource for the model. It seems I need to link the diagram with my own resource implementation but how to do that?

Thanks,
Alexander
Re: How to create own loader of model for GMF-based editor [message #535622 is a reply to message #531180] Mon, 24 May 2010 23:10 Go to previous message
SebastianFriend
Messages: 8
Registered: May 2010
Junior Member
Hi Alexander,

when I understand you correctly you have already an implementation of an org.eclipse.emf.ecore.resource.Resource, which is able to read and store data from/to a database.
Then try the following:
In GMF/EMF these resources are managed by the EditingDomain. To load a resource one can call, e.g. in an DiagramEditor, getEditingDomain().getResourceSet().getResource(uri, true). The resource to load is identified by an URI. Normally they point to files, but you can define your own URI format and register a ResourceFactory for it which can create you implementation of Resource, when it detects its URI. This is done by extending org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl and overwritting the createResource method. Make a contribution to the org.eclipse.emf.ecore.extension_parser extension point of your factory. Now the editing domain should be able to resolve your special URIs and create the appropriate resource.
Have a look in the class org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactor y and the plugin.xml of your diagram plugin for an example, this is the way GMF registers its own resource factory, and this should work for custom implementations too. I'm not sure, whether there is an URIConverter required or not, because I did not do this for my own, but a resource based approach could work as described.

HTH.

Regards,
Sebastian
Previous Topic:How to indicate the generated project name?
Next Topic:Labels being Clipped when Exporting Diagram to Image (SVG/PDF)
Goto Forum:
  


Current Time: Sat Jul 27 01:35:39 GMT 2024

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

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

Back to the top