Purpose of DataBindingContext's validation realm [message #334106] |
Wed, 21 January 2009 03:19  |
Eclipse User |
|
|
|
Hi,
the question below was asked in Topic "Databinding and
ISelectionChanged" in Newsgroup eclipse.tools.emf, where it was OT.
Tom Schindl wrote:
> Hi Jan,
>
> Well the purpose of Realms is to sync between different threads for
> example if you set a Model-Value from a none-ui-thread the purpose of
> the Realm used by SWT-Observable is to sync back to the UI-Thread when
> setting the attribute on the SWT widget.
Hi Tom,
I still don't understand the purpose of the DataBindingContext's
validation realm. Could you explain, please?
Kind regards, Sebastian
|
|
|
|
|
Re: Purpose of DataBindingContext's validation realm [message #334160 is a reply to message #334151] |
Thu, 22 January 2009 12:25   |
Eclipse User |
|
|
|
Sebastian Paul wrote:
> But where do I know which Realm I have to use for it? Currently my calls
> run on the display thread, so everything works. But I don't know why.
You can use any realm, but it's usually easier to use the display realm
since some of our support classes aren't yet designed to cope with other
realms (WizardPageSupport for example).
> What happens when there are Bindings between SWT (needs the display
> thread) and an arbitrary model that runs in another thread?
Bindings are designed to handle this. Here is how the update pipeline
works:
Assuming the following:
Realm displayRealm = SWTObservables.getRealm(text.getDisplay());
Realm workerRealm = new WorkerRealm(workerThread); // custom realm
bindingContext.bindValue(
// displayRealm is implied for SWT and Viewer observables
SWTObservables.observeText(text, SWT.Modify),
BeansObservables.observeValue(workerRealm, company, "name"));
When a user makes changes in the text field, here is what happens:
display realm:
get new value from text observable (source)
validate value using after-get validator (see UpdateValueStrategy)
convert value if there is a convert
validate converted value using after-convert validator
validate again using before-set validator
jump to the other realm using realm.exec()
worker realm:
set the new, converted value on the bean observable (target)
This same process works in reverse if the model observable changes.
(Note that Realm.exec() is asynchronous--this is how we avoid deadlocks)
> Is it possible to mix bindings of any type, or does this depend on the
> Realm of the DBC?
Any combination of realms is allowed for the model observable, target
observable and validation realm of the DataBindingContext.
Hope this helps,
Matthew
|
|
|
|
Powered by
FUDForum. Page generated in 0.14909 seconds