Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Re: [JFace Databinding] How to bind a pojo list to a viewer
Re: [JFace Databinding] How to bind a pojo list to a viewer [message #334796] Fri, 27 February 2009 16:40 Go to next message
Eclipse UserFriend
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
Matthew Hall is currently offline Matthew HallFriend
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.
>
Previous Topic:Debug: mouseover to look at value
Next Topic:Library Example ZIP.
Goto Forum:
  


Current Time: Fri Aug 16 19:21:52 GMT 2024

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

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

Back to the top