Difference between revisions of "AddingRemovingTabs"

From Protege Wiki
Jump to: navigation, search
(moved page content from old wiki)
 
m
Line 16: Line 16:
 
</pre></code>
 
</pre></code>
  
=== Removing a tab ===
+
=== Removing a Tab Widget ===
  
 
The following code snippet shows how the "ClsesAndInstances" tab can be programmatically removed from Protege's main panel:
 
The following code snippet shows how the "ClsesAndInstances" tab can be programmatically removed from Protege's main panel:

Revision as of 17:48, October 3, 2007

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.