##### Page tree

This pages gives you a walk-through on how to build a custom plugin implemenation:

# Introduction

SelectionPlugin  is a simple CalculatorPlugin descendant class written as an example for custom plugin implementation.  SelectionPluginDisplay  is the corresponding CalculatorPluginDisplay descendant class. This latter is not mandatory for a custom plugin; for most plugins the default implementation is enough, provided that the plugin implements getResultMolecule() in a way that it returns a molecule object with atomic results set in atom extra labels and molecular results in molecule properties. SelectionPluginDisplay gives an example to modify the default molecule view display: it adds a text area with some data.

SelectionPluginTest  is the test sketcher application that shows how to insert the plugin administration into your code in case when you want to use a customized GUI for plugin invocation instead of or in addition to the built-in Tools menu.

# Examples

## Marvin Beans

### Integrate the plugin into MarvinSketch/MarvinView

To integrate the SelectionPlugin into MarvinSketch/MarvinView, you need to do the following steps (you should also perform similar tasks if you have your own plugin):

1. Create the plugin JAR with manifest SelectionPlugin.txt:

jar cmf SelectionPlugin.txt SelectionPlugin.jar SelectionPlugin.class SelectionPluginDisplay.class xjars/SelectionPluginParameters.xml
2. Copy the plugin JAR into the plugins directory (if the plugins directory does not exist, create it in the home directory of Marvin Beans):

cp SelectionPlugin.jar MarvinBeans/plugins		(Linux / UNIX)
copy SelectionPlugin.jar MarvinBeans\plugins		(Windows)
3. Edit the MarvinBeans/plugins/plugins.properties file. Add this line to the file:

plugin_999=$$SelectionPlugin.jarSelectionS$$

Run MarvinSketch/MarvinView. You can run the example plugin by selecting Selection from the Tools menu.

### Run the test application

The test application can be started by running the run.sh script (Linux/Unix) or the RUN.BAT batch file (Windows).

## Marvin Applets

The steps for integrating the plugin into the MarvinSketch/MarvinView applet are:

#### Compilation

Use JAR files from Marvin Applets package for compilation of the new plugin. Since Marvin applets classes are compiled with 1.5 compatible compiler, additional code has to be compatible with 1.5 compatible JDK. To provide compatibility, set the source and the target attributes to 1.5.

javac -source 1.5 -target 1.5 -classpath "marvin/jmarvin.jar:marvin/sjars/Plugin.jar:marvin/sjars/PluginGUI.jar" SelectionPlugin.java SelectionPluginDisplay.java



#### Create JAR file

Marvin applets accept custom plugins from certain location: marvin/plugin/extensions.jar. Therefore, wrap resources for your plugin intoextensions.jar. In this example, SelectionPlugin.txt is the manifest file for the JAR file.

jar cmf SelectionPlugin.txt extensions.jar *.class xjars/SelectionPluginParameters.xml

The JAR files that Marvin applets load have to be signed.

jarsigner -keystore "<keystorepath>" -storepass <password> extensions.jar <alias>

In the above statement, the <keystorepath> is the location of the keystore file where your signing key is stored. The <password> gives the password for the keystore. The <alias> is the alias of the certification key in the keystore.

#### Installation

Copy the JAR file into the marvin/plugins directory.

cp extensions.jar marvin/plugins/.

Create your own instance of plugins.properties in the marvin/plugins directory. This properties file describes the structure of the Tools menu in MarvinSketch / MarvinView. If this file exists, it overwrites the default "Tools" menu. There is a template for plugins.properties (plugins.properties.sample.txt) in this directory. Just make a copy of it, then edit it.

cp marvin/plugins/plugins.properties.sample.txt marvin/plugins/plugins.properties

To assign your plugin to ChemAxon plugins add the following line to this file. The header of the properties file describes the syntax:

plugin999=$SelectionPlugin$extensions.jar$Selection$Slc$Other$S



Now you are ready. In MarvinSketch/MarvinView applet the new plugin will be displayed in the Tools/Other menu.