Using Automatic Data Binding wizard [message #1173284] |
Wed, 06 November 2013 12:14 |
Baruch Youssin 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 .
After that, everything worked fine.
[Updated on: Wed, 06 November 2013 12:16] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03579 seconds