Chinaunix首页 | 论坛 | 博客
  • 博客访问: 351840
  • 博文数量: 51
  • 博客积分: 2011
  • 博客等级: 大尉
  • 技术积分: 613
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-06 17:19
文章分类

全部博文(51)

文章存档

2011年(1)

2010年(3)

2009年(27)

2008年(20)

我的朋友

分类:

2009-05-17 23:50:58

 

Realm cannot be null

When I try to add an composite (made by JFace Automatic Databinding, in this case "PeopleDB.java") to an existing Shell-Application (in this case "PersonList.java"), the error-message "Realm cannot be null" appears:

Code: Select all
org.eclipse.core.runtime.AssertionFailedException: null argument:Realm cannot be null
   at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:86)
   at org.eclipse.core.databinding.observable.ChangeManager.(ChangeManager.java:36)
   at org.eclipse.core.databinding.observable.AbstractObservable.(AbstractObservable.java:28)
   at org.eclipse.core.databinding.observable.value.AbstractObservableValue.(AbstractObservableValue.java:42)
   at org.eclipse.core.internal.databinding.beans.JavaBeanObservableValue.(JavaBeanObservableValue.java:63)
   at org.eclipse.core.internal.databinding.beans.JavaBeanObservableValue.(JavaBeanObservableValue.java:52)
   at org.eclipse.core.databinding.beans.BeansObservables.observeValue(BeansObservables.java:89)
   at org.eclipse.core.databinding.beans.BeansObservables.observeValue(BeansObservables.java:69)
   at ch.clicdesign.artistadmin.simpleclient.PeopleDB.initDataBindings(PeopleDB.java:92)
   at ch.clicdesign.artistadmin.simpleclient.PeopleDB.(PeopleDB.java:70)
   at ch.clicdesign.artistadmin.simpleclient.PersonList.createContents(PersonList.java:167)
   at ch.clicdesign.artistadmin.simpleclient.PersonList.open(PersonList.java:62)


I know, there're some workarounds to replace the code made by the Automatic Databinding, but it's not a real solution.
Does anyone have the same problem or a good tip?
Thx!

Re: Realm cannot be null

The realm needs to be set up when your application starts. Composites will use the realm set up in the parent shell. If you don't have a realm set up in your shell, you need to do so.

The databinding example project provided with SWT Designer shows how to do this, or you can simply refer to the Eclipse Data Binding docs.
 
public static void main(String[] args) {
  Display display = Display.getDefault();
  Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
    public void run() {
     try {
      MainBackFrom window = new MainBackFrom();
      
      window.open();
     } catch (Exception e) {
      e.printStackTrace();
     }
    }
   });
}
阅读(2005) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~