SQLEditor Plugin Documentation - AngusHardie/SQLEditorSQLitePlugin GitHub Wiki

SQLEditor Plugin Documentation

This document describes the SQLEditor plugin API. SQLEditor plugins can be used to extend the SQLEditor application. This first release of the API supports export plugins and, to some extent, import plugins. Later releases may support other ways of extending the application.

Requirements

To write a plugin for SQLEditor you need a Mac running at least Mac OS X 10.6 or later, 10.10 is really strongly recommended.

You also need a licensed copy of SQLEditor, you will be able to develop plugins using the demo or unlicensed versions but it will get annoying, because you'll need to restart regularly to reload plugins.

Also, by using this early access version of the SDK, you're agreeing to be a guinea pig. The current release isn't really complete and was assembled in parts for our convenience not yours. This is something that needs improvement and I'm hoping that with enough feedback it can be become generally useful. Also you will need to be prepared to update plugins to match a changing sdk as necessary. It isn't frozen yet.

You can send any feedback to [email protected]

SQLEditor Versions Supported

The current plugin architecture allows plugins to work on SQLEditor 1.6 and newer, it is strongly recommended to target 2.9 or 3.0

What can an export plugin do?

An export plugin can provide an export dialect to SQLEditor, which is then used to generate the source code in the source view sidebar, source code exported into a file and source code sent to a database system.

It is possible to provide custom JDBC actions as well, but this isn't very well documented yet.

You can currently only provide one dialect per plugin.

What can an import plugin do?

An import plugin can convert an existing file into a SQLEditor document

JDBC actions

JDBC actions are used to allow SQLEditor to interact with a database or other system in order to import or export documents. Essentially they override behaviours in the JDBCImport and JDBCExport modules to customize parts of the process.

How to write a plugin

Plugins are cocoa bundles, written using xcode and normally in Objective C. The principle class must implement initPlugin and respond to certain other messages. There is an interface called SQLEditorPlugin in the SQLModel framework that shows the interface that is used.

initPlugin is called on your plugin when SQLEditor loads and allows you to configure the plugin. If you plugin doesn't respond to initPlugin correctly, then SQLEditor will ignore your plugin.

You must declare the name of your plugin, this should be a human readable name and be unique. Also ensure that the plugin has a unique bundle identifier (like "com.example.myplugin")

Exporting

To actually export something you need to implement a method called getExporter and return an object that is capable of exporting something.

There are several different objects that can appear in a document (SQLContainer):

  • SQLDocumentInfo - a class representing document settings
  • SQLTable - a table object
  • SQLField - a field or column in a table
  • SQLForeignKey - a multi-column foreign key
  • SQLIndex - a table level index
  • SQLComment - a comment

SQLDocumentInfo will not be passed as an object, it is normally passed in separately, because it is removed from the container when loaded.