Search code examples
javapluginsjdbcsquirrel-sql

SQuirreL Plugin Tutorial


I have an idea for a plugin for SQuirreL SQL client and I'd like to know how to make a plugin. My plugin will be a query builder UI which needs access to the schema model including tables, columns, primary keys, foreign keys and constraints etc.

I have searched the web for SQurreL plugin information / tutorials and I can't find much. The best I can find is on Wikipedia which is quite brief.

If you have any links, tutorials, examples or any other information on creating SQuirreL plugins, please post them here.

Thanks


Solution

  • Here is a class for extending a Squirrel Plugin made in Java:

    public class FulltextsearchPlugin extends DefaultSessionPlugin {  
    private final Analyzer analyzer = new StandardAnalyzer();  
    private final String path = "c:/temp/lucene/squirrel/";  
    private final IndexWriter writer = createIndexWriter();  
    
    @Override  
    public String getAuthor() {  
        return "Mike Haller";  
    }  
    
    @Override  
    public String getDescriptiveName() {  
        return "Full-Text Search Plugin";  
    }  
    
    @Override  
    public String getInternalName() {  
        return "fulltextsearchplugin";  
    }  
    
    @Override  
    public String getVersion() {  
        return "0.0.1";  
    }  
    
    @Override  
    public PluginSessionCallback sessionStarted(ISession session) {  
        // Add context menu items to the object tree's view and procedure nodes.  
        IObjectTreeAPI otApi = session.getSessionInternalFrame()  
                .getObjectTreeAPI();  
        otApi.addToPopup(DatabaseObjectType.TABLE, new FulltextsearchMenu(this,  
                session));  
        return new PluginSessionCallbackAdaptor(this);  
     }  
    }  
    

    That is a code snapshot from one of the best tutorials in my view, which provides a very clear discussion with steps on how to get a plugin implemented. The material provides a good template to extend it to other cases.