tabSet.setTabBarControls(TabBarControls.TAB_SCROLLER, TabBarControls.TAB_PICKER, buttons );
tabSet.addTabSelectedHandler(new TabSelectedHandler() {
public void onTabSelected(TabSelectedEvent tabSelectedEvent) {
NamedTab selectedTab = tabSet.getTabByTitle(tabSelectedEvent.getTab().getTitle());
/*
* do not record history item if initially loading the DashboardsView. if the selectedDashboardView is
* null, suppression will prevent redirection from #Dashboards to #Dashboards/dashboardId,
* which would require the user to hit the back button twice to return to the previous page.
*/
if (selectedDashboardView != null) {
Log.debug(" ***** selectedTab: " + selectedTab.getName() + ", " + selectedTab.getTitle());
CoreGUI.goToView(LinkManager.getDashboardLink(Integer.valueOf(selectedTab.getName())), true);
}
selectedDashboardView = (DashboardView) selectedTab.getPane();
selectedDashboard = selectedDashboardView.getDashboard();
editButton.setTitle(editMode ? MSG.common_title_view_mode() : MSG.common_title_edit_mode());
selectedDashboardView.setEditMode(editMode);
// If re-selecting a Dashboard, make sure it, and its portlets, are up to date
if (selectedDashboardView.isDrawn()) {
// I think this should work with markForRedraw but for some reason it does not
selectedDashboardView.redraw();
}
}
});
for (Dashboard dashboard : dashboards) {
String dashboardName = String.valueOf(dashboard.getId());
String dashboardTitle = dashboard.getName();
DashboardView dashboardView = new DashboardView(this, dashboard);
Tab tab = new NamedTab(new ViewName(dashboardName, dashboardTitle), null);
tab.setPane(dashboardView);
tab.setCanClose(true);
tabSet.addTab(tab);
if (dashboard.getName().equals(selectedTabName)) {
tabSet.selectTab(tab);
}