Full list of in-depth articles -
Feedback and questions -
Request demo -
Generate Series 60 Java apps with SoProMach
1
| The sample ShoppingList application |
|
2
| A grocery shopping list application |
|
3
| Generating and building the applications |
|
4
| A plumbing shopping list application |
|
5
| Machine-made Java source code |
|
5.1
| Grocery Shopping List |
|
5.2
| Plumbing Shopping List |
|
6
| Importing the machine-made code into JBuilder X |
|
A previous article introduced a generator of C++
form editing applications for the Series 60 Platform,
built on the Symbian OS, which is currently the leading smartphone
platform in the world.
This article describes a similar generator,
producing Java shopping list applications for
the same platform.
Both Series 60 generators produce fully functioning applications
that run on the Series 60 emulator, starting from the same type
of input model.
The reference development environment for this article is the
Series 60 2nd Edition SDK for Symbian OS Supporting Feature Pack 2 for MIDP.
Within the J2ME (Java 2 Mobile Edition) context,
MIDP stands for Mobile Information Device Profile: see
java.sun.com/products/midp for more information.
The Series 60 MIDP SDK is available
after registration on www.forum.nokia.com. It contains
several example applications, one of which is the ShoppingList Example
used for the custom-made generator described in this article.
The ShoppingList example application
handles a shopping list, containing an unsorted
list of items, and the quantity required. As things are
purchased the user can remove them from the list. The pictures below
show the editing functions of the application.
The example makes use of the standard MIDP application framework
and LCDUI API, and demonstrates how to open and save
an RMS (Record Management System) database,
using the java.io package to store a class as a byte array.
The class diagram of this application is shown in the figure below,
taken from the SDK documentation.
Figure 3 - ShoppingList: Class diagram
In a way, the above class diagram defines a class, or macroclass, of
form applications. The custom-made generator here described
produces complete applications belonging to this macroclass. This
generator is hereinafter referred to as SoProMach/S60JslGen, which stands
for Java Shopping List Generator.
The original ShoppingList contains all basic functions necessary to
build different types of shopping lists. Additional functions on top
of those functions
provide a more user-friendly interface, allowing for instance to quickly
create pre-prepared lists of shopping items, as shown below.
Once the selected groups have been added to the shopping list, it is possible to
edit the quantities of individual shopping items by clicking on the "Ok"
button, as the following pictures show.
After choosing the quantities for each desired shopping item, the
"Compact list" function allows to delete all items with a zero quantity,
thus producing the desired shopping list, as shown below.
It is of course possible to add specific items by typing in the item
name and the related quantity, as the next picture shows.
Figure 11 - Hand-added item
How can a developer produce the application above with SoProMach/S60JslGen? How can
the application's pre-prepared lists be designed and described?
SoProMach is a purely textual software production machine, and so
are the custom generators built on top of it.
Therefore to "configure" the generation job, the
developer writes one or more textual files. Several formats are accepted
by SoProMach: Somusar/EF (see below), XML, CSV,
or ad-hoc domain-specific languages (DSL).
For this specific SoProMach/S60JslGen generator, the only
input required is an EF (entity file) description as the one
shown below.
Figure 12 - Input to the generator: "grocery.ef"
Note that this is the same input format used for the
Series 60 C++ form application generator: this format
is independent of the target language and platform. In fact,
readers unfamiliar with EF files may view different examples in different
contexts, such as the entity files of
the Eclipse-driven Java/JSP/DAO Struts generator.
The Grocery Shopping List application described in the previous paragraph
is generated and built in a
completely automatic fashion starting from "grocery.ef": no hand-edits
whatsoever are required to build it. In fact, SoProMach/S60JslGen itself
runs the commands of the build environment (compile, preverify),
as shown in the next picture.
Figure 13 - Generating and building
Each EF input file drives the generation of three Java classes, conforming
to the class diagram of the original ShoppingList example application.
Now that the software production mechanism is in place, it is easy
to create new applications by simply creating new EF files, as the one
shown below.
Figure 14 - Input to the generator: "plumbing.ef"
When the EF file is ready, re-running SoProMach/S60JslGen results in a new
application. The Plumbing Shopping List
application is shown in the screenshots below.
The links to the code files generated by SoProMach/S60JslGen for the two
applications are listed below. The code looks very similar to the
code of the original Shopping List example application.
The generated Java code can be easily imported
into IDEs such as Borland JBuilder X. SoProMach-based
generators can be integrated with any IDE providing support for external tool
invocation: see examples of
integration with Eclipse and
with Visual Basic Express 2005 Beta.
While creating with JBuilder X the new project that will host the
machine-made code, the J2ME libraries from
the Series 60 MIDP SDK need to be added as shown in the picture below.
Figure 18 - Adding the J2ME library
Afterwards, a new package is created, and the generated Java classes are
added to the project as the following pictures show.
Figure 19 - Creating a new package
Figure 20 - Adding the machine-made Java code
Figure 21 - Source code in place
Building the project results in the "Build succedeed" status message
shown at the bottom of the JBuilder X screenshot below.
Figure 22 - Building the application
Among other advantages resulting from using JBuilder X, it is also possible
to browse through the package documentation generated by JBuilder X, as shown below.
Figure 23 - Viewing the package documentation
Written on 30 March 2005
Full list of in-depth articles -
Feedback and questions -
Request demo -
|