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.samples.SampleListComponent.java

License:Open Source License

public SampleListComponent(CaseReferenceDto caseRef) {
    setWidth(100, Unit.PERCENTAGE);/*from ww w .jav  a2  s.  c  o  m*/
    setMargin(false);
    setSpacing(false);

    HorizontalLayout componentHeader = new HorizontalLayout();
    componentHeader.setMargin(false);
    componentHeader.setSpacing(false);
    componentHeader.setWidth(100, Unit.PERCENTAGE);
    addComponent(componentHeader);

    list = new SampleList(caseRef);
    addComponent(list);
    list.reload();

    Label tasksHeader = new Label(I18nProperties.getString(Strings.entitySamples));
    tasksHeader.addStyleName(CssStyles.H3);
    componentHeader.addComponent(tasksHeader);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.sampleNewSample));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton
                .addClickListener(e -> ControllerProvider.getSampleController().create(caseRef, this::reload));
        componentHeader.addComponent(createButton);
        componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT);
    }
}

From source file:de.symeda.sormas.ui.samples.SamplesView.java

License:Open Source License

public SamplesView() {
    super(VIEW_NAME);

    sampleListComponent = new SampleGridComponent(getViewTitleLabel(), this);
    setSizeFull();//from   w  w  w .  j av  a 2  s . co  m
    addComponent(sampleListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EXPORT)) {
        PopupButton exportButton = new PopupButton(I18nProperties.getCaption(Captions.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.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(sampleListComponent.getGrid(),
                "sormas_samples", "sormas_samples_" + DateHelper.formatDateForExport(new Date()) + ".csv",
                SampleGrid.EDIT_BTN_ID);
        FileDownloader fileDownloader = new FileDownloader(streamResource);
        fileDownloader.extend(basicExportButton);

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        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(
                SampleExportDto.class,
                (Integer start, Integer max) -> FacadeProvider.getSampleFacade().getExportList(
                        UserProvider.getCurrent().getUuid(), sampleListComponent.getGrid().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(extendedExportStreamResource).extend(extendedExportButton);
    }
}

From source file:de.symeda.sormas.ui.statistics.DatabaseExportView.java

License:Open Source License

public DatabaseExportView() {
    super(VIEW_NAME);

    databaseTableToggles = new HashMap<>();
    databaseExportLayout = new VerticalLayout();
    databaseExportLayout.setSpacing(false);
    databaseExportLayout.setMargin(false);
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setSpacing(true);/*from   ww w . j a  v a  2s.  c om*/
    headerLayout.setMargin(false);
    Label infoLabel = new Label(I18nProperties.getString(Strings.infoDatabaseExportTables));
    headerLayout.addComponent(infoLabel);
    headerLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_LEFT);
    headerLayout.addComponent(createSelectionButtonsLayout());
    databaseExportLayout.addComponent(headerLayout);
    databaseExportLayout.addComponent(createDatabaseTablesLayout());
    Button exportButton = new Button(I18nProperties.getCaption(Captions.export), VaadinIcons.DOWNLOAD);
    CssStyles.style(exportButton, ValoTheme.BUTTON_PRIMARY);
    StreamResource streamResource = DownloadUtil.createDatabaseExportStreamResource(this,
            "sormas_export_" + DateHelper.formatDateForExport(new Date()) + ".zip", "application/zip");
    FileDownloader fileDownloader = new FileDownloader(streamResource);
    fileDownloader.extend(exportButton);
    databaseExportLayout.addComponent(exportButton);
    databaseExportLayout.setMargin(true);
    databaseExportLayout.setSpacing(true);

    addComponent(databaseExportLayout);
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

private void addFiltersLayout(VerticalLayout statisticsLayout) {
    Label filtersLayoutTitle = new Label(I18nProperties.getString(Strings.headingFilters));
    filtersLayoutTitle.setWidthUndefined();
    CssStyles.style(filtersLayoutTitle, CssStyles.STATISTICS_TITLE);
    statisticsLayout.addComponent(filtersLayoutTitle);

    VerticalLayout filtersSectionLayout = new VerticalLayout();
    CssStyles.style(filtersSectionLayout, CssStyles.STATISTICS_TITLE_BOX);
    filtersSectionLayout.setSpacing(true);
    filtersSectionLayout.setWidth(100, Unit.PERCENTAGE);
    Label filtersInfoText = new Label(I18nProperties.getString(Strings.infoStatisticsFilter), ContentMode.HTML);
    filtersSectionLayout.addComponent(filtersInfoText);

    filtersLayout = new VerticalLayout();
    filtersLayout.setSpacing(true);//ww  w  . j  ava2s  . c  o  m
    filtersLayout.setMargin(false);
    filtersSectionLayout.addComponent(filtersLayout);

    // Filters footer
    HorizontalLayout filtersSectionFooter = new HorizontalLayout();
    {
        filtersSectionFooter.setSpacing(true);

        Button addFilterButton = new Button(I18nProperties.getCaption(Captions.statisticsAddFilter),
                VaadinIcons.PLUS);
        CssStyles.style(addFilterButton, ValoTheme.BUTTON_PRIMARY);
        addFilterButton.addClickListener(e -> {
            filtersLayout.addComponent(createFilterComponentLayout());
        });
        filtersSectionFooter.addComponent(addFilterButton);

        Button resetFiltersButton = new Button(I18nProperties.getCaption(Captions.statisticsResetFilters));
        resetFiltersButton.addClickListener(e -> {
            filtersLayout.removeAllComponents();
            filterComponents.clear();
        });
        filtersSectionFooter.addComponent(resetFiltersButton);
    }
    filtersSectionLayout.addComponent(filtersSectionFooter);

    statisticsLayout.addComponent(filtersSectionLayout);
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

private void addGenerateButton(VerticalLayout statisticsLayout) {
    Button generateButton = new Button(I18nProperties.getCaption(Captions.actionGenerate));
    CssStyles.style(generateButton, ValoTheme.BUTTON_PRIMARY);
    generateButton.addClickListener(e -> {
        // Check whether there is any invalid empty filter or grouping data
        Notification errorNotification = null;
        for (StatisticsFilterComponent filterComponent : filterComponents) {
            if (filterComponent.getSelectedAttribute() != StatisticsCaseAttribute.REGION_DISTRICT
                    && (filterComponent.getSelectedAttribute() == null
                            || filterComponent.getSelectedAttribute().getSubAttributes().length > 0
                                    && filterComponent.getSelectedSubAttribute() == null)) {
                errorNotification = new Notification(
                        I18nProperties.getString(Strings.messageSpecifyFilterAttributes), Type.WARNING_MESSAGE);
                break;
            }//  w  w w .  j a  v  a2 s .  co m
        }

        if (errorNotification == null && visualizationComponent.getRowsAttribute() != null
                && visualizationComponent.getRowsAttribute().getSubAttributes().length > 0
                && visualizationComponent.getRowsSubAttribute() == null) {
            errorNotification = new Notification(I18nProperties.getString(Strings.messageSpecifyRowAttribute),
                    Type.WARNING_MESSAGE);
        } else if (errorNotification == null && visualizationComponent.getColumnsAttribute() != null
                && visualizationComponent.getColumnsAttribute().getSubAttributes().length > 0
                && visualizationComponent.getColumnsSubAttribute() == null) {
            errorNotification = new Notification(
                    I18nProperties.getString(Strings.messageSpecifyColumnAttribute), Type.WARNING_MESSAGE);
        }

        if (errorNotification != null) {
            errorNotification.setDelayMsec(-1);
            errorNotification.show(Page.getCurrent());
        } else {
            resultsLayout.removeAllComponents();
            switch (visualizationComponent.getVisualizationType()) {
            case TABLE:
                generateTable();
                break;
            case MAP:
                generateMap();
                break;
            default:
                generateChart();
                break;
            }
        }
    });

    statisticsLayout.addComponent(generateButton);
}

From source file:de.symeda.sormas.ui.statistics.StatisticsView.java

License:Open Source License

public void generateTable() {
    List<Object[]> resultData = generateStatistics();

    if (resultData.isEmpty()) {
        resultsLayout.addComponent(emptyResultLabel);
        return;/*  w ww. ja  v  a 2 s .co m*/
    }

    exportButton = new Button(I18nProperties.getCaption(Captions.export));
    exportButton.setDescription(I18nProperties.getDescription(Descriptions.descExportButton));
    exportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    exportButton.setIcon(VaadinIcons.TABLE);
    resultsLayout.addComponent(exportButton);
    resultsLayout.setComponentAlignment(exportButton, Alignment.TOP_RIGHT);

    statisticsCaseGrid = new StatisticsCaseGrid(visualizationComponent.getRowsAttribute(),
            visualizationComponent.getRowsSubAttribute(), visualizationComponent.getColumnsAttribute(),
            visualizationComponent.getColumnsSubAttribute(), zeroValues.getValue(), resultData, caseCriteria);
    resultsLayout.addComponent(statisticsCaseGrid);
    resultsLayout.setExpandRatio(statisticsCaseGrid, 1);

    StreamResource streamResource = DownloadUtil.createGridExportStreamResource(
            statisticsCaseGrid.getContainerDataSource(), statisticsCaseGrid.getColumns(), "sormas_statistics",
            "sormas_statistics_" + DateHelper.formatDateForExport(new Date()) + ".csv");
    FileDownloader fileDownloader = new FileDownloader(streamResource);
    fileDownloader.extend(exportButton);
}

From source file:de.symeda.sormas.ui.task.TaskGridComponent.java

License:Open Source License

private void updateArchivedButton() {
    if (switchArchivedActiveButton == null) {
        return;// ww  w .  ja  va  2 s .  co m
    }

    if (Boolean.TRUE.equals(criteria.getArchived())) {
        viewTitleLabel.setValue(
                I18nProperties.getPrefixCaption("View", TasksView.VIEW_NAME.replaceAll("/", ".") + ".archive"));
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowActive)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_PRIMARY);
    } else {
        viewTitleLabel.setValue(originalViewTitle);
        switchArchivedActiveButton
                .setCaption(I18nProperties.getCaption(I18nProperties.getCaption(Captions.taskShowArchived)));
        switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
    }
}

From source file:de.symeda.sormas.ui.task.TaskListComponent.java

License:Open Source License

public TaskListComponent(TaskContext context, ReferenceDto entityRef) {
    setWidth(100, Unit.PERCENTAGE);/*from w ww  .j  a  v a 2s . c o m*/
    setMargin(false);
    setSpacing(false);

    HorizontalLayout componentHeader = new HorizontalLayout();
    componentHeader.setMargin(false);
    componentHeader.setSpacing(false);
    componentHeader.setWidth(100, Unit.PERCENTAGE);
    addComponent(componentHeader);

    list = new TaskList(context, entityRef);
    addComponent(list);
    list.reload();

    Label tasksHeader = new Label(I18nProperties.getString(Strings.entityTasks));
    tasksHeader.addStyleName(CssStyles.H3);
    componentHeader.addComponent(tasksHeader);

    if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
        createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(
                e -> ControllerProvider.getTaskController().create(context, entityRef, this::reload));
        componentHeader.addComponent(createButton);
        componentHeader.setComponentAlignment(createButton, Alignment.MIDDLE_RIGHT);
    }
}

From source file:de.symeda.sormas.ui.task.TasksView.java

License:Open Source License

public TasksView() {
    super(VIEW_NAME);

    if (!ViewModelProviders.of(TasksView.class).has(TaskCriteria.class)) {
        // init default filter
        TaskCriteria taskCriteria = new TaskCriteria();
        taskCriteria.taskStatus(TaskStatus.PENDING);
        ViewModelProviders.of(TasksView.class).get(TaskCriteria.class, taskCriteria);
    }/* ww w  .ja  va 2  s  .  co  m*/

    taskListComponent = new TaskGridComponent(getViewTitleLabel(), this);
    addComponent(taskListComponent);

    if (UserProvider.getCurrent().hasUserRight(UserRight.TASK_CREATE)) {
        Button createButton = new Button(I18nProperties.getCaption(Captions.taskNewTask));
        createButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        createButton.setIcon(VaadinIcons.PLUS_CIRCLE);
        createButton.addClickListener(e -> ControllerProvider.getTaskController().create(TaskContext.GENERAL,
                null, taskListComponent.getGrid()::reload));
        addHeaderComponent(createButton);
    }
}

From source file:de.symeda.sormas.ui.therapy.TherapyView.java

License:Open Source License

private VerticalLayout createPrescriptionsHeader() {
    VerticalLayout prescriptionsHeader = new VerticalLayout();
    prescriptionsHeader.setMargin(false);
    prescriptionsHeader.setSpacing(false);
    prescriptionsHeader.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);//from w w  w.j  a  va  2s  .co m
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label prescriptionsLabel = new Label(I18nProperties.getString(Strings.entityPrescriptions));
        CssStyles.style(prescriptionsLabel, CssStyles.H3);
        headlineRow.addComponent(prescriptionsLabel);
        headlineRow.setExpandRatio(prescriptionsLabel, 1);

        // Bulk operations
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = new MenuBar();
            MenuItem bulkOperationsItem = bulkOperationsDropdown
                    .addItem(I18nProperties.getCaption(Captions.bulkActions), null);

            Command deleteCommand = selectedItem -> {
                ControllerProvider.getTherapyController()
                        .deleteAllSelectedPrescriptions(prescriptionGrid.getSelectedRows(), new Runnable() {
                            public void run() {
                                reloadPrescriptionGrid();
                            }
                        });
            };
            bulkOperationsItem.addItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH,
                    deleteCommand);

            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }

        Button newPrescriptionButton = new Button(
                I18nProperties.getCaption(Captions.prescriptionNewPrescription));
        CssStyles.style(newPrescriptionButton, ValoTheme.BUTTON_PRIMARY);
        newPrescriptionButton.addClickListener(e -> {
            ControllerProvider.getTherapyController().openPrescriptionCreateForm(
                    prescriptionCriteria.getTherapy(), this::reloadPrescriptionGrid);
        });
        headlineRow.addComponent(newPrescriptionButton);

        headlineRow.setComponentAlignment(newPrescriptionButton, Alignment.MIDDLE_RIGHT);
    }
    prescriptionsHeader.addComponent(headlineRow);

    HorizontalLayout filterRow = new HorizontalLayout();
    filterRow.setMargin(false);
    filterRow.setSpacing(true);
    {
        prescriptionTypeFilter = new ComboBox();
        prescriptionTypeFilter.setWidth(140, Unit.PIXELS);
        prescriptionTypeFilter.setInputPrompt(I18nProperties.getPrefixCaption(PrescriptionDto.I18N_PREFIX,
                PrescriptionDto.PRESCRIPTION_TYPE));
        prescriptionTypeFilter.addItems((Object[]) TreatmentType.values());
        prescriptionTypeFilter.addValueChangeListener(e -> {
            prescriptionCriteria.prescriptionType(((TreatmentType) e.getProperty().getValue()));
            navigateTo(prescriptionCriteria);
        });
        filterRow.addComponent(prescriptionTypeFilter);

        prescriptionTextFilter = new TextField();
        prescriptionTextFilter.setWidth(300, Unit.PIXELS);
        prescriptionTextFilter.setNullRepresentation("");
        prescriptionTextFilter.setInputPrompt(I18nProperties.getString(Strings.promptPrescriptionTextFilter));
        prescriptionTextFilter.addTextChangeListener(e -> {
            prescriptionCriteria.textFilter(e.getText());
            reloadPrescriptionGrid();
        });
        filterRow.addComponent(prescriptionTextFilter);
    }
    prescriptionsHeader.addComponent(filterRow);

    return prescriptionsHeader;
}