Using Automatic Data Binding wizard [message #1173284] |
Wed, 06 November 2013 07:14  |
Eclipse User |
|
|
|
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 .
After that, everything worked fine.
[Updated on: Wed, 06 November 2013 07:16] by Moderator
|
|
|
|
Re: Using Automatic Data Binding wizard [message #1173478 is a reply to message #1173386] |
Wed, 06 November 2013 09:51  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.02934 seconds