Custom Calculator Plugin implementation¶
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):
-
Create the plugin JAR with manifest SelectionPlugin.txt:
-
Copy the plugin JAR into the
pluginsdirectory (if thepluginsdirectory does not exist, create it in the home directory of Marvin Beans): -
Edit the
MarvinBeans/plugins/plugins.propertiesfile. Add this line to the file:
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.
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.
The JAR files that Marvin applets load have to be signed.
In the above statement, the
Installation¶
Copy the JAR file into the marvin/plugins directory.
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.
To assign your plugin to Chemaxon plugins add the following line to this file. The header of the properties file describes the syntax:
Now you are ready. In MarvinSketch/MarvinView applet the new plugin will be displayed in the Tools/Other menu.