Setting EReference [message #1736132] |
Sun, 26 June 2016 19:11  |
Eclipse User |
|
|
|
I created my own EMFResource and added objects to it programmatically.
Everything works fine. But whenever I set an EReference to any of the EObjects, it gets added to the object at first. But after adding it to the resource, it becomes null again. I do not know what am I doing wrong while setting the EReference. But setting the EReference works fine when I do it from the editor. When I tried to find out the difference between the two, I found that the "eFlags=131076 (in MinimalEObjectImpl) class" for the editor change and "eFlags=0" for the change which I made Programmatically.
Because of this difference, the eNotificationRequired() method returns false. So the EReference is not set.
The code below shows how I set the EReference.
//Setting EReference "upDatedElement"
for(EStructuralFeature eReference:extendedClass.getEAllStructuralFeatures())
{
if(eReference.getName().equals("upDatedElement"))
{
extendedObject.eSet(eReference, linkObject );
}
}
[Updated on: Sun, 26 June 2016 19:26] by Moderator
|
|
|
Re: Setting EReference [message #1736181 is a reply to message #1736132] |
Mon, 27 June 2016 06:52  |
Eclipse User |
|
|
|
Comments below.
On 26.06.2016 19:11, UmaShankar Subramani wrote:
> I created my own EMFResource and added objects to it programmatically.
> Everything works fine. But whenever I set an EReference to any of the
> EObjects, it gets added to the object at first. But after adding it
> to the resource, it becomes null again.
By default, cross resource containment is not supported, so adding an
object to a resource's contents will remove it from its containment
reference. Mostly likely you shouldn't be adding the object to the
resource's contents because that's likely redundant, i.e., the object
will be serialized if it is directly contained by a resource or if is
indirectly contained (via containment references) by any object directly
contained by a resource. You can also set the GenModel property
Containment Proxies to true if you want to allow an object to be both in
a containment reference and contained directly be a resource.
> I do not know what am I doing wrong while setting the EReference. But
> setting the EReference works fine when I do it from the editor. When
> I tried to find out the difference between the two, I found that the
> "eFlags=131076 (in MinimalEObjectImpl) class" for the editor change
> and "eFlags=0" for the change which I made Programmatically.
>
> The code below shows how I set the EReference.
>
> //Setting EReference "upDatedElement"
>
> for(EStructuralFeature
> eReference:extendedClass.getEAllStructuralFeatures())
> {
> if(eReference.getName().equals("upDatedElement"))
> {
> extendedObject.eSet(eReference, linkObject );
> }
> }
|
|
|
Powered by
FUDForum. Page generated in 0.02708 seconds