Example usage for com.vaadin.ui ProgressBar setWidth

List of usage examples for com.vaadin.ui ProgressBar setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui ProgressBar setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java

License:Open Source License

public ProjectFormAttachmentUploadField() {
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    currentPollInterval = UI.getCurrent().getPollInterval();

    receiver = createReceiver();//from w  w  w  .jav a 2 s .c o m

    attachmentBtn = new MultiUpload();
    attachmentBtn.setButtonCaption("Select File(s)");
    attachmentBtn.setImmediate(true);

    MultiUploadHandler handler = new MultiUploadHandler() {
        private LinkedList<ProgressBar> indicators;

        @Override
        public void streamingStarted(StreamVariable.StreamingStartEvent event) {
        }

        @Override
        public void streamingFinished(StreamVariable.StreamingEndEvent event) {
            String tempName = event.getFileName();
            final String fileName;
            int index = tempName.lastIndexOf(".");
            if (index > 0) {
                String fileExt = tempName.substring(index + 1, tempName.length());
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "."
                        + fileExt;
            } else {
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis();
            }
            if (!indicators.isEmpty()) {
                rowWrap.replaceComponent(indicators.remove(0),
                        MobileAttachmentUtils.renderAttachmentFieldRow(
                                MobileAttachmentUtils.constructContent(fileName, attachmentPath),
                                new Button.ClickListener() {

                                    private static final long serialVersionUID = 581451358291203810L;

                                    @Override
                                    public void buttonClick(Button.ClickEvent event) {
                                        fileStores.remove(fileName);
                                    }
                                }));
            }

            if (indicators.size() == 0) {
                UI.getCurrent().setPollInterval(currentPollInterval);
            }

            File file = receiver.getFile();

            receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived());
            receiver.setValue(null);

        }

        @Override
        public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
            if (!indicators.isEmpty()) {
                Label uploadResult = new Label("Upload failed! File: " + event.getFileName());
                uploadResult.setStyleName("upload-status");
                rowWrap.replaceComponent(indicators.remove(0), uploadResult);
            }
        }

        @Override
        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            long readBytes = event.getBytesReceived();
            long contentLength = event.getContentLength();
            float f = (float) readBytes / (float) contentLength;
            indicators.get(0).setValue(f);
        }

        @Override
        public OutputStream getOutputStream() {
            MultiUpload.FileDetail next = attachmentBtn.getPendingFileNames().iterator().next();
            return receiver.receiveUpload(next.getFileName(), next.getMimeType());
        }

        @Override
        public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) {
            UI.getCurrent().setPollInterval(500);
            if (indicators == null) {
                indicators = new LinkedList<ProgressBar>();
            }
            for (MultiUpload.FileDetail f : pendingFileNames) {
                ProgressBar pi = new ProgressBar();
                pi.setValue(0f);
                pi.setStyleName("upload-progress");
                pi.setWidth("100%");
                rowWrap.addComponentAsFirst(pi);
                pi.setEnabled(true);
                pi.setVisible(true);
                indicators.add(pi);
            }
        }

        @Override
        public boolean isInterrupted() {
            return false;
        }
    };
    attachmentBtn.setHandler(handler);

    fileStores = new HashMap<String, File>();

    constructUI();
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java

License:Open Source License

private void prepareUploadField() {
    receiver = createReceiver();/* w w w  . j  a  v a2 s.c  om*/

    uploadField = new MultiUpload();
    uploadField.setButtonCaption("");
    uploadField.setImmediate(true);

    MultiUploadHandler handler = new MultiUploadHandler() {
        private LinkedList<ProgressBar> indicators;

        @Override
        public void streamingStarted(StreamVariable.StreamingStartEvent event) {
        }

        @Override
        public void streamingFinished(StreamVariable.StreamingEndEvent event) {
            String fileName = event.getFileName();
            int index = fileName.lastIndexOf(".");
            if (index > 0) {
                String fileExt = fileName.substring(index + 1, fileName.length());
                fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "."
                        + fileExt;
            }

            if (!indicators.isEmpty()) {
                statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName));
            }

            if (indicators.size() == 0) {
                UI.getCurrent().setPollInterval(currentPollInterval);
            }

            File file = receiver.getFile();

            receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived());
            receiver.setValue(null);
        }

        @Override
        public void streamingFailed(StreamVariable.StreamingErrorEvent event) {
            if (!indicators.isEmpty()) {
                Label uploadResult = new Label("Upload failed! File: " + event.getFileName());
                uploadResult.setStyleName("upload-status");
                statusWrapper.replaceComponent(indicators.remove(0), uploadResult);
            }
        }

        @Override
        public void onProgress(StreamVariable.StreamingProgressEvent event) {
            long readBytes = event.getBytesReceived();
            long contentLength = event.getContentLength();
            float f = (float) readBytes / (float) contentLength;
            indicators.get(0).setValue(f);
        }

        @Override
        public OutputStream getOutputStream() {
            MultiUpload.FileDetail next = uploadField.getPendingFileNames().iterator().next();
            return receiver.receiveUpload(next.getFileName(), next.getMimeType());
        }

        @Override
        public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) {
            UI.getCurrent().setPollInterval(500);
            if (indicators == null) {
                indicators = new LinkedList<ProgressBar>();
            }
            for (MultiUpload.FileDetail f : pendingFileNames) {
                ProgressBar pi = new ProgressBar();
                pi.setValue(0f);
                pi.setStyleName("upload-progress");
                pi.setWidth("100%");
                statusWrapper.addComponent(pi);
                pi.setEnabled(true);
                pi.setVisible(true);
                indicators.add(pi);
            }
        }

        @Override
        public boolean isInterrupted() {
            return false;
        }
    };
    uploadField.setHandler(handler);
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java

public DayWidget() {

    //Creating Panel
    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setWidth("876px");
    iPanel.setHeight("41px");

    ProgressBar iDayProgressBar = new ProgressBar();
    iDayProgressBar.setCaption("Period 3, 10th October");
    iDayProgressBar.setWidth("875px");
    iDayProgressBar.setValue(0.3f);//from w  w w .j a  va 2  s.c  o m
    addComponent(iDayProgressBar);

    //Adding Panel to Vertical Layout
    addComponent(iPanel);
    VerticalLayout iVerticalLayout = new VerticalLayout();

    GridLayout iGridLayout = new GridLayout(9, 1);
    iGridLayout.setWidth("1000px");
    iGridLayout.setHeight("40px");

    for (int i = 1; i <= 8; i++) {

        HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8);
        iHourAtAGlanceWidget.setSizeFull();
        iGridLayout.addComponent(iHourAtAGlanceWidget);
        iGridLayout.setColumnExpandRatio(i, 1);
    }

    iVerticalLayout.addComponent(iGridLayout);
    iPanel.setContent(iVerticalLayout);

}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java

License:Open Source License

private Component createSEOProgressBar() {
    ProgressBar seoProgressBar = new ProgressBar();
    seoProgressBar.setWidth("250px");
    seoProgressBar.setValue(0.5f);/*from w ww  .  jav  a  2 s.c o  m*/

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(new Label("SEO Rating:"));
    layout.addComponent(seoProgressBar);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, false, true, false));

    NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            // do nothing
        }
    });
    addUpdateButton.addStyleName("update-button");
    addUpdateButton.setHeight("28px");
    addUpdateButton.setCaption("Update");
    addUpdateButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            updateMetaDescriptionPreview(textArea.getValue());
        }
    });
    layout.addComponent(addUpdateButton);

    return layout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private Component createSEOProgressBar() {
    ProgressBar seoProgressBar = new ProgressBar();
    seoProgressBar.setWidth("300px");
    seoProgressBar.setValue(0.5f);/* w ww.ja v a2  s  .  c  o m*/

    HorizontalLayout layout = new HorizontalLayout();
    layout.addComponent(new Label("SEO Rating:"));
    layout.addComponent(seoProgressBar);
    layout.setSpacing(true);
    layout.setMargin(new MarginInfo(false, false, true, false));
    return layout;
}

From source file:dhbw.clippinggorilla.userinterface.windows.PasswordRecoveryWindow.java

public void changeWindow() {
    String errorMsg;//from   w  w w . j  a va 2s  . c  o m
    if (emailOrUsername.getValue().contains("@")) {
        errorMsg = UserUtils.checkEmailOnFormalCorrectness(emailOrUsername.getValue().toLowerCase());
    } else {
        errorMsg = UserUtils.checkUsernameOnFormalCorrectness(emailOrUsername.getValue());
    }

    if (errorMsg.isEmpty()) {
        VaadinUtils.middleInfoNotification(Language.get(Word.IF_USER_EXIST_CHECK_MAIL));
        try {
            String stringEmailOrUsername = emailOrUsername.getValue();
            if (stringEmailOrUsername.contains("@")) {
                stringEmailOrUsername = stringEmailOrUsername.toLowerCase();
            }
            String token = UserUtils.initiateForgottenPasswordRecovery(stringEmailOrUsername);
            forms.removeAllComponents();

            TextField resetCode = new TextField(Language.get(Word.RESET_CODE));
            resetCode.setMaxLength(6);
            resetCode.addValueChangeListener(e -> {
                if (resetCode.getValue().length() > 5) {
                    resetCode.setComponentError(null);
                    setError(resetCode, false);
                } else {
                    resetCode.setComponentError(new UserError(Language.get(Word.RESET_CODE_SIX_CHARS),
                            AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                    VaadinUtils.infoNotification(Language.get(Word.RESET_CODE_SIX_CHARS));
                    setError(resetCode, true);
                }
            });

            ProgressBar strength = new ProgressBar();

            PasswordField pw1 = new PasswordField(Language.get(Word.PASSWORD));
            pw1.setMaxLength(51);
            pw1.addValueChangeListener(e -> {
                String pwErrorMsg = UserUtils.checkPassword(e.getValue());
                strength.setValue(UserUtils.calculatePasswordStrength(e.getValue()));
                if (!pwErrorMsg.isEmpty()) {
                    pw1.setComponentError(new UserError(pwErrorMsg, AbstractErrorMessage.ContentMode.HTML,
                            ErrorMessage.ErrorLevel.ERROR));
                    VaadinUtils.infoNotification(pwErrorMsg);
                    setError(pw1, true);
                } else {
                    pw1.setComponentError(null);
                    setError(pw1, false);
                }
            });

            strength.setWidth("184px");
            strength.setHeight("1px");

            PasswordField pw2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
            pw2.setMaxLength(51);
            pw2.addValueChangeListener(e -> {
                String pwErrorMsg = UserUtils.checkSecondPassword(pw1.getValue(), e.getValue());
                if (!pwErrorMsg.isEmpty()) {
                    pw2.setComponentError(new UserError(pwErrorMsg, AbstractErrorMessage.ContentMode.HTML,
                            ErrorMessage.ErrorLevel.ERROR));
                    VaadinUtils.infoNotification(pwErrorMsg);
                    setError(pw2, true);
                } else {
                    pw2.setComponentError(null);
                    setError(pw2, false);
                }
            });

            send.setCaption(Language.get(Word.RESET));
            send.setEnabled(false);
            sendListener.remove();
            send.addClickListener(ce -> {
                try {
                    UserUtils.executeForgottenPasswordRecovery(emailOrUsername.getValue(), resetCode.getValue(),
                            token, pw1.getValue(), pw2.getValue());
                    VaadinUtils.infoNotification(Language.get(Word.RESET_SUCCESSFUL));
                    close();
                } catch (PasswordChangeException ex) {
                    VaadinUtils.infoNotification(Language.get(Word.RESET_FAILED));
                }
            });
            forms.addComponents(resetCode, pw1, strength, pw2);
            center();
        } catch (UserNotFoundException e) {
            VaadinUtils.errorNotification(Language.get(Word.RESET_FAILED));
        }
    } else {
        VaadinUtils.infoNotification(errorMsg);
    }
}

From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java

private Component buildUserTab(User user) {
    HorizontalLayout root = new HorizontalLayout();
    root.setCaption(Language.get(Word.PROFILE));
    root.setIcon(VaadinIcons.USER);/* w w  w.ja va2s  .  c  o m*/
    root.setWidth("100%");
    root.setSpacing(true);
    root.setMargin(true);

    FormLayout details = new FormLayout();
    details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT);
    root.addComponent(details);

    firstNameField = new TextField(Language.get(Word.FIRST_NAME));
    firstNameField.setValue(user.getFirstName());
    firstNameField.setMaxLength(20);
    firstNameField.addValueChangeListener(event -> {
        String firstNameError = UserUtils.checkName(event.getValue());
        if (!firstNameError.isEmpty()) {
            firstNameField.setComponentError(new UserError(firstNameError,
                    AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(firstNameError);
            saveButton.setEnabled(setError(firstNameField, true));
        } else {
            firstNameField.setComponentError(null);
            boolean enabled = setError(firstNameField, false);
            saveButton.setEnabled(enabled);
        }
    });
    setError(firstNameField, false);

    lastNameField = new TextField(Language.get(Word.LAST_NAME));
    lastNameField.setValue(user.getLastName());
    lastNameField.setMaxLength(20);
    lastNameField.addValueChangeListener(event -> {
        String lastNameError = UserUtils.checkName(event.getValue());
        if (!lastNameError.isEmpty()) {
            lastNameField.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(lastNameError);
            saveButton.setEnabled(setError(lastNameField, true));
        } else {
            lastNameField.setComponentError(null);
            saveButton.setEnabled(setError(lastNameField, false));
        }
    });
    setError(lastNameField, false);

    usernameField = new TextField(Language.get(Word.USERNAME));
    usernameField.setValue(user.getUsername());
    usernameField.setMaxLength(20);
    usernameField.addValueChangeListener(event -> {
        if (!event.getValue().equals(user.getUsername())) {
            String userNameError = UserUtils.checkUsername(event.getValue());
            if (!userNameError.isEmpty()) {
                usernameField.setComponentError(new UserError(userNameError,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(userNameError);
                saveButton.setEnabled(setError(usernameField, true));
            } else {
                usernameField.setComponentError(null);
                saveButton.setEnabled(setError(usernameField, false));
            }
        } else {
            usernameField.setComponentError(null);
            saveButton.setEnabled(setError(usernameField, false));
        }
    });
    setError(usernameField, false);

    emailField = new TextField(Language.get(Word.EMAIL));
    emailField.setValue(user.getEmail());
    emailField.setMaxLength(256);
    emailField.addValueChangeListener(event -> {
        if (!event.getValue().equals(user.getEmail())) {
            String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase());
            if (!email1Error.isEmpty()) {
                emailField.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML,
                        ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(email1Error);
                saveButton.setEnabled(setError(emailField, true));
            } else {
                emailField.setComponentError(null);
                saveButton.setEnabled(setError(emailField, false));
            }
        } else {
            emailField.setComponentError(null);
            saveButton.setEnabled(setError(emailField, false));
        }
    });
    setError(emailField, false);

    oldPasswordField = new PasswordField(Language.get(Word.OLD_PASSWORD));
    oldPasswordField.setValue("");
    oldPasswordField.setMaxLength(51);
    oldPasswordField.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password1Error = UserUtils.checkPassword(event.getValue());
            if (!password1Error.isEmpty()) {
                oldPasswordField.setComponentError(new UserError(password1Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password1Error);
                saveButton.setEnabled(setError(oldPasswordField, true));
            } else {
                oldPasswordField.setComponentError(null);
                saveButton.setEnabled(setError(oldPasswordField, false));
            }
        } else {
            oldPasswordField.setComponentError(null);
            saveButton.setEnabled(setError(oldPasswordField, false));
        }
    });
    setError(oldPasswordField, false);

    ProgressBar strength = new ProgressBar();

    password1Field = new PasswordField(Language.get(Word.PASSWORD));
    password1Field.setValue("");
    password1Field.setMaxLength(51);
    password1Field.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password1Error = UserUtils.checkPassword(event.getValue());
            strength.setValue(UserUtils.calculatePasswordStrength(event.getValue()));
            if (!password1Error.isEmpty()) {
                password1Field.setComponentError(new UserError(password1Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password1Error);
                saveButton.setEnabled(setError(password1Field, true));
            } else {
                password1Field.setComponentError(null);
                saveButton.setEnabled(setError(password1Field, false));
            }
        } else {
            password1Field.setComponentError(null);
            saveButton.setEnabled(setError(password1Field, false));
        }
    });
    setError(password1Field, false);

    strength.setWidth("184px");
    strength.setHeight("1px");

    password2Field = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
    password2Field.setValue("");
    password2Field.setMaxLength(51);
    password2Field.addValueChangeListener(event -> {
        if (!event.getValue().isEmpty()) {
            String password2Error = UserUtils.checkPassword(event.getValue())
                    + UserUtils.checkSecondPassword(password1Field.getValue(), event.getValue());
            if (!password2Error.isEmpty()) {
                password2Field.setComponentError(new UserError(password2Error,
                        AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
                VaadinUtils.infoNotification(password2Error);
                saveButton.setEnabled(setError(password2Field, true));
            } else {
                password2Field.setComponentError(null);
                saveButton.setEnabled(setError(password2Field, false));
            }
        } else {
            password2Field.setComponentError(null);
            saveButton.setEnabled(setError(password2Field, false));
        }
    });
    setError(password2Field, false);

    details.addComponents(firstNameField, lastNameField, usernameField, emailField, oldPasswordField,
            password1Field, strength, password2Field);

    return root;
}

From source file:dhbw.clippinggorilla.userinterface.windows.RegisterWindow.java

public RegisterWindow() {
    setModal(true);/*from  w  w  w  .ja  va 2s .  co  m*/
    setResizable(false);
    setDraggable(false);
    setCaption(Language.get(Word.REGISTER));
    addCloseShortcut(KeyCode.ENTER, null);

    Button save = new Button(Language.get(Word.REGISTER));

    VerticalLayout windowLayout = new VerticalLayout();
    windowLayout.setMargin(false);
    windowLayout.setSizeUndefined();

    FormLayout forms = new FormLayout();
    forms.setMargin(true);
    forms.setSizeUndefined();

    TextField firstName = new TextField(Language.get(Word.FIRST_NAME));
    firstName.focus();
    firstName.setMaxLength(20);
    firstName.addValueChangeListener(event -> {
        String firstNameError = UserUtils.checkName(event.getValue());
        if (!firstNameError.isEmpty()) {
            firstName.setComponentError(new UserError(firstNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(firstNameError);
            save.setEnabled(setError(firstName, true));
        } else {
            firstName.setComponentError(null);
            boolean enabled = setError(firstName, false);
            save.setEnabled(enabled);
        }
    });
    forms.addComponent(firstName);

    TextField lastName = new TextField(Language.get(Word.LAST_NAME));
    lastName.setMaxLength(20);
    lastName.addValueChangeListener(event -> {
        String lastNameError = UserUtils.checkName(event.getValue());
        if (!lastNameError.isEmpty()) {
            lastName.setComponentError(new UserError(lastNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(lastNameError);
            save.setEnabled(setError(lastName, true));
        } else {
            lastName.setComponentError(null);
            save.setEnabled(setError(lastName, false));
        }
    });
    forms.addComponent(lastName);

    TextField userName = new TextField(Language.get(Word.USERNAME));
    userName.setMaxLength(20);
    userName.addValueChangeListener(event -> {
        String userNameError = UserUtils.checkUsername(event.getValue());
        if (!userNameError.isEmpty()) {
            userName.setComponentError(new UserError(userNameError, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(userNameError);
            save.setEnabled(setError(userName, true));
        } else {
            userName.setComponentError(null);
            save.setEnabled(setError(userName, false));

        }
    });
    forms.addComponent(userName);

    TextField email1 = new TextField(Language.get(Word.EMAIL));
    email1.setMaxLength(256);
    email1.addValueChangeListener(event -> {
        String email1Error = UserUtils.checkEmail(event.getValue().toLowerCase());
        if (!email1Error.isEmpty()) {
            email1.setComponentError(new UserError(email1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email1Error);
            save.setEnabled(setError(email1, true));
        } else {
            email1.setComponentError(null);
            save.setEnabled(setError(email1, false));
        }
    });
    forms.addComponent(email1);

    TextField email2 = new TextField(Language.get(Word.EMAIL_AGAIN));
    email2.setMaxLength(256);
    email2.addValueChangeListener(event -> {
        String email2Error = UserUtils.checkEmail(event.getValue().toLowerCase())
                + UserUtils.checkSecondEmail(email1.getValue().toLowerCase(), event.getValue().toLowerCase());
        if (!email2Error.isEmpty()) {
            email2.setComponentError(new UserError(email2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(email2Error);
            save.setEnabled(setError(email2, true));
        } else {
            email2.setComponentError(null);
            save.setEnabled(setError(email2, false));
        }
    });
    forms.addComponent(email2);

    ProgressBar strength = new ProgressBar();

    PasswordField password1 = new PasswordField(Language.get(Word.PASSWORD));
    password1.setMaxLength(51);
    password1.addValueChangeListener(event -> {
        String password1Error = UserUtils.checkPassword(event.getValue());
        strength.setValue(UserUtils.calculatePasswordStrength(event.getValue()));
        if (!password1Error.isEmpty()) {
            password1.setComponentError(new UserError(password1Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password1Error);
            save.setEnabled(setError(password1, true));
        } else {
            password1.setComponentError(null);
            save.setEnabled(setError(password1, false));
        }

    });
    forms.addComponent(password1);

    strength.setWidth("184px");
    strength.setHeight("1px");
    forms.addComponent(strength);

    PasswordField password2 = new PasswordField(Language.get(Word.PASSWORD_AGAIN));
    password2.setMaxLength(51);
    password2.addValueChangeListener(event -> {
        String password2Error = UserUtils.checkPassword(event.getValue())
                + UserUtils.checkSecondPassword(password1.getValue(), event.getValue());
        if (!password2Error.isEmpty()) {
            password2.setComponentError(new UserError(password2Error, AbstractErrorMessage.ContentMode.HTML,
                    ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(password2Error);
            save.setEnabled(setError(password2, true));
        } else {
            password2.setComponentError(null);
            save.setEnabled(setError(password2, false));
        }
    });
    forms.addComponent(password2);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth(100.0f, Unit.PERCENTAGE);

    Label placeholder = new Label();

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.setIcon(VaadinIcons.CLOSE);
    cancel.addClickListener(ce -> {
        close();
    });
    cancel.setClickShortcut(KeyCode.ESCAPE, null);

    save.setEnabled(false);
    save.setIcon(VaadinIcons.CHECK);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addClickListener(ce -> {
        try {
            User user = UserUtils.registerUser(userName.getValue(), password1.getValue(), password2.getValue(),
                    email1.getValue().toLowerCase(), email2.getValue().toLowerCase(), firstName.getValue(),
                    lastName.getValue());
            UserUtils.setCurrentUser(user);
            close();
            UI.getCurrent().addWindow(ActivateWindow.get());
        } catch (UserCreationException ex) {
            Log.error("Registration failed", ex);
            VaadinUtils.errorNotification(Language.get(Word.REG_FAILED));
        }
    });
    save.setClickShortcut(KeyCode.ENTER, null);

    footer.addComponents(placeholder, cancel, save);
    footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER);

    windowLayout.addComponent(forms);
    windowLayout.addComponent(footer);

    setContent(windowLayout);
}