@Override
protected void onFirstShowPage() {
super.onFirstShowPage();
final PDockLayoutPanel dockLayoutPanel = new PDockLayoutPanel(PUnit.PX);
dockLayoutPanel.setSizeFull();
final PTabPanel tabPanel = new PTabPanel();
tabPanel.setSizeFull();
tabPanel.addBeforeSelectionHandler(new PBeforeSelectionHandler<Integer>() {
@Override
public void onBeforeSelection(final PBeforeSelectionEvent<Integer> event) {
PNotificationManager.showTrayNotification("onBeforeSelection, tab index : " + event.getSelectedItem());
}
});
tabPanel.addSelectionHandler(new PSelectionHandler<Integer>() {
@Override
public void onSelection(final PSelectionEvent<Integer> event) {
PNotificationManager.showTrayNotification("onSelection, tab index : " + event.getSelectedItem());
}
});
final PButton button = new PButton("Add Tab");
button.setStyleProperty("margin", "10px");
button.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
addTabContent(tabPanel);
}
});
final PButton addCustomTabButton = new PButton("Add Tab (custom tab)");
addCustomTabButton.setStyleProperty("margin", "10px");
addCustomTabButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
addCustomTabContent(tabPanel);
}
});
final PTextBox indexTextBox = new PTextBox();
final PButton selectButton = new PButton("Select Tab");
selectButton.setStyleProperty("margin", "10px");
selectButton.addClickHandler(new PClickHandler() {
@Override
public void onClick(final PClickEvent clickEvent) {
final String text = indexTextBox.getText();
tabPanel.selectTab(Integer.valueOf(text));
}
});
final PHorizontalPanel horizontalPanel = new PHorizontalPanel();
horizontalPanel.setVerticalAlignment(PVerticalAlignment.ALIGN_MIDDLE);
horizontalPanel.add(button);
horizontalPanel.add(addCustomTabButton);
horizontalPanel.add(indexTextBox);
horizontalPanel.add(selectButton);
final PHorizontalPanel tabPanelContainer = new PHorizontalPanel();
tabPanelContainer.add(tabPanel);
dockLayoutPanel.addNorth(horizontalPanel, 50);
dockLayoutPanel.add(tabPanelContainer);
addTabContent(tabPanel);
examplePanel.setWidget(dockLayoutPanel);
}