Difference between revisions of "Software Development Kit"
Line 21: | Line 21: | ||
We will create an example plugin that is simply called <tt>test</tt>. This will be a very simple visualization plugin that just displays a blank blue region. | We will create an example plugin that is simply called <tt>test</tt>. This will be a very simple visualization plugin that just displays a blank blue region. | ||
− | + | === Setting the Plugin Name === | |
+ | |||
+ | In the provided <tt>build.xml</tt>, this line can be found near the beginning of the file: | ||
<property name="component" value="noname"/> | <property name="component" value="noname"/> | ||
Line 30: | Line 32: | ||
This specifies the name of our component, which is used for all build products. | This specifies the name of our component, which is used for all build products. | ||
− | + | ||
+ | === Adding Source === | ||
+ | |||
+ | Next, a single .java source file is added to the org.organization.test package. The file <tt>TestComponent.java</tt> goes in the <tt>src/org/organization/test</tt> and has the following contents: | ||
package org.organization.test; | package org.organization.test; | ||
Line 40: | Line 45: | ||
/** | /** | ||
+ | * A simple component for demonstration purposes. | ||
+ | * | ||
* @author John Watkinson | * @author John Watkinson | ||
*/ | */ | ||
Line 56: | Line 63: | ||
} | } | ||
− | + | If the component required any .jar files, those would be added to the <tt>lib</tt> directory. | |
+ | |||
+ | === Configure Plugin === | ||
+ | |||
+ | The configuration file for the Developer Kit is called <tt>minimal.xml</tt> and it is in the <tt>conf</tt> directory. The following directive is added: | ||
<plugin id="testPanel" name="Test Panel" class="org.organization.test.TestComponent" source="test"> | <plugin id="testPanel" name="Test Panel" class="org.organization.test.TestComponent" source="test"> | ||
Line 62: | Line 73: | ||
</plugin> | </plugin> | ||
− | + | === Running the Plugin in geWorkbench === | |
+ | |||
+ | The plugin will now appear when the application is run. It can be run with the command: | ||
ant run | ant run | ||
− | + | === Releasing the Plugin === | |
+ | |||
+ | Satisfied with the plugin, it can now be released by running: | ||
ant gear | ant gear | ||
This creates the file <tt>test.gear</tt>. A .gear file is the geWorkbench analogue of a .war file for a web application. Is a bundled plugin that can deployed to a geWorkbench install by placing the file in the <tt>components</tt> directory. A configuration directive (such as the one above) would also need to be added to the configuration file to activate the plugin. | This creates the file <tt>test.gear</tt>. A .gear file is the geWorkbench analogue of a .war file for a web application. Is a bundled plugin that can deployed to a geWorkbench install by placing the file in the <tt>components</tt> directory. A configuration directive (such as the one above) would also need to be added to the configuration file to activate the plugin. |
Revision as of 13:29, 1 February 2006
The Developer Kit is a self-contained package that facilitates the process of developing plugins for geWorkbench.
Contents
Using the Developer Kit
The Developer Kit is available as a .zip file. Unzip it in to a directory of your choice, then follow the instructions below to create a geWorkbench plugin.
The high-level steps for creating, testing and releasing a plugin are as follows:
- Edit the provided Apache Ant build script to specify the name of your plugin.
- Add the .java source files for your plugin to the src directory.
- Add any .jar libraries that your plugin requires to the lib directory.
- Run ant to build your plugin.
- Edit the geWorkbench configuration file to add a directive for your new plugin.
- Run geWorkbench with ant run to test your plugin.
- Once satisfied with your plugin, use the provided utility to package your plugin in to a single file for distribution.
The next section will illustrate the above steps with an example.
An Example Plugin
We will create an example plugin that is simply called test. This will be a very simple visualization plugin that just displays a blank blue region.
Setting the Plugin Name
In the provided build.xml, this line can be found near the beginning of the file:
<property name="component" value="noname"/>
The line is changed to:
<property name="component" value="test"/>
This specifies the name of our component, which is used for all build products.
Adding Source
Next, a single .java source file is added to the org.organization.test package. The file TestComponent.java goes in the src/org/organization/test and has the following contents:
package org.organization.test; import org.geworkbench.engine.config.VisualPlugin; import javax.swing.*; import java.awt.*; /** * A simple component for demonstration purposes. * * @author John Watkinson */ public class TestComponent implements VisualPlugin { private JPanel panel; public TestComponent() { panel = new JPanel(); panel.setBackground(Color.blue); } public Component getComponent() { return panel; } }
If the component required any .jar files, those would be added to the lib directory.
Configure Plugin
The configuration file for the Developer Kit is called minimal.xml and it is in the conf directory. The following directive is added:
<plugin id="testPanel" name="Test Panel" class="org.organization.test.TestComponent" source="test"> <gui-area name="VisualArea"/> </plugin>
Running the Plugin in geWorkbench
The plugin will now appear when the application is run. It can be run with the command:
ant run
Releasing the Plugin
Satisfied with the plugin, it can now be released by running:
ant gear
This creates the file test.gear. A .gear file is the geWorkbench analogue of a .war file for a web application. Is a bundled plugin that can deployed to a geWorkbench install by placing the file in the components directory. A configuration directive (such as the one above) would also need to be added to the configuration file to activate the plugin.