(pronounced Jay-Res)
A visual builder of Java resource files

by Richard Redpath, Gennaro (Jerry) Cuomo - IBM Software Solutions Division

Date: 8/2/96, Version: Draft 1.0

Background

The JRes compiler, introduces the new concepts of Java resource files and Java resource classes. (See "JRes- A Java Resource file compiler" ). These resource classes encapsulate data and provide a natural vehicle for national language support in Java. Java resource classes can also dramatically improve the performance of loading static resources.

Typically, the people providing resource content for applications, like images, sound clips, and etc., are not the same people writing Java programs. It is probably safe to say, these graphical designers would be less comfortable with creating a resource file by writing code, then by visually building the resources.

jresVisual provides a user interface for building and maintaining Java resource files without having to actually understand the syntax or semantics of the Java language.

Introducing jresVisual

The IBM Java Resource File Builder, jresVisual, is a Java application to visually build jres (Jay-Res) format

resource files. (See figure below.) Resource files enable national language support by encapsulating the language dependent data in a Java class. The jresVisual Builder is intended for seamless usage by large community of users, including; the Java software engineer, the content designer and the information developer at the national language translation center.

Using jresVisual

The jresVisual builder produces a JRes resource file. Alternatively, it can also be used to produce a national language translation file.

To start jresVisual enter the following:

	java  ibm.jresv.jresVisual  {myresource.jrc} 

Initially the programmer starts with an empty canvas. Resource file objects are added through the toolbar or context menu provided above the canvas display area.

When saving the resource file, the blue IBM Tazza mascot (tm) should appear in a rocket ship to indicate success. At this time the filename will appear in the titlebar area. The demo version has limited saving capability. (To obtain a full version of jresVisual, contact IBM.)

Building a sample resource file

Consider the following example which will help guide you through the process of visually developing a resource file. An imaginary product called "the Super Editor" by "the Ajax company" has been defined to illustrate the usage of jresVisual. The Super Editor is to have a menubar, which contains the standard "File" and "Edit" menubar items. A resource file will be used to title the product (title text string), display a logo and display a menubar.

First, select the PACKAGENAME toolbar icon to create a package name. The package name will be "ajax.editor" and corresponds to the desired Java class package.

Next, the IMAGE toolbar icon is selected to create the product logo. The logo image will be "ajax.gif". (jresVisual supports both GIF and JPEG image formats.) Right click on the image object to access the context menu. Select "Properties" to change the default ID from "????" to "Logo".

Next, the STRINGTABLE toolbar icon is selected to create a STRINGTABLE which will be used to contain the product title. The fields are filled in as shown below, then the apply button is pressed to apply the changes.

Finally, a menu is created by selecting the MENU toolbar icon. The default menu name is "root.". The "File" pane is added to the "root" pane by adding "100" to the "ID" field and "File" to the "Name" field found at the top of the Menu Properties dialog. Continue populating the menu by pressing the "Add" button for each node in the elastic node canvas. The apply button is pressed to apply the changes.

Now that all object have been created, we are ready to save the visual resource file into a physical JRes resource file. This is done by selecting the "SAVE AS" toolbar icon. At this time you be presented with a file dialog allowing you to specify the name of your resource file. For example, the following demo saves to the file "editordata.jrc".


-----------------------------------------------------
PACKAGENAME  ajax.editor

IMAGE  Logo  ajax.gif

STRINGTABLE
   product    Super Editor
ENDSTRINGTABLE

MENU root
   SUBMENU 100    File
      MENUITEM 101   Open..
      MENUITEM 102   Save..
      MENUITEM 103   Save as...
   ENDSUBMENU

   SUBMENU 200    Edit
      MENUITEM 201 Cut
      MENUITEM 202 Copy
      MENUITEM 203 Paste
   ENDSUBMENU
ENDMENU
-----------------------------------------------------

Now the visual resource file is ready for compilation by the JRes compile. Use the Jres compiler to compile.

	java      ibm.jres.jres      editordata.jrc
Once compiled an "editordata.class" file is created and ready to be used by the Super Editor Java application.

Adding a national language translation file

The "editordata.jrc" file (created above) contains "hard coded" strings for both product name and menu text. Unfortunately, these hard coded strings will make it very difficult for a translation center to translate the string information into other national languages. A need exists for a way to localize strings. jresVisual provides support which will assist a translation center. This feature is enabled through the INCLUDE and DEFINE toolbar icons.

So, to continue our example, we build a translation file (which is really just a resource file containing only DEFINE keywords). The toolbar icon "New" is selected to start the creation of a translation file. The DEFINE toolbar icon is selected which shows the properties sheet for a DEFINE table. The following fields are added to this sheet and the apply button is pressed.

.

The translation (resource) file is saved as "editor.pii.", producing the following results:


--------------------------------------------
DEFINE STR_PRODUCT  Super Editor
DEFINE STR_FILE     File
DEFINE STR_OPEN     Open..
DEFINE STR_SAVE     Save..
DEFINE STR_SAVEAS   Save as..
DEFINE STR_EDIT     Edit
DEFINE STR_CUT      Cut
DEFINE STR_COPY     Copy
DEFINE STR_PASTE    Paste
--------------------------------------------

Then the "editordata.jrc" file is edited again, using the toolbar icon "Open", to load the file. The resource file is modified as seen below with symbolic names for the STRINGTABLE and MENU text. This can be done visually by right clicking on the menu object and editing it's properties via the properties dialog. The same can be done for the "Product" text string.


STRINGTABLE
   Product    STR_PRODUCT
ENDSTRINGTABLE

MENU root
   SUBMENU 100   STR_FILE
      MENUITEM 101   STR_OPEN
      MENUITEM 102   STR_SAVE
      MENUITEM 103   STR_SAVEAS
   ENDSUBMENU

   SUBMENU 200   STR_EDIT
      MENUITEM 201 STR_CUT
      MENUITEM 202 STR_COPY
      MENUITEM 203 STR_PASTE
   ENDSUBMENU
ENDMENU

Lastly, the toolbar icon "INCLUDE" is selected and the editor.pii file is included which reconciles the STRINGTABLE and MENU information in real-time. The "editordata.jrc" file is saved which is the following file.


PACKAGENAME  ajax.editor

INCLUDE      editor.pii

IMAGE  Logo     ajax.gif

STRINGTABLE
   Product    STR_PRODUCT
ENDSTRINGTABLE

MENU main

   SUBMENU 100   STR_FILE
      MENUITEM 101   STR_OPEN
      MENUITEM 102   STR_SAVE
      MENUITEM 103   STR_SAVEAS
   ENDSUBMENU

   SUBMENU 200   STR_EDIT
      MENUITEM 201 STR_CUT
      MENUITEM 202 STR_COPY
      MENUITEM 203 STR_PASTE
   ENDSUBMENU

ENDMENU
Now the visual resource file is ready for compilation by the JRes compiler again. Use the Jres compiler to compile.
	java      ibm.jres.jres      editordata.jrc

Once compiled an "editordata.class" file is created and ready to be used by the Super Editor Java application.