Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Howto create a reference to an attribute?
Howto create a reference to an attribute? [message #1067078] Fri, 05 July 2013 17:32 Go to next message
Daniel Golesny is currently offline Daniel GolesnyFriend
Messages: 12
Registered: January 2013
Junior Member
Hi,
I have an EClass "Person" that has several attributes (like name, age, etc.).
And another EClass "PDFTemplate" (same model) has EClass children like HLine, VLine, Box, etc.

I want a template sub-element "TextReference" that has a reference to one attribute of the Person.
My goal is to print the attribute to a PDF.
I can't imagine how I can create such a reference with EMF and I couldn't find a documentation for this.
For the user in my ECP application I would like to have a combobox or popup with all available attributes (tree or list).

What is the best way to create something like that in an ECore-Model?

Thanks,
Daniel
Re: Howto create a reference to an attribute? [message #1067084 is a reply to message #1067078] Fri, 05 July 2013 18:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Daniel,

Comments below.

On 05/07/2013 7:32 PM, Daniel Golesny wrote:
> Hi, I have an EClass "Person" that has several attributes (like name,
> age, etc.).
> And another EClass "PDFTemplate" (same model) has EClass children like
> HLine, VLine, Box, etc.
>
> I want a template sub-element "TextReference" that has a reference to
> one attribute of the Person.
You don't reference an attribute...
> My goal is to print the attribute to a PDF.
> I can't imagine how I can create such a reference with EMF and I
> couldn't find a documentation for this.
You can reference a Person, or you can reference any old EObject, but
you can't reference just one feature of such a thing...
> For the user in my ECP application I would like to have a combobox or
> popup with all available attributes (tree or list).
eObject.eClass().getEAllAttributes lists all the attributes of some object.
>
> What is the best way to create something like that in an ECore-Model?
It's not so clear what exactly you're trying to do. If you really want
something that specifies a particular feature of some object, you'd need
two things: the reference to the object, and a reference to some
feature of that object (or an attribute with the name of that feature)...


>
> Thanks,
> Daniel


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Howto create a reference to an attribute? [message #1067088 is a reply to message #1067084] Fri, 05 July 2013 18:40 Go to previous messageGo to next message
Daniel Golesny is currently offline Daniel GolesnyFriend
Messages: 12
Registered: January 2013
Junior Member
I have following EClasses:

Person
- name : EString
- age : EInt
- template : PDFTemplate

PDFTemplate
- elements[0..*] : ReferencedText

ReferencedText
- x : EFloat
- y : EFloat
- attributeReference : ?this here is my problem?

In the ECP Client I want to create a PDFTemplate instance with a child ReferencedText like this:

person1 => Person(name="Daniel Golesny",age=35, template=)
ReferencedText(x=50,y=100,attributeReference="person1->name")

I have a command "Generate PDF" which generates a PDF and I want to add the text "Daniel Golesny" to the pdf at position 50/100.

And the question is: What is the best way to get that or something similar?
Re: Howto create a reference to an attribute? [message #1067130 is a reply to message #1067088] Sat, 06 July 2013 07:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Daniel,

Comments below.

On 05/07/2013 8:40 PM, Daniel Golesny wrote:
> I have following EClasses:
>
> Person
> - name : EString
> - age : EInt
> - template : PDFTemplate
>
> PDFTemplate
> - elements[0..*] : ReferencedText
>
> ReferencedText
> - x : EFloat
> - y : EFloat
> - attributeReference : ?this here is my problem?
Think of how you'd do it in Java. You'd need two things. You'd need a
reference to the object with the value, and something to specify which
value of the object you want to access. Otherwise you'd just refer
directly to the value. It's no different in EMF. You need a reference
to the Person in your example and you'd need to know you wanted the
person's "name" feature.
>
> In the ECP Client I want to create a PDFTemplate instance with a child
> ReferencedText like this:
>
> person1 => Person(name="Daniel Golesny",age=35, template=)
> ReferencedText(x=50,y=100,attributeReference="person1->name")
>
> I have a command "Generate PDF" which generates a PDF and I want to
> add the text "Daniel Golesny" to the pdf at position 50/100.
>
> And the question is: What is the best way to get that or something
> similar?
I'm not sure how general you want this to be. To be completely general
you'd have an EReference of type EObject and you could have an
EAttribute of type EString to specify the feature of that EObject you
want to display. You'd use eObject.eClass().getEAllAttributes() to
provide the valid choices for the features of the EObject in the derived
property descriptor for that. You'd need to choose the object before
choosing which feature of the object... Perhaps you'd have a property
descriptor for only one of the features and you'd display all the
choices of object/feature pairs and set both features with a single
compound command. Or perhaps you'd bring up a dialog for the feature:
http://wiki.eclipse.org/EMF/Recipes#Recipe:_Create_your_own_property_editor_in_a_generated_application
that lets the user choose the EObject that EObject's feature.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Howto create a reference to an attribute? [message #1067194 is a reply to message #1067130] Sun, 07 July 2013 13:00 Go to previous messageGo to next message
Daniel Golesny is currently offline Daniel GolesnyFriend
Messages: 12
Registered: January 2013
Junior Member
Thank you very much, your explanation helped me a lot.
The reference to the Person was easy. I did it with a marker-interface "Referencable", so I could select all the entities I've marked.
The rest I will check later ... while playing around I'm sure that modelling a PDF by using a non-graphical editor is pain in the a**. Perhaps GEF would be better for that.

But I think I need some basics first before using GEF ...
Is there any up-to-date book or PDF about GEF? (or EMF with GEF)? All EMF books are many years old ...

Thanks,
Daniel
Re: Howto create a reference to an attribute? [message #1067198 is a reply to message #1067194] Sun, 07 July 2013 13:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Daniel,

Comments below.

On 07/07/2013 3:00 PM, Daniel Golesny wrote:
> Thank you very much, your explanation helped me a lot.
You're welcome.
> The reference to the Person was easy. I did it with a marker-interface
> "Referencable", so I could select all the entities I've marked.
I'm not exactly sure what you mean...
> The rest I will check later ... while playing around I'm sure that
> modelling a PDF by using a non-graphical editor is pain in the a**.
I can imagine.
> Perhaps GEF would be better for that.
Yes, though project's like Graphiti and GMF are likely a better choice;
they make it easy to build a graphical editor for an EMF model...
>
> But I think I need some basics first before using GEF ...
Personally I'd start with Graphiti; it's being quite actively developed
further: http://www.eclipse.org/graphiti/
> Is there any up-to-date book or PDF about GEF?
This isn't the GEF forum. :-P
> (or EMF with GEF)?
There's a redbook, but yes, it's quite old, and you probably don't want
to use GEF directly but rather reuse Graphiti or GMF.
> All EMF books are many years old ...
EMF has evolved in a completely binary compatible way, so everything in
the EMF book is still valid today.
>
> Thanks,
> Daniel


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Use only the editor from EMF Client Platform (ECP)
Next Topic:[CDO/EMF] Modeling BIG amounts of tiny data
Goto Forum:
  


Current Time: Thu Apr 25 15:37:13 GMT 2024

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

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

Back to the top