Example usage for com.vaadin.ui Button focus

List of usage examples for com.vaadin.ui Button focus

Introduction

In this page you can find the example usage for com.vaadin.ui Button focus.

Prototype

@Override
    public void focus() 

Source Link

Usage

From source file:by.bigvova.ui.LoginUI.java

License:Apache License

private Component buildFields() {
    final VerticalLayout layout = new VerticalLayout();
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//from w  w  w .java2s  . c o  m
    fields.addStyleName("fields");

    final TextField username = new TextField("Username");
    username.setIcon(FontAwesome.USER);
    username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final PasswordField password = new PasswordField("Password");
    password.setIcon(FontAwesome.LOCK);
    password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    signin.focus();

    final CheckBox checkBox = new CheckBox("Remember me", true);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            login(username.getValue(), password.getValue(), checkBox.getValue());
        }
    });

    fields.addComponents(username, password, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    layout.setSpacing(true);
    layout.addComponent(fields);
    layout.addComponent(checkBox);
    return layout;
}

From source file:com.esofthead.mycollab.vaadin.ui.ConfirmDialogFactory.java

License:Open Source License

@Override
public ConfirmDialog create(final String caption, final String message, final String okCaption,
        final String cancelCaption, String notOkCaption) {
    final ConfirmDialog d = super.create(caption, message, okCaption, cancelCaption, notOkCaption);

    d.getContent().setStyleName("custom-dialog");
    d.getContent().setHeightUndefined();
    d.setHeightUndefined();/*ww w . j  a va2  s .  c om*/

    final Button ok = d.getOkButton();
    ok.setStyleName(UIConstants.THEME_GREEN_LINK);

    HorizontalLayout buttons = (HorizontalLayout) ok.getParent();
    buttons.setHeightUndefined();

    final Button cancelBtn = d.getCancelButton();
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    cancelBtn.focus();

    return d;
}

From source file:com.esofthead.mycollab.vaadin.web.ui.ConfirmDialogFactory.java

License:Open Source License

@Override
public ConfirmDialog create(String caption, String message, String okCaption, String cancelCaption,
        String notOkCaption) {/*from ww w  .j  a  v a 2 s . c o m*/
    ConfirmDialog d = super.create(caption, message, okCaption, cancelCaption, notOkCaption);

    d.getContent().setStyleName("custom-dialog");
    d.getContent().setHeightUndefined();
    d.setHeightUndefined();

    Button ok = d.getOkButton();
    ok.setStyleName(UIConstants.BUTTON_ACTION);

    HorizontalLayout buttons = (HorizontalLayout) ok.getParent();
    buttons.setHeightUndefined();

    Button cancelBtn = d.getCancelButton();
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
    cancelBtn.focus();

    return d;
}

From source file:com.github.djabry.platform.vaadin.view.LoginView.java

License:Open Source License

private Component buildFields() {
    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);//from  w  w w.j  a  va2  s  . c  o m

    userField = new TextField("Username");

    userField.setIcon(FontAwesome.USER);
    userField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    //username.addStyleName(ValoTheme.TEXTFIELD_TINY);

    passwordField = new PasswordField("Password");
    passwordField.setIcon(FontAwesome.LOCK);
    passwordField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    //password.addStyleName(ValoTheme.TEXTFIELD_TINY);

    final Button signin = new Button("Sign In");
    signin.addStyleName(ValoTheme.BUTTON_PRIMARY);
    signin.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    //signin.addStyleName(ValoTheme.BUTTON_TINY);
    signin.focus();

    fields.addComponents(userField, passwordField, signin);
    fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT);

    signin.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            loginAction.login(userField.getValue(), passwordField.getValue());
        }
    });
    return fields;
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);//from www .j a v a  2s . com
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showMessageDialog(String title, String message, MessageType messageType) {
    backgroundWorker.checkUIAccess();//from w w  w  .j av a  2  s  . com

    final com.vaadin.ui.Window vWindow = new CubaWindow(title);

    if (ui.isTestMode()) {
        vWindow.setCubaId("messageDialog");
        vWindow.setId(ui.getTestIdManager().getTestId("messageDialog"));
    }

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers())) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

    vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {
            vWindow.close();
        }
    });

    VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("c-app-message-dialog");
    layout.setSpacing(true);
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        layout.setWidthUndefined();
    }
    vWindow.setContent(layout);

    Label messageLab = new CubaLabel();
    messageLab.setValue(message);
    if (MessageType.isHTML(messageType)) {
        messageLab.setContentMode(ContentMode.HTML);
    } else {
        messageLab.setContentMode(ContentMode.TEXT);
    }
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        messageLab.setWidthUndefined();
    }
    layout.addComponent(messageLab);

    DialogAction action = new DialogAction(Type.OK);
    Button button = WebComponentsHelper.createButton();

    button.setCaption(action.getCaption());
    button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
    button.addStyleName(WebButton.ICON_STYLE);
    button.addClickListener(event -> vWindow.close());

    button.focus();

    layout.addComponent(button);

    layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT);

    float width;
    SizeUnit unit;
    DialogParams dialogParams = getDialogParams();
    if (messageType.getWidth() != null) {
        width = messageType.getWidth();
        unit = messageType.getWidthUnit();
    } else if (dialogParams.getWidth() != null) {
        width = dialogParams.getWidth();
        unit = dialogParams.getWidthUnit();
    } else {
        SizeWithUnit size = SizeWithUnit
                .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.messageDialog.width"));
        width = size.getSize();
        unit = size.getUnit();
    }

    vWindow.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS);
    vWindow.setResizable(false);

    boolean modal = true;
    if (!hasModalWindow()) {
        if (messageType.getModal() != null) {
            modal = messageType.getModal();
        } else if (dialogParams.getModal() != null) {
            modal = dialogParams.getModal();
        }
    }
    vWindow.setModal(modal);

    boolean closeOnClickOutside = false;
    if (vWindow.isModal()) {
        if (messageType.getCloseOnClickOutside() != null) {
            closeOnClickOutside = messageType.getCloseOnClickOutside();
        }
    }
    ((CubaWindow) vWindow).setCloseOnClickOutside(closeOnClickOutside);

    if (messageType.getMaximized() != null) {
        if (messageType.getMaximized()) {
            vWindow.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            vWindow.setWindowMode(WindowMode.NORMAL);
        }
    }

    dialogParams.reset();

    ui.addWindow(vWindow);
    vWindow.center();
    vWindow.focus();
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) {
    backgroundWorker.checkUIAccess();//from   w  w w. ja  v a 2 s. c  om

    final com.vaadin.ui.Window window = new CubaWindow(title);

    if (ui.isTestMode()) {
        window.setCubaId("optionDialog");
        window.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }
    window.setClosable(false);

    Label messageLab = new CubaLabel();
    messageLab.setValue(message);
    if (MessageType.isHTML(messageType)) {
        messageLab.setContentMode(ContentMode.HTML);
    } else {
        messageLab.setContentMode(ContentMode.TEXT);
    }
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        messageLab.setWidthUndefined();
    }

    float width;
    SizeUnit unit;
    if (messageType.getWidth() != null) {
        width = messageType.getWidth();
        unit = messageType.getWidthUnit();
    } else if (getDialogParams().getWidth() != null) {
        width = getDialogParams().getWidth();
        unit = getDialogParams().getWidthUnit();
    } else {
        SizeWithUnit size = SizeWithUnit
                .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width"));
        width = size.getSize();
        unit = size.getUnit();
    }

    if (messageType.getModal() != null) {
        log.warn("MessageType.modal is not supported for showOptionDialog");
    }

    getDialogParams().reset();

    window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS);
    window.setResizable(false);
    window.setModal(true);

    boolean closeOnClickOutside = false;
    if (window.isModal()) {
        if (messageType.getCloseOnClickOutside() != null) {
            closeOnClickOutside = messageType.getCloseOnClickOutside();
        }
    }
    ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside);

    if (messageType.getMaximized() != null) {
        if (messageType.getMaximized()) {
            window.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            window.setWindowMode(WindowMode.NORMAL);
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setStyleName("c-app-option-dialog");
    layout.setSpacing(true);
    if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) {
        layout.setWidthUndefined();
    }
    window.setContent(layout);

    HorizontalLayout buttonsContainer = new HorizontalLayout();
    buttonsContainer.setSpacing(true);

    boolean hasPrimaryAction = false;
    Map<Action, Button> buttonMap = new HashMap<>();
    for (Action action : actions) {
        Button button = WebComponentsHelper.createButton();
        button.setCaption(action.getCaption());
        button.addClickListener(event -> {
            try {
                action.actionPerform(null);
            } finally {
                ui.removeWindow(window);
            }
        });

        if (StringUtils.isNotEmpty(action.getIcon())) {
            button.setIcon(WebComponentsHelper.getIcon(action.getIcon()));
            button.addStyleName(WebButton.ICON_STYLE);
        }

        if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) {
            button.addStyleName("c-primary-action");
            button.focus();

            hasPrimaryAction = true;
        }

        if (ui.isTestMode()) {
            button.setCubaId("optionDialog_" + action.getId());
            button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId()));
        }

        buttonsContainer.addComponent(button);
        buttonMap.put(action, button);
    }

    assignDialogShortcuts(buttonMap);

    if (!hasPrimaryAction && actions.length > 0) {
        ((Button) buttonsContainer.getComponent(0)).focus();
    }

    layout.addComponent(messageLab);
    layout.addComponent(buttonsContainer);

    layout.setExpandRatio(messageLab, 1);
    layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT);

    ui.addWindow(window);
    window.center();
}

From source file:com.naoset.framework.frontend.view.window.Window.java

private HorizontalLayout buildFooter() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    layout.setWidth(100.0f, Unit.PERCENTAGE);

    //Si el objeto a mostrar hereda de Widget, mostraremos su cabecera con el men en la ventana.
    if (Widget.class.isInstance(body)) {
        //if (details.getClass().isInstance(Widget.class)) {
        Widget aux = (Widget) body;/*  www . j  av a2  s .com*/
        HorizontalLayout header = aux.getHeader();
        header.setWidth(100.0f, Unit.PERCENTAGE);
        layout.addComponent(header);
        //layout.setComponentAlignment(header, Alignment.TOP_LEFT);
        layout.setExpandRatio(header, 1);
    }

    Button ok = new Button("Cerrar");
    ok.addStyleName(ValoTheme.BUTTON_PRIMARY);
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Boolean canClose = true;
            if (Widget.class.isInstance(body)) {
                Widget aux = (Widget) body;
                canClose = !aux.isModified();
            }
            if (canClose) {
                close();
            } else {

                buildConfirmCloseDialog();

            }

        }
    });
    ok.focus();
    layout.addComponent(ok);
    layout.setComponentAlignment(ok, Alignment.TOP_RIGHT);
    return layout;
}

From source file:com.skysql.manager.ui.CalendarDialog.java

License:Open Source License

/**
 * Show delete popup./* w  ww  . j  av  a2 s  .  c  o  m*/
 *
 * @param event the event
 */
private void showDeletePopup(final CalendarCustomEvent event) {
    if (event == null) {
        return;
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    deleteSchedulePopup = new Window("Delete Recurring Event", layout);
    deleteSchedulePopup.setWidth("740px");
    deleteSchedulePopup.setModal(true);
    deleteSchedulePopup.center();
    deleteSchedulePopup.setContent(layout);
    deleteSchedulePopup.addCloseListener(new CloseListener() {
        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            UI.getCurrent().removeWindow(deleteSchedulePopup);
        }
    });

    Label warning = new Label(
            "Do you want to delete the original event, or this and all future occurrences of the event, or only the selected occurrence?");
    layout.addComponent(warning);

    Button cancel = new Button("Cancel", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(deleteSchedulePopup);
        }
    });

    Button deleteAll = new Button("Delete Original Event", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            Schedule.delete(scheduleID);

            schedule.getScheduleList().remove(scheduleID);

            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    Button deleteFuture = new Button("Delete All Future Events", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID);
            VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal());
            ManagerUI.log("before Delete All Future Events\n" + vEvent);
            iCalSupport.deleteAllFuture(vEvent, event.getStart());
            ManagerUI.log("after Delete All Future Events\n" + vEvent);
            scheduleRecord.setICal(vEvent.toString());

            Schedule.update(scheduleID, vEvent.toString());
            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            schedule.getScheduleList().put(scheduleID, scheduleRecord);

            addEventsToMap(scheduleID, vEvent, event.getNode());
            eventsList = eventsMap.get(scheduleID);
            for (CalendarCustomEvent addEvent : eventsList) {
                if (!dataSource.containsEvent(addEvent)) {
                    dataSource.addEvent(addEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    Button deleteSelected = new Button("Delete Only This Event", new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent dummy) {
            String scheduleID = (String) event.getData();
            ScheduleRecord scheduleRecord = schedule.getScheduleList().get(scheduleID);
            VEvent vEvent = iCalSupport.readVEvent(scheduleRecord.getICal());
            ManagerUI.log("before Exclude\n" + vEvent);
            iCalSupport.addExcludedDate(vEvent, event.getStart());
            ManagerUI.log("after Exclude\n" + vEvent);
            scheduleRecord.setICal(vEvent.toString());

            Schedule.update(scheduleID, vEvent.toString());
            ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID);
            for (CalendarCustomEvent removeEvent : eventsList) {
                if (dataSource.containsEvent(removeEvent)) {
                    dataSource.removeEvent(removeEvent);
                }
            }

            schedule.getScheduleList().put(scheduleID, scheduleRecord);

            addEventsToMap(scheduleID, vEvent, event.getNode());
            eventsList = eventsMap.get(scheduleID);
            for (CalendarCustomEvent addEvent : eventsList) {
                if (!dataSource.containsEvent(addEvent)) {
                    dataSource.addEvent(addEvent);
                }
            }

            UI.getCurrent().removeWindow(deleteSchedulePopup);

            UI.getCurrent().removeWindow(scheduleEventPopup);

        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(cancel);
    buttons.addComponent(deleteAll);
    buttons.addComponent(deleteFuture);
    buttons.addComponent(deleteSelected);
    deleteSelected.focus();

    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    if (!UI.getCurrent().getWindows().contains(deleteSchedulePopup)) {
        UI.getCurrent().addWindow(deleteSchedulePopup);
    }
}

From source file:com.skysql.manager.ui.SystemForm.java

License:Open Source License

/**
 * Instantiates a new system form.//from  w  w  w. j  a v  a  2s. c o m
 *
 * @param system the system
 * @param description the description
 * @param commitButton the commit button
 */
SystemForm(final SystemRecord system, String description, final Button commitButton) {
    this.system = system;

    setMargin(new MarginInfo(true, true, false, true));
    setSpacing(false);

    HorizontalLayout formDescription = new HorizontalLayout();
    formDescription.setSpacing(true);

    Embedded info = new Embedded(null, new ThemeResource("img/info.png"));
    info.addStyleName("infoButton");
    String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n"
            + "     <tr bgcolor=\"#ccccff\">" + "         <th align=left>Field"
            + "         <th align=left>Description" + "     <tr>" + "         <td><code>Name</code>"
            + "         <td>Name of the system" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Type</code>" + "         <td>Type of the system e.g. aws or galera"
            + "     <tr>" + "         <td><code>Database Username</code>"
            + "         <td>System default for database user name" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Database Password</code>"
            + "         <td>System default for database password" + "     <tr>"
            + "         <td><code>Replication Username</code>"
            + "         <td>System default for replication user name" + "     <tr bgcolor=\"#eeeeff\">"
            + "         <td><code>Replication Password</code>"
            + "         <td>System default for replication password" + " </table>" + " </blockquote>";
    info.setDescription(infoText);

    formDescription.addComponent(info);
    Label labelDescription = new Label(description);
    formDescription.addComponent(labelDescription);
    formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT);
    addComponent(formDescription);

    addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(null);

    String value;
    if ((value = system.getName()) != null) {
        name.setValue(value);
    }
    form.addField("name", name);
    name.focus();
    name.setImmediate(true);
    name.addValidator(new SystemNameValidator(system.getName()));

    for (String systemType : SystemTypes.getList().keySet()) {
        this.systemType.addItem(systemType);
    }
    systemType.select(system.getSystemType() != null ? system.getSystemType() : SystemTypes.DEFAULT_SYSTEMTYPE);
    systemType.setNullSelectionAllowed(false);
    systemType.setEnabled(false);
    form.addField("systemType", systemType);

    if ((value = system.getDBUsername()) != null) {
        dbUsername.setValue(value);
    } else {
        dbUsername.setValue("skysql");
    }
    form.addField("dbusername", dbUsername);
    dbUsername.setRequired(true);
    dbUsername.setImmediate(true);
    dbUsername.setRequiredError("Database Username is a required field");
    dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption()));

    if ((value = system.getDBPassword()) != null) {
        dbPassword.setValue(value);
    }
    form.addField("dbpassword", dbPassword);
    dbPassword.setRequired(true);
    dbPassword.setImmediate(false);
    dbPassword.setRequiredError("Database Password is a required field");

    if ((value = system.getDBPassword()) != null) {
        dbPassword2.setValue(value);
    }
    form.addField("dbpassword2", dbPassword2);
    dbPassword2.setRequired(true);
    dbPassword2.setImmediate(true);
    dbPassword2.setRequiredError("Confirm Password is a required field");
    dbPassword2.addValidator(new Password2Validator(dbPassword));

    if ((value = system.getRepUsername()) != null) {
        repUsername.setValue(value);
    } else {
        repUsername.setValue("repluser");
    }
    form.addField("repusername", repUsername);
    repUsername.setRequired(true);
    repUsername.setImmediate(true);
    repUsername.setRequiredError("Replication Username is a required field");
    repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption()));
    repUsername.addValidator(new UserDifferentValidator(dbUsername));

    if ((value = system.getRepPassword()) != null) {
        repPassword.setValue(value);
    }
    form.addField("reppassword", repPassword);
    repPassword.setRequired(true);
    repPassword.setImmediate(true);
    repPassword.setRequiredError("Replication Password is a required field");
    repPassword.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            commitButton.setClickShortcut(KeyCode.ENTER);
        }
    });

    if ((value = system.getRepPassword()) != null) {
        repPassword2.setValue(value);
    }
    form.addField("reppassword2", repPassword2);
    repPassword2.setRequired(true);
    repPassword2.setImmediate(true);
    repPassword2.setRequiredError("Confirm Password is a required field");
    repPassword2.addValidator(new Password2Validator(repPassword));
    repPassword2.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            commitButton.focus();
        }
    });

}