PluginsPlugins provide users of SuperQuaiL to create custom plugins. To create a plugin, start a Java project with the superquail jar as a dependent jar. Implement a superquail plugin interface and provide the fully qualified class name in the manifest file with with the attribute key "SUPERQUAIL_PLUGIN_CLASS". Three types of plugins
IPlugin
package superquail.plugin;
import javax.swing.JPanel;
import superquail.model.application.ApplicationContext;
/**
* The interface used to create custom plugins
*
* @author Rudy Yeung
*/
public interface IPlugin {
/**
* Initializes the plugin
* @param context
*/
void initialize(final ApplicationContext context);
/**
* Initializes the plugin
* @param context
*/
void unInitialize(final ApplicationContext context);
/**
* Gets the panels that provides custom settings for the plugin.
* This method is called by the plugin manager for installed plugins.
*
* @return
*/
JPanel[] getSettingsPanel(final ApplicationContext context);
/**
* Gets the name of the interface
* @return
*/
String getName();
}
IPluginAction
package superquail.plugin;
import javax.swing.KeyStroke;
import superquail.model.application.ApplicationContext;
/**
* A plugin that provides an action that can be run
*
* @author Rudy Yeung
*
*/
public interface IPluginAction extends IPlugin {
/**
* Runs an action
* @param context
*/
void run(final ApplicationContext context);
String getMenuPath();
KeyStroke getShortCut();
}
IPluginMultipleAction
package superquail.plugin;
/**
* Interface where there are multiple actions
* @author Rudy Yeung
*
*/
public interface IPluginMultipleActions extends IPlugin {
/**
* Gets an array of plugin interfaces
* @return
*/
IPluginAction[] getIPluginActions();
}
Example PluginHelloWorldPlugin
package superquail.plugins.rudster.helloworld;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import superquail.model.application.ApplicationContext;
import superquail.plugin.IPluginAction;
import superquail.plugin.PluginInfoPanel;
import superquail.view.MainFrame;
public class HelloWorldPlugin implements IPluginAction {
public String getMenuPath() {
return "/Plugins/Hello World";
}
public KeyStroke getShortCut() {
return KeyStroke.getKeyStroke('H', KeyEvent.CTRL_MASK);
}
public void run(ApplicationContext context) {
MainFrame mainFrame = context.getViews().getMainFrame();
JOptionPane.showMessageDialog(mainFrame, "Hello World");
}
public String getName() {
return "Hello World";
}
public JPanel[] getSettingsPanel(ApplicationContext context) {
JPanel[] panels = new JPanel[1];
panels[0] = new PluginInfoPanel("Rudy Yeung", "April 2007", "0",
"Hello World plugin - illustrates how to interface with SuperQuaiL.");
return panels;
}
public void initialize(ApplicationContext context) {
// do nothing
}
public void unInitialize(ApplicationContext context) {
// do nothing
}
}
MANIFEST.MFManifest-Version: 1.0 SUPERQUAIL_PLUGIN_CLASS: superquail.plugins.rudster.helloworld.HelloWorldPlugin Installing the Plugin Into SuperQuaiL
|