Community
Participate
Working Groups
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)
Created attachment 118740 [details] Snippet008ComputedValue
SWT.CR is a keyboard constant, whereas SWT.None and SWT.Modify are event type constants. Shouldn't this be SWT.DefaultSelection instead?
This might be also related to Bug 133548
What is the expected behavior with observeText(SWT.DefaultSelection) if the control loses focus while changes are pending? Update the observable? Reverse the changes?
In our case, it should still update the observable.
Is transferring focus an expectation?
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.
taking ownership
*** Bug 156264 has been marked as a duplicate of this bug. ***
Boris, +1 to support observeText(SWT.DefaultSelection)? Changes will fire on either SWT.DefaultSelection or SWT.FocusOut
How about a new method observeText(Control, int[]) so that clients can pass both DefaultSelection and FocusOut?
(In reply to comment #11) > How about a new method observeText(Control, int[]) so that clients can pass > both DefaultSelection and FocusOut? Ok
Created attachment 123631 [details] Patch with tests
Created attachment 123632 [details] mylyn/context/zip
Created attachment 123635 [details] Update SWTVetoableValueDecorator was causing problems (calling decorated.getValue() on verify short-circuited the value change on the decorated observable
Created attachment 123636 [details] mylyn/context/zip
Created attachment 123637 [details] Snippet008 patch against HEAD
Created attachment 123638 [details] mylyn/context/zip
Released to HEAD > 20090124
*** Bug 133548 has been marked as a duplicate of this bug. ***
Matt, I know this was targeted for 3.5 M5, however, by any chance has it made into 3.4.2?
This did not go in to 3.4.2, sorry.