Creating an instance of an ObservableList - java?

I am trying to understand the concept of ObservableList and Realms. I tried to create an instance of ObservableList, for example:

  public ObservableList createObservableList() {
    ObservableList myObsList = new ObservableList(new ArrayList<String>(),
        "test") {
    };

    return myObsList;
  }

But when I call this method, I get:

org.eclipse.core.runtime.AssertionFailedException: null argument:Realm cannot be null
 at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)

I understand that this is something to do, we are not set by default. But where can I find documentation on these concepts? I watched:

http://wiki.eclipse.org/JFace_Data_Binding/Observable

http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/databinding/observable/list/ObservableList.html

but it contains very limited information / examples.

I also have an Eclipse EMF book, but I cannot find examples of how to use it, for example. Observablelist

Where can I find Observable rules / concepts tutorials / documentation?

I just tried:

  public static ObservableList createObservableList() {
    ObservableList myObsList = null;
    Realm.getDefault().exec(new Runnable() {
      @Override
      public void run() {
        myObsList = new ObservableList(new ArrayList<String>(), "test") {
        };
      }
    });
    return myObsList;
  }

, myObsList . final run. ?

+3
4

Realm . , :

if (Realm.getDefault() == null) {

Realm ( ):

   Realm.setDefault(new Realm());
}

(JFace Databinding - ...)

+2

SWTObservables.getRealm(display)

Realm, . , API Realm .

+2

, , API Eclipse - , .

FAQ JFaces:

http://wiki.eclipse.org/JFace_Data_Binding_FAQ#What_is_a_Realm.2C_and_do_I_need_to_care.3F

, - , :

Realm.exec(Runnable runnable)

try creating an observable list from the Runnable block. Hope this helps.

Cm:

http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/databinding/observable/Realm.html

It would be nice if we had a convenient Eclipse URL user!

+1
source
  • Make the main class to implement Runnable inerface.
  • Move all logic to method run()
  • In a call to the static main method Realm.runWithDefault()

    Main main = new Main();  
    Realm realm = SWTObservables.getRealm(Display.getDefault());  
    //for JFace data binding  
    Realm.runWithDefault(realm, main);
    
+1
source

Source: https://habr.com/ru/post/1786663/


All Articles