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:de.fatalix.bookery.view.common.BookMenuLayout.java

@PostConstruct
private void postInit() {
    addStyleName("bookery-menu-wrapper");
    addStyleName("bookery-menu");
    Label titleLabel = new Label("Bookery Menu");
    titleLabel.addStyleName(ValoTheme.LABEL_COLORED);
    titleLabel.addStyleName(ValoTheme.LABEL_BOLD);

    Button cancelButton = new Button("close", new Button.ClickListener() {

        @Override/*w  w w. java2  s. c om*/
        public void buttonClick(Button.ClickEvent event) {
            setLayoutVisible(false);
        }
    });
    cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    cancelButton.addStyleName(ValoTheme.BUTTON_DANGER);

    VerticalLayout rootLayout = new VerticalLayout(titleLabel, cancelButton);
    rootLayout.setSpacing(true);
    addComponent(rootLayout);
}

From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java

License:Apache License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();/*  w ww  .  j a  v a 2  s  .com*/
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField(translate("login.name.caption")));
    username.setDescription(translate("login.name.description"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField(translate("login.password.caption")));
    password.setWidth(15, Unit.EM);
    password.setDescription(translate("login.password.description"));
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    login = new Button(translate("login.login-button.caption"));
    buttons.addComponent(login);
    login.setDescription(translate("login.login-button.description"));
    login.setDisableOnClick(true);
    login.addClickListener(event -> {
        try {
            login();
        } finally {
            login.setEnabled(true);
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    Button forgotPassword;
    buttons.addComponent(forgotPassword = new Button(translate("login.password-forgotten.caption")));
    forgotPassword.setDescription(translate("login.password-forgotten.description"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            NotificationPayload notification = new NotificationPayload("login.password-forgotten.text");
            bus.post(new NotificationEvent(this, notification));
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java

License:Apache License

@Inject
public MenuImpl(final Authenticator accessControl, final EventBus bus, final I18NHandler i18n,
        final List<View> allViews) {
    this.accessControl = accessControl;
    this.bus = bus;
    this.i18n = i18n;
    this.allViews = allViews;

    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);//from w  w  w . j a  va 2s .c  o m
    Label title = new Label(translate("application.name"));
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem(translate("button.logout.caption"), FontAwesome.valueOf(translate("button.logout.icon")),
            selectedItem -> {
                VaadinSession.getCurrent().getSession().invalidate();
                Page.getCurrent().reload();
            });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button(translate("application.name"), new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:de.metas.procurement.webui.ui.view.LoginView.java

License:Open Source License

public LoginView() {
    super();/* w  ww .ja  v a  2 s . c  o  m*/
    Application.autowire(this);

    addStyleName(STYLE);

    //
    // Content
    {
        final VerticalComponentGroup content = new VerticalComponentGroup();

        final Resource logoResource = getLogoResource();
        final Image logo = new Image(null, logoResource);
        logo.addStyleName(STYLE_Logo);
        content.addComponent(logo);

        this.email = new EmailField(i18n.get("LoginView.fields.email"));
        email.addStyleName(STYLE_LoginEmail);
        email.setIcon(FontAwesome.USER);
        content.addComponent(email);

        this.password = new PasswordField(i18n.get("LoginView.fields.password"));
        password.addStyleName(STYLE_LoginPassword);
        password.setIcon(FontAwesome.LOCK);
        content.addComponent(password);

        final Button loginButton = new Button(i18n.get("LoginView.fields.loginButton"));
        loginButton.addStyleName(STYLE_LoginButton);
        loginButton.setClickShortcut(KeyCode.ENTER);
        loginButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onUserLogin(email.getValue(), password.getValue());
            }
        });

        final Button forgotPasswordButton = new Button(i18n.get("LoginView.fields.forgotPasswordButton"));
        forgotPasswordButton.setStyleName(STYLE_ForgotPasswordButton);
        forgotPasswordButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                onForgotPassword(email.getValue());
            }
        });

        final CssLayout contentWrapper = new CssLayout(content, loginButton, forgotPasswordButton);
        contentWrapper.addStyleName(STYLE_LoginFormWrapper);
        setContent(contentWrapper);
    }

    //
    // Bottom:
    {
        //
        // Powered-by logo resource
        // Use the configured one if any; fallback to default embedded powered-by logo
        final Resource poweredByLogoResource;
        if (poweredByLogoUrl != null && !poweredByLogoUrl.trim().isEmpty()) {
            poweredByLogoResource = new ExternalResource(poweredByLogoUrl.trim());
        } else {
            poweredByLogoResource = Constants.RESOURCE_PoweredBy;
        }

        //
        // Powered-by component:
        final Component poweredByComponent;
        if (poweredByLinkUrl != null && !poweredByLinkUrl.trim().isEmpty()) {
            final Link link = new Link();
            link.setIcon(poweredByLogoResource);
            link.setResource(new ExternalResource(poweredByLinkUrl.trim()));
            link.setTargetName("_blank");
            poweredByComponent = link;
        } else {
            final Image image = new Image(null, poweredByLogoResource);
            poweredByComponent = image;
        }
        //
        poweredByComponent.addStyleName(STYLE_PoweredBy);
        setToolbar(poweredByComponent);
    }
}

From source file:de.metas.procurement.webui.ui.view.WeeklyDetailedReportingView.java

License:Open Source License

private final void updateUI_NextWeekTrand() {
    final WeekProductQtyReport weekQtyReport = weekQtyReportItem == null ? null : weekQtyReportItem.getBean();
    final Trend nextWeekTrend = weekQtyReport == null ? null : weekQtyReport.getNextWeekTrend();

    for (Map.Entry<Trend, Button> e : trend2button.entrySet()) {
        final Trend trend = e.getKey();
        final Button button = e.getValue();

        if (Objects.equal(nextWeekTrend, trend)) {
            button.addStyleName(STYLE_CurrentTrend);
        } else {//from  ww w  .ja v  a 2s .c  o m
            button.removeStyleName(STYLE_CurrentTrend);
        }
    }
}

From source file:de.steinwedel.messagebox.MessageBox.java

License:Apache License

/**
 * Adds a button./*from   ww w . j  av  a  2 s .com*/
 *
 * @param buttonType A {@link ButtonType}
 * @param runOnClick The Runnable, that is executed on clicking the button
 * @param options    Some optional {@link ButtonOption}s
 * @return The {@link MessageBox} instance
 */
public MessageBox withButton(ButtonType buttonType, Runnable runOnClick, ButtonOption... options) {
    Button button = new Button(BUTTON_DEFAULT_CAPTION_FACTORY.translate(buttonType, DIALOG_DEFAULT_LOCALE));
    buttons.put(buttonType, button);
    button.setData(runOnClick);
    if (buttonType != null) {
        button.addStyleName(buttonType.name().toLowerCase() + "Icon");
    }
    button.addStyleName("messageBoxIcon");
    if (BUTTON_DEFAULT_ICONS_VISIBLE) {
        button.setIcon(BUTTON_DEFAULT_ICON_FACTORY.getIcon(buttonType));
    }
    return withButton(button, options);
}

From source file:de.symeda.sormas.ui.caze.AbstractTableField.java

License:Open Source License

protected Button createAddButton() {

    Button button = new Button(I18nProperties.getCaption(Captions.actionNewEntry));
    button.addStyleName(ValoTheme.BUTTON_LINK);

    button.addClickListener(new ClickListener() {

        @Override/* w  w w .ja va  2 s  .  com*/
        public void buttonClick(ClickEvent event) {
            addEntry();
        }
    });

    return button;
}

From source file:de.symeda.sormas.ui.caze.CaseContactsView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setWidth("100%");
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.contactStatus(null);//from w ww . ja  v  a2 s  . com
        navigateTo(criteria);
    });
    CssStyles.style(statusAll, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER);
    statusAll.setCaptionAsHtml(true);
    statusFilterLayout.addComponent(statusAll);
    statusButtons.put(statusAll, I18nProperties.getCaption(Captions.all));
    activeStatusButton = statusAll;

    for (ContactStatus status : ContactStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.contactStatus(status);
            navigateTo(criteria);
        });
        statusButton.setData(status);
        CssStyles.style(statusButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.BUTTON_FILTER,
                CssStyles.BUTTON_FILTER_LIGHT);
        statusButton.setCaptionAsHtml(true);
        statusFilterLayout.addComponent(statusButton);
        statusButtons.put(statusButton, status.toString());
    }
    statusFilterLayout
            .setExpandRatio(statusFilterLayout.getComponent(statusFilterLayout.getComponentCount() - 1), 1);

    // Bulk operation dropdown
    if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
        statusFilterLayout.setWidth(100, Unit.PERCENTAGE);

        MenuBar bulkOperationsDropdown = new MenuBar();
        MenuItem bulkOperationsItem = bulkOperationsDropdown
                .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

        Command changeCommand = selectedItem -> {
            ControllerProvider.getContactController().showBulkContactDataEditComponent(
                    grid.asMultiSelect().getSelectedItems(), getCaseRef().getUuid());
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkEdit), VaadinIcons.ELLIPSIS_H,
                changeCommand);

        Command cancelFollowUpCommand = selectedItem -> {
            ControllerProvider.getContactController()
                    .cancelFollowUpOfAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkCancelFollowUp), VaadinIcons.CLOSE,
                cancelFollowUpCommand);

        Command lostToFollowUpCommand = selectedItem -> {
            ControllerProvider.getContactController().setAllSelectedItemsToLostToFollowUp(
                    grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkLostToFollowUp), VaadinIcons.UNLINK,
                lostToFollowUpCommand);

        Command deleteCommand = selectedItem -> {
            ControllerProvider.getContactController()
                    .deleteAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                        public void run() {
                            grid.deselectAll();
                            grid.reload();
                        }
                    });
        };
        bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                deleteCommand);

        statusFilterLayout.addComponent(bulkOperationsDropdown);
        statusFilterLayout.setComponentAlignment(bulkOperationsDropdown, Alignment.TOP_RIGHT);
        statusFilterLayout.setExpandRatio(bulkOperationsDropdown, 1);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_EXPORT)) {
        Button exportButton = new Button(I18nProperties.getCaption(Captions.export));
        exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        exportButton.setIcon(VaadinIcons.DOWNLOAD);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_contacts",
                "sormas_contacts_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(exportButton);

        statusFilterLayout.addComponent(exportButton);
        statusFilterLayout.setComponentAlignment(exportButton, Alignment.MIDDLE_RIGHT);
        if (!UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            statusFilterLayout.setExpandRatio(exportButton, 1);
        }
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE)) {
        newButton = new Button(
                I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, Captions.contactNewContact));
        newButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        newButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        newButton.addClickListener(e -> ControllerProvider.getContactController().create(this.getCaseRef()));
        statusFilterLayout.addComponent(newButton);
        statusFilterLayout.setComponentAlignment(newButton, Alignment.MIDDLE_RIGHT);
    }

    statusFilterLayout.addStyleName("top-bar");
    activeStatusButton = statusAll;
    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.caze.CaseController.java

License:Open Source License

private void appendSpecialCommands(CaseDataDto caze,
        CommitDiscardWrapperComponent<? extends Component> editView) {
    if (UserProvider.getCurrent().hasUserRole(UserRole.ADMIN)) {
        editView.addDeleteListener(new DeleteListener() {
            @Override/*www  .j a va 2 s.  c  o m*/
            public void onDelete() {
                FacadeProvider.getCaseFacade().deleteCase(caze.toReference(),
                        UserProvider.getCurrent().getUserReference().getUuid());
                UI.getCurrent().getNavigator().navigateTo(CasesView.VIEW_NAME);
            }
        }, I18nProperties.getString(Strings.entityCase));
    }

    // Initialize 'Archive' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_ARCHIVE)) {
        boolean archived = FacadeProvider.getCaseFacade().isArchived(caze.getUuid());
        Button archiveCaseButton = new Button();
        archiveCaseButton.addStyleName(ValoTheme.BUTTON_LINK);
        if (archived) {
            archiveCaseButton.setCaption(I18nProperties.getCaption(Captions.actionDearchive));
        } else {
            archiveCaseButton.setCaption(I18nProperties.getCaption(Captions.actionArchive));
        }
        archiveCaseButton.addClickListener(e -> {
            editView.commit();
            archiveOrDearchiveCase(caze.getUuid(), !archived);
        });

        editView.getButtonsPanel().addComponentAsFirst(archiveCaseButton);
        editView.getButtonsPanel().setComponentAlignment(archiveCaseButton, Alignment.BOTTOM_LEFT);
    }

    // Initialize 'Transfer case' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_TRANSFER) && !caze.isUnreferredPortHealthCase()) {
        Button transferCaseButton = new Button();
        transferCaseButton.setCaption(I18nProperties.getCaption(Captions.caseTransferCase));
        transferCaseButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                editView.commit();
                CaseDataDto cazeDto = findCase(caze.getUuid());
                transferCase(cazeDto);
            }
        });

        editView.getButtonsPanel().addComponentAsFirst(transferCaseButton);
        editView.getButtonsPanel().setComponentAlignment(transferCaseButton, Alignment.BOTTOM_LEFT);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_REFER_FROM_POE)
            && caze.isUnreferredPortHealthCase()) {
        Button btnReferToFacility = new Button();
        btnReferToFacility.setCaption(I18nProperties.getCaption(Captions.caseReferToFacility));
        btnReferToFacility.addClickListener(e -> {
            editView.commit();
            CaseDataDto caseDto = findCase(caze.getUuid());
            referFromPointOfEntry(caseDto);
        });

        editView.getButtonsPanel().addComponentAsFirst(btnReferToFacility);
        editView.getButtonsPanel().setComponentAlignment(btnReferToFacility, Alignment.BOTTOM_LEFT);
    }
}

From source file:de.symeda.sormas.ui.caze.CasesView.java

License:Open Source License

public CasesView() {
    super(VIEW_NAME);
    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(CasesView.class).get(CaseCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);//from w  w w. ja v  a2 s  .  c o  m
    }

    grid = new CaseGrid();
    grid.setCriteria(criteria);
    gridLayout = new VerticalLayout();
    gridLayout.addComponent(createFilterBar());
    gridLayout.addComponent(createStatusFilterBar());
    gridLayout.addComponent(grid);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");

    grid.getDataProvider().addDataProviderListener(e -> updateStatusButtons());

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_IMPORT)) {
        Button importButton = new Button(I18nProperties.getCaption(Captions.actionImport));
        importButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        importButton.setIcon(VaadinIcons.UPLOAD);
        importButton.addClickListener(e -> {
            Window popupWindow = VaadinUiUtil.showPopupWindow(new CaseImportLayout());
            popupWindow.setCaption(I18nProperties.getString(Strings.headingImportCases));
            popupWindow.addCloseListener(c -> {
                grid.reload();
            });
        });
        addHeaderComponent(importButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EXPORT)) {
        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.export));
        exportButton.setId("export");
        exportButton.setIcon(VaadinIcons.DOWNLOAD);
        VerticalLayout exportLayout = new VerticalLayout();
        exportLayout.setSpacing(true);
        exportLayout.setMargin(true);
        exportLayout.addStyleName(CssStyles.LAYOUT_MINIMAL);
        exportLayout.setWidth(200, Unit.PIXELS);
        exportButton.setContent(exportLayout);
        addHeaderComponent(exportButton);

        Button basicExportButton = new Button(I18nProperties.getCaption(Captions.exportBasic));
        basicExportButton.setId("basicExport");
        basicExportButton.setDescription(I18nProperties.getString(Strings.infoBasicExport));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

        StreamResource streamResource = new GridExportStreamResource(grid, "sormas_cases",
                "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton.setId("extendedExport");
        extendedExportButton.setDescription(I18nProperties.getString(Strings.infoDetailedExport));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

        StreamResource extendedExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                CaseExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getCaseFacade()
                        .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(CaseExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(EpiDataDto.I18N_PREFIX,
                                                            propertyId,
                                                            I18nProperties.getPrefixCaption(
                                                                    HospitalizationDto.I18N_PREFIX,
                                                                    propertyId))))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_cases_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(extendedExportStreamResource).extend(extendedExportButton);

        Button sampleExportButton = new Button(I18nProperties.getCaption(Captions.exportSamples));
        sampleExportButton.setId("sampleExport");
        sampleExportButton.setDescription(I18nProperties.getString(Strings.infoSampleExport));
        sampleExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        sampleExportButton.setIcon(VaadinIcons.FILE_TEXT);
        sampleExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(sampleExportButton);

        StreamResource sampleExportStreamResource = DownloadUtil.createCsvExportStreamResource(
                SampleExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getSampleFacade()
                        .getExportList(UserProvider.getCurrent().getUuid(), grid.getCriteria(), start, max),
                (propertyId, type) -> {
                    String caption = I18nProperties.getPrefixCaption(SampleExportDto.I18N_PREFIX, propertyId,
                            I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, propertyId,
                                    I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, propertyId,
                                            I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, propertyId,
                                                    I18nProperties.getPrefixCaption(
                                                            AdditionalTestDto.I18N_PREFIX, propertyId)))));
                    if (Date.class.isAssignableFrom(type)) {
                        caption += " (" + DateHelper.getLocalShortDatePattern() + ")";
                    }
                    return caption;
                }, "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv");
        new FileDownloader(sampleExportStreamResource).extend(sampleExportButton);

        // Warning if no filters have been selected
        Label warningLabel = new Label(I18nProperties.getString(Strings.infoExportNoFilters), ContentMode.HTML);
        warningLabel.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(warningLabel);
        warningLabel.setVisible(false);

        exportButton.addClickListener(e -> {
            warningLabel.setVisible(!criteria.hasAnyFilterActive());
        });
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_MERGE)) {
        Button mergeDuplicatesButton = new Button(I18nProperties.getCaption(Captions.caseMergeDuplicates));
        mergeDuplicatesButton.setId("mergeDuplicates");
        mergeDuplicatesButton.setIcon(VaadinIcons.COMPRESS_SQUARE);
        mergeDuplicatesButton
                .addClickListener(e -> ControllerProvider.getCaseController().navigateToMergeCasesView());
        addHeaderComponent(mergeDuplicatesButton);
    }

    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.caseNewCase));
        createButton.setId("create");
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getCaseController().create());
        addHeaderComponent(createButton);
    }

    addComponent(gridLayout);
}