A tab widget plug-in is the simplest type of plug-in to write. There are only two requirements which are specific to
this plug-in type:
- Subclass the
AbstractTabWidget
class.
- Implement the
initialize()
method.
We have provided source code for an example tab widget plug-in called "Frame Counter" that displays the number of
frames in the knowledge base when the user presses a button. It illustrates the two requirements above, as well as how to access
the underlying knowledge base.
Follow these steps to compile and run the "Frame Counter" 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 "FrameCounter.class" file into the
"
plugins/examples/tabwidget
" 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. Once Protégé launches, there is still one more step to make your tab visible...
- Choose Project | Configure... to bring up the "Configure" dialog. The new FrameCounter tab
will be listed on the Tab Widgets panel. Check the "Visible" checkbox and click the OK button. The system
will now display the new tab.