Difference between revisions of "AddingRemovingTabs"

From Protege Wiki
Jump to: navigation, search
(moved page content from old wiki)
 
 
(2 intermediate revisions by the same user not shown)
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:
Line 32: Line 32:
  
 
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]]

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.