SWT CTabFolder Check If CTAB Exists

277 views Asked by At

I am trying to create a tab inferface for my application in SWT. I would like to setup my menu button so that when it is clicked it check to see if a tab is open. If it is open I want to switch to the tab and if it is not I want to open it. I have already created a menu item that will create the tab, but I am unsure how to check to see if the tab exists.

2

There are 2 answers

0
Talon06 On BEST ANSWER
public static Boolean CtabExists(CTabFolder folder, CTabItem tab) {
    if (tab != null) {
        int intIndex = -1;
        intIndex = folder.indexOf(tab);
        if (intIndex == -1) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}
1
R.Shanmukha sai On
int tabItemIndex=tabFolderItem.getSelectionIndex();
if(tabItemIndex!=-1)
  tabFolderItem.setSelection(tabItemIndex);
else
  tabFolderItem.setSelection(value); //keep your required index in the place of value