panel = new Panel(getCompositeContainer());
tabBar = new TabBar(panel.getContainer());
tabBar.addTabSelectedListener(new TabBar.TabSelectedListener() {
public void onTabSelected(TabSelectedEvent event) {
Tab tab = event.getTab();
int index = tabs.indexOf(tab);
selectTab(index);
}
});
deckPanel = new DeckPanel(panel.getContainer());
deckContainer = new WrapperContainer(deckPanel.getContainer()) {
public void add(Widget widget) {
super.add(widget);
widgets.add(widget);
tabs.add(new TabBar.Tab(tabBar));
}
public void remove(Widget widget) {
super.remove(widget);
int tabIndex = getTabIndexForWidget(widget);
assert (tabIndex != -1);
Tab tab = tabs.get(tabIndex);
tab.destroy();
// TODO(jgw): Deal with the selected widget being removed.
widgets.remove(tabIndex);
tabs.remove(tabIndex);