Re: [JFace Databinding] How to bind a pojo list to a viewer [message #334796] |
Fri, 27 February 2009 16:40 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
FYI, DataBinding questions are not SWT-specific and belong on the
eclipse.platform newsgroup (which I've copied to this response).
An undecorated implementation of java.util.List does not fire any
notifications when items are added or removed, so it can't be wired up
using DataBinding. I believe you can wrap any java.util.List in a
org.eclipse.core.databinding.observable.list.WritableList to get the
behavior you want, but I've never used that myself.
Hope this helps,
Eric
On 2/27/2009 10:45 AM, Martin Brylski wrote:
> Hi,
>
> I want to bind a pojo java.util.List with a table viewer. The viewer
> should automatically updated when I add some elements to the list or
> labels changes (properties of an element).
>
>
> How to do that?
>
> ---- What I actually wanted ----
> Is there any possibility not to add an element directly to the model,
> hence to "add" it just to the view.
> Looking at ordinary binding with a swt text widget and a pojo property:
> I change the property by modifying the content of the widget and then
> update the binding context to write the new data to the model.
>
> I want to do the same with a viewer. I want to add an element to the
> viewer, and then want to call (in a save operation) to update the model
> via binding context.
|
|
|
Re: [JFace Databinding] How to bind a pojo list to a viewer [message #334805 is a reply to message #334796] |
Fri, 27 February 2009 19:20 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Matthew Hall![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=qualidafial%40gmail.com) Messages: 368 Registered: July 2009 |
Senior Member |
|
|
Starting with integration builds created after February 06, '09, you can
also wrap an arbitrary list in an IObservableList as follows:
List list = ... // this is your java.util.List
IObservableList wrappedList =
Properties.selfList(elementType).observe(list);
As Eric noted, java.util.List has no event change notifications so if
you want changes to the list to show up in the viewer, you should make
those changes through the IObservableList wrapper rather than directly
on the wrapped list.
Matthew
Eric Rizzo wrote:
> FYI, DataBinding questions are not SWT-specific and belong on the
> eclipse.platform newsgroup (which I've copied to this response).
>
> An undecorated implementation of java.util.List does not fire any
> notifications when items are added or removed, so it can't be wired up
> using DataBinding. I believe you can wrap any java.util.List in a
> org.eclipse.core.databinding.observable.list.WritableList to get the
> behavior you want, but I've never used that myself.
>
> Hope this helps,
> Eric
>
>
> On 2/27/2009 10:45 AM, Martin Brylski wrote:
>> Hi,
>>
>> I want to bind a pojo java.util.List with a table viewer. The viewer
>> should automatically updated when I add some elements to the list or
>> labels changes (properties of an element).
>>
>>
>> How to do that?
>>
>> ---- What I actually wanted ----
>> Is there any possibility not to add an element directly to the model,
>> hence to "add" it just to the view.
>> Looking at ordinary binding with a swt text widget and a pojo property:
>> I change the property by modifying the content of the widget and then
>> update the binding context to write the new data to the model.
>>
>> I want to do the same with a viewer. I want to add an element to the
>> viewer, and then want to call (in a save operation) to update the model
>> via binding context.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03005 seconds