Home » Eclipse Projects » Eclipse Platform » [DataBinding] AssertionFailedException: "null argument" when using DataBindingContext's de
| | |
Re: [DataBinding] AssertionFailedException: "null argument" when using DataBindingContext' [message #332597 is a reply to message #332592] |
Thu, 30 October 2008 15:19 |
Matthew Hall Messages: 368 Registered: July 2009 |
Senior Member |
|
|
Wrap you app's main() instructions in a call to:
The default realm is set using a call to Realm.runWithDefault(Realm,
Runnable). The default realm is set while the runnable is running, and
is set to the previous realm after the runnable completes.
Most of my apps have a main method that looks like this:
Display display = new Display();
Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
public void run() {
// create and open main application window
}
});
Matthew
Sebastian Paul wrote:
> Databinding is triggered by a PropertyChangeListener. I can workaround
> my problem by databinding on the UI thread.
>
> public void propertyChange(PropertyChangeEvent evt) {
> [...]
> getDisplay().asyncExec(new Runnable() {
> public void run() {
> bind(notifier);
> }
> });
> }
>
> protected void bind(PropertyChangeNotifier notifier) {
> dataBindingContext = new DataBindingContext(); // PROBLEM HERE
> dataBindingContext.bindValue(
> SWTObservables.observeText(myText, SWT.Modify),
> BeansObservables.observeValue(notifier, "MY_PROP"),
> null, null);
> [...]
> }
>
> But isn't it an implementation detail of DataBindingContext? If not,
> where do I find information about the Realm stuff?
>
> Kind regards, Sebastian
>
|
|
| | |
Re: [DataBinding] AssertionFailedException: "null argument" when using DataBindingContext' [message #332616 is a reply to message #332600] |
Fri, 31 October 2008 16:06 |
Boris Bokowski Messages: 272 Registered: July 2009 |
Senior Member |
|
|
The workbench sets the default realm for you (or you can use
Realm.runWithDefault) but this will only set the default realm for the UI
thread. If you start other threads (directly, or through scheduling a Job,
or IRunnableContext.run), welcome to the wonderful world of multi-threaded
programming where you start having to worry about things that you didn't
even know existed before.
What exactly are you trying to do in your runnable? It will be executed by a
separate thread. From that thread, you cannot just access observables and a
data binding context that was created using the default realm, like you
cannot just call methods on SWT widgets.
Have a look at this wiki page, does it explain what's going on?
http://wiki.eclipse.org/JFace_Data_Binding/Realm
If not, what questions does it leave open?
Boris
"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gecisc$2rv$1@build.eclipse.org...
> The workbench already does this when to starts up.
>
> Tom
>
> Sebastian Paul schrieb:
>> Matthew Hall wrote:
>>> Wrap you app's main() instructions in a call to:
>>>
>>> The default realm is set using a call to Realm.runWithDefault(Realm,
>>> Runnable). The default realm is set while the runnable is running,
>>> and is set to the previous realm after the runnable completes.
>>>
>>> Most of my apps have a main method that looks like this:
>>>
>>> Display display = new Display();
>>> Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
>>> public void run() {
>>> // create and open main application window
>>> }
>>> });
>>
>> Ah thank you, the missing piece.
>> We have an RCP application here. Any idea who to do it in an elegant way?
>>
>> I'm still lacking good documentation. I found some short tutorials
>> covering just the basics.
>>
>> Kind regards, Sebastian
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
|
|
|
Re: [DataBinding] AssertionFailedException: "null argument" when using DataBindingContext' [message #332617 is a reply to message #332616] |
Fri, 31 October 2008 16:07 |
Boris Bokowski Messages: 272 Registered: July 2009 |
Senior Member |
|
|
It might help if you can post a code snippet, or at least describe in detail
what you are trying to do.
"Boris Bokowski" <Boris_Bokowski@ca.ibm.com> wrote in message
news:gefaef$bd0$1@build.eclipse.org...
> The workbench sets the default realm for you (or you can use
> Realm.runWithDefault) but this will only set the default realm for the UI
> thread. If you start other threads (directly, or through scheduling a Job,
> or IRunnableContext.run), welcome to the wonderful world of multi-threaded
> programming where you start having to worry about things that you didn't
> even know existed before.
>
> What exactly are you trying to do in your runnable? It will be executed by
> a separate thread. From that thread, you cannot just access observables
> and a data binding context that was created using the default realm, like
> you cannot just call methods on SWT widgets.
>
> Have a look at this wiki page, does it explain what's going on?
> http://wiki.eclipse.org/JFace_Data_Binding/Realm
>
> If not, what questions does it leave open?
>
> Boris
>
> "Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
> news:gecisc$2rv$1@build.eclipse.org...
>> The workbench already does this when to starts up.
>>
>> Tom
>>
>> Sebastian Paul schrieb:
>>> Matthew Hall wrote:
>>>> Wrap you app's main() instructions in a call to:
>>>>
>>>> The default realm is set using a call to Realm.runWithDefault(Realm,
>>>> Runnable). The default realm is set while the runnable is running,
>>>> and is set to the previous realm after the runnable completes.
>>>>
>>>> Most of my apps have a main method that looks like this:
>>>>
>>>> Display display = new Display();
>>>> Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
>>>> public void run() {
>>>> // create and open main application window
>>>> }
>>>> });
>>>
>>> Ah thank you, the missing piece.
>>> We have an RCP application here. Any idea who to do it in an elegant
>>> way?
>>>
>>> I'm still lacking good documentation. I found some short tutorials
>>> covering just the basics.
>>>
>>> Kind regards, Sebastian
>>
>>
>> --
>> B e s t S o l u t i o n . at
>> ------------------------------------------------------------ --------
>> Tom Schindl JFace-Committer
>> ------------------------------------------------------------ --------
>
>
|
|
|
Re: [DataBinding] AssertionFailedException: "null argument" when using DataBindingContext' [message #332637 is a reply to message #332617] |
Mon, 03 November 2008 11:35 |
Sebastian Paul Messages: 106 Registered: July 2009 |
Senior Member |
|
|
Hi Boris,
thanks for the explanations. Sorry for not providing an example, but the
problem is trivial.
There's a long running operation on my model that is triggered in a
wizard using IRunnableContext.run(boolean, boolean,
IRunnableWithProgress), with fork = true. So, model changes are
definitely not run on the UI thread.
I have situations where I have to bind to a different model object or
unbind completely. For this, I have 2 methods - bind(ModelObject) and
unbind(), where the first will create the DataBindingContext and the
latter dispose it. These are called from event handlers in my UI
component class.
In another forum thread, I discussed the problem where dispose() caused
an AssertionException. I had to wrap the call like this:
dataBindingContext.getBindings().getRealm().exec(new Runnable() {
public void run() {
dataBindingContext.dispose();
dataBindingContext = null;
}
});
Similar problem in bind(). I have to make sure that it is run on the UI
thread.
What I don't fully understand: Why do I have to worry about such thing.
Shouldn't the observables take care of this?
Where do I know in which Realm I have to create the DataBindingContext?
Is it always the target's realm, and never the model's realm?
A good point for a quote from the wiki:
"To bridge between observables in different realms, use a data binding
context - you can bind two observables even if they belong to different
realms and the bindings take care of this for you by using
Realm.asyncExec() where necessary."
I just want to understand, when and why *I* have to take care.
Kind regards, Sebastian
|
|
|
Goto Forum:
Current Time: Sun Nov 10 18:11:07 GMT 2024
Powered by FUDForum. Page generated in 0.03821 seconds
|