Difference between revisions of "UseOWLClassesPanel"

From Protege Wiki
Jump to: navigation, search
(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...)
 
(How to use the OWL Classes Panel in your own application)
Line 36: Line 36:
 
     }
 
     }
 
     owlModel.getOWLThingClass().setVisible(true);
 
     owlModel.getOWLThingClass().setVisible(true);
 +
    owlModel.getProject().setDisplayHiddenClasses(false);
 
}
 
}
 
</pre></code>
 
</pre></code>
  
 
Call the <code>makeSystemClassesHidden</code> method before the call to the constructor for <code>SelectClassPanel</code>.
 
Call the <code>makeSystemClassesHidden</code> method before the call to the constructor for <code>SelectClassPanel</code>.

Revision as of 15:04, March 18, 2008

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);
    owlModel.getProject().setDisplayHiddenClasses(false);
}

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