Quick Start with the GUI Editor

Purpose

The GUI Editor application allows you to test objects created from resource bundle definitions or strings. Testing with the GUI Editor is usually much faster than testing applications that create components using the text2gui library because no restarting is necessary to see the results of changes.

Usage

The GUI Editor can be started by running bin/guieditor.exe if you're a Windows user, or running the shell script bin/guieditor if you're a UNIX user. Otherwise, you can run the GUI Editor from the command-line as follows:

java com.taco.swinger.text2gui.tools.GUIEditor

assuming that the text2gui library, the full log4j and BeanShell libraries, and guieditor.jar are in you classpath.

The following is a screenshot of the GUI Editor:

GUI Editor Screenshot


The main text window is the text of a multi-line properties file which is used to back a resource bundle. The combobox labeled "Object type" allows you to choose which converter to use -- depending on what converter is used, different types of objects can be created. If you want to test conversion from a resource bundle key, you can fill in the text field below with the name of the resource bundle key to convert. In the screenshot above, the key slider is about to be tested. If instead, you want to test conversion from a string, you can fill in the field below (be sure to select the radio button next to it, to indicate you want to convert from a string, not a resource bundle key). Once you have decided what to convert, hit either the View or Introspect button. The View button will display components, borders, colors, and fonts as the user would see them. For example, hitting View in the screenshot above results in the following window being displayed:

View screenshot

On the other hand, the Introspect button displays a tree view of the object created, by introspecting its properties. This is useful for objects that don't have visual aspect, or for viewing the precise details of an object. Hitting the Introspect button results in the following window being displayed:

Introspect screenshot

If a non-recoverable error occurs during conversion, a dialog with the stack trace will come up. If warnings occur during conversion, they will be saved in the log output. The log output can be viewed by selected Test ... Log Output from the menu. Normally, if any log output is produced, it is automatically displayed, but this can be disabled by unchecking Test ... Auto Show Log Output.

Other Features

Of course, properties files can be loaded and saved with the GUI Editor. This makes it easy to write, test, then save your component definitions.

The Look and Feel of the application, and also the components created can be changed with the View ... Look and Feel menu item. Thus you can easily see how your components will look under different Look and Feels.

Examples

The properties files in examples/ are meant to be tested with the GUI Editor.

Hints on Usage

You can view any key defined in the resource bundle, so you may decide to test your entire hierarchy or a single component at a time.

Because the GUI Editor is not your application, it does not know what keys to pass to the converter in the argument map. Thus it's a good idea to provide default values for argument map references (see Default Values). GUI Editor passes an empty, observable map to whichever converter you select, so self-managed components should work fine (although there may be some warnings about null property values, and the initial state may not be configured correctly).

Limitation

At this time, the GUI Editor is not exactly suitable for testing localized resource bundles, although there is a workaround. Suppose you want to test a bundle has the filename "CP/foo/bar/MyResourceBundle_es.properties", for the Spanish locale. CP represents one of the directories in your classpath. Unfortunately, since the GUI Editor converts the contents of the main window into a base resource bundle, without regard for the filename, the resource bundle you are testing won't inherit the keys of "CP/foo/bar/MyResourceBundle.properties". To work around this problem, set the parentBundle property to the name of the base resource bundle. In this example, you would add the line

parentBundle=foo.bar.MyResourceBundle

to the resource bundle you are editing. This will allow the current resource bundle to inherit the keys of foo.bar.MyResourceBundle.

After testing with the GUI Editor and before saving the final file, be sure to remove the above line.