Difference between revisions of "AddingRemovingTabs"

From Protege Wiki
Jump to: navigation, search
(categorizing page)
 
Line 33: Line 33:
 
The <code>ProjectView.getTabbedPane()</code> method is deprecated, but still working. Future versions of Protege will hopefully support a better API for handling tab widgets.
 
The <code>ProjectView.getTabbedPane()</code> method is deprecated, but still working. Future versions of Protege will hopefully support a better API for handling tab widgets.
  
[[Category:Protege Developer Documentation]]
+
[[Category:Protege developer documentation]]
[[Category:Protege 3 Documentation]]
 

Latest revision as of 15:53, May 27, 2008

Adding and Removing Tabs Programmatically

Using the Protege API, you can add or remove tab widgets (such as the "ClsesAndInstanceTab") from the user interface programmatically. To add or remove a tab, just replace the class name in the example below with the full class name of your tab widget.

Adding a Tab Widget

The following code snippet shows how the "ClsesAndInstances" tab can be progammatically added to Protege's main panel:

WidgetDescriptor tabWidgetDescriptor = prj.getTabWidgetDescriptor("edu.stanford.smi.protege.widget.ClsesAndInstancesTab");
tabWidgetDescriptor.setVisible(true);

ProjectView view = ProjectManager.getProjectManager().getCurrentProjectView();	    	
view.addTab(tabWidgetDescriptor); 

Removing a Tab Widget

The following code snippet shows how the "ClsesAndInstances" tab can be programmatically removed from Protege's main panel:

ProjectView view = ProjectManager.getProjectManager().getCurrentProjectView();	    
TabWidget tabWidget = view.getTabByClassName("edu.stanford.smi.protege.widget.ClsesAndInstancesTab");
if (tabWidget != null) {				
    int tabIndex = view.getTabbedPane().indexOfComponent((Component) tabWidget);
    if (tabIndex > 0) { view.getTabbedPane().removeTabAt(tabIndex); }
}

Note

The ProjectView.getTabbedPane() method is deprecated, but still working. Future versions of Protege will hopefully support a better API for handling tab widgets.