Dynamic insertion of a Attribute [message #431763] |
Fri, 24 July 2009 00:53  |
Eclipse User |
|
|
|
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 11:22  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03245 seconds