Skip to content.
MouseBIRN > CreatingPlugins
Table of Contents


Adding Plugins to the MBAT source code

These instructions are for adding and creating a new plugin in the MBAT source code. General instructions and Eclipse specific directions are given below.

If you follow the source code plugin file structure, you can run the included ant builds to automatically build and copy your plugin .zip to the correct folder. The following examples assume a new plugin MyPlugin is being added to the mbRegistrationPlugins project.

  1. Create file structure for plugin:
    1. Create a plugin folder in the project (mbRegistrationPlugins/plugins/net.nbirn.mbat.plugins.registration.MyPlugin). For Eclipse, in the "Navigator" view, choose "File->New->Folder".
    2. Create a source folder "src" in the plugin folder (mbRegistrationPlugins/plugins/net.nbirn.mbat.plugins.registration.MyPlugin/src. For Eclipse, in the "Navigator" view, choose "File->New->Folder".
    3. Create and place the plugin manifest file plugin.xml in the source folder (mbRegistrationPlugins/plugins/net.nbirn.mbat.plugins.registration.MyPlugin/src/plugin.xml)
    4. For Eclipse, add the source folder to the project: Right click on the project (mbRegistrationPlugins). Choose "New"->"Src Folder". Select the folder name by clicking "Browse" and navigate to the above source folder.
    5. For Eclipse, set the output folder for the plugin. Right-click the newly added source folder and select "Build Path->Configure Build Path". In the "Source" tab, enable "Allow output folders for source folders" by clicking the checkbox. "Output folder" will then appear under the source folders. Double click the "Output folder" item and choose "Specific output folder". Browse for the root source folder and create a classes folder ( mbRegistrationPlugins/plugins/net.nbirn.mbat.plugins.registration.MyPlugin/classes).
  2. Add the source directory to the mbRegistrationPlugins/build.xml to automatically create the .zip archive and copy it to the plugin directory:

  3. Run the ant build:
    1. For Eclipse, in the "Package Explorer" view, right-click on the build.xml file under the !mbRegistrationPlugins project
    2. Select "Run As.." --> "Ant Build"

Adding Plugins Credit

If you would like to show the plugin info on the About dialog, you can edit the plugin.xml like the following:

Example:

Parameters:

Parameter Name Description
displayName The display name of the plugin
pluginDesc The description of the plugin background or function
contact The contact info of the plugin. It can be phone number, email or http link
provider The plugin provider info e.g LONI UCLA
author The plugin authors
version The plugin build version e.g. 1.0.11
acknowledgement The acknowlegement information such as grant(s) that suppport(s) the project


Adding JAR libraries to plugins

If your plugin depends on external JAR libraries, there are 2 steps to follow:

  1. JPF allows you to specify the JAR libraries in the plugin.xml manifest (see the JPF home page http://jpf.sourceforge.net for more details). An example to add 3 libraries (RegularDiscreteDataTools.jar, ShapeTool.jar, and LandmarkWarpLibrary.jar) to a plugin is given below:

    Note that the path variable is relative to the location of the plugin.xml. If you are using the soure code file structure mentioned above, you need to create a lib folder under the src folder (ie: net.nbirn.mbat.plugins.registration.Landmark/src/lib. This lib directory will then be included in the archive which is built using the build.xml in the previous section.

  2. To get your plugin to compile in Eclipse, you will need to setup an Eclipse classpath variable if it doesn't exist already (see Setup Classpath Variable). By convention, we use the root folder of the plugins for the name the classpath variable (ie: MBREGISTRATION_PLUGINS_SRC_HOME). After the classpath variable is setup, you then have to add the JAR libraries to the project's build path: Right-click project->"Build Path"->"Configure Build Path"->"Libraries"->"Add Variable"->Select the appropriate class path variable->"Extend"->Select JAR file by navigating through the file browser->Click "OK".