I have a tab panel where I add tabs dynamically.
At a given point it can look like:
tabPanel.add(new HTML("Dashboard"), new Hyperlink("Dashboard", "dashboard"));
tabPanel.add(new CashGameTabPage(this), new Hyperlink("Cash Games", "cash"));
tabPanel.add(new TournamentTabPage(this), new Hyperlink("Tournament", "tournament"));
I would like to check if a Tab already exists. If it exists, I should get its index. If it does not exist I should get 0. I was thinking as a function such as:
public static int getIndexIfAlreadyExists(DecoratedTabPanel tabPanel, String title) {
int tabcount = tabPanel.getTabBar().getTabCount();
for(int i = 0; i < tabcount;i++) {
if(/*TODO get a Tab Text */.equals(title))
return i;
return 0;
}
I would like to get
getIndexIfAlreadyExists(tabPanel, "Dashboard") -> 0
getIndexIfAlreadyExists(tabPanel, "Cash Games") -> 1
getIndexIfAlreadyExists(tabPanel, "Tournament") -> 2
However I do not manage to find a method to retrieve the Text. Any idea how to achieve this behaviour.
Thanks in advanced.