Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Dynamic insertion of a Attribute
Dynamic insertion of a Attribute [message #431763] Fri, 24 July 2009 04:53 Go to next message
Graham Jenson is currently offline Graham JensonFriend
Messages: 6
Registered: July 2009
Junior Member
If I create a dynamic emf object, then insert a EAttribute into it's
eClass, then try read the property I get an error because the Dynamic
object has not initialized that property.

So for instance

EObject eo = Factory.createDynamicObject().

EAttribute ea = EcoreFactory.eINSTANCE.createEAttribute();
ea.setName("ea");

eo.eClass().getEStructuralFeatures().add(ea);

eo.eGet(ea) // throws an Error!!

Is there a nice way of checking, or perhaps forcing the Dynamic object of
updating when a new Attribute is added.
Re: Dynamic insertion of a Attribute [message #431775 is a reply to message #431763] Fri, 24 July 2009 15:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Graham,

Comments below.

Graham Jenson wrote:
> If I create a dynamic emf object, then insert a EAttribute into it's
> eClass, then try read the property I get an error because the Dynamic
> object has not initialized that property.
>
> So for instance
>
> EObject eo = Factory.createDynamicObject().
>
> EAttribute ea = EcoreFactory.eINSTANCE.createEAttribute();
> ea.setName("ea");
>
> eo.eClass().getEStructuralFeatures().add(ea);
>
> eo.eGet(ea) // throws an Error!!
>
> Is there a nice way of checking, or perhaps forcing the Dynamic object
> of updating when a new Attribute is added.
>
No, you can't modify generated models at all and can't modify a model
once instances of it exist. At best you can create a new package with a
new class that extends the base class and put your new attribute in
that. Then you'd need to create an instance of this new derived class.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Resolving proxies
Next Topic:Default value of EAttribute typed to an Enumeration
Goto Forum:
  


Current Time: Sat Apr 27 04:18:54 GMT 2024

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

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

Back to the top