package thaw.plugins;
import java.sql.*;
import thaw.core.*;
public class PluginUsingHsqldb implements Plugin {
private Core core;
private Hsqldb hsqldb;
private IndexEditorPanel editorPanel;
private JPanel panel;
public PluginUsingHsqldb() {
/* never called */
}
public boolean run(Core core) {
this.core = core;
/* If Hsqldb plugin is not already loaded, then we need to load it */
if(core.getPluginManager().getPlugin("thaw.plugins.Hsqldb") == null) {
Logger.info(this, "Loading Hsqldb plugin");
if(!core.getPluginManager().loadPlugin("thaw.plugins.Hsqldb")
|| !core.getPluginManager().runPlugin("thaw.plugins.Hsqldb")) { /* Hsqldb.run() do almost nothing, see Hsqldb.registerChilld() */
Logger.error(this, "Unable to load thaw.plugins.Hsqldb !");
return false;
}
}
hsqldb = (Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
/* We need to register: Like this, Hsqldb plugin can know how many child plugins
it has. When this number reach 0, then it can disconnect from the database.
*/
hsqldb.registerChild(this);
/* ADD HERE YOUR CODE */
return true;
}
public boolean stop() {
hsqldb.unregisterChild(this);
return true;
}
public String getNameForUser() {
return I18n.getMessage("thaw.plugin.PluginUsingHsqldb");
}
}