return tabPanelContract;
}
private TabPanelContract createPages(InteractionUnit<StereoTypes> interactionUnit, EventBus eventBus) {
final Pages pagedView = new Pages();
pagedView.addBeforeSelectionHandler(new NavigationHandler(interactionUnit, childUnits, pagedView));
// activation listener
eventBus.addHandler(SystemEvent.TYPE,
new ChildActivationHandler<Pages>(pagedView, childUnits, new ChildUnitCommand<Pages>() {
@Override
public void execute(Pages parent, int key) {
// TODO: this doesn't really work (rendering bugs) ...
parent.selectTab(key, false);
parent.getDeckPanel().showWidget(key); // workaround
}
})
);
TabPanelContract tabPanelContract = new TabPanelContract() {
@Override
public void add(InteractionUnit unit, Widget widget) {
//widget.addStyleName("rhs-content-panel");
pagedView.add(widget, unit.getLabel());
// register tab2index mapping
childUnits.put(pagedView.getWidgetCount() - 1, unit.getId());
}
@Override
public Widget as() {
Widget widget = pagedView.asWidget();
widget.addStyleName("fill-layout");
widget.addAttachHandler(new AttachEvent.Handler() {
@Override
public void onAttachOrDetach(AttachEvent attachEvent) {
if (pagedView.getWidgetCount() > 0)
pagedView.selectTab(0, true);
}
});
//pagedView.showPage(0);
return pagedView;