|
Re: Eclipse 3.2 Databinding -> Realm is null [message #527752 is a reply to message #527749] |
Fri, 16 April 2010 11:32 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Are you running as a RCP-Application or stand-alone?
Running standalone:
-------------------
The standard trick normally is that you launch your application like this:
------------8<------------
Display d = new Display();
Shell s = new Shell();
Realm.runWithDefault(SWTObservable.getRealm(d), new Runnable() {
public void run() {
runApp();
while( ! s.isDiposed() ) {
if( ! d.readAndDispatch() ) {
d.sleep();
}
}
}
})
d.dispose();
------------8<------------
Running in RCP or EclipsePlugin:
--------------------------------
I'm not sure about when the workbench itself started using
Eclipse-Databinding but it could be that workbench-startup in 3.2 is not
wrapped inside a run block like shown above.
So if this is the case then you need wrap your code your own in a block
like the one shown above. This way always a default-realm is set which
is working on the swt-ui-thread.
Tom
Am 16.04.10 13:17, schrieb Jan:
> Hi,
>
> we work with Eclipse 3.2 and EMF 2.3 and we use the Databinding
> functionalities from Eclipse 3.4 and EMF 2.4.
>
> Now I have the problem that there isn't set a default realm. The
> following call returns "null":
> Realm testRealm = Realm.getDefault();
>
> If I set-up a DataBindingContext I get an Exception: "Validation realm
> cannot be null"
>
> Cause of that I have implemented my own Realm:
>
> public class MyTestValidationRealm extends Realm {
>
> private Realm previousRealm;
>
> public boolean isCurrent() {
> return true;
> }
>
> public MyTestValidationRealm() {
> previousRealm = super.setDefault(this);
> }
>
> protected void syncExec(Runnable runnable) {
> runnable.run();
> }
>
> public void asyncExec(Runnable runnable) {
> throw new UnsupportedOperationException("asyncExec is unsupported");
> }
>
> public void dispose() {
> if (getDefault() == this) {
> setDefault(previousRealm);
> }
> }
> }
>
>
> But with this I get an error if I want to bind some things in another
> composite:
>
> ObservableListTreeContentProvider cp = new
> ObservableListTreeContentProvider(EMFEditObservables.listFac tory(Realm.getDefault(),
> editingDomain, WebpagePackage.Literals.MY_WEB__PAGES),null);
>
> There I get the error: "Children observable collection must be on the
> Display realm"
>
> I don't thing it is a good idea for:
>
> ObservableListTreeContentProvider cp = new
> ObservableListTreeContentProvider(EMFEditObservables.listFac tory(SWTObservables.getRealm(compTreeViewer.getDisplay()),
> editingDomain, WebpagePackage.Literals.MY_WEB__PAGES),null);
>
> Cause then I have different Realms, and my BindingContext doesn't know
> anything about the other.
>
> What is wrong in this implementation and how it is right?
>
> Greetings
> Jan
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03728 seconds