Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [databinding] bind to a null EReference
[databinding] bind to a null EReference [message #422365] Wed, 03 September 2008 07:54 Go to next message
Luca Lusso is currently offline Luca LussoFriend
Messages: 1
Registered: July 2009
Junior Member
Hi, I have a model object with a optional reference to an other model
object. Sometimes this reference is NULL because it's optional. In my
GUI what I want to do is bind some attribute of the optional reference
to text field. Is possible to use databinding in such a way that, when
user fill those fields, the referenced object will be created, filled
with correct data and attached to parent model object? I think I have to
write custom code to do so, and I'm looking for suggestion.

Thanks

Lusso Luca
Re: [databinding] bind to a null EReference [message #422369 is a reply to message #422365] Wed, 03 September 2008 12:15 Go to previous messageGo to next message
Ed Merks is currently online Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Lusso,

It seems like a relatively common type of situation. Unfortunately my
data binding skills are close to zero, so I'm hoping Tom or someone else
will see your question, which is more of a general data binding question
than a specific-EMF one, and provide some guidance...


Luca Lusso wrote:
> Hi, I have a model object with a optional reference to an other model
> object. Sometimes this reference is NULL because it's optional. In my
> GUI what I want to do is bind some attribute of the optional reference
> to text field. Is possible to use databinding in such a way that, when
> user fill those fields, the referenced object will be created, filled
> with correct data and attached to parent model object? I think I have
> to write custom code to do so, and I'm looking for suggestion.
>
> Thanks
>
> Lusso Luca


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [databinding] bind to a null EReference [message #422371 is a reply to message #422369] Wed, 03 September 2008 12:47 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Lusso,

Let's give it a try. Does your model look like this?

Person
+ address: Address
+ street: String

And you want to bind address.street? But it is possible that address is
null and you expect that if someone is entering a text in the TextField
a new Address-instance is created and its street value is filled?

If that's the case then no sorry this is *not possible* because
Databinding has no idea how to create the Address-Instance (it might not
even know/has access to the implementation-class because EMF is only
presenting the interface from the out side and OSGi is hidding the
implementation).

Still I think you can work around this using a trick like this:

Person
+ address: Address
+ street: String
+ addressStreet: String (volatile transient derived feature)
+ ... => other attributes of the none mandatory address-attributes

The trick shown here is a very cool one and I used it a e.g. for the
following problem.

Person
+ addresses: EList<Address>
+ homeAddress: Address (volatile transient derived feature)
+ billingAddress: Address (volatile transient derived feature)

So EMF makes this fairly easy but even with any other Model-Technology ;-)

Maybe I should write a small example for the Databinding-Snippet pages
using Standard Beans (or anyone else eager on doing so).

Tom

Ed Merks schrieb:
> Lusso,
>
> It seems like a relatively common type of situation. Unfortunately my
> data binding skills are close to zero, so I'm hoping Tom or someone else
> will see your question, which is more of a general data binding question
> than a specific-EMF one, and provide some guidance...
>
>
> Luca Lusso wrote:
>> Hi, I have a model object with a optional reference to an other model
>> object. Sometimes this reference is NULL because it's optional. In my
>> GUI what I want to do is bind some attribute of the optional reference
>> to text field. Is possible to use databinding in such a way that, when
>> user fill those fields, the referenced object will be created, filled
>> with correct data and attached to parent model object? I think I have
>> to write custom code to do so, and I'm looking for suggestion.
>>
>> Thanks
>>
>> Lusso Luca


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: [databinding] bind to a null EReference [message #422384 is a reply to message #422371] Wed, 03 September 2008 15:51 Go to previous messageGo to next message
Ben is currently offline BenFriend
Messages: 46
Registered: July 2009
Member
Hey Tom,

Would you mind posting the the link to the Databinding-Snippets page?

Thanks!
Re: [databinding] bind to a null EReference [message #422385 is a reply to message #422384] Wed, 03 September 2008 15:56 Go to previous messageGo to next message
Ed Merks is currently online Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080509010601050107050708
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ben,

Google search can answer such questions extremely quickly:
<http://wiki.eclipse.org/JFace_Data_Binding/Snippets>

http://wiki.eclipse.org/JFace_Data_Binding/Snippets


Ben wrote:
> Hey Tom,
>
> Would you mind posting the the link to the Databinding-Snippets page?
>
> Thanks!
>

--------------080509010601050107050708
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ben,<br>
<br>
Google search can answer such questions extremely quickly:<a
href="http://wiki.eclipse.org/JFace_Data_Binding/Snippets"><br>
</a>
<blockquote><a
href="http://wiki.eclipse.org/JFace_Data_Binding/Snippets">http://wiki.eclipse.org/JFace_Data_Binding/Snippets</a><br>
</blockquote>
<br>
Ben wrote:
<blockquote
cite="mid:237c7cbb5371b0a8b388f8b86ea2e17f$1@www.eclipse.org"
type="cite">Hey Tom,
<br>
<br>
Would you mind posting the the link to the Databinding-Snippets page?
<br>
<br>
Thanks!
<br>
<br>
</blockquote>
</body>
</html>

--------------080509010601050107050708--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [databinding] bind to a null EReference [message #422414 is a reply to message #422371] Fri, 05 September 2008 07:55 Go to previous messageGo to next message
Axel Nitert is currently offline Axel NitertFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Tom,

thanks for this example. It really helped me to save a lot of time. I
would like to suggest to include this into your example application.

I didn't have the time yet to test your example application but I will
do so soon. I am very curiour on the CDO part.

Axel
Re: [databinding] bind to a null EReference [message #422416 is a reply to message #422414] Fri, 05 September 2008 08:21 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Axel,

Good I idea. I'll add such a thing to the example application. The CDO
thing is in fact so straight forward because all the real magic happens
inside this framework. The only thing I had to figure out was how to
make create connect to the server and for this problem there are great
snippets available.

Tom

Axel Nitert schrieb:
> Hi Tom,
>
> thanks for this example. It really helped me to save a lot of time. I
> would like to suggest to include this into your example application.
>
> I didn't have the time yet to test your example application but I will
> do so soon. I am very curiour on the CDO part.
>
> Axel


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: [databinding] bind to a null EReference [message #422420 is a reply to message #422416] Fri, 05 September 2008 11:22 Go to previous messageGo to next message
Axel Nitert is currently offline Axel NitertFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Tom,

I thought about the data model and it seems that the example is not
quite correct compared to the reality.

The data structure should be like

FIFA (world-wide)
UEFA (Europe)
DFB (Germany)

What I mean is that the class Country should be a specialization of a
class like Region.

Region
Country
World
Continent

or something like this.

I didn't want to be pedantic it's just a remark.

Axel


Tom Schindl schrieb:
> Hi Axel,
>
> Good I idea. I'll add such a thing to the example application. The CDO
> thing is in fact so straight forward because all the real magic happens
> inside this framework. The only thing I had to figure out was how to
> make create connect to the server and for this problem there are great
> snippets available.
>
> Tom
>
> Axel Nitert schrieb:
>> Hi Tom,
>>
>> thanks for this example. It really helped me to save a lot of time. I
>> would like to suggest to include this into your example application.
>>
>> I didn't have the time yet to test your example application but I will
>> do so soon. I am very curiour on the CDO part.
>>
>> Axel
>
>
Re: [databinding] bind to a null EReference [message #422425 is a reply to message #422420] Fri, 05 September 2008 12:08 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Axel,

You are right I'll correct this :-)

Tom

Axel Nitert schrieb:
> Hi Tom,
>
> I thought about the data model and it seems that the example is not
> quite correct compared to the reality.
>
> The data structure should be like
>
> FIFA (world-wide)
> UEFA (Europe)
> DFB (Germany)
>
> What I mean is that the class Country should be a specialization of a
> class like Region.
>
> Region
> Country
> World
> Continent
>
> or something like this.
>
> I didn't want to be pedantic it's just a remark.
>
> Axel
>
>
> Tom Schindl schrieb:
>> Hi Axel,
>>
>> Good I idea. I'll add such a thing to the example application. The CDO
>> thing is in fact so straight forward because all the real magic happens
>> inside this framework. The only thing I had to figure out was how to
>> make create connect to the server and for this problem there are great
>> snippets available.
>>
>> Tom
>>
>> Axel Nitert schrieb:
>>> Hi Tom,
>>>
>>> thanks for this example. It really helped me to save a lot of time. I
>>> would like to suggest to include this into your example application.
>>>
>>> I didn't have the time yet to test your example application but I will
>>> do so soon. I am very curiour on the CDO part.
>>>
>>> Axel
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Genmodel's ignore project source directory
Next Topic:Integrating external classes into ecore models
Goto Forum:
  


Current Time: Thu Apr 25 15:06:47 GMT 2024

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

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

Back to the top