loading a genmodel [message #652597] |
Fri, 04 February 2011 16:15 |
|
Hi
using EcorePlugin.getEPackageNsURIToGenModelLocationMap()
I managed to get the URI of the genmodel of an ecore, and I get this URI
(simplified)
platform:/plugin/org.myproj/org/myproj/My.genmodel
then, I try to load the GenModel as follows:
ResourceSet resourceSet = model.eResource().getResourceSet();
Map<String, Object> extensionToFactoryMap =
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
if (!extensionToFactoryMap.containsKey("genmodel")) {
EcoreResourceFactoryImpl ecoreFactory = new EcoreResourceFactoryImpl();
extensionToFactoryMap.put("genmodel", ecoreFactory);
GenModelPackage.eINSTANCE.eClass();
}
Resource resource = resourceSet.getResource(uri, true);
but at this point I get an exception:
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.FileNotFoundException: /org/myproj/My.genmodel
am I doing something wrong? Or is it not possible to load a GenModel
from a plugin URI?
many thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: loading a genmodel [message #652665 is a reply to message #652597] |
Sat, 05 February 2011 00:39 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Lorenzo,
Comments below.
Lorenzo Bettini wrote:
> Hi
>
> using EcorePlugin.getEPackageNsURIToGenModelLocationMap()
>
> I managed to get the URI of the genmodel of an ecore, and I get this
> URI (simplified)
>
> platform:/plugin/org.myproj/org/myproj/My.genmodel
>
> then, I try to load the GenModel as follows:
>
> ResourceSet resourceSet = model.eResource().getResourceSet();
> Map<String, Object> extensionToFactoryMap =
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap();
>
> if (!extensionToFactoryMap.containsKey("genmodel")) {
> EcoreResourceFactoryImpl ecoreFactory = new
> EcoreResourceFactoryImpl();
> extensionToFactoryMap.put("genmodel", ecoreFactory);
> GenModelPackage.eINSTANCE.eClass();
> }
Are you doing this loading from an Equinox application or standalone?
You'd not need this normally.
>
> Resource resource = resourceSet.getResource(uri, true);
>
> but at this point I get an exception:
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> java.io.FileNotFoundException: /org/myproj/My.genmodel
>
> am I doing something wrong? Or is it not possible to load a GenModel
> from a plugin URI?
If you're doing this stand alone, you'll have to define URI mappings for
all the involved projects.
>
> many thanks in advance
> Lorenzo
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02726 seconds