@PublicAPI public class PluginFactory extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
PluginFactory.PluginRecord
Stores plugin data.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CONFIG_FILE
The default config file name.
|
static java.lang.String |
NOPARAMS
No parameter panel sign in property file:
if present then no parameter panel belongs to the plugin.
|
static java.lang.String |
PRELOAD
Deprecated.
Not used.
|
static java.lang.String |
SEPARATOR
Menuitem separator in Tools menu:
if present then separator will be added to the Tools menu after the plugin menuitem.
|
Constructor and Description |
---|
PluginFactory()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static ParameterPanelHandler |
createDefaultParameterPanel(java.lang.Class pluginClass,
java.lang.String cl,
java.awt.Component parent) |
static ParameterPanelHandler |
createDefaultParameterPanel(java.lang.String cl,
java.awt.Component parent)
Creates default parameter panel based on XML config.
|
int |
getCount()
Returns the number of plugin records.
|
CalculatorPluginDisplay |
getDisplay(int index)
Gets a display object, loads it if needed.
|
java.lang.String |
getGroup(int index)
Gets the menu group for a plugin.
|
char |
getGroupMnemonic(int index)
Gets the group mnemonic for a plugin.
|
java.lang.String |
getKey(int index)
Gets the menu key for a plugin.
|
java.lang.String |
getMenu(int index)
Gets the menu string for a plugin.
|
char |
getMnemonic(int index)
Gets the menu mnemonic for a plugin.
|
OptionsPane |
getOptionsPane(int index)
Gets the options pane for a plugin, loads it if needed.
|
ParameterPanelHandler |
getParameterPanel(int index)
Gets the parameter panel for a plugin, loads it if needed.
|
CalculatorPlugin |
getPlugin(int index)
Gets a plugin, loads it if needed.
|
int |
getPluginIndex(java.lang.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)
Returns
true if plugin has parameter panel,
false otherwise. |
boolean |
isOptionsPaneLoaded(int index)
Returns
true is options pane is loaded for plugin,
false otherwise. |
void |
load()
Loads default property file.
|
void |
load(java.util.Properties props)
Loads plugin data from properties.
|
void |
load(java.lang.String file,
java.lang.String alterfile)
Loads plugin data from property file.
|
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). |
void |
setOKActionListener(java.awt.event.ActionListener okActionListener)
Sets the "OK" button pressed action listener.
|
void |
setParentComponent(java.awt.Component parent)
Sets the parent component - this is used to set options panes positions.
|
public static final java.lang.String DEFAULT_CONFIG_FILE
@Deprecated public static final java.lang.String PRELOAD
public static final java.lang.String NOPARAMS
public static final java.lang.String SEPARATOR
public void setOKActionListener(java.awt.event.ActionListener okActionListener)
okActionListener
- is the "OK" button pressed action listenerpublic void setParentComponent(java.awt.Component parent)
parent
- is parent componentpublic static ParameterPanelHandler createDefaultParameterPanel(java.lang.String cl, java.awt.Component parent) throws PluginException
ParameterPanel
object based on the
<plugin class name>Parameters.xml
configuration XML read from CalculatorPlugin.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).
Returns null
(no paramter panel for this plugin) if the configuration XML
is not found.cl
- the full plugin class namenull
if no XML config file foundPluginException
public static ParameterPanelHandler createDefaultParameterPanel(java.lang.Class pluginClass, java.lang.String cl, java.awt.Component parent) throws PluginException
PluginException
public void load() throws PluginException
PluginException
public void load(java.lang.String file, java.lang.String alterfile) throws PluginException
key=$<plugin class name>$<plugin JAR URL>$<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. At least one of the plugin class name and the plugin JAR has to be specified, all other entries are optional. Omitted fields should be denoted by empty strings.
Creating the plugin parameter panel:
<plugin name>Parameters.xml
.
If this file is found then a generic parameter panel is generated,
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
in plugin.getParameterPanel()
.
Creating the plugin:
Plugin-Class
attribute of the JAR manifest.
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 filePluginException
- on errorpublic void load(java.util.Properties props) throws PluginException
key=$<plugin class name>$<plugin JAR URL>$<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. At least one of the plugin class name and the plugin JAR has to be specified, all other entries are optional. Omitted fields should be denoted by empty strings.
Creating the plugin parameter panel:
plugin/<plugin name>Parameters.xml
.
If this file is found then a generic parameter panel is generated,
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
in plugin.getParameterPanel()
.
Creating the plugin:
Plugin-Class
attribute of the JAR manifest.
props
- is the property object storing the plugin configurationPluginException
- on errorpublic void saveParameterSettings()
$HOME/chemaxon/<plugin class name>Parameters.properties
(Windows), or
$HOME/.chemaxon/<plugin class name>Parameters.properties
(UNIX / Linux).public int getCount()
public java.lang.String getMenu(int index)
index
- is the plugin record indexpublic java.lang.String getKey(int index)
index
- is the plugin record indexpublic char getMnemonic(int index)
index
- is the plugin record indexpublic java.lang.String getGroup(int index)
index
- is the plugin record indexpublic char getGroupMnemonic(int index)
index
- is the plugin record indexpublic boolean getSeparator(int index)
index
- is the plugin record indextrue
if separator is needed, false
otherwisepublic ParameterPanelHandler getParameterPanel(int index) throws PluginException
index
- is the plugin record indexPluginException
- on errorpublic OptionsPane getOptionsPane(int index) throws PluginException
index
- is the plugin record indexPluginException
- on errorpublic CalculatorPlugin getPlugin(int index) throws PluginException
index
- is the plugin record indexPluginException
- on errorpublic CalculatorPluginDisplay getDisplay(int index) throws PluginException
index
- is the plugin record indexPluginException
- on errorpublic boolean hasParameters(int index)
true
if plugin has parameter panel,
false
otherwise.public boolean isOptionsPaneLoaded(int index)
true
is options pane is loaded for plugin,
false
otherwise.public int getPluginIndex(java.lang.String key)
key
- is the plugin record key-1
for non-existent key