AddingRemovingTabs
From Protege Wiki
Revision as of 14:53, May 27, 2008 by JenniferVendetti (talk | contribs)
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.