@Override
  protected void setup(VaadinRequest request) {

    final TabSheet tabsheet = new TabSheet();
    tabsheet.setWidth("400px");

    Component lastLabel = null;

    for (int i = 1; i <= 5; i++) {
      String caption = "Tab " + i;
      Label label = new Label(caption);
      tabsheet.addTab(label, caption);

      lastLabel = label;
    }

    tabsheet.setSelectedTab(0);

    final Component lastTab = lastLabel;

    tabsheet.addSelectedTabChangeListener(
        new SelectedTabChangeListener() {

          @Override
          public void selectedTabChange(SelectedTabChangeEvent event) {
            if (tabsheet.getSelectedTab().equals(lastTab)) {

              // Set focus back to first tab in tabsheet
              tabsheet.setSelectedTab(0);
              Notification.show("Focus set back to tab at position 0");
            }
          }
        });

    addComponent(tabsheet);

    addButton(
        "Select Last Tab",
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            tabsheet.setSelectedTab(lastTab);
          }
        });
  }
  @Override
  public TabSheet createTabs(Object itemId) throws RpcException {
    final TabSheet tabsheet = new TabSheet();
    tabsheet.addSelectedTabChangeListener(this);
    tabsheet.addTab(new GenericForm("pac", session, itemId, "name"), I18N.getText("pac"));
    final HSTab usersTab = new HSTab("user", session, "pac", itemId, "name");
    usersTab.fillTable();
    tabsheet.addTab(usersTab, I18N.getText("user"));
    final HSTab aliasTab = new HSTab("emailalias", session, "pac", itemId, "name");
    tabsheet.addTab(aliasTab, I18N.getText("emailalias"));
    final HSTab domainTab = new HSTab("domain", session, "pac", itemId, "name");
    tabsheet.addTab(domainTab, I18N.getText("domain"));

    final HSTab mysqluserTab = new HSTab("mysqluser", session, "pac", itemId, "name");
    tabsheet.addTab(mysqluserTab, I18N.getText("mysqluser"));
    final HSTab mysqldbTab = new HSTab("mysqldb", session, "pac", itemId, "name");
    tabsheet.addTab(mysqldbTab, I18N.getText("mysqldb"));
    final HSTab postgresqluserTab = new HSTab("postgresqluser", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqluserTab, I18N.getText("postgresqluser"));
    final HSTab postgresqldbTab = new HSTab("postgresqldb", session, "pac", itemId, "name");
    tabsheet.addTab(postgresqldbTab, I18N.getText("postgresqldb"));
    return tabsheet;
  }