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:
- Subclass
AbstractProjectPlugin
.
- 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:
- Download the source code. (Please make sure to preserve the path information in the ZIP file).
- 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>
.
- 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
- 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.