|
Re: Load ecore metamodel in eclipse runtime [message #1436816 is a reply to message #1436798] |
Fri, 03 October 2014 12:53 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Alexander,
Comments below.
On 03/10/2014 2:25 PM, Alexander R wrote:
> Hey all,
>
> maybe it is stupid question but I would like to load the Ecore.ecore
> metamodell to
> a resourceset which is used by an editor.
Hmm...
> The editor is running in a runtime eclipse instance. Here is the way I
> did it:
>
>
> //register the package
> EcorePackage.eINSTANCE.eClass();
This isn't necessary in an Eclipse environment.
> EPackage.Registry.INSTANCE.put(EcoreFactory.eINSTANCE.getEPackage().getNsURI(),
This is just EcorePackage.eNS_URI
> EcoreFactory.eINSTANCE.getEPackage());
This is just EcorePackage.eINSTANCE.
This too is redundant in an Eclipse environment.
> //get the uri
> URI ecoreUri =
> URI.createURI(EcoreFactory.eINSTANCE.getEPackage().getNsURI(), true);
> //get the resource
> Resource ecoreResource = xtextResourceSet.getResource(ecoreUri, true);
This will just return the resource already in the package registry.
I.e., the same as EcorePackage.eINSTANCE.eResource().
> try {
> //load it
> ecoreResource.load(null);
It's already loaded, so this will do nothing.
> } catch (IOException e) {
> e.printStackTrace();
> }
>
>
> This works, but only if the Ecore.ecore file is inside the runtime
> workspace. Otherwise the the metamodel is can't be found.
Perhaps you want to be loading using the URI
"platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore"; that will
load the development time instance of Ecore. Note that the Ecore editor
does
resourceSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap(true));
before loading any models...
>
> What am I doing wrong?
> Criticism is welcome!
>
> ~Alex
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.04362 seconds