Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 271720 - [DataBinding] Clarify DateTimeSelectionProperty javadoc with respect to null values
Summary: [DataBinding] Clarify DateTimeSelectionProperty javadoc with respect to null ...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Matthew Hall CLA
QA Contact: Matthew Hall CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-09 00:12 EDT by Elias Volanakis CLA
Modified: 2009-04-17 21:05 EDT (History)
1 user (show)

See Also:


Attachments
Test Case (3.30 KB, text/plain)
2009-04-09 00:17 EDT, Elias Volanakis CLA
no flags Details
Fix with tests (6.85 KB, patch)
2009-04-09 11:51 EDT, Matthew Hall CLA
no flags Details | Diff
Javadoc patch for DateAndTimeObservable (1.95 KB, patch)
2009-04-09 16:15 EDT, Elias Volanakis CLA
no flags Details | Diff
Javadoc patch (2.58 KB, patch)
2009-04-13 21:51 EDT, Elias Volanakis CLA
qualidafial: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Volanakis CLA 2009-04-09 00:12:09 EDT
In experimenting with the new DateAndTimeObservableValue, I found the following two cases to cause NPEs in Calendar.setTime, which is invoked via DateTimeSelectionProperty:

64: Calendar cal = (Calendar) calendar.get();
65: cal.setTime((Date) value);

Here is a summary of the case:

WritableValue value;
DateAndTimeObservableValue dAndTObservable;
Binding binding = dbc.bindValue(dAndTObservable, value);

(a) value.setValue(null)

(b) dAndTObservable.setValue(null);

Also it is not clear to me what the expected result of dAndTObservable.getValue() is on those cases (i.e. considering the DateTime widgets do not support null values).

See attached test case for details.
Comment 1 Elias Volanakis CLA 2009-04-09 00:17:57 EDT
Created attachment 131361 [details]
Test Case
Comment 2 Matthew Hall CLA 2009-04-09 11:26:08 EDT
DateAndTimeObservableValue inherits its constraints from the underlying date and time observables.  Since as you stated DateTime does not support null selection this would also apply to DateAndTimeObservableValues backed by a DateTimeSelectionProperty observable.

We should change to DateTimeSelectionProperty.doSetValue to throw a more informative exception if a null value is passed in.
Comment 3 Matthew Hall CLA 2009-04-09 11:51:33 EDT
Created attachment 131409 [details]
Fix with tests
Comment 4 Matthew Hall CLA 2009-04-09 11:53:26 EDT
Fix released to HEAD > 20090409
Comment 5 Elias Volanakis CLA 2009-04-09 16:13:09 EDT
Thanks for the clarification and fix.

I'm reopening, to contribute an enhancement to the javadoc of DateAndTimeObservable related to this bug. I found the original javadoc confusing, because it gives impression that null is an acceptable value.

Hope this helps,
Elias.

Comment 6 Elias Volanakis CLA 2009-04-09 16:15:04 EDT
Created attachment 131454 [details]
Javadoc patch for DateAndTimeObservable
Comment 7 Matthew Hall CLA 2009-04-10 13:17:01 EDT
The javadoc changes in your patch are not accurate.  Setting a null value does not necessarily cause a RuntimeException, even though that is a possibility.  It depends on the underlying date and time observables.

For example the CalendarCombo project in Nebula has a "None" button so in that case DateAndTimeObservableValue would work fine with a null value.
Comment 8 Matthew Hall CLA 2009-04-10 13:29:08 EDT
The javadoc changes in your patch are not accurate.  Setting a null value does not necessarily cause a RuntimeException, even though that is a possibility.  It depends on the underlying date and time observables.

For example the CalendarCombo project in Nebula has a "None" button so in that case DateAndTimeObservableValue would work fine with a null value.
Comment 9 Elias Volanakis CLA 2009-04-13 21:51:16 EDT
Created attachment 131726 [details]
Javadoc patch

Hi Matthew,

thanks for your input. I did not consider the fact that different widgets may or may not support null. 

Still I think it is important to document that restrictions do exist. I've also added some clarifying remarks regarding binding to only one widget, as you suggested in Bug #169876.

Attaching patch...
Comment 10 Matthew Hall CLA 2009-04-17 21:05:47 EDT
Released to HEAD > 20090417

Thanks Elias for the patch!  And thanks for not giving up earlier :)