Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Using Automatic Data Binding wizard(Tip)
Using Automatic Data Binding wizard [message #1173284] Wed, 06 November 2013 12:14 Go to next message
Baruch Youssin is currently offline Baruch YoussinFriend
Messages: 29
Registered: April 2013
Junior Member
I wanted to share one thing I have learned about the Automatic Data Binding wizard
(Help: WindowBuilder Pro User Guide > Wizards > SWT/JFace/RCP > Data Binding > Automatic Data Binding Wizard).

I created my project using SWT/JFace Java Project wizard.

When I chose extending the Composite class in the Automatic Data Binding wizard (i.e., I chose my SuperClass to be Composite rather than Shell) and did everything as directed, my program did not run; it threw a null pointer exception. When I chose a Shell class, the code ran fine. (I did not try extending Dialog; if it misses the code below, it needs to be added manually.)

The reason was that I was missing the realm code in my main(..) method.

My solution was to copy the code created by the wizard for the Shell case. Another source for this is the code of the tutorial
help: WindowBuilder Pro User Guide > Tutorials > SWT/JFace Data Binding Example.
The code can be found in
http://help.eclipse.org/kepler/topic/org.eclipse.wb.rcp.doc.user/html/features/swt/data_binding/DataBindingTest.zip

What I did, was replacing the code
                try {
                   MyClassName window = new MyClassName();
                    window.open();
                } catch (Exception e) {
                    e.printStackTrace();
                }
by the code
        Display display = new Display();
        Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable(){
            public void run(){
                try {
                    MyClassName window = new MyClassName();
                    window.open();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

in
main(..)
.
After that, everything worked fine.

[Updated on: Wed, 06 November 2013 12:16]

Report message to a moderator

Re: Using Automatic Data Binding wizard [message #1173386 is a reply to message #1173284] Wed, 06 November 2013 13:37 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
The behavior you are seeing is quite intentional. Since Composites aren't intended to be main windows, WB does not generate any realm code for them. If you create a main window that uses data binding, WB will generate the realm code for you. If you create a main window without data binding or create a main() somewhere else, you need to create the data binding realm on your own. That would be a case where understanding the data binding framework itself is important.
Re: Using Automatic Data Binding wizard [message #1173478 is a reply to message #1173386] Wed, 06 November 2013 14:51 Go to previous message
Baruch Youssin is currently offline Baruch YoussinFriend
Messages: 29
Registered: April 2013
Junior Member
Eric, Thanks!
I understand that the automatic data binding wizard did not know in which shell I would eventually embed my composite and thus could not insert the realm code in it.
I hope that my post may be helpful to beginning users like me.
Previous Topic:Unexpected internal error
Next Topic:Eclipse WindowBuilder
Goto Forum:
  


Current Time: Fri Mar 29 06:08:44 GMT 2024

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

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

Back to the top