Difference between revisions of "UseTabInApplication"
From Protege Wiki
(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...) |
|||
Line 32: | Line 32: | ||
} | } | ||
+ | // Replace in the next line OWLClassesTab with the plugin class that you want to show in the JFrame | ||
WidgetDescriptor widgetDescriptor = prj.getTabWidgetDescriptor(OWLClassesTab.class.getName()); | WidgetDescriptor widgetDescriptor = prj.getTabWidgetDescriptor(OWLClassesTab.class.getName()); | ||
Line 58: | Line 59: | ||
** looks-2.1.3.jar | ** looks-2.1.3.jar | ||
* ''(Optional)'' If you use OWL, add to your classpath: | * ''(Optional)'' If you use OWL, add to your classpath: | ||
− | ** all jars from the plugins/edu.stanford.smi.protegex.owl folder | + | ** 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: | * ''(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 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. | ** 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. | ||
+ | |||
+ | |||
+ | For more information on using Protege forms in other applications, see [http://protege.stanford.edu/doc/pdk/using_forms_in_other_applications.html this page]. |
Revision as of 10:08, June 3, 2008
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; } // Replace in the next line OWLClassesTab with the plugin class that you want to show in the JFrame 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.
For more information on using Protege forms in other applications, see this page.