|
Re: Newbie: How to load an ecore model in code? [message #416094 is a reply to message #416090] |
Thu, 17 January 2008 14:52 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000001090609090406060109
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Jochen,
It should be as simple as this:
ResourceSet resourceSet = new ResourceSetImpl();
Resource ecoreResource =
resourceSet.getResource(<uri-of-*.ecore-resource>, true);
EPackage ePackage = (EPackage)ecoreResource.getContents().get(0);
If you're loading a resource form the work space, use
URI.createPlatformResourceURI(iFile.getFullPath().toString() , true), and
if it's a file system file, use URI.createFileURI(new
File(<path>).getAbsolutePath()).
Looking at what EcoreEditor does to load a model and then let you edit
it shows it in a fancier context...
Jochen wrote:
> Hi,
>
> I'm just getting started with EMF, so if this question has been
> answered before just point me to the right place.
>
>
> I'm trying to build a plug-in that processes Ecore models, looks for
> annotations and patterns and stuff like that. For that I believe I
> need to be able to access the model somehow. I was expecting to find
> some sort of API that allows the loading of an ecore file and returns
> the root package of the model, or something like that. So far I've
> been unable to locate such an API. I tried working through the
> org.eclipse.emf.importer stuff, but I don't really see what this is
> doing and documentation is rather sparse.
>
> Can anyone point me to the right place where to start looking or does
> anyone even have example code?
>
> Thanks
> Jochen
--------------000001090609090406060109
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jochen,<br>
<br>
It should be as simple as this:<br>
<blockquote> ResourceSet resourceSet = new ResourceSetImpl();<br>
Resource ecoreResource =
resourceSet.getResource(<uri-of-*.ecore-resource& gt;, true);<br>
EPackage ePackage = (EPackage)ecoreResource.getContents().get(0);<br>
</blockquote>
If you're loading a resource form the work space, use
URI.createPlatformResourceURI(iFile.getFullPath().toString() , true),
and if it's a file system file, use URI.createFileURI(new
File(<path>).getAbsolutePath()).<br>
<br>
Looking at what EcoreEditor does to load a model and then let you edit
it shows it in a fancier context...<br>
<br>
<br>
Jochen wrote:
<blockquote cite="mid:fmnpdr$meu$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
I'm just getting started with EMF, so if this question has been
answered before just point me to the right place.
<br>
<br>
<br>
I'm trying to build a plug-in that processes Ecore models, looks for
annotations and patterns and stuff like that. For that I believe I need
to be able to access the model somehow. I was expecting to find some
sort of API that allows the loading of an ecore file and returns the
root package of the model, or something like that. So far I've been
unable to locate such an API. I tried working through the
org.eclipse.emf.importer stuff, but I don't really see what this is
doing and documentation is rather sparse.
<br>
<br>
Can anyone point me to the right place where to start looking or does
anyone even have example code?
<br>
<br>
Thanks
<br>
Jochen
<br>
</blockquote>
<br>
</body>
</html>
--------------000001090609090406060109--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03544 seconds