Example usage for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY

List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY.

Prototype

String BUTTON_PRIMARY

To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY.

Click Source Link

Document

Primary action button (e.g.

Usage

From source file:de.symeda.sormas.ui.user.UsersView.java

License:Open Source License

public UsersView() {
    super(VIEW_NAME);

    criteria = ViewModelProviders.of(UsersView.class).get(UserCriteria.class);

    grid = new UserGrid();
    grid.setCriteria(criteria);//ww  w. ja  v  a 2  s  . com
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");

    addComponent(gridLayout);

    if (UserProvider.getCurrent().hasUserRight(UserRight.USER_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.userNewUser));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getUserController().create());
        addHeaderComponent(createButton);
    }
}

From source file:de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent.java

License:Open Source License

/**
 * Durch das Aufrufen dieser Methode wird ein Button zum Speichern erzeugt, aber nicht eingefgt.
 * Das passiert in setWrappedComponent().
 * @return//from   www  . j  a v  a  2s.c  om
 */
public Button getCommitButton() {
    if (commitButton == null) {
        commitButton = new Button(I18nProperties.getCaption(Captions.actionSave));
        commitButton.setId("commit");
        commitButton.addStyleName(ValoTheme.BUTTON_PRIMARY);

        commitButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                commitAndHandle();
            }
        });
    }
    return commitButton;
}

From source file:de.symeda.sormas.ui.utils.ConfirmationComponent.java

License:Open Source License

public Button getConfirmButton() {
    if (confirmButton == null) {
        confirmButton = new Button(I18nProperties.getCaption(Captions.actionConfirm));
        cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY);

        confirmButton.addClickListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                onConfirm();/*from  w w  w  .  j  a  v  a  2s. c  om*/
                onDone();
            }
        });
    }
    return confirmButton;
}

From source file:de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent.java

License:Open Source License

public EpiWeekAndDateFilterComponent(Button applyButton, boolean fillAutomatically, boolean showCaption,
        String infoText, Class<E> dateType, String dateTypePrompt, Enum<E> defaultDateType) {
    setSpacing(true);/*from w w w  . j a v a  2  s.co m*/

    Calendar c = Calendar.getInstance();
    c.setTime(new Date());

    dateFilterOptionFilter = new ComboBox();
    dateTypeSelector = new ComboBox();
    weekFromFilter = new ComboBox();
    weekToFilter = new ComboBox();
    dateFromFilter = new PopupDateField();
    dateToFilter = new PopupDateField();

    // Date filter options
    dateFilterOptionFilter.setWidth(200, Unit.PIXELS);
    dateFilterOptionFilter.addItems((Object[]) DateFilterOption.values());
    dateFilterOptionFilter.setNullSelectionAllowed(false);
    dateFilterOptionFilter.select(DateFilterOption.EPI_WEEK);
    if (showCaption) {
        CssStyles.style(dateFilterOptionFilter, CssStyles.FORCE_CAPTION);
    }

    dateFilterOptionFilter.addValueChangeListener(e -> {
        if (e.getProperty().getValue() == DateFilterOption.DATE) {
            int newIndex = getComponentIndex(weekFromFilter);
            removeComponent(weekFromFilter);
            removeComponent(weekToFilter);
            addComponent(dateFromFilter, newIndex);
            addComponent(dateToFilter, newIndex + 1);

            if (fillAutomatically) {
                dateFromFilter.setValue(DateHelper.subtractDays(c.getTime(), 7));
            }
            if (fillAutomatically) {
                dateToFilter.setValue(c.getTime());
            }
        } else {
            int newIndex = getComponentIndex(dateFromFilter);
            removeComponent(dateFromFilter);
            removeComponent(dateToFilter);
            addComponent(weekFromFilter, newIndex);
            addComponent(weekToFilter, newIndex + 1);

            if (fillAutomatically) {
                weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime()));
            }
            if (fillAutomatically) {
                weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime()));
            }
        }
    });
    addComponent(dateFilterOptionFilter);

    // New case date type selector
    if (dateType != null) {
        dateTypeSelector.setWidth(200, Unit.PIXELS);
        dateTypeSelector.addItems((Object[]) dateType.getEnumConstants());
        if (dateTypePrompt != null) {
            dateTypeSelector.setInputPrompt(dateTypePrompt);
        }
        if (defaultDateType != null) {
            dateTypeSelector.select(defaultDateType);
        }
        if (showCaption) {
            CssStyles.style(dateTypeSelector, CssStyles.FORCE_CAPTION);
        }
        addComponent(dateTypeSelector);

        if (!StringUtils.isEmpty(infoText)) {
            Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
            infoLabel.setSizeUndefined();
            infoLabel.setDescription(infoText);
            CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
            addComponent(infoLabel);
        }
    }

    // Epi week filter
    List<EpiWeek> epiWeekList = DateHelper.createEpiWeekList(c.get(Calendar.YEAR),
            c.get(Calendar.WEEK_OF_YEAR));

    weekFromFilter.setWidth(200, Unit.PIXELS);
    for (EpiWeek week : epiWeekList) {
        weekFromFilter.addItem(week);
    }
    weekFromFilter.setNullSelectionAllowed(false);
    if (fillAutomatically) {
        weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime()));
    }
    if (showCaption) {
        weekFromFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekFrom));
    }
    if (applyButton != null) {
        weekFromFilter.addValueChangeListener(e -> {
            applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        });
    }
    addComponent(weekFromFilter);

    weekToFilter.setWidth(200, Unit.PIXELS);
    for (EpiWeek week : epiWeekList) {
        weekToFilter.addItem(week);
    }
    weekToFilter.setNullSelectionAllowed(false);
    if (fillAutomatically) {
        weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime()));
    }
    if (showCaption) {
        weekToFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekTo));
    }
    if (applyButton != null) {
        weekToFilter.addValueChangeListener(e -> {
            applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        });
    }
    addComponent(weekToFilter);

    // Date filter
    dateFromFilter.setWidth(200, Unit.PIXELS);
    if (showCaption) {
        dateFromFilter.setCaption(I18nProperties.getCaption(Captions.from));
    }
    if (applyButton != null) {
        dateFromFilter.addValueChangeListener(e -> {
            applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        });
    }

    dateToFilter.setWidth(200, Unit.PIXELS);
    if (showCaption) {
        dateToFilter.setCaption(I18nProperties.getCaption(Captions.to));
    }
    if (applyButton != null) {
        dateToFilter.addValueChangeListener(e -> {
            applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        });
    }
}

From source file:de.symeda.sormas.ui.utils.VaadinUiUtil.java

License:Open Source License

public static Window showSimplePopupWindow(String caption, String contentText) {
    Window window = new Window(null);
    window.setModal(true);//w  w w.ja  va2 s  . c o  m
    window.setSizeUndefined();
    window.setResizable(false);
    window.center();

    VerticalLayout popupLayout = new VerticalLayout();
    popupLayout.setMargin(true);
    popupLayout.setSpacing(true);
    popupLayout.setSizeUndefined();
    Label contentLabel = new Label(contentText);
    contentLabel.setWidth(100, Unit.PERCENTAGE);
    popupLayout.addComponent(contentLabel);
    Button okayButton = new Button(I18nProperties.getCaption(Captions.actionOkay));
    okayButton.addClickListener(e -> {
        window.close();
    });
    CssStyles.style(okayButton, ValoTheme.BUTTON_PRIMARY);
    popupLayout.addComponent(okayButton);
    popupLayout.setComponentAlignment(okayButton, Alignment.BOTTOM_RIGHT);

    window.setCaption(caption);
    window.setContent(popupLayout);

    UI.getCurrent().addWindow(window);

    return window;
}

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

public ClippingView(Clipping clipping) {
    User user = UserUtils.getCurrent();/*from  w  w w.j  ava  2  s . c o  m*/

    clippingArticlesLayout = new VerticalLayout();
    clippingArticlesLayout.setSpacing(true);
    clippingArticlesLayout.setMargin(false);
    clippingArticlesLayout.setSizeFull();

    HorizontalLayout clippingOptionsLayout = new HorizontalLayout();
    clippingOptionsLayout.setSpacing(true);
    clippingOptionsLayout.setMargin(false);
    clippingOptionsLayout.setWidth("100%");

    ComboBox<SortOptions> comboBoxSortOptions = new ComboBox<>(Language.get(Word.SORT_BY));
    Language.setCustom(Word.SORT_BY, s -> {
        comboBoxSortOptions.setCaption(s);
        comboBoxSortOptions.getDataProvider().refreshAll();
    });
    comboBoxSortOptions.setItems(EnumSet.allOf(SortOptions.class));
    comboBoxSortOptions.setItemCaptionGenerator(s -> s.getName());
    comboBoxSortOptions.setItemIconGenerator(s -> s.getIcon());
    comboBoxSortOptions.setValue(SortOptions.BYPROFILE);
    comboBoxSortOptions.setTextInputAllowed(false);
    comboBoxSortOptions.setEmptySelectionAllowed(false);
    comboBoxSortOptions.addStyleName("comboboxsort");
    comboBoxSortOptions.addValueChangeListener(e -> {
        switch (e.getValue()) {
        case BYDATE:
            createClippingViewByDate(clipping);
            break;
        case BYPROFILE:
            createClippingViewByProfile(clipping);
            break;
        case BYSOURCE:
            createClippingViewBySource(clipping);
            break;
        }
    });

    Button buttonRegenerateClipping = new Button(VaadinIcons.REFRESH);
    buttonRegenerateClipping.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonRegenerateClipping.addClickListener(ce -> {
        user.setLastClipping(ClippingUtils.generateClipping(user, false));
        ClippingGorillaUI.getCurrent().setMainContent(ClippingView.getCurrent());
    });

    clippingOptionsLayout.addComponents(comboBoxSortOptions, buttonRegenerateClipping);
    clippingOptionsLayout.setExpandRatio(comboBoxSortOptions, 5);
    clippingOptionsLayout.setComponentAlignment(buttonRegenerateClipping, Alignment.BOTTOM_CENTER);

    addComponents(clippingOptionsLayout, clippingArticlesLayout);

    createClippingViewByProfile(clipping);
    if (clipping.getArticles().keySet().isEmpty() && clipping.getArticlesFromGroup().keySet().isEmpty()) {
        Label labelNoProfile = new Label();
        Language.setCustom(Word.NO_PROFILE_PRESENT, s -> labelNoProfile.setValue(s));
        labelNoProfile.addStyleName(ValoTheme.LABEL_H2);
        clippingArticlesLayout.addComponent(labelNoProfile);
    }
}

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

public GroupView() {
    User user = UserUtils.getCurrent();//  w w w. j  a  va2s  . c  om
    Set<Group> groups = UserUtils.getAllGroups(user);

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

    TextField textFieldNewGroupName = new TextField();
    Language.setCustom(Word.GROUP_NAME, s -> textFieldNewGroupName.setPlaceholder(s));
    textFieldNewGroupName.setWidth("260px");
    textFieldNewGroupName.setMaxLength(255);
    newGroupGroup.addComponent(textFieldNewGroupName);

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

    groups.forEach(g -> {
        accordion.addTab(createTab(g), g.getName());
    });
    addComponents(newGroupGroup, accordion);
    //SESSIONS.put(user, this);
}

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

public VerticalLayout createTab(Group g) {
    User u = UserUtils.getCurrent();/*from ww  w  . ja  v  a  2  s  .  c  om*/
    VerticalLayout groupSettingsLayout = new VerticalLayout();
    groupSettingsLayouts.put(g, groupSettingsLayout);
    GridLayout tabContent;
    TextField textFieldName = new TextField();
    if (GroupUtils.isAdmin(g, u)) {
        tabContent = new GridLayout(3, 2);
        Language.set(Word.NAME, textFieldName);
        textFieldName.setWidth("100%");
        textFieldName.setValue(g.getName());
        textFieldName.setMaxLength(255);
        tabContent.addComponent(textFieldName);
        tabContent.setComponentAlignment(textFieldName, Alignment.MIDDLE_LEFT);
    } else {
        tabContent = new GridLayout(3, 1);
    }

    buttonLeave = new Button();
    Language.set(Word.LEAVE, buttonLeave);
    buttonLeave.setIcon(VaadinIcons.MINUS);
    buttonLeave.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonLeave.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_LEAVE_GROUP).replace("[GROUP]", g.getName()), () -> {
            long amountAdmins = g.getUsers().entrySet().stream().filter(e -> e.getValue()).count();
            if (amountAdmins > 1 || !GroupUtils.isAdmin(g, u)) {
                GroupUtils.removeUser(g, u);
                refreshAll(g);
            } else {
                VaadinUtils.errorNotification(Language.get(Word.NOT_ENOUGH_ADMINS_IN_GROUP));
            }
        });
    });

    buttonDelete = new Button();
    Language.set(Word.DELETE, buttonDelete);
    buttonDelete.setIcon(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.addClickListener(ce -> {
        ConfirmationDialog.show(Language.get(Word.REALLY_DELETE_GROUP).replace("[GROUP]", g.getName()), () -> {
            GroupUtils.removeGroup(g);
            refreshAll(g);
        });
    });

    Button buttonSave = new Button();
    Language.set(Word.SAVE, buttonSave);
    buttonSave.setIcon(VaadinIcons.CHECK);
    buttonSave.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonSave.addClickListener(ce -> {
        if (GroupUtils.isAdmin(g, u)) {
            GroupUtils.changeName(g, textFieldName.getValue());
            accordion.getTab(groupSettingsLayout).setCaption(textFieldName.getValue());
        }
        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 placeholder3 = new Label();

    GridLayout footer = new GridLayout(4, 1);
    footer.setSpacing(true);
    footer.setMargin(new MarginInfo(false, true));
    footer.setSizeUndefined();
    footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR);
    footer.setWidth("100%");
    footer.addStyleName("menubar");
    if (GroupUtils.isAdmin(g, u)) {
        footer.addComponents(placeholder, buttonDelete, buttonLeave, buttonSave);
        footer.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    } else {
        footer.addComponents(placeholder, placeholder3, buttonLeave, buttonSave);
    }
    footer.setColumnExpandRatio(0, 5);
    footer.setComponentAlignment(buttonLeave, Alignment.MIDDLE_CENTER);
    footer.setComponentAlignment(buttonSave, Alignment.MIDDLE_CENTER);

    if (GroupUtils.isAdmin(g, u)) {
        tabContent.addComponent(getProfiles(g), 0, 1, 1, 1);
        tabContent.addComponent(getMembers(g), 2, 1);
    } else {
        tabContent.addComponent(getProfiles(g), 0, 0, 1, 0);
        tabContent.addComponent(getMembers(g), 2, 0);
    }
    tabContent.setWidth("100%");
    tabContent.setSpacing(true);
    tabContent.setMargin(true);
    tabContent.addStyleName("profiles");
    groupSettingsLayout.addComponents(tabContent, footer);
    groupSettingsLayout.setMargin(false);
    groupSettingsLayout.setSpacing(false);
    groupSettingsLayout.setWidth("100%");
    return groupSettingsLayout;
}

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

private Component getProfiles(Group g) {
    VerticalLayout layoutRootProfiles = new VerticalLayout();
    layoutRootProfiles.setMargin(false);
    layoutRootProfiles.setWidth("100%");
    Panel panelProfiles = new Panel(Language.get(Word.PROFILES));
    Language.setCustom(Word.PROFILES, s -> panelProfiles.setCaption(s));
    panelProfiles.setWidth("100%");
    panelProfiles.setHeight("200px");

    VerticalLayout layoutProfiles = new VerticalLayout();
    mapLayoutProfiles.put(g, layoutProfiles);
    layoutProfiles.setWidth("100%");

    refreshProfiles(g, layoutProfiles);/*  ww w.  j a  v  a  2 s  .  c  om*/

    panelProfiles.setContent(layoutProfiles);
    layoutRootProfiles.addComponent(panelProfiles);

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

        TextField textFieldAddProfile = new TextField();
        Language.setCustom(Word.PROFILE_NAME, s -> textFieldAddProfile.setPlaceholder(s));
        textFieldAddProfile.setMaxLength(255);
        textFieldAddProfile.setWidth("35%");
        addProfileGroup.addComponent(textFieldAddProfile);

        Button buttonAddProfile = new Button();
        buttonAddProfile.setIcon(VaadinIcons.PLUS);
        buttonAddProfile.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddProfile.setWidth("15%");
        buttonAddProfile.addClickListener(e -> {
            try {
                String name = textFieldAddProfile.getValue();
                textFieldAddProfile.clear();
                Runnable onClose = () -> refreshAll(g);
                UI.getCurrent().addWindow(GroupProfileWindow.create(g, name, true, onClose));
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addProfileGroup.addComponent(buttonAddProfile);

        layoutRootProfiles.addComponent(addProfileGroup);
    }
    return layoutRootProfiles;
}

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 .j  a va2s. c  om
    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;
}