UseTabInApplication
From Protege Wiki
Revision as of 11:05, June 3, 2008 by TaniaTudorache (talk | contribs) (New page: = Using a Tab Plugin in your own application = This page shows how you can use an existing Tab Plugin as part of your application. The following code snippet shows an example on how to a...)
Using a Tab Plugin in your own application
This page shows how you can use an existing Tab Plugin as part of your application.
The following code snippet shows an example on how to add the OWLClassesTab
in a JFrame
.
package examples; import java.awt.Component; import java.util.ArrayList; import javax.swing.JFrame; import edu.stanford.smi.protege.model.Project; import edu.stanford.smi.protege.model.WidgetDescriptor; import edu.stanford.smi.protege.widget.TabWidget; import edu.stanford.smi.protege.widget.WidgetUtilities; import edu.stanford.smi.protegex.owl.ui.cls.OWLClassesTab; public class StandaloneTabWidget { public static void main(String[] args) { ArrayList errors = new ArrayList(); Project prj = Project.loadProjectFromFile("/work/protege/projects/pizza/pizza.owl.pprj", errors); if (errors.size() > 0) { System.out.println("There were erros at loading prj: " + prj); return; } WidgetDescriptor widgetDescriptor = prj.getTabWidgetDescriptor(OWLClassesTab.class.getName()); if (widgetDescriptor == null) { System.out.println("Cannot instantiate tab widget."); return; } TabWidget widget = WidgetUtilities.createTabWidget(widgetDescriptor, prj); JFrame frame = new JFrame("My Application Frame"); frame.getContentPane().add((Component)widget); frame.pack(); frame.setVisible(true); } }
You need to add to your classpath:
- From Protege installation directory:
- protege.jar
- looks-2.1.3.jar
- (Optional) If you use OWL, add to your classpath:
- all jars from the plugins/edu.stanford.smi.protegex.owl folder
- (Optional) If you use a tab plugin that is not part of the protege.jar or protege-owl.jar, you will need to include:
- all the jars from the plugin directory (e.g. for TGVizTab, add all jars from plugins/uk.ac.iam.soton.akt.tgviztab)
- all the jars that the plugin depends on (e.g. if the plugin depends on protege-owl, then add all jars for protege-owl). You can find out the plugins that a plugin depends on by looking in the plugin.properties file. See PluginDependencies for more information.