|
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 Go to previous message](theme/Solstice/images/up.png) |
Sebastian![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=sebastian.woelk%40sw-k.net) 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
|
|
|
Powered by
FUDForum. Page generated in 0.08782 seconds