Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 256543 - [DataBinding] SWTObservables.observeText(SWT.DefaultSelection)
Summary: [DataBinding] SWTObservables.observeText(SWT.DefaultSelection)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Matthew Hall CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 133548 156264 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-25 23:57 EST by Al B CLA
Modified: 2009-03-13 01:04 EDT (History)
6 users (show)

See Also:


Attachments
Snippet008ComputedValue (4.70 KB, text/plain)
2008-11-25 23:59 EST, Al B CLA
no flags Details
Patch with tests (25.19 KB, patch)
2009-01-24 12:11 EST, Matthew Hall CLA
no flags Details | Diff
mylyn/context/zip (5.08 KB, application/octet-stream)
2009-01-24 12:11 EST, Matthew Hall CLA
no flags Details
Update (27.55 KB, patch)
2009-01-24 12:43 EST, Matthew Hall CLA
no flags Details | Diff
mylyn/context/zip (27.79 KB, application/octet-stream)
2009-01-24 12:43 EST, Matthew Hall CLA
no flags Details
Snippet008 patch against HEAD (2.37 KB, patch)
2009-01-24 12:48 EST, Matthew Hall CLA
no flags Details | Diff
mylyn/context/zip (30.28 KB, application/octet-stream)
2009-01-24 12:48 EST, Matthew Hall CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Al B CLA 2008-11-25 23:57:02 EST
Currently, SWTObservables.observeText does not support the SWT.CR event type so the model is not updated when the users presses the enter/return key.  The attached snippet throws the following exception:

Exception in thread "main" java.lang.IllegalArgumentException: UpdateEventType [13] is not supported.
	at org.eclipse.jface.internal.databinding.swt.TextObservableValue.<init>(TextObservableValue.java:123)
	at org.eclipse.jface.internal.databinding.swt.TextObservableValue.<init>(TextObservableValue.java:105)
	at org.eclipse.jface.databinding.swt.SWTObservables.observeText(SWTObservables.java:244)
	at gov.nasa.ensemble.msl.detail.view.type.editor.Snippet008ComputedValue$1.run(Snippet008ComputedValue.java:44)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at gov.nasa.ensemble.msl.detail.view.type.editor.Snippet008ComputedValue.main(Snippet008ComputedValue.java:33)
Comment 1 Al B CLA 2008-11-25 23:59:26 EST
Created attachment 118740 [details]
Snippet008ComputedValue
Comment 2 Matthew Hall CLA 2008-11-26 10:05:27 EST
SWT.CR is a keyboard constant, whereas SWT.None and SWT.Modify are event type constants.  Shouldn't this be SWT.DefaultSelection instead?
Comment 3 Al B CLA 2008-11-26 11:43:11 EST
This might be also related to Bug 133548
	

Comment 4 Matthew Hall CLA 2008-12-08 10:22:29 EST
What is the expected behavior with observeText(SWT.DefaultSelection) if the control loses focus while changes are pending?  Update the observable?  Reverse the changes?

Comment 5 Al B CLA 2008-12-08 10:31:32 EST
In our case, it should still update the observable.
Comment 6 Matthew Hall CLA 2008-12-08 10:56:30 EST
Is transferring focus an expectation?
Comment 7 Al B CLA 2008-12-08 13:47:04 EST
Yes, transferring focus is an expectation.  However, let me clarify something regarding my previous comment since you brought a good point.

It will be ideal that when the control loses focus AND IStatus is equal to ValidationStatus.ok(), then to update the observable.  Otherwise, it should reverse the changes.

The same applies to transferring focus from one part to another.
Comment 8 Matthew Hall CLA 2009-01-21 20:37:40 EST
taking ownership
Comment 9 Matthew Hall CLA 2009-01-21 20:52:58 EST
*** Bug 156264 has been marked as a duplicate of this bug. ***
Comment 10 Matthew Hall CLA 2009-01-23 20:27:07 EST
Boris, +1 to support observeText(SWT.DefaultSelection)?  Changes will fire on either SWT.DefaultSelection or SWT.FocusOut
Comment 11 Boris Bokowski CLA 2009-01-24 08:53:02 EST
How about a new method observeText(Control, int[]) so that clients can pass both DefaultSelection and FocusOut?
Comment 12 Matthew Hall CLA 2009-01-24 10:09:57 EST
(In reply to comment #11)
> How about a new method observeText(Control, int[]) so that clients can pass
> both DefaultSelection and FocusOut?

Ok
Comment 13 Matthew Hall CLA 2009-01-24 12:11:02 EST
Created attachment 123631 [details]
Patch with tests
Comment 14 Matthew Hall CLA 2009-01-24 12:11:05 EST
Created attachment 123632 [details]
mylyn/context/zip
Comment 15 Matthew Hall CLA 2009-01-24 12:43:42 EST
Created attachment 123635 [details]
Update

SWTVetoableValueDecorator was causing problems (calling decorated.getValue() on verify short-circuited the value change on the decorated observable
Comment 16 Matthew Hall CLA 2009-01-24 12:43:47 EST
Created attachment 123636 [details]
mylyn/context/zip
Comment 17 Matthew Hall CLA 2009-01-24 12:48:05 EST
Created attachment 123637 [details]
Snippet008 patch against HEAD
Comment 18 Matthew Hall CLA 2009-01-24 12:48:08 EST
Created attachment 123638 [details]
mylyn/context/zip
Comment 19 Matthew Hall CLA 2009-01-24 12:51:36 EST
Released to HEAD > 20090124
Comment 20 Boris Bokowski CLA 2009-01-24 23:46:37 EST
*** Bug 133548 has been marked as a duplicate of this bug. ***
Comment 21 Al B CLA 2009-02-26 16:55:56 EST
Matt, I know this was targeted for 3.5 M5, however, by any chance has it made into 3.4.2?
Comment 22 Matthew Hall CLA 2009-02-26 18:33:11 EST
This did not go in to 3.4.2, sorry.
Comment 23 Matthew Hall CLA 2009-03-13 01:04:25 EDT
*** Bug 133548 has been marked as a duplicate of this bug. ***