Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm
[DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336343] Tue, 09 June 2009 11:24 Go to next message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
I have an object created in a separate initialization thread. The object
contains a WritableList. Doing a Realm.getDefault() returns null because
the realm has not been set yet on that thread. However, once the
object is initialized, I want the realm to be the default SWT realm that
is created with the workbench because the change events should run on
the UI thread. The object is a model for a UI component and the UI needs
to be updated when the model changes.

How can I create an observable, perhaps with a dummy realm on one
thread, but then use the realm from the workbench/SWT? Do I need to use
a realm proxy or delegate of some sort?
Re: [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336345 is a reply to message #336343] Tue, 09 June 2009 11:34 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5434
Registered: July 2009
Senior Member
Hi,

Could you provide a small example to fully understand your problem. In
theory you could simply create your own realm and the SWT-Observables
take care that the synchronization is done appropriately when your
writable-value changes.

Please provide a completely runnable snippet!

Tom

aappddeevv schrieb:
> I have an object created in a separate initialization thread. The object
> contains a WritableList. Doing a Realm.getDefault() returns null because
> the realm has not been set yet on that thread. However, once the object
> is initialized, I want the realm to be the default SWT realm that is
> created with the workbench because the change events should run on the
> UI thread. The object is a model for a UI component and the UI needs to
> be updated when the model changes.
>
> How can I create an observable, perhaps with a dummy realm on one
> thread, but then use the realm from the workbench/SWT? Do I need to use
> a realm proxy or delegate of some sort?
Re: [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336347 is a reply to message #336345] Tue, 09 June 2009 13:00 Go to previous messageGo to next message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
Its a spring dynamic modules/OSGi services example so a snippet may not
be useful. The OSGi extender that creates application contexts for each
bundle in its own thread so when the WritableList is created, it tries
to get Realm.getDefault()which is null for that thread.

I'll test your idea though by creating a Realm and using it explicitly.
The only problem is that the initialization thread terminates so I need
a Realm that is a little smarter somehow than just running in the
initialization thread (which is not under my control).

Since spring dm is built on OSGi services, its possible that any
observable requiring a realm may have this problem if OSGi services are
started in their own thread versus a thread where the realm has been set
(such as the UI thread created when the workbench runs).


Tom Schindl wrote:
> Hi,
>
> Could you provide a small example to fully understand your problem. In
> theory you could simply create your own realm and the SWT-Observables
> take care that the synchronization is done appropriately when your
> writable-value changes.
>
> Please provide a completely runnable snippet!
>
> Tom
>
> aappddeevv schrieb:
>> I have an object created in a separate initialization thread. The object
>> contains a WritableList. Doing a Realm.getDefault() returns null because
>> the realm has not been set yet on that thread. However, once the object
>> is initialized, I want the realm to be the default SWT realm that is
>> created with the workbench because the change events should run on the
>> UI thread. The object is a model for a UI component and the UI needs to
>> be updated when the model changes.
>>
>> How can I create an observable, perhaps with a dummy realm on one
>> thread, but then use the realm from the workbench/SWT? Do I need to use
>> a realm proxy or delegate of some sort?
Re: [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336353 is a reply to message #336347] Tue, 09 June 2009 13:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5434
Registered: July 2009
Senior Member
Hi,

Do you have access to the Display or the Workbench? Then you can create
your WritableValue by using syncExec or use the SWTRealm provided to you
from SWTObservables.

Tom

aappddeevv schrieb:
> Its a spring dynamic modules/OSGi services example so a snippet may not
> be useful. The OSGi extender that creates application contexts for each
> bundle in its own thread so when the WritableList is created, it tries
> to get Realm.getDefault()which is null for that thread.
>
> I'll test your idea though by creating a Realm and using it explicitly.
> The only problem is that the initialization thread terminates so I need
> a Realm that is a little smarter somehow than just running in the
> initialization thread (which is not under my control).
>
> Since spring dm is built on OSGi services, its possible that any
> observable requiring a realm may have this problem if OSGi services are
> started in their own thread versus a thread where the realm has been set
> (such as the UI thread created when the workbench runs).
>
>
> Tom Schindl wrote:
>> Hi,
>>
>> Could you provide a small example to fully understand your problem. In
>> theory you could simply create your own realm and the SWT-Observables
>> take care that the synchronization is done appropriately when your
>> writable-value changes.
>>
>> Please provide a completely runnable snippet!
>>
>> Tom
>>
>> aappddeevv schrieb:
>>> I have an object created in a separate initialization thread. The object
>>> contains a WritableList. Doing a Realm.getDefault() returns null because
>>> the realm has not been set yet on that thread. However, once the object
>>> is initialized, I want the realm to be the default SWT realm that is
>>> created with the workbench because the change events should run on the
>>> UI thread. The object is a model for a UI component and the UI needs to
>>> be updated when the model changes.
>>>
>>> How can I create an observable, perhaps with a dummy realm on one
>>> thread, but then use the realm from the workbench/SWT? Do I need to use
>>> a realm proxy or delegate of some sort?
Re: [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336371 is a reply to message #336353] Tue, 09 June 2009 20:03 Go to previous message
No real name is currently offline No real name
Messages: 113
Registered: July 2009
Senior Member
I do not. Right now I created a simple realm that just runs in a thread.
So its not ideal but it works for the moment. I think that if you are
going to use "eclipse" level resources in OSGi services, you have to be
more thoughtful about what the dependencies mean.


Tom Schindl wrote:
> Hi,
>
> Do you have access to the Display or the Workbench? Then you can create
> your WritableValue by using syncExec or use the SWTRealm provided to you
> from SWTObservables.
Previous Topic:Downloaded Eclipse 3.4.2 JST version--but no Eclipse source plugins included.
Next Topic:Closing customized XML editor (MultiPageEditorPart) if error on XML when opening
Goto Forum:
  


Current Time: Thu Oct 30 17:45:23 GMT 2014

Powered by FUDForum. Page generated in 0.03736 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software