Adding your own widgets

An important feature of armidale is its support for adding new widgets in a very simple manner.

Automatic code generation from XML

Each of the GUI widgets provided by armidale are implemented by a number Java classes and interfaces. For example the PushButton object is implemented by the following Java interface and classes:

interface armidale.api.gui.PushButton
class armidale.api.gui.PushButtonFactory
class armidale.api.gui.impl.clientserver.PushButtonClientImpl
class armidale.api.gui.impl.clientserver.PushButtonServerImpl
class armidale.api.gui.impl.platform.swing.PushButtonImpl

All of these interfaces and classes, with the exception of armidale.api.gui.impl.platform.swing.PushButtonImpl, are completely generated by the armidale.utilities.makeclass.Main program based on a specification provided in an XML file. See the development/src/armidale/api/gui/xml directory for XML specifications of the standard armidale GUI objects.

The Swing platform implementation

The platform implementations of a widget (eg. armidale.api.gui.impl.platform.swing.PushButtonImpl) are generated by the armidale.utilities.makeclass.Main program with empty method bodies. It is up to the widget developer to implement the bodies of these methods (ie. the swing implementation of the widget). This often involves no more than making simple calls to Swing objects. Note that special comments in the generated source file are used to identify code added by the developer so that it is not lost when widgets are regenerated.

Installing the new widget

In order to use a new widget, it need to be installed on the client and server computers. This simply involves placing the widget class files, or a jar containing the class files in a directory on the users class path. This directory is usually <install_dir>/jars.