Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating instance of domain EClass
Creating instance of domain EClass [message #964610] Tue, 30 October 2012 17:02 Go to next message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Hi again,

If I make a domain class:

EClass d = EcoreFactory.eINSTANCE.createEClass();
d.setName( "D" );

Is it possible to create an instance of this class programmatically, e.g.:

EObject dO = ... d ...

Help is appreciated!
Re: Creating instance of domain EClass [message #964615 is a reply to message #964610] Tue, 30 October 2012 17:06 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Peter,

EObject dO = EcoreUtil.create(d);

HTH,

Christian


On 2012-10-30 17:02:44 +0000, Peter Johnsen said:

> Hi again,
>
> If I make a domain class:
>
> EClass d = EcoreFactory.eINSTANCE.createEClass();
> d.setName( "D" );
>
> Is it possible to create an instance of this class programmatically, e.g.:
>
> EObject dO = ... d ...
>
> Help is appreciated!
Re: Creating instance of domain EClass [message #964622 is a reply to message #964615] Tue, 30 October 2012 17:07 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Note, however, that the EClass must be in an EPackage so that its
factory is reachable.

On 2012-10-30 17:06:30 +0000, Christian W. Damus said:

> Hi, Peter,
>
> EObject dO = EcoreUtil.create(d);
>
> HTH,
>
> Christian
>
>
> On 2012-10-30 17:02:44 +0000, Peter Johnsen said:
>
>> Hi again,
>>
>> If I make a domain class:
>>
>> EClass d = EcoreFactory.eINSTANCE.createEClass();
>> d.setName( "D" );
>>
>> Is it possible to create an instance of this class programmatically, e.g.:
>>
>> EObject dO = ... d ...
>>
>> Help is appreciated!
Re: Creating instance of domain EClass [message #966781 is a reply to message #964622] Thu, 01 November 2012 08:19 Go to previous message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Thank you Christian!

I actually tried using EcoreUtil.create(...) before posting on this forum, but I hadn't added the class to a package, and thus, it didn't work. Your second post addressed that.

Great, take care!
Previous Topic:Get the selected menu item
Next Topic:Setting Value via FeaturePath
Goto Forum:
  


Current Time: Wed Apr 24 17:30:46 GMT 2024

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

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

Back to the top