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

Bug 262407

Summary: [DataBinding] Option to specify default values for DuplexingObservableValue instead of subclassing
Product: [Eclipse Project] Platform Reporter: Matthew Hall <qualidafial>
Component: UIAssignee: Matthew Hall <qualidafial>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: bokowski
Version: 4.0   
Target Milestone: 3.5 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch
none
mylyn/context/zip none

Description Matthew Hall CLA 2009-01-26 12:55:39 EST
The expected 90% case for DuplexingObservableValue is to iterate the collection and:
* return null if empty
* return the first element if there are no other elements
* return the first element if all other elements are equals() to it
* return a predefined stand-in replacement value otherwise

We should provide a static method to make this easy, e.g.

public static DuplexingObservableValue withReplacementValue(IObservableList target, Object replacementValue)
Comment 1 Matthew Hall CLA 2009-02-04 19:25:44 EST
Refining the use case a bit:

Iterate the collection and:
* return a predefined "empty" value if empty
* return the first element if there is only one element
* return the first element if all other elements are equals() to it
* return a predefined "multi" value otherwise

Changed the method signature to:

public static DuplexingObservableValue withDefaults(IObservableList target, Object emptyValue, Object multiValue);
Comment 2 Matthew Hall CLA 2009-02-04 19:27:55 EST
Created attachment 124747 [details]
Patch

Also changed Snippet028 to customize multi-value message for each property, e.g. "<Multiple titles>", "<Multiple directors>", etc
Comment 3 Matthew Hall CLA 2009-02-04 19:27:58 EST
Created attachment 124748 [details]
mylyn/context/zip
Comment 4 Matthew Hall CLA 2009-02-04 19:28:50 EST
Boris, +1?
Comment 5 Matthew Hall CLA 2009-02-05 18:21:46 EST
Released to HEAD > 20090205