Thursday, June 12, 2008
Picking Arbitrary MIDlets In The Resource Editor
The Resource Editor was mentioned by Comverse as one of the most important features they saw in LWUIT and with good reason, it allows them to separate the roles of developers and designers while delegating to people who aren't necessarily technical in nature.
One of the cool features I added in the latest version of the resource editor is the ability to pick an arbitrary MIDlet to run within the preview panel for theme editing, theme preview allows us to see the theme changes applied directly to our custom MIDlet. However, like in everything there are caveats in this feature that should be clarified...
To understand the feature we need to understand how the resource editor preview works, the resource editor preview is essentially a port of LWUIT running on top of Java SE. To run the preview we load the MIDlet and invoke its startApp() method in Java SE, Since LWUIT is running as usual pretty much everything within LWUIT would work in the same way as it would on the device (although currently key events aren't handled, only mouse navigation).
What happens when you invoke a MIDP API such as RMS, GCF etc.?
Nothing, these API's are currently implemented as stubs and would just do nothing or return null/0 where appropriate. This will probably cause a problem with your code... You will need to adapt your MIDlet so it can handle this situation and load the GUI when necessary.
Furthermore, if your MIDlet tries to set the current theme it might cause minor issues but these should be easily fixable by refreshing the UI.
If there is a failure in the MIDlet the resource editor will silently load the LWUIT Demo in the preview and use it instead. To debug this you can run the resource editor in command line (java -jar editor.jar) and when you will go to the theme option you would see the stack for your MIDlet allowing you to fix this.
To use this feature do the following:
1. Make sure your MIDlet will work without networking & GCF, you can dynamically detect running under Java SE using one of the many System.getProperty() values from Java SE.
2. In the MIDlets menu select Pick MIDlet
3. Choose the Jar for your MIDlet and the specific MIDlet to run.
4. Open your theme file and select the theme