We have problems with custom controls in design mode. SWT Designer is unable to interpret our code. For example, these error messages :
java.lang.reflect.InvocationTargetException
...
java.lang.NullException
We don't understand how the Designer works. In design mode, we just want to see and work with graphical controls (composite, text, labels...) and we don't want to know which are datas displayed in these controls.
A little example :
we have an xml property file in which are the traductions for several languages. When we set the text to the label, text, composite ... using a function, Designer is unable to display this control and generates an error (in Design Mode).
- Code: Select all
...
Label myLabel = new Label(body, "", SWT.NONE);
...
myLabel.setText(MyStaticClass.getValue("fr", "UserId"));
...
Why do you try to interpret the setText of this control ?
We understand you parse the code for displaying graphical controls, but why to try to interpret the business around this control ?
Why not to catch the error when the setText() is done and go one with the next instruction ?
If you use the Beans.isDesignTime() in your code, you know when you are in design and then do :
- Code: Select all
myLabel.setText("");
- Code: Select all
myLabel.setText(MyStaticClass.getValue("fr", "UserId"));
We think it isn't our job to differentiate in our code, portions to execute in Design Mode and others portions in Execution Mode. We should modify a lot of things in our project with your solution (...Beans.isDesignTime()...).
Have you an other solution on your side ?
Thanks a lot and have a nice day.
Kim