| 
| [DataBinding] Have WritableList created in separate init thread, but want SWT default Realm [message #336343] | Tue, 09 June 2009 07:24  |  | 
| Eclipse User  |  |  |  |  | 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 09:11   |  | 
| Eclipse User  |  |  |  |  | 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 16:03  |  | 
| Eclipse User  |  |  |  |  | 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.
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03488 seconds