UseOWLClassesPanel

From Protege Wiki
Revision as of 19:21, March 11, 2008 by TaniaTudorache (talk | contribs) (New page: == How to use the OWL Classes Panel in your own application == The recommended way is to use the <code>edu.stanford.smi.protegex.owl.ui.dialogs.SelectClassPanel</code> class. It will prov...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to use the OWL Classes Panel in your own application

The recommended way is to use the edu.stanford.smi.protegex.owl.ui.dialogs.SelectClassPanel class. It will provide you with the same view of the classes tree as the one showed in the OWL Classes Tab.

The code below shows how to use the classes panel in a JFrame:

    SelectClassPanel panel = new SelectClassPanel(owlModel, rootClses, false, true);

    JFrame f = new JFrame();
    f.setSize(300, 700);
    f.setContentPane(panel);
    f.setVisible(true);


The arguments of the SelectClassesPanel constructor are:

  • the OWLModel owlModel
  • Collection rootClses - e.g. can be a collection containing just owl:Thing
  • boolean multiple - allows multiple selection in the classes tree or not
  • boolean editable - allows or not the creation of subclasses and siblings (by showing the create icons)


Note: If you loaded the OWL ontology by using the Project methods (e.g. Project.load(String path, Collection errors)) then the system classes (e.g. owl:Class, rdf:Property, etc.) will be hidden by default.

If you load the OWL ontology by using the ProtegeOWL methods (e.g. ProtegeOWL.createJenaOWLModelFromURI(someURI)) then you will need to use the method from below to hide the system frames:

public static void makeSystemClassesHidden(OWLModel owlModel) {
    Collection systemFrames = new HashSet(owlModel.getSystemFrames().getFrames());
    systemFrames.addAll(owlModel.getOWLSystemResources());
		
    for (Iterator iterator = systemFrames.iterator(); iterator.hasNext();) {
        Frame frame = (Frame) iterator.next();
        frame.setVisible(false);
    }
    owlModel.getOWLThingClass().setVisible(true);
}

Call the makeSystemClassesHidden method before the call to the constructor for SelectClassPanel.