Difference between revisions of "UseTabInApplication"

From Protege Wiki
Jump to: navigation, search
 
Line 66: Line 66:
  
 
[http://protege.stanford.edu/doc/pdk/using_forms_in_other_applications.html Using Protege Forms in other applications]<br />
 
[http://protege.stanford.edu/doc/pdk/using_forms_in_other_applications.html Using Protege Forms in other applications]<br />
[http://protege.stanford.edu/doc/pdk/plugins/tab_widget.html How to write a tab widget plug-in]<br /><br /><br />
+
[http://protege.stanford.edu/doc/pdk/plugins/tab_widget.html How to write a tab widget plug-in]<br /><br />
  
 
[[Category:Protege developer documentation]]
 
[[Category:Protege developer documentation]]

Latest revision as of 14:13, June 3, 2008

Using a Protege tab plug-in in your own application

This page shows how you can use an existing Protege tab widget plug-in as part of your application.

The following code snippet is an example of adding the OWLClassesTab to 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;
        }
		
        // In the next line, replace "OWLClassesTab" with the plug-in 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);
    }		
}

The following JAR files need to be on the classpath:

  • From the Protege installation directory:
    • protege.jar
    • looks-2.1.3.jar
  • (Optional) If you use OWL, add:
    • all JAR files from the plugins/edu.stanford.smi.protegex.owl folder
  • (Optional) If you use a tab plug-in that is not part of protege.jar or protege-owl.jar, you need to include:
    • all JAR files from the plug-in's directory (e.g., for TGVizTab, add all the JAR files from plugins/uk.ac.iam.soton.akt.tgviztab)
    • all JAR files that the plug-in depends on (e.g., if the plug-in depends on Protege-OWL, then add all the Protege-OWL JAR files). You can find information about the plug-ins that a plug-in depends on by looking in the plugin.properties file. See the documentation on declaring plug-in dependencies for more information.


See Also:

Using Protege Forms in other applications
How to write a tab widget plug-in