Plugins

Plugins 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 - a plugin that integrate with superquail. Defines the basic structure of a plugin. Most of the time this will not be the interface to use.
  • IPluginAction - a plugin that defines an action to perform in SuperQuaiL. Provides hooks within SuperQuail to define a menu path and a short cut to execute an action
  • IPluginMultipleAction - a plugin which defines multiple plugin actions.

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 Plugin

HelloWorldPlugin

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.MF

Manifest-Version: 1.0
SUPERQUAIL_PLUGIN_CLASS: superquail.plugins.rudster.helloworld.HelloWorldPlugin

Installing the Plugin Into SuperQuaiL

  • export plugin code with manifest file into a jar
  • go to Plugins->Manager Plugins
  • choose "Install Plugin"
  • In the Settings panel choose load jar and pick the plugin
helloworld.jar

SourceForge.net Logo