Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

private void refreshProfiles(Group g, Layout layoutProfiles) {
    layoutProfiles.removeAllComponents();
    GroupUtils.getAllInterestProfiles(g, UserUtils.getCurrent()).forEach((p, enabled) -> {
        HorizontalLayout layoutProfile = new HorizontalLayout();
        layoutProfile.setWidth("100%");

        CheckBox checkBoxEnabled = new CheckBox();
        checkBoxEnabled.setValue(enabled);
        checkBoxEnabled.addValueChangeListener(v -> {
            GroupInterestProfileUtils.changeEnabled(p, UserUtils.getCurrent(), v.getValue());
            refreshAll(g);// w ww .jav a 2 s  .  c  o m
        });

        long subscribers = p.getEnabledUsers().values().stream().filter(v -> v).count();
        Label labelProfileInfo = new Label();
        Language.setCustom(Word.SUBSCRIBERS, s -> {
            String info = p.getName() + " (" + subscribers + " ";
            info += subscribers == 1 ? Language.get(Word.SUBSCRIBER) + ")"
                    : Language.get(Word.SUBSCRIBERS) + ")";
            labelProfileInfo.setValue(info);
        });

        boolean isAdmin = g.getUsers().getOrDefault(UserUtils.getCurrent(), false);

        Button buttonOpen = new Button(VaadinIcons.EXTERNAL_LINK);
        buttonOpen.addClickListener(ce -> {
            UI.getCurrent().addWindow(GroupProfileWindow.show(p, isAdmin, () -> {
            }));
        });

        if (isAdmin) {
            Button buttonRemove = new Button(VaadinIcons.MINUS);
            buttonRemove.addStyleName(ValoTheme.BUTTON_DANGER);
            buttonRemove.addClickListener(ce -> {
                ConfirmationDialog.show(
                        Language.get(Word.REALLY_DELETE_PROFILE).replace("[PROFILE]", p.getName()), () -> {
                            GroupInterestProfileUtils.delete(p);
                            refreshAll(g);
                        });
            });

            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen, buttonRemove);
        } else {
            layoutProfile.addComponents(checkBoxEnabled, labelProfileInfo, buttonOpen);
        }

        layoutProfile.setExpandRatio(labelProfileInfo, 5);
        layoutProfile.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
        layoutProfile.setComponentAlignment(labelProfileInfo, Alignment.MIDDLE_LEFT);

        layoutProfiles.addComponent(layoutProfile);
    });
}

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

private Component getMembers(Group g) {
    VerticalLayout layoutRootMembers = new VerticalLayout();
    layoutRootMembers.setMargin(false);//from   w w w .ja v  a 2s  . co  m
    layoutRootMembers.setWidth("100%");
    Panel panelMembers = new Panel(Language.get(Word.MEMBERS));
    Language.setCustom(Word.MEMBERS, s -> panelMembers.setCaption(s));
    panelMembers.setWidth("100%");
    panelMembers.setHeight("200px");

    VerticalLayout layoutMembers = new VerticalLayout();
    mapLayoutMembers.put(g, layoutMembers);
    layoutMembers.setWidth("100%");

    refreshMembers(g, layoutMembers);

    panelMembers.setContent(layoutMembers);
    layoutRootMembers.addComponent(panelMembers);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addUserGroup = new CssLayout();
        addUserGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addUserGroup.setWidth("100%");

        TextField textFieldaddUser = new TextField();
        Language.setCustom(Word.USERNAME, s -> textFieldaddUser.setPlaceholder(s));
        textFieldaddUser.setMaxLength(255);
        textFieldaddUser.setWidth("70%");
        addUserGroup.addComponent(textFieldaddUser);

        Button buttonAddUser = new Button();
        buttonAddUser.setIcon(VaadinIcons.PLUS);
        buttonAddUser.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddUser.setWidth("30%");
        buttonAddUser.addClickListener(e -> {
            try {
                User u = UserUtils.getUser(textFieldaddUser.getValue());
                textFieldaddUser.clear();
                GroupUtils.addUser(g, u);
                refreshAll(g);
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addUserGroup.addComponent(buttonAddUser);

        layoutRootMembers.addComponent(addUserGroup);
    }

    return layoutRootMembers;
}

From source file:dhbw.clippinggorilla.userinterface.views.GroupView.java

public void refreshMembers(Group g, Layout layoutMembers) {
    layoutMembers.removeAllComponents();
    Map<User, Boolean> allMembers = GroupUtils.getAllMembers(g);
    boolean isAdmin = GroupUtils.isAdmin(g, UserUtils.getCurrent());
    if (!isAdmin) {
        if (allMembers.size() < 2) {
            buttonLeave.setVisible(false);
        } else {/*w  w  w.ja va 2  s.  co m*/
            buttonLeave.setVisible(true);
        }
    } else {
        if (allMembers.entrySet().stream().map(e -> e.getValue()).filter(b -> b == true).count() > 1) {
            buttonLeave.setVisible(true);
        } else {
            buttonLeave.setVisible(false);
        }
    }
    allMembers.forEach((u, admin) -> {
        HorizontalLayout layoutMember = new HorizontalLayout();
        layoutMember.setWidth("100%");

        VaadinIcons iconRole = admin ? VaadinIcons.KEY : VaadinIcons.USER;
        Label labelMemberName = new Label(iconRole.getHtml() + " " + u.getUsername(), ContentMode.HTML);
        //labelMemberName.setWidth("50%");

        layoutMember.addComponents(labelMemberName);
        layoutMember.setComponentAlignment(labelMemberName, Alignment.MIDDLE_LEFT);
        layoutMember.setExpandRatio(labelMemberName, 5);
        if (isAdmin) {
            if (g.getUsers().size() > 1) {
                Button buttonChangeRole = new Button(admin ? VaadinIcons.ARROW_DOWN : VaadinIcons.ARROW_UP);
                buttonChangeRole.addClickListener(ce -> {
                    if (g.getUsers().get(u)) {//Downgrade
                        long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
                        if (amountAdmins > 1) {
                            if (UserUtils.getCurrent() == u) {
                                ConfirmationDialog.show(Language.get(Word.REALLY_DEADMIN_YOURSELF), () -> {
                                    GroupUtils.makeNormalMember(g, u);
                                    refreshAll(g);
                                });
                            } else {
                                GroupUtils.makeNormalMember(g, u);
                                refreshAll(g);
                            }
                        } else {
                            VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
                            buttonLeave.setVisible(false);
                        }
                    } else {//Upgrade
                        GroupUtils.makeAdmin(g, u);
                        refreshAll(g);
                    }
                });
                layoutMember.addComponent(buttonChangeRole);

                if (g.getUsers().values().stream().filter(v -> v).count() > 1 || !GroupUtils.isAdmin(g, u)) {
                    Button buttonRemoveUser = new Button(VaadinIcons.MINUS);
                    buttonRemoveUser.addStyleName(ValoTheme.BUTTON_DANGER);
                    buttonRemoveUser.addClickListener(ce -> {
                        ConfirmationDialog.show(
                                Language.get(Word.REALLY_REMOVE_USER_FROM_GROUP)
                                        .replace("[USER]", u.getUsername()).replace("[GROUP]", g.getName()),
                                () -> {
                                    GroupUtils.removeUser(g, u);
                                    refreshAll(g);
                                });
                    });
                    layoutMember.addComponents(buttonRemoveUser);
                }
            }
        }
        layoutMembers.addComponent(layoutMember);
    });
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public InterestProfileView() {
    User user = UserUtils.getCurrent();// www .j a  va  2  s .  co m
    Set<InterestProfile> profiles = UserUtils.getAllInterestProfiles(user);

    CssLayout newProfileGroup = new CssLayout();
    newProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    TextField textFieldNewProfileName = new TextField();
    Language.setCustom(Word.PROFILE_NAME, s -> textFieldNewProfileName.setPlaceholder(s));
    textFieldNewProfileName.setWidth("260px");
    textFieldNewProfileName.setMaxLength(255);
    newProfileGroup.addComponent(textFieldNewProfileName);

    Button buttonNewProfile = new Button();
    buttonNewProfile.setIcon(VaadinIcons.PLUS);
    buttonNewProfile.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonNewProfile.addClickListener(e -> {
        Tab newTab = accordion.addTab(createTab(createEmptyProfile(textFieldNewProfileName.getValue())),
                textFieldNewProfileName.getValue());
        accordion.setSelectedTab(newTab);
        accordion.setWidth("100%");
        textFieldNewProfileName.clear();
    });
    newProfileGroup.addComponent(buttonNewProfile);
    textFieldNewProfileName
            .addFocusListener(f -> buttonNewProfile.setClickShortcut(ShortcutAction.KeyCode.ENTER, null));
    textFieldNewProfileName.addBlurListener(f -> buttonNewProfile.removeClickShortcut());

    profiles.forEach((InterestProfile profile) -> {
        accordion.addTab(createTab(profile), profile.getName());
    });
    addComponents(newProfileGroup, accordion);
    SESSIONS.put(user, this);
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public VerticalLayout createTab(InterestProfile profile) {
    VerticalLayout profileSettingsLayout = new VerticalLayout();
    GridLayout tabContent = new GridLayout(3, 3);

    TextField textFieldName = new TextField();
    Language.set(Word.NAME, textFieldName);
    textFieldName.setWidth("100%");
    textFieldName.setValue(profile.getName());
    textFieldName.setMaxLength(255);//from   w  w  w . j  a v  a 2 s  .c  o  m
    CheckBox checkBoxEnabled = new CheckBox();
    checkBoxEnabled.setValue(profile.isEnabled());
    Language.setCustom(Word.ENABLED, s -> checkBoxEnabled.setCaption(s));

    Button buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        InterestProfileUtils.delete(profile);
        accordion.removeTab(accordion.getTab(profileSettingsLayout));
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        InterestProfileUtils.changeName(profile, textFieldName.getValue());
        accordion.getTab(profileSettingsLayout).setCaption(textFieldName.getValue());
        InterestProfileUtils.changeEnabled(profile, checkBoxEnabled.getValue());
        InterestProfileUtils.changeSources(profile, profile.getSources());
        InterestProfileUtils.changeCategories(profile, profile.getCategories());
        InterestProfileUtils.changeAllTags(profile, profile.getTags());
        VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
    });
    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    Label placeholder = new Label();
    Label placeholder2 = new Label();
    placeholder2.setWidth("100%");

    Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML);
    Language.setCustom(Word.HELP_TEXT, s -> labelHelp.setValue(s));
    labelHelp.setWidth("500px");
    PopupView popupHelp = new PopupView(null, labelHelp);

    Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION);
    buttonHelp.addClickListener(ce -> {
        popupHelp.setPopupVisible(true);
    });

    GridLayout footer = new GridLayout(5, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(buttonHelp, popupHelp, placeholder, buttonDelete, buttonSave);
    footer.setColumnExpandRatio(2, 5);
    footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    tabContent.addComponents(textFieldName, checkBoxEnabled, placeholder2);
    tabContent.addComponent(getSources(profile), 0, 1, 1, 1);
    tabContent.addComponent(getCategories(profile), 2, 1);
    tabContent.addComponent(getTags(profile), 0, 2, 2, 2);
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    tabContent.setComponentAlignment(checkBoxEnabled, Alignment.MIDDLE_CENTER);
    profileSettingsLayout.addComponents(tabContent, footer);
    profileSettingsLayout.setMargin(false);
    profileSettingsLayout.setSpacing(false);
    profileSettingsLayout.setWidth("100%");
    return profileSettingsLayout;
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

private Component getAddTagGroup(InterestProfile profile, boolean included) {
    CssLayout newTagGroup = new CssLayout();
    newTagGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    TextField textFieldTag = new TextField();
    textFieldTag.setWidth("325px");
    textFieldTag.setMaxLength(255);//from ww w . ja v a 2 s.  com
    Language.setCustom(Word.NEW_TAG, s -> textFieldTag.setPlaceholder(s));

    Button buttonAddTag = new Button(VaadinIcons.PLUS);
    buttonAddTag.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonAddTag.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttonAddTag.addClickListener(event -> {
        addRow(profile, included, textFieldTag.getValue());
        profile.getTags().put(textFieldTag.getValue(), included);
        textFieldTag.clear();
    });
    textFieldTag.addFocusListener(f -> buttonAddTag.setClickShortcut(ShortcutAction.KeyCode.ENTER, null));
    textFieldTag.addBlurListener(f -> buttonAddTag.removeClickShortcut());

    newTagGroup.addComponents(textFieldTag, buttonAddTag);
    newTagGroup.setWidth("100%");
    return newTagGroup;
}

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

private void addRow(InterestProfile profile, boolean included, String value) {
    GridLayout tagLayout = new GridLayout(2, 1);
    tagLayout.setWidth("100%");

    Label labelTagName = new Label(value, ContentMode.HTML);
    labelTagName.setWidth("100%");
    labelTagName.addStyleName(ValoTheme.LABEL_H3);
    labelTagName.addStyleName(ValoTheme.LABEL_NO_MARGIN);

    Button buttonDeleteTag = new Button(VaadinIcons.TRASH);
    buttonDeleteTag.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDeleteTag.addClickListener(ev -> {
        profile.getTags().remove(value);
        if (included) {
            includedTagsLayouts.get(profile).removeComponent(tagLayout);
        } else {//from  w  w  w.j av  a 2 s  . c om
            excludedTagsLayouts.get(profile).removeComponent(tagLayout);
        }
    });

    tagLayout.addComponents(labelTagName, buttonDeleteTag);
    tagLayout.setComponentAlignment(labelTagName, Alignment.MIDDLE_LEFT);
    tagLayout.setComponentAlignment(buttonDeleteTag, Alignment.MIDDLE_RIGHT);
    tagLayout.setWidth("100%");
    tagLayout.setColumnExpandRatio(0, 5);
    tagLayout.setSpacing(true);
    tagLayout.setMargin(false);

    if (included) {
        includedTagsLayouts.get(profile).addComponent(tagLayout, 2);
    } else {
        excludedTagsLayouts.get(profile).addComponent(tagLayout, 2);
    }
}

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

public static Window get() {
    Window window = new Window();
    window.setModal(true);//from w  w w.  ja v  a  2  s. c om
    window.setResizable(false);
    window.setDraggable(false);
    window.setCaption(Language.get(Word.ACTIVATION_CODE));
    window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null);

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

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

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

    TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE));
    activationCode.setMaxLength(6);
    activationCode.focus();
    activationCode.addValueChangeListener(e -> {
        if (activationCode.getValue().length() > 5) {
            save.setEnabled(true);
            activationCode.setComponentError(null);
        } else {
            save.setEnabled(false);
            activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS),
                    AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION));
            VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS));
        }
    });
    forms.addComponent(activationCode);

    Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE));
    resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED);
    resendMail.addClickListener(ce -> {
        try {
            UserUtils.resendActivationMail(UserUtils.getCurrent());
            VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL));
        } catch (EmailException ex) {
            VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED));
        }
    });
    forms.addComponent(resendMail);

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

    Label placeholder = new Label();

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

    save.setEnabled(false);
    save.setIcon(VaadinIcons.CHECK);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addClickListener(ce -> {
        try {
            String code = activationCode.getValue();
            User user = UserUtils.getCurrent();
            if (UserUtils.activateUser(user, code)) {
                VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL));
                window.close();
            } else {
                activationCode.setValue("");
                VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED));
            }
        } catch (NumberFormatException e) {
        }
    });
    save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    footer.setSizeUndefined();
    footer.setWidth("100%");
    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);

    window.setContent(windowLayout);
    return window;
}

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

public ConfirmationDialog(String confirmationText, Runnable onOk, Runnable onCancel) {
    addCloseListener(ce -> onCancel.run());
    setCaption(Language.get(Word.CONFIRMATION));

    VerticalLayout root = new VerticalLayout();
    root.setSpacing(false);//from ww w.j a va  2 s. c o  m
    root.setMargin(false);
    root.setSizeFull();

    Label text = new Label(confirmationText);
    text.setStyleName(ValoTheme.LABEL_H3);
    text.setWidth("100%");
    VerticalLayout layoutText = new VerticalLayout(text);
    layoutText.setSizeFull();
    layoutText.addStyleName("tags");
    layoutText.setSpacing(false);

    root.addComponent(layoutText);

    Label ignoreMe = new Label();

    Button ok = new Button(Language.get(Word.OK));
    ok.addClickListener(c -> {
        close();
        onOk.run();
    });
    ok.addStyleName(ValoTheme.BUTTON_DANGER);

    Button cancel = new Button(Language.get(Word.CANCEL));
    cancel.addClickListener(c -> {
        close();
        onCancel.run();
    });
    cancel.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    GridLayout footer = new GridLayout(3, 1);
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.addComponents(ignoreMe, ok, cancel);
    footer.setColumnExpandRatio(0, 5);
    footer.setComponentAlignment(ok, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER);
    root.setExpandRatio(layoutText, 5);
    root.addComponent(footer);

    setContent(root);
    setModal(true);
    center();
    setDraggable(false);
    setResizable(false);
    setWidth("350px");
    setHeight("200px");
    UI.getCurrent().addWindow(this);

}

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

public GroupProfileWindow(GroupInterestProfile p, Runnable onClose, boolean isAdmin) {
    VerticalLayout profileSettingsLayout = new VerticalLayout();
    GridLayout windowContent;/*from  w ww. jav a 2s  .c om*/
    Button buttonSave = new Button();

    if (isAdmin) {
        windowContent = new GridLayout(3, 3);

        TextField textFieldName = new TextField();
        Language.set(Word.NAME, textFieldName);
        textFieldName.setWidth("100%");
        textFieldName.setValue(p.getName());
        textFieldName.setMaxLength(255);

        Language.set(Word.SAVE, buttonSave);
        buttonSave.setIcon(VaadinIcons.CHECK);
        buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonSave.addClickListener(ce -> {
            GroupInterestProfileUtils.changeName(p, textFieldName.getValue());
            GroupInterestProfileUtils.changeSources(p, p.getSources());
            GroupInterestProfileUtils.changeCategories(p, p.getCategories());
            GroupInterestProfileUtils.changeAllTags(p, p.getTags());
            VaadinUtils.infoNotification(Language.get(Word.SUCCESSFULLY_SAVED));
            close();
            onClose.run();
        });

        Label placeholder2 = new Label();
        placeholder2.setWidth("100%");
        windowContent.addComponents(textFieldName, placeholder2);
        windowContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
        windowContent.addComponent(getSources(p, true), 0, 1, 1, 1);
        windowContent.addComponent(getCategories(p, true), 2, 1);
        windowContent.addComponent(getTags(p, true), 0, 2, 2, 2);
    } else {
        windowContent = new GridLayout(3, 2);

        Language.set(Word.CLOSE, buttonSave);
        buttonSave.setIcon(VaadinIcons.CLOSE);
        buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonSave.addClickListener(ce -> {
            close();
            onClose.run();
        });

        windowContent.addComponent(getSources(p, false), 0, 0, 1, 0);
        windowContent.addComponent(getCategories(p, false), 2, 0);
        windowContent.addComponent(getTags(p, false), 0, 1, 2, 1);
    }

    buttonSave.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);

    Label placeholder = new Label();

    Label labelHelp = new Label(Language.get(Word.HELP_TEXT), ContentMode.HTML);
    labelHelp.setWidth("500px");
    PopupView popupHelp = new PopupView(null, labelHelp);

    Button buttonHelp = new Button(Language.get(Word.HELP), VaadinIcons.QUESTION);
    buttonHelp.addClickListener(ce -> {
        popupHelp.setPopupVisible(true);
    });

    GridLayout footer;
    if (isAdmin) {
        footer = new GridLayout(4, 1);
        footer.addComponents(buttonHelp, popupHelp, placeholder, buttonSave);
        footer.setColumnExpandRatio(2, 5);
    } else {
        footer = new GridLayout(2, 1);
        footer.addComponents(placeholder, buttonSave);
        footer.setColumnExpandRatio(0, 5);

    }
    footer.setSpacing(true);
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    windowContent.setWidth("100%");
    windowContent.setSpacing(true);
    windowContent.setMargin(true);
    windowContent.addStyleName("profiles");
    profileSettingsLayout.addComponents(windowContent, footer);
    profileSettingsLayout.setMargin(false);
    profileSettingsLayout.setSpacing(false);
    profileSettingsLayout.setWidth("100%");

    setContent(profileSettingsLayout);
    center();
    setWidthUndefined();
    setCaption(p.getName());
    setWidth("950px");
}