Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323799

Summary: [DataBinding] Binding to single entry in List<?>
Product: [Eclipse Project] Platform Reporter: redzack81
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: chengdong.li, tom.schindl
Version: 3.6   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description redzack81 CLA 2010-08-27 05:34:51 EDT
Add support to bind against single list entries.

Model example:
class Person {
     List<String> hobbies;
}

There should be a way to bind against a single hobby from this list.
Comment 1 chengdong Mising name CLA 2010-09-15 16:39:54 EDT
Just want to clarify: It would be nice if given the Person object, we can observe (for example) the nth hobby.
Comment 2 Matthew Hall CLA 2010-09-23 00:12:36 EDT
So something like this?

  IObservableList list = ...
  IObservableValue item4 = Observables.observeListElement(list, 4)

We could possibly also allow using an IObservableValue to control which index to get at.

Is this what you're looking for?
Comment 3 redzack81 CLA 2010-09-24 08:06:42 EDT
Yes. That's what I'm looking for.

What about modifications to the list after the creation of the IObservableValue for the item? Would this be solved by also having the index as an IObservableValue?
Comment 4 Thomas Schindl CLA 2011-09-14 10:43:06 EDT
EMF-Databinding introduced support for this using the properties-API but we are not forcing a specific index but pass a callback which calculates the index to observe
Comment 5 Matthew Hall CLA 2011-09-14 10:54:29 EDT
See also bug 300043 which had a ListReducers proposal of which one of the reducers was to use the element at the nth index. This is potentially more generically applicable.
Comment 6 Thomas Schindl CLA 2011-09-14 11:26:41 EDT
(In reply to comment #5)
> See also bug 300043 which had a ListReducers proposal of which one of the
> reducers was to use the element at the nth index. This is potentially more
> generically applicable.

Yeah this one looks very similar to ours but ours has the difference that we also allow to write back to the list.