Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » inspecting an ecore
inspecting an ecore [message #635657] Wed, 27 October 2010 15:53 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

In my application I'd like to able to load an ecore file and be able to
inspect all the elements defined there...

is there any tutorial/example showing that?

many thanks in advance
cheers
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


Re: inspecting an ecore [message #635713 is a reply to message #635657] Wed, 27 October 2010 19:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030201070609080901030101
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Lorenzo,

Loading resources works the same for all models and that's described in
the introductory overview. The paper about dynamic Ecore will probably
be very helpful for what you want to do.

Discover the Eclipse Modeling Framework (EMF) and Its Dynamic
Capabilities <http://www.devx.com/Java/Article/29093/0/page/1>


Lorenzo Bettini wrote:
> Hi
>
> In my application I'd like to able to load an ecore file and be able
> to inspect all the elements defined there...
>
> is there any tutorial/example showing that?
>
> many thanks in advance
> cheers
> Lorenzo
>

--------------030201070609080901030101
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">
Lorenzo,<br>
<br>
Loading resources works the same for all models and that's described in
the introductory overview.&nbsp;&nbsp; The paper about dynamic Ecore will
probably be very helpful for what you want to do.<br>
<blockquote><a target="_out"
href="http://www.devx.com/Java/Article/29093/0/page/1">Discover the
Eclipse Modeling Framework (EMF) and Its Dynamic Capabilities</a><br>
</blockquote>
<br>
Lorenzo Bettini wrote:
<blockquote cite="mid:ia9hmu$re8$1@news.eclipse.org" type="cite">Hi
<br>
<br>
In my application I'd like to able to load an ecore file and be able to
inspect all the elements defined there...
<br>
<br>
is there any tutorial/example showing that?
<br>
<br>
many thanks in advance
<br>
cheers
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Lorenzo
<br>
<br>
</blockquote>
</body>
</html>

--------------030201070609080901030101--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: inspecting an ecore [message #636966 is a reply to message #635713] Wed, 03 November 2010 15:08 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 10/27/2010 09:08 PM, Ed Merks wrote:
> Lorenzo,
>
> Loading resources works the same for all models and that's described in
> the introductory overview. The paper about dynamic Ecore will probably
> be very helpful for what you want to do.
>
> Discover the Eclipse Modeling Framework (EMF) and Its Dynamic
> Capabilities <http://www.devx.com/Java/Article/29093/0/page/1>
>
>
> Lorenzo Bettini wrote:
>> Hi
>>
>> In my application I'd like to able to load an ecore file and be able
>> to inspect all the elements defined there...
>>
>> is there any tutorial/example showing that?
>>

I'm doing something like this, does it look right?

ResourceSet resourceSet = new ResourceSetImpl();

resourceSet
.getResourceFactoryRegistry()
.getContentTypeToFactoryMap()
.put(EcorePackage.eCONTENT_TYPE, new
EcoreResourceFactoryImpl());

resourceSet
.getURIConverter()
.getContentHandlers()
.add(new RootXMLContentHandlerImpl(EcorePackage.eCONTENT_TYPE,
null, null,
EcorePackage.eNS_URI, null));

resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
EcorePackage.eINSTANCE);

URI uri = URI.createFileURI("model/FJ.ecore");

Resource resource = resourceSet.getResource(uri, true);
System.out.println("Loaded " + uri); //$NON-NLS-1$

System.out.println("Resource: " + resource.toString());

--
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


Re: inspecting an ecore [message #637013 is a reply to message #636966] Wed, 03 November 2010 18:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Lorenzo,

Comments below.


Lorenzo Bettini wrote:
> On 10/27/2010 09:08 PM, Ed Merks wrote:
>> Lorenzo,
>>
>> Loading resources works the same for all models and that's described in
>> the introductory overview. The paper about dynamic Ecore will probably
>> be very helpful for what you want to do.
>>
>> Discover the Eclipse Modeling Framework (EMF) and Its Dynamic
>> Capabilities <http://www.devx.com/Java/Article/29093/0/page/1>
>>
>>
>> Lorenzo Bettini wrote:
>>> Hi
>>>
>>> In my application I'd like to able to load an ecore file and be able
>>> to inspect all the elements defined there...
>>>
>>> is there any tutorial/example showing that?
>>>
>
> I'm doing something like this, does it look right?
Does it work?
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet
> .getResourceFactoryRegistry()
> .getContentTypeToFactoryMap()
> .put(EcorePackage.eCONTENT_TYPE, new
> EcoreResourceFactoryImpl());
>
> resourceSet
> .getURIConverter()
> .getContentHandlers()
> .add(new RootXMLContentHandlerImpl(EcorePackage.eCONTENT_TYPE,
> null, null,
> EcorePackage.eNS_URI, null));
I've not tried content handlers for Ecore.
>
> resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
> EcorePackage.eINSTANCE);
>
> URI uri = URI.createFileURI("model/FJ.ecore");
It's best to use an absolute path.
>
> Resource resource = resourceSet.getResource(uri, true);
> System.out.println("Loaded " + uri); //$NON-NLS-1$
>
> System.out.println("Resource: " + resource.toString());
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: inspecting an ecore [message #637680 is a reply to message #637013] Mon, 08 November 2010 10:35 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 11/03/2010 07:28 PM, Ed Merks wrote:
> Lorenzo Bettini wrote:
>> On 10/27/2010 09:08 PM, Ed Merks wrote:
>>> Lorenzo,
>>>
>>> Loading resources works the same for all models and that's described in
>>> the introductory overview. The paper about dynamic Ecore will probably
>>> be very helpful for what you want to do.
>>>
>>> Discover the Eclipse Modeling Framework (EMF) and Its Dynamic
>>> Capabilities <http://www.devx.com/Java/Article/29093/0/page/1>
>>>
>>>
>>> Lorenzo Bettini wrote:
>>>> Hi
>>>>
>>>> In my application I'd like to able to load an ecore file and be able
>>>> to inspect all the elements defined there...
>>>>
>>>> is there any tutorial/example showing that?
>>>>
>>
>> I'm doing something like this, does it look right?
> Does it work?

yes, but I wanted to be sure I was doing it right :)

>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>>
>> resourceSet
>> .getResourceFactoryRegistry()
>> .getContentTypeToFactoryMap()
>> .put(EcorePackage.eCONTENT_TYPE, new
>> EcoreResourceFactoryImpl());
>>
>> resourceSet
>> .getURIConverter()
>> .getContentHandlers()
>> .add(new RootXMLContentHandlerImpl(EcorePackage.eCONTENT_TYPE,
>> null, null,
>> EcorePackage.eNS_URI, null));
> I've not tried content handlers for Ecore.

actually I started from the code generated when "generate test code"

>>
>> resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
>> EcorePackage.eINSTANCE);
>>
>> URI uri = URI.createFileURI("model/FJ.ecore");
> It's best to use an absolute path.

yes, that was just a test... by the way, is there a kind of reference
sheet for the several available URI syntaxes?

thanks
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


Re: inspecting an ecore [message #637731 is a reply to message #637680] Mon, 08 November 2010 13:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Lorenzo,

Comments below.


Lorenzo Bettini wrote:
> On 11/03/2010 07:28 PM, Ed Merks wrote:
>> Lorenzo Bettini wrote:
>>> On 10/27/2010 09:08 PM, Ed Merks wrote:
>>>> Lorenzo,
>>>>
>>>> Loading resources works the same for all models and that's
>>>> described in
>>>> the introductory overview. The paper about dynamic Ecore will probably
>>>> be very helpful for what you want to do.
>>>>
>>>> Discover the Eclipse Modeling Framework (EMF) and Its Dynamic
>>>> Capabilities <http://www.devx.com/Java/Article/29093/0/page/1>
>>>>
>>>>
>>>> Lorenzo Bettini wrote:
>>>>> Hi
>>>>>
>>>>> In my application I'd like to able to load an ecore file and be able
>>>>> to inspect all the elements defined there...
>>>>>
>>>>> is there any tutorial/example showing that?
>>>>>
>>>
>>> I'm doing something like this, does it look right?
>> Does it work?
>
> yes, but I wanted to be sure I was doing it right :)
>
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>>
>>> resourceSet
>>> .getResourceFactoryRegistry()
>>> .getContentTypeToFactoryMap()
>>> .put(EcorePackage.eCONTENT_TYPE, new
>>> EcoreResourceFactoryImpl());
>>>
>>> resourceSet
>>> .getURIConverter()
>>> .getContentHandlers()
>>> .add(new RootXMLContentHandlerImpl(EcorePackage.eCONTENT_TYPE,
>>> null, null,
>>> EcorePackage.eNS_URI, null));
>> I've not tried content handlers for Ecore.
>
> actually I started from the code generated when "generate test code"
Then it must be right. :-P
>
>>>
>>> resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
>>> EcorePackage.eINSTANCE);
>>>
>>> URI uri = URI.createFileURI("model/FJ.ecore");
>> It's best to use an absolute path.
>
> yes, that was just a test... by the way, is there a kind of reference
> sheet for the several available URI syntaxes?
Well, anything that's a well formed URL is allowed. Others define how
http:, file:, zip: are structured. The Eclipse platform defines how
platform: is structured...
>
> thanks
> Lorenzo
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Reference not properly loaded from XML file
Next Topic:Configuration for Tables
Goto Forum:
  


Current Time: Thu Apr 25 02:00:59 GMT 2024

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

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

Back to the top