Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Working with annotations
Working with annotations [message #635990] Thu, 28 October 2010 20:23 Go to next message
Bernd is currently offline BerndFriend
Messages: 3
Registered: July 2009
Junior Member
Hi,

I modeled an EClass (e.g. 'Car') and annotated it with an annotation.
The annotation has a containment reference to an EObject (e.g. an
'Config' element) described by a model provided via the package registry.

After serializing my Model with the 'Car' EClass the XML file contains
all the content I excpect: The 'Car' EClass, the annotaion and the
'Config' EObject contained in the annotaion. So far, so good.

I ran into problems when I tried to access the content of the annotaion
at runtime. It's empty. :-(

EAnnotation eAnnotation =
CarPackage.eINSTANCE.getCar().getEAnnotation("source");
eAnnotation.getContents().isEmpty(); // returns true

Is this generally not possible? Or is there something I have to consider
when working with annotations?

Thanks in advance.

Cheers,
Bernd
Re: Working with annotations [message #636004 is a reply to message #635990] Thu, 28 October 2010 21:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Bernd,

If you need such things at runtime, you'll have to specify Initialize by
Loading on the GenPackage.


Bernd wrote:
> Hi,
>
> I modeled an EClass (e.g. 'Car') and annotated it with an annotation.
> The annotation has a containment reference to an EObject (e.g. an
> 'Config' element) described by a model provided via the package registry.
>
> After serializing my Model with the 'Car' EClass the XML file contains
> all the content I excpect: The 'Car' EClass, the annotaion and the
> 'Config' EObject contained in the annotaion. So far, so good.
>
> I ran into problems when I tried to access the content of the
> annotaion at runtime. It's empty. :-(
>
> EAnnotation eAnnotation =
> CarPackage.eINSTANCE.getCar().getEAnnotation("source");
> eAnnotation.getContents().isEmpty(); // returns true
>
> Is this generally not possible? Or is there something I have to
> consider when working with annotations?
>
> Thanks in advance.
>
> Cheers,
> Bernd


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Working with annotations [message #636234 is a reply to message #636004] Fri, 29 October 2010 18:52 Go to previous message
Bernd is currently offline BerndFriend
Messages: 3
Registered: July 2009
Junior Member
> If you need such things at runtime, you'll have to specify Initialize by
> Loading on the GenPackage.

Fantastic, it works. Thanks for the hint.
Previous Topic:How to Extend Ecore Model with Extension XML Schema
Next Topic:[CDO] cdoPrefetch() Timeout
Goto Forum:
  


Current Time: Sat Apr 20 03:33:13 GMT 2024

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

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

Back to the top