chemaxon.marvin.plugin
Class CommandPlugger

java.lang.Object
  extended by chemaxon.marvin.plugin.CommandPlugger
All Implemented Interfaces:
java.io.Serializable

public class CommandPlugger
extends java.lang.Object
implements java.io.Serializable

Plugin handler superclass with the ability to store the localized menu labels and a module name for each plugin. This class is under development, use it at your own risk!

Since:
Marvin 3.5, 07/07/2004
Version:
5.0, 05/25/2007
Author:
Peter Csizmadia, Tamas Vertse
See Also:
Serialized Form

Constructor Summary
CommandPlugger()
          Constructs an empty plugger.
 
Method Summary
protected  void addCommand(java.lang.String cmd, java.lang.String modname, java.lang.Object icon, java.lang.String folder, java.lang.Class cl)
          Adds a plugin.
protected  void addFolder(java.lang.String name, java.lang.Class cl)
          Adds a plugin folder.
protected  void clear()
          Removes all plugins.
 java.lang.String getCommand(int i)
          Gets a command.
 int getCommandCount()
          Gets the number of commands (plugins).
 java.lang.String getCommandFolder(java.lang.String cmd)
          Gets the folder name for a command.
 java.lang.Object getCommandIcon(int i)
          Gets the small icon for a command.
 java.lang.String getCommandLabel(int i)
          Gets the menu item label for a command.
 java.lang.Class getCommandPluggerClass(int i)
          Gets the class of the plugger the specified plugin corresponds to.
 java.util.ResourceBundle getCommandPluggerRC(int i)
          Gets the resource bundle of the plugger the specified plugin corresponds to.
 int getFolderCount()
          Gets the number of folders.
 java.lang.String getFolderLabel(int i)
          Gets the label of a folder.
 java.lang.String getFolderLabel(java.lang.String folder)
          Gets the label of a folder.
 java.lang.String getFolderName(int i)
          Gets the name of a folder.
 java.lang.Class getFolderPluggerClass(int i)
          Gets the class of the plugger that created the specified folder.
 java.util.ResourceBundle getFolderPluggerRC(int i)
          Gets the resource bundle of the plugger that created the specified folder.
 java.util.ResourceBundle getFolderPluggerRC(java.lang.String name)
          Gets the resource bundle of the plugger that created the specified folder.
 java.lang.String getModuleName(java.lang.String cmd)
          Gets the module name for a command.
static java.util.ResourceBundle getResourceBundle(java.lang.String name, java.lang.String locales)
          Utility method to get a resource bundle.
 void init(java.lang.String locales)
          Initializes the plugger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandPlugger

public CommandPlugger()
Constructs an empty plugger.

Method Detail

init

public void init(java.lang.String locales)
Initializes the plugger. Plugins and their folders are added here.

Parameters:
locales - the default locales or null
See Also:
addCommand(String, String, Object, String, Class), addFolder(String, Class)

clear

protected final void clear()
Removes all plugins.


addCommand

protected final void addCommand(java.lang.String cmd,
                                java.lang.String modname,
                                java.lang.Object icon,
                                java.lang.String folder,
                                java.lang.Class cl)
Adds a plugin. Plugins and their folders must be added in the init(String) method.

Parameters:
cmd - the command
modname - the module name
icon - the icon object or null
folder - folder name in "/folder" or "/folder1/.../folderN" form, the first character is the field separator (slash "/" is recommended)
cl - this plugger class
See Also:
init(String), addFolder(java.lang.String, java.lang.Class)

addFolder

protected final void addFolder(java.lang.String name,
                               java.lang.Class cl)
                        throws java.lang.IllegalArgumentException
Adds a plugin folder. Plugins and their folders must be added in the init(String) method.

Parameters:
name - folder name in "/folder" or "/folder1/.../folderN" form, the first character is the field separator (slash "/" is recommended)
cl - this plugger class
Throws:
java.lang.IllegalArgumentException - if a parent folder was not added
See Also:
init(String), addCommand(String, String, Object, String, Class)

getCommandCount

public final int getCommandCount()
Gets the number of commands (plugins).

Returns:
the number of commands

getCommand

public final java.lang.String getCommand(int i)
Gets a command.

Parameters:
i - the command index
Returns:
the name

getCommandLabel

public final java.lang.String getCommandLabel(int i)
Gets the menu item label for a command.

Parameters:
i - the command index
Returns:
the command label

getCommandIcon

public final java.lang.Object getCommandIcon(int i)
Gets the small icon for a command.

Parameters:
i - the command index
Returns:
the command icon

getCommandFolder

public final java.lang.String getCommandFolder(java.lang.String cmd)
Gets the folder name for a command.

Parameters:
cmd - the command
Returns:
the folder name

getCommandPluggerClass

public final java.lang.Class getCommandPluggerClass(int i)
Gets the class of the plugger the specified plugin corresponds to.

Parameters:
i - the command index
Returns:
the plugger class

getFolderCount

public final int getFolderCount()
Gets the number of folders.

Returns:
the number of folders

getFolderName

public final java.lang.String getFolderName(int i)
Gets the name of a folder.

Parameters:
i - the folder index
Returns:
the folder name

getFolderLabel

public final java.lang.String getFolderLabel(int i)
Gets the label of a folder.

Parameters:
i - the folder index
Returns:
the folder label

getFolderLabel

public final java.lang.String getFolderLabel(java.lang.String folder)
Gets the label of a folder.

Parameters:
folder - the folder name
Returns:
the folder label

getFolderPluggerClass

public final java.lang.Class getFolderPluggerClass(int i)
Gets the class of the plugger that created the specified folder.

Parameters:
i - the folder index
Returns:
the plugger class

getFolderPluggerRC

public final java.util.ResourceBundle getFolderPluggerRC(int i)
Gets the resource bundle of the plugger that created the specified folder.

Parameters:
i - the folder index
Returns:
the resource bundle

getFolderPluggerRC

public final java.util.ResourceBundle getFolderPluggerRC(java.lang.String name)
Gets the resource bundle of the plugger that created the specified folder.

Parameters:
name - the folder name
Returns:
the resource bundle

getCommandPluggerRC

public final java.util.ResourceBundle getCommandPluggerRC(int i)
Gets the resource bundle of the plugger the specified plugin corresponds to.

Parameters:
i - the command index
Returns:
the resource bundle

getModuleName

public final java.lang.String getModuleName(java.lang.String cmd)
Gets the module name for a command.

Parameters:
cmd - the command
Returns:
the module name

getResourceBundle

public static java.util.ResourceBundle getResourceBundle(java.lang.String name,
                                                         java.lang.String locales)
Utility method to get a resource bundle. If the "LOCALES" resource is set and the current locale is listed, then also loads resources for to the current locale.

Parameters:
name - resource file path
locales - the locales to use or null
Returns:
the resource bundle