Example usage for com.vaadin.ui HorizontalLayout setMargin

List of usage examples for com.vaadin.ui HorizontalLayout setMargin

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setMargin.

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseStatisticsComponent.java

License:Open Source License

private DashboardStatisticsSubComponent createTestResultComponent() {
    DashboardStatisticsSubComponent testResultComponent = new DashboardStatisticsSubComponent();

    // Header//from   w w w  . j av  a  2  s.  c o  m
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setMargin(false);
    headerLayout.setSpacing(false);
    // count
    testResultCountLabel = new Label();
    CssStyles.style(testResultCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE,
            CssStyles.LABEL_BOLD, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
    headerLayout.addComponent(testResultCountLabel);
    // title
    Label titleLabel = new Label(I18nProperties.getCaption(Captions.dashboardNewTestResults));
    CssStyles.style(titleLabel, CssStyles.H2, CssStyles.HSPACE_LEFT_4);
    headerLayout.addComponent(titleLabel);

    testResultComponent.addComponent(headerLayout);

    // Count layout
    CssLayout countLayout = testResultComponent.createCountLayout(true);
    testResultPositive = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardPositive), CountElementStyle.CRITICAL);
    testResultComponent.addComponentToCountLayout(countLayout, testResultPositive);
    testResultNegative = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardNegative), CountElementStyle.POSITIVE);
    testResultComponent.addComponentToCountLayout(countLayout, testResultNegative);
    testResultPending = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardPending), CountElementStyle.IMPORTANT);
    testResultComponent.addComponentToCountLayout(countLayout, testResultPending);
    testResultIndeterminate = new DashboardStatisticsCountElement(
            I18nProperties.getCaption(Captions.dashboardIndeterminate), CountElementStyle.MINOR);
    testResultComponent.addComponentToCountLayout(countLayout, testResultIndeterminate);
    testResultComponent.addComponent(countLayout);

    return testResultComponent;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java

License:Open Source License

void addTopLayout(Disease disease, Long casesCount, boolean isOutbreak) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);/*from  w  w w  . j a v a2 s .  c  om*/
    CssStyles.style(layout, CssStyles.getDiseaseColor(disease));
    layout.setHeight(75, Unit.PIXELS);
    layout.setWidth(100, Unit.PERCENTAGE);

    VerticalLayout nameAndOutbreakLayout = new VerticalLayout();
    nameAndOutbreakLayout.setMargin(false);
    nameAndOutbreakLayout.setSpacing(false);
    nameAndOutbreakLayout.setHeight(100, Unit.PERCENTAGE);
    nameAndOutbreakLayout.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout nameLayout = new HorizontalLayout();
    nameLayout.setMargin(false);
    nameLayout.setSpacing(false);
    nameLayout.setWidth(100, Unit.PERCENTAGE);
    nameLayout.setHeight(100, Unit.PERCENTAGE);
    Label nameLabel = new Label(disease.toShortString());
    CssStyles.style(nameLabel, CssStyles.LABEL_WHITE,
            nameLabel.getValue().length() > 12 ? CssStyles.LABEL_LARGE : CssStyles.LABEL_XLARGE,
            CssStyles.LABEL_BOLD, CssStyles.ALIGN_CENTER, CssStyles.LABEL_UPPERCASE);
    nameLayout.addComponent(nameLabel);
    nameLayout.setComponentAlignment(nameLabel, Alignment.MIDDLE_CENTER);
    nameAndOutbreakLayout.addComponent(nameLayout);
    nameAndOutbreakLayout.setExpandRatio(nameLayout, 1);

    if (isOutbreak) {
        HorizontalLayout outbreakLayout = new HorizontalLayout();
        outbreakLayout.setMargin(false);
        outbreakLayout.setSpacing(false);
        CssStyles.style(outbreakLayout, CssStyles.BACKGROUND_CRITICAL);
        outbreakLayout.setWidth(100, Unit.PERCENTAGE);
        outbreakLayout.setHeight(30, Unit.PIXELS);
        Label outbreakLabel = new Label(I18nProperties.getCaption(Captions.dashboardOutbreak));
        CssStyles.style(outbreakLabel, CssStyles.LABEL_WHITE, CssStyles.ALIGN_CENTER,
                CssStyles.LABEL_UPPERCASE);
        outbreakLayout.addComponent(outbreakLabel);
        outbreakLayout.setComponentAlignment(outbreakLabel, Alignment.MIDDLE_CENTER);
        nameAndOutbreakLayout.addComponent(outbreakLayout);
    }

    layout.addComponent(nameAndOutbreakLayout);
    layout.setExpandRatio(nameAndOutbreakLayout, 1);

    HorizontalLayout countLayout = new HorizontalLayout();
    countLayout.setMargin(false);
    countLayout.setSpacing(false);
    CssStyles.style(countLayout, CssStyles.getDiseaseColor(disease), CssStyles.BACKGROUND_DARKER);
    countLayout.setHeight(100, Unit.PERCENTAGE);
    countLayout.setWidth(100, Unit.PERCENTAGE);

    Label countLabel = new Label(casesCount.toString());
    CssStyles.style(countLabel, CssStyles.LABEL_WHITE, CssStyles.LABEL_BOLD, CssStyles.LABEL_XXXLARGE,
            CssStyles.ALIGN_CENTER);
    countLayout.addComponent(countLabel);
    countLayout.setComponentAlignment(countLabel, Alignment.MIDDLE_CENTER);

    layout.addComponent(countLayout);
    layout.setExpandRatio(countLayout, 0.65f);

    addComponent(layout);
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.DiseaseTileComponent.java

License:Open Source License

HorizontalLayout createStatsItem(String label, String value, boolean isCritical) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(false);
    layout.setSpacing(false);/* w  w w. ja  v a2s  .  c o m*/

    Label nameLabel = new Label(label);
    CssStyles.style(nameLabel, CssStyles.LABEL_PRIMARY, isCritical ? CssStyles.LABEL_CRITICAL : "",
            CssStyles.HSPACE_LEFT_3);
    layout.addComponent(nameLabel);
    layout.setExpandRatio(nameLabel, 1);

    Label valueLabel = new Label(value);
    CssStyles.style(valueLabel, CssStyles.LABEL_PRIMARY, isCritical ? CssStyles.LABEL_CRITICAL : "",
            CssStyles.ALIGN_CENTER);
    layout.addComponent(valueLabel);
    layout.setExpandRatio(valueLabel, 0.65f);

    return layout;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.SurveillanceDiseaseCarouselLayout.java

License:Open Source License

private HorizontalLayout createCarouselMenuLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(false);
    CssStyles.style(layout, CssStyles.HSPACE_LEFT_2);

    CheckBox autoSlide = this.setupSlideShow();
    layout.addComponent(autoSlide);//from  ww w.ja  v a2s . c o m
    layout.setComponentAlignment(autoSlide, Alignment.MIDDLE_LEFT);

    carouselMenu = new SubMenu();

    for (Disease disease : diseases) {
        carouselMenu.addView(disease.getName(), disease.toShortString(), (e) -> {
            this.changeSelectedDisease(disease);
        });
    }

    if (diseases.size() > 0) {
        this.setActiveDisease(diseases.get(0));
    }

    layout.addComponent(carouselMenu);

    return layout;
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.SurveillanceOverviewLayout.java

License:Open Source License

private void addDiseaseBurdenView() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(false);

    layout.addComponent(diseaseTileViewLayout);
    layout.setExpandRatio(diseaseTileViewLayout, 1);

    // "Expand" and "Collapse" buttons
    Button showTableViewButton = new Button("", VaadinIcons.TABLE);
    CssStyles.style(showTableViewButton, CssStyles.BUTTON_SUBTLE);
    showTableViewButton.addStyleName(CssStyles.VSPACE_NONE);

    Button showTileViewButton = new Button("", VaadinIcons.SQUARE_SHADOW);
    CssStyles.style(showTileViewButton, CssStyles.BUTTON_SUBTLE);
    showTileViewButton.addStyleName(CssStyles.VSPACE_NONE);

    showTableViewButton.addClickListener(e -> {
        layout.removeComponent(diseaseTileViewLayout);
        layout.addComponent(diseaseBurdenComponent);
        layout.setExpandRatio(diseaseBurdenComponent, 1);

        layout.removeComponent(showTableViewButton);
        layout.addComponent(showTileViewButton);
        layout.setComponentAlignment(showTileViewButton, Alignment.TOP_RIGHT);
    });// w  w w.j a v  a 2s  .  com
    showTileViewButton.addClickListener(e -> {
        layout.removeComponent(diseaseBurdenComponent);
        layout.addComponent(diseaseTileViewLayout);
        layout.setExpandRatio(diseaseTileViewLayout, 1);

        layout.removeComponent(showTileViewButton);
        layout.addComponent(showTableViewButton);
        layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT);
    });

    layout.addComponent(showTableViewButton);
    layout.setComponentAlignment(showTableViewButton, Alignment.TOP_RIGHT);

    diseaseBurdenView = layout;
    addComponent(diseaseBurdenView, BURDEN_LOC);

    if (UserRole.isSupervisor(UserProvider.getCurrent().getUser().getUserRoles()))
        showTableViewButton.click();
}

From source file:de.symeda.sormas.ui.dashboard.surveillance.SurveillanceOverviewLayout.java

License:Open Source License

private void addShowMoreAndLessButtons() {

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setHeightUndefined();/*w  ww .  j  ava 2  s  . c o m*/
    buttonsLayout.setWidth(100, Unit.PERCENTAGE);
    buttonsLayout.setMargin(new MarginInfo(false, true));

    showMoreButton = new Button(I18nProperties.getCaption(Captions.dashboardShowAllDiseases),
            VaadinIcons.CHEVRON_DOWN);
    CssStyles.style(showMoreButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.VSPACE_TOP_NONE, CssStyles.VSPACE_4);
    showLessButton = new Button(I18nProperties.getCaption(Captions.dashboardShowFirstDiseases),
            VaadinIcons.CHEVRON_UP);
    CssStyles.style(showLessButton, ValoTheme.BUTTON_BORDERLESS, CssStyles.VSPACE_TOP_NONE, CssStyles.VSPACE_4);
    hideOverview = new CheckBox(I18nProperties.getCaption(Captions.dashboardHideOverview));
    CssStyles.style(hideOverview, CssStyles.VSPACE_3);

    showMoreButton.addClickListener(e -> {
        isShowingAllDiseases = true;
        refresh();

        showMoreButton.setVisible(false);
        showLessButton.setVisible(true);
    });

    showLessButton.addClickListener(e -> {
        isShowingAllDiseases = false;
        refresh();

        showLessButton.setVisible(false);
        showMoreButton.setVisible(true);
    });

    hideOverview.addValueChangeListener(e -> {
        if (hideOverview.getValue()) {
            diseaseBurdenView.setVisible(false);
            diseaseDifferenceComponent.setVisible(false);
            showLessButton.setVisible(false);
            showMoreButton.setVisible(false);
        } else {
            diseaseBurdenView.setVisible(true);
            diseaseDifferenceComponent.setVisible(true);
            showLessButton.setVisible(isShowingAllDiseases);
            showMoreButton.setVisible(!isShowingAllDiseases);
        }
    });

    buttonsLayout.addComponent(showMoreButton);
    buttonsLayout.addComponent(showLessButton);
    buttonsLayout.setComponentAlignment(showMoreButton, Alignment.BOTTOM_CENTER);
    buttonsLayout.setExpandRatio(showMoreButton, 1);
    buttonsLayout.setComponentAlignment(showLessButton, Alignment.BOTTOM_CENTER);
    buttonsLayout.setExpandRatio(showLessButton, 1);
    buttonsLayout.addComponent(hideOverview);
    buttonsLayout.setComponentAlignment(hideOverview, Alignment.BOTTOM_RIGHT);
    buttonsLayout.setExpandRatio(hideOverview, 0);

    addComponent(buttonsLayout, EXTEND_BUTTONS_LOC);

    isShowingAllDiseases = false;
    showLessButton.setVisible(false);
    buttonsLayout.setExpandRatio(showLessButton, 1);
}

From source file:de.symeda.sormas.ui.events.EventsView.java

License:Open Source License

public HorizontalLayout createFilterBar() {
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setSpacing(true);/*from  w ww  . j a va  2 s . com*/
    filterLayout.setMargin(false);
    filterLayout.setSizeUndefined();

    diseaseFilter = new ComboBox();
    diseaseFilter.setWidth(140, Unit.PIXELS);
    diseaseFilter
            .setInputPrompt(I18nProperties.getPrefixCaption(EventIndexDto.I18N_PREFIX, EventIndexDto.DISEASE));
    diseaseFilter
            .addItems(FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases().toArray());
    diseaseFilter.addValueChangeListener(e -> {
        criteria.disease(((Disease) e.getProperty().getValue()));
        navigateTo(criteria);
    });
    filterLayout.addComponent(diseaseFilter);

    reportedByFilter = new ComboBox();
    reportedByFilter.setWidth(140, Unit.PIXELS);
    reportedByFilter.setInputPrompt(I18nProperties.getString(Strings.reportedBy));
    reportedByFilter.addItems((Object[]) UserRole.values());
    reportedByFilter.addValueChangeListener(e -> {
        criteria.reportingUserRole((UserRole) e.getProperty().getValue());
        navigateTo(criteria);
    });
    filterLayout.addComponent(reportedByFilter);

    resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters));
    resetButton.setVisible(false);
    resetButton.addClickListener(event -> {
        ViewModelProviders.of(EventsView.class).remove(EventCriteria.class);
        navigateTo(null);
    });
    filterLayout.addComponent(resetButton);

    return filterLayout;
}

From source file:de.symeda.sormas.ui.events.EventsView.java

License:Open Source License

public HorizontalLayout createStatusFilterBar() {
    HorizontalLayout statusFilterLayout = new HorizontalLayout();
    statusFilterLayout.setSpacing(true);
    statusFilterLayout.setMargin(false);
    statusFilterLayout.setWidth(100, Unit.PERCENTAGE);
    statusFilterLayout.addStyleName(CssStyles.VSPACE_3);

    statusButtons = new HashMap<>();

    Button statusAll = new Button(I18nProperties.getCaption(Captions.all), e -> {
        criteria.eventStatus(null);/*from   w  w  w .j av a 2  s .  c  om*/
        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 (EventStatus status : EventStatus.values()) {
        Button statusButton = new Button(status.toString(), e -> {
            criteria.eventStatus(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());
    }

    HorizontalLayout actionButtonsLayout = new HorizontalLayout();
    actionButtonsLayout.setSpacing(true);
    {
        // Show archived/active cases button
        if (UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW_ARCHIVED)) {
            switchArchivedActiveButton = new Button(I18nProperties.getCaption(Captions.eventShowArchived));
            switchArchivedActiveButton.setStyleName(ValoTheme.BUTTON_LINK);
            switchArchivedActiveButton.addClickListener(e -> {
                criteria.archived(Boolean.TRUE.equals(criteria.getArchived()) ? null : Boolean.TRUE);
                navigateTo(criteria);
            });
            actionButtonsLayout.addComponent(switchArchivedActiveButton);
        }

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

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

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

            Command archiveCommand = selectedItem -> {
                ControllerProvider.getEventController()
                        .archiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            archiveItem = bulkOperationsItem.addItem(
                    I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionArchive)),
                    VaadinIcons.ARCHIVE, archiveCommand);

            Command dearchiveCommand = selectedItem -> {
                ControllerProvider.getEventController()
                        .dearchiveAllSelectedItems(grid.asMultiSelect().getSelectedItems(), new Runnable() {
                            public void run() {
                                grid.reload();
                            }
                        });
            };
            dearchiveItem = bulkOperationsItem.addItem(
                    I18nProperties.getCaption(I18nProperties.getCaption(Captions.actionDearchive)),
                    VaadinIcons.ARCHIVE, dearchiveCommand);
            dearchiveItem.setVisible(false);

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

    return statusFilterLayout;
}

From source file:de.symeda.sormas.ui.reports.ReportsView.java

License:Open Source License

public HorizontalLayout createFilterBar() {
    HorizontalLayout filterLayout = new HorizontalLayout();
    filterLayout.setMargin(false);
    filterLayout.setSpacing(true);/*w  w  w. java 2s  .c om*/
    filterLayout.addStyleName(CssStyles.VSPACE_3);
    filterLayout.setWidth(100, Unit.PERCENTAGE);

    EpiWeek prevEpiWeek = DateHelper.getPreviousEpiWeek(new Date());
    int year = prevEpiWeek.getYear();
    int week = prevEpiWeek.getWeek();

    yearFilter = new ComboBox();
    yearFilter.setWidth(200, Unit.PIXELS);
    yearFilter.addItems(DateHelper.getYearsToNow());
    yearFilter.select(year);
    yearFilter.setCaption(I18nProperties.getString(Strings.year));
    yearFilter.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
    yearFilter.addValueChangeListener(e -> {
        updateEpiWeeks((int) e.getProperty().getValue(), (int) epiWeekFilter.getValue());
        reloadGrid();
    });
    filterLayout.addComponent(yearFilter);

    epiWeekFilter = new ComboBox();
    epiWeekFilter.setWidth(200, Unit.PIXELS);
    updateEpiWeeks(year, week);
    epiWeekFilter.setCaption(I18nProperties.getString(Strings.epiWeek));
    epiWeekFilter.addValueChangeListener(e -> {
        reloadGrid();
    });
    filterLayout.addComponent(epiWeekFilter);

    Button lastWeekButton = new Button(I18nProperties.getCaption(Captions.dashboardLastWeek));
    lastWeekButton.addStyleName(CssStyles.FORCE_CAPTION);
    lastWeekButton.addClickListener(e -> {
        EpiWeek epiWeek = DateHelper.getPreviousEpiWeek(new Date());
        yearFilter.select(epiWeek.getYear());
        epiWeekFilter.select(epiWeek.getWeek());
    });
    filterLayout.addComponent(lastWeekButton);

    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
    infoLabel.setDescription(I18nProperties.getString(Strings.infoWeeklyReportsView));
    infoLabel.setSizeUndefined();
    CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY);
    filterLayout.addComponent(infoLabel);
    filterLayout.setComponentAlignment(infoLabel, Alignment.MIDDLE_RIGHT);
    filterLayout.setExpandRatio(infoLabel, 1);

    return filterLayout;
}

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

License:Open Source License

public PathogenTestListEntry(PathogenTestDto pathogenTest) {
    setSpacing(true);//from   ww w .j av  a  2 s . c  om
    setMargin(false);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);
    this.pathogenTest = pathogenTest;

    VerticalLayout labelLayout = new VerticalLayout();
    labelLayout.setSpacing(false);
    labelLayout.setMargin(false);
    labelLayout.setWidth(100, Unit.PERCENTAGE);
    addComponent(labelLayout);
    setExpandRatio(labelLayout, 1);

    HorizontalLayout topLabelLayout = new HorizontalLayout();
    topLabelLayout.setSpacing(false);
    topLabelLayout.setMargin(false);
    topLabelLayout.setWidth(100, Unit.PERCENTAGE);
    labelLayout.addComponent(topLabelLayout);
    Label labelTopLeft = new Label(
            PathogenTestType.toString(pathogenTest.getTestType(), pathogenTest.getTestTypeText()));
    CssStyles.style(labelTopLeft, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    topLabelLayout.addComponent(labelTopLeft);

    if (pathogenTest.getTestResultVerified()) {
        Label labelTopRight = new Label(VaadinIcons.CHECK_CIRCLE.getHtml(), ContentMode.HTML);
        labelTopRight.setSizeUndefined();
        labelTopRight.addStyleName(CssStyles.LABEL_LARGE);
        labelTopRight.setDescription(I18nProperties.getPrefixCaption(PathogenTestDto.I18N_PREFIX,
                PathogenTestDto.TEST_RESULT_VERIFIED));
        topLabelLayout.addComponent(labelTopRight);
        topLabelLayout.setComponentAlignment(labelTopRight, Alignment.TOP_RIGHT);
    }

    if (!DataHelper.isNullOrEmpty(pathogenTest.getTestResultText())) {
        Label resultTextLabel = new Label(pathogenTest.getTestResultText());
        labelLayout.addComponent(resultTextLabel);
    }

    HorizontalLayout middleLabelLayout = new HorizontalLayout();
    middleLabelLayout.setSpacing(false);
    middleLabelLayout.setMargin(false);
    middleLabelLayout.setWidth(100, Unit.PERCENTAGE);
    labelLayout.addComponent(middleLabelLayout);
    Label labelLeft = new Label(DataHelper.toStringNullable(
            DiseaseHelper.toString(pathogenTest.getTestedDisease(), pathogenTest.getTestedDiseaseDetails())));
    middleLabelLayout.addComponent(labelLeft);

    Label labelRight = new Label(DateHelper.formatLocalShortDateTime(pathogenTest.getTestDateTime()));
    labelRight.addStyleName(CssStyles.ALIGN_RIGHT);
    middleLabelLayout.addComponent(labelRight);
    middleLabelLayout.setComponentAlignment(labelRight, Alignment.TOP_RIGHT);

    Label labelBottom = new Label(DataHelper.toStringNullable(pathogenTest.getTestResult()));
    CssStyles.style(labelBottom, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
    if (pathogenTest.getTestResult() == PathogenTestResultType.POSITIVE)
        CssStyles.style(labelBottom, CssStyles.LABEL_CRITICAL);
    else
        CssStyles.style(labelBottom, CssStyles.LABEL_WARNING);
    labelLayout.addComponent(labelBottom);
}