| the Apache Ant site |

| Home |
| Projects |

# Module HOW-TO

### Introduction

The purpose of this document is to provide an overview of the basic steps one must undertake to add a new module to Antidote. Please see The Antidote Design Overview for information on what a module is and how it fits into Antidote. If you've already got all that, then read on!

NB: Please submit updates and criticisms to this, particularly areas that were unclear, missing, or difficult to follow.

### Step by step

## 1) Specialize `org.apache.tools.ant.gui.core.AntModule`

All modules must inherit from the `AntModule` class. This will probably irritate some of you, but it essentially enforces inheritance from `javax.swing.JComponent` and provides encapsulated handling of the `AppContext` instance that is so important to this class.

Your module is required to implement the `AntModule.contextualize(AppContext)` method. The first thing this method should do is call `AntModule.setContext(AppContext)`, and then it is safe for it to begin constructing its display, using whatever resources it needs from the given `AppContext` instance. Think of this in a similar manner to `Applet.init()` or `Servlet.init()`.

## 2) Update `org/apache/tools/ant/gui/resources/antidote.properties`

### 2a) Externalize All Displayable Strings

All displayable strings must be externalized to the `antidote.properties` file, and looked up via the `AppContext.getResources()` method after the `AntModule.contextualize()` method has been called. Follow the naming convention currently used in the properties file and you should have to problems. This task should be done during development of your module. Under no circumstances should your module be submitted or committed without this task being completed. Remember that Antidote has an international audience.

### 2b) Add Module to List of Auto-Loaded Modules

Look for the properties with the format `org.apache.tools.ant.gui.Antidote.xxx.modules` where `xxx` is one of {left | right | top | bottom}. Depending on where you want your module to appear, and the order that you want it to appear in relationship to the other modules, add the class name of your module appropriately. If multiple modules are listed for a single property (via a comma delimited list), then each module will have it's own tab in a `javax.swing.JTabbedPane`.

NB:This goofy way of constructing the main screen will probably change to something much more general (but not as general as, say BML).

## Run it!

That should be all you need to do, at least to get your module plugged in. Check out the source code for `ProjectNavigator` and `PropertyEditor` for module examples that use the various facilities of the Antidote framework.

Copyright © 2000-2003 The Apache Software Foundation. All rights reserved.