Package com.chemaxon.calculations.gui
Class PluginFactory
java.lang.Object
com.chemaxon.calculations.gui.PluginFactory
Plugin factroy: responsible for plugin parameter panel
and plugin creation and central management.
- Since:
- Marvin 4.0
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default config file name.static final String
No parameter panel sign in property file: if present then no parameter panel belongs to the plugin.static final String
Deprecated, for removal: This API element is subject to removal in a future version.Not used.static final String
Menuitem separator in Tools menu: if present then separator will be added to the Tools menu after the plugin menuitem. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ParameterPanelHandler
createDefaultParameterPanel
(Class pluginClass, String cl, Component parent) static ParameterPanelHandler
createDefaultParameterPanel
(String cl, Component parent) Creates default parameter panel based on XML config.int
getCount()
Returns the number of plugin records.getDisplay
(int index) Gets a display object, loads it if needed.getGroup
(int index) Gets the menu group for a plugin.char
getGroupMnemonic
(int index) Gets the group mnemonic for a plugin.getKey
(int index) Gets the menu key for a plugin.getMenu
(int index) Gets the menu string for a plugin.char
getMnemonic
(int index) Gets the menu mnemonic for a plugin.getOptionsPane
(int index) Gets the options pane for a plugin, loads it if needed.getParameterPanel
(int index) Gets the parameter panel for a plugin, loads it if needed.getPlugin
(int index) Gets a plugin, loads it if needed.int
getPluginIndex
(String key) Gets a plugin index from record key.boolean
getSeparator
(int index) Gets if a separator is required after the plugin menuitem in the Tools menu.boolean
hasParameters
(int index) Returnstrue
if plugin has parameter panel,false
otherwise.boolean
isOptionsPaneLoaded
(int index) Returnstrue
is options pane is loaded for plugin,false
otherwise.void
load()
Loads default property file.void
Loads plugin data from property file.void
load
(Properties props) Loads plugin data from properties.void
Saves plugin parameter settings to file$HOME/chemaxon/<plugin class name>Parameters.properties
(Windows), or$HOME/.chemaxon/<plugin class name>Parameters.properties
(UNIX / Linux).void
setOKActionListener
(ActionListener okActionListener) Sets the "OK" button pressed action listener.void
setParentComponent
(Component parent) Sets the parent component - this is used to set options panes positions.
-
Field Details
-
DEFAULT_CONFIG_FILE
The default config file name.- See Also:
-
PRELOAD
Deprecated, for removal: This API element is subject to removal in a future version.Not used.Preload sign in property file: if present then the plugin loader and the plugin should be preloaded, otherwise both are loaded when first used.- See Also:
-
NOPARAMS
No parameter panel sign in property file: if present then no parameter panel belongs to the plugin.- See Also:
-
SEPARATOR
Menuitem separator in Tools menu: if present then separator will be added to the Tools menu after the plugin menuitem.- See Also:
-
-
Constructor Details
-
PluginFactory
public PluginFactory()Constructor.
-
-
Method Details
-
setOKActionListener
Sets the "OK" button pressed action listener. If set, the factory generates option pane with "OK" button, setting the "OK" button action command to "plugin_" and adds this action listener to the button. - Parameters:
okActionListener
- is the "OK" button pressed action listener
-
setParentComponent
Sets the parent component - this is used to set options panes positions.- Parameters:
parent
- is parent component
-
createDefaultParameterPanel
public static ParameterPanelHandler createDefaultParameterPanel(String cl, Component parent) throws PluginException Creates default parameter panel based on XML config. This is aParameterPanel
object based on the<plugin class name>Parameters.xml
configuration XML read fromCalculatorPlugin.PLUGIN_DIR
, with user parameter settings read from$HOME/chemaxon/<plugin class name>Parameters.properties
(Windows), or$HOME/.chemaxon/<plugin class name>Parameters.properties
(UNIX / Linux). Returnsnull
(no paramter panel for this plugin) if the configuration XML is not found.- Parameters:
cl
- the full plugin class name- Returns:
- the parameter panel, or
null
if no XML config file found - Throws:
PluginException
-
createDefaultParameterPanel
public static ParameterPanelHandler createDefaultParameterPanel(Class pluginClass, String cl, Component parent) throws PluginException - Throws:
PluginException
-
load
Loads default property file.- Throws:
PluginException
-
load
Loads plugin data from property file. There is a line for each plugin in the property file according to the following syntax:key=$<plugin class name>$$<menu>$<mnemonics>$<group>$<groupmnemonic>$<NOPARAMS>
The first character in the value (after the '=' sign) is the delimiter - can be any ASCII character that does not occur in the value string. The '$' character is appropriate in most cases. Plugins will be sorted by key. The plugin class name has to be specified, all other entries are optional. Omitted fields should be denoted by empty strings.Note: the second argument was originally an optional name of plugin-specific jar. We no longer use this argument, it is ignored for backward compatibility.
Creating the plugin parameter panel:
- First a configuration XML is searched in the CLASSPATH.
Its name is generated from the plugin class name without the package name:
<plugin name>Parameters.xml
. If this file is found then a generic parameter panel is generated, - otherwise the plugin should be created to fetch its specific parameter panel
by
plugin.getParameterPanel()
.
$HOME/chemaxon/<plugin name>Parameters.properties
(Windows) or$HOME/.chemaxon/<plugin name>Parameters.properties
(UNIX / Linux) if exists, otherwise default initial values are set from the configuration XML or inplugin.getParameterPanel()
.The plugin is instantiated from the current CLASSPATH by its name. Plugin and parameter panels are created as needed.
- Parameters:
file
- is the config file name as resource, relative to the CLASSPATHalterfile
- the optional config file name as resource, relative to the CLASSPATH, set it to null to prefer the default config file- Throws:
PluginException
- on error
- First a configuration XML is searched in the CLASSPATH.
Its name is generated from the plugin class name without the package name:
-
load
Loads plugin data from properties. Format:key=$<plugin class name>$$<menu>$<mnemonics>$<group>$<groupmnemonic>$<NOPARAMS>
The first character in the value (after the '=' sign) is the delimiter - can be any ASCII character that does not occur in the value string. The '$' character is appropriate in most cases. Plugins will be sorted by key. The plugin class name has to be specified, all other entries are optional. Omitted fields should be denoted by empty strings.Note: the second argument was originally an optional name of plugin-specific jar. We no longer use this argument, it is ignored for backward compatibility.
Creating the plugin parameter panel:
- First a configuration XML is searched in the CLASSPATH.
Its name is generated from the plugin class name without the package name:
plugin/<plugin name>Parameters.xml
. If this file is found then a generic parameter panel is generated, - otherwise the plugin should be created to fetch its specific parameter panel
by
plugin.getParameterPanel()
.
$HOME/chemaxon/<plugin name>Parameters.properties
(Windows) or$HOME/.chemaxon/<plugin name>Parameters.properties
(UNIX / Linux) if exists, otherwise default initial values are set from the configuration XML or inplugin.getParameterPanel()
.The plugin is instantiated from the current CLASSPATH by its name. Plugin and parameter panels are created as needed.
- Parameters:
props
- is the property object storing the plugin configuration- Throws:
PluginException
- on error
- First a configuration XML is searched in the CLASSPATH.
Its name is generated from the plugin class name without the package name:
-
saveParameterSettings
public void saveParameterSettings()Saves plugin parameter settings to file$HOME/chemaxon/<plugin class name>Parameters.properties
(Windows), or$HOME/.chemaxon/<plugin class name>Parameters.properties
(UNIX / Linux). -
getCount
public int getCount()Returns the number of plugin records.- Returns:
- the number of plugin records
-
getMenu
Gets the menu string for a plugin.- Parameters:
index
- is the plugin record index- Returns:
- the plugin menu string
-
getKey
Gets the menu key for a plugin.- Parameters:
index
- is the plugin record index- Returns:
- the menu key
-
getMnemonic
public char getMnemonic(int index) Gets the menu mnemonic for a plugin.- Parameters:
index
- is the plugin record index- Returns:
- the menu mnemonic
-
getGroup
Gets the menu group for a plugin.- Parameters:
index
- is the plugin record index- Returns:
- the menu group
-
getGroupMnemonic
public char getGroupMnemonic(int index) Gets the group mnemonic for a plugin.- Parameters:
index
- is the plugin record index- Returns:
- the menu mnemonic
-
getSeparator
public boolean getSeparator(int index) Gets if a separator is required after the plugin menuitem in the Tools menu.- Parameters:
index
- is the plugin record index- Returns:
true
if separator is needed,false
otherwise- Since:
- Marvin 5.4
-
getParameterPanel
Gets the parameter panel for a plugin, loads it if needed.- Parameters:
index
- is the plugin record index- Returns:
- the parameter panel
- Throws:
PluginException
- on error
-
getOptionsPane
Gets the options pane for a plugin, loads it if needed.- Parameters:
index
- is the plugin record index- Returns:
- the options pane
- Throws:
PluginException
- on error
-
getPlugin
Gets a plugin, loads it if needed.- Parameters:
index
- is the plugin record index- Returns:
- the plugin
- Throws:
PluginException
- on error
-
getDisplay
Gets a display object, loads it if needed.- Parameters:
index
- is the plugin record index- Returns:
- the display object
- Throws:
PluginException
- on error
-
hasParameters
public boolean hasParameters(int index) Returnstrue
if plugin has parameter panel,false
otherwise.- Returns:
- whether plugin has parameter panel
-
isOptionsPaneLoaded
public boolean isOptionsPaneLoaded(int index) Returnstrue
is options pane is loaded for plugin,false
otherwise.- Returns:
- whether potions pane is loaded for plugin
-
getPluginIndex
Gets a plugin index from record key.- Parameters:
key
- is the plugin record key- Returns:
- the plugin record index, or
-1
for non-existent key
-