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 appropriate, provided that the plugin implements getResultMolecule() such 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.
To integrate the SelectionPlugin into MarvinSketch / MarvinView you need to accomplish the following steps (you should also perform similar tasks if you have your own plugin):
jar cmf SelectionPlugin.txt SelectionPlugin.jar SelectionPlugin.class SelectionPluginDisplay.class xjars/SelectionPluginParameters.xml
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)
MarvinBeans/plugins/plugins.properties
file. Add this line to the file
(see configuration file description):
plugin_999=$$SelectionPlugin.jar$Selection$S$$
Run MarvinSketch / MarvinView. You can run the example plugin by selecting Selection
from the Tools menu.
The test application can be started by running the run.sh script (Linux / Unix) or the RUN.BAT batch file (Windows).
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 compile 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
Marvin applets accept custom plugins from certain location: marvin/plugin/extensions.jar
. Therefore, wrap resources for your plugin into extensions.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.
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 about it, and edit it.
cp marvin/plugins/plugins.properties.sample.txt marvin/plugins/plugins.properties
To assign your plugin to ChemAxon plugins, gave 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 display in the Tools/Other menu.