USERS
DEVELOPERS


see also:
BACKEND
CREATEPROJECT
EXPORT
SLOT WIDGET
TAB WIDGET
 how to write a project plug-in

A project plug-in is a plug-in whose methods are called at various points in a Protégé project's life cycle. This plug-in type allows you to manipulate a project and the project UI as you would like. The interface plugin.ProjectPlugin shows the methods that are available for you to implement. The easiest way to develop such a plug-in is to:
  1. Subclass AbstractProjectPlugin.
  2. Implement the abstract methods.
If you only want to implement one or two of the methods, then you may choose to subclass ProjectPluginAdapter. This class implements all of the required methods with "do nothing" implementations. Thus you can just override the method(s) that you want.

We have provided example code for a project plug-in that just adds a menu item to the edit menu. It also prints to the console whenever any of its methods are called.

Follow these steps to compile and run the project plug-in example:
  1. Download the source code. (Please make sure to preserve the path information in the ZIP file).
  2. Set up your Java development environment:
    • Use JDK 1.4 or higher for your compiler.
    • Configure the compiler to write output classes to <protege_install_dir>/plugins (replacing protege_install_dir with your Protégé installation directory).
    • Add the following JAR files to your classpath: protege.jar, looks.jar, unicode_panel.jar.
    • Pass the JVM the following parameter -Dprotege.dir=<protege_install_dir>.
  3. Compile the source code. Check that your compiler has indeed put the "MenuItemInserter.class" file into the "plugins/examples/projectplugin" directory. Also, please make sure that your development environment copies the meta-inf directory with the manifest file to your output directory. Some development environments do this by default, others require you to specify that MF files should be copied to the output directory. The following is an example of what your directory structure should look like after properly downloading and compiling the example code:
    
    <protege_install_dir>
        plugins
            examples
                backend
                createprojectplugin
                exportplugin
                projectplugin
                slotwidget
                tabwidget
            meta-inf
    
  4. Run the example from your development environment, specifying edu.stanford.smi.protege.Application as the main class. You may also wish to specify the name of a project as an application parameter so that when Protégé starts up, a project will automatically be loaded. Any "Duplicate plugin" warnings are benign and can be ignored. Protégé should launch, you should get messages in the console window, and the new menu item should appear in the Edit menu.