Example usage for com.vaadin.ui VerticalLayout setSpacing

List of usage examples for com.vaadin.ui VerticalLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

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

License:Open Source License

public PathogenTestListEntry(PathogenTestDto pathogenTest) {
    setSpacing(true);//www .j  a  va 2  s. co m
    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);
}

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

License:Open Source License

private void requestSampleCollectionTaskCreation(SampleDto dto, SampleEditForm form) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from  w  ww . ja  v a 2s .c o m

    ConfirmationComponent requestTaskComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(I18nProperties.getString(Strings.messageCreateCollectionTask),
            ContentMode.HTML);
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(requestTaskComponent);
    layout.setComponentAlignment(requestTaskComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingCreateNewTaskQuestion));
    requestTaskComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
            ControllerProvider.getTaskController().createSampleCollectionTask(TaskContext.CASE,
                    dto.getAssociatedCase(), dto);
        }
    });
    requestTaskComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

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

License:Open Source License

public void showChangePathogenTestResultWindow(CommitDiscardWrapperComponent<SampleEditForm> editComponent,
        String sampleUuid, PathogenTestResultType newResult) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);//from  w w  w .  jav  a2 s.c  o m

    ConfirmationComponent confirmationComponent = VaadinUiUtil.buildYesNoConfirmationComponent();

    Label description = new Label(String
            .format(I18nProperties.getString(Strings.messageChangePathogenTestResult), newResult.toString()));
    description.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(description);
    layout.addComponent(confirmationComponent);
    layout.setComponentAlignment(confirmationComponent, Alignment.BOTTOM_RIGHT);
    layout.setSizeUndefined();
    layout.setSpacing(true);

    Window popupWindow = VaadinUiUtil.showPopupWindow(layout);
    popupWindow.setSizeUndefined();
    popupWindow.setCaption(I18nProperties.getString(Strings.headingChangePathogenTestResult));
    confirmationComponent.getConfirmButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            editComponent.commit();
            SampleDto sample = FacadeProvider.getSampleFacade().getSampleByUuid(sampleUuid);
            sample.setPathogenTestResult(newResult);
            FacadeProvider.getSampleFacade().saveSample(sample);
            popupWindow.close();
            SormasUI.refreshView();
        }
    });
    confirmationComponent.getCancelButton().addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            popupWindow.close();
        }
    });
}

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

License:Open Source License

private void styleGridLayout(VerticalLayout gridLayout) {
    gridLayout.setSpacing(false);
    gridLayout.setSizeFull();//from   w  w w  .ja  va  2 s. c  om
    gridLayout.setExpandRatio(grid, 1);
    gridLayout.setStyleName("crud-main-layout");
}

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

License:Open Source License

public SampleListEntry(SampleIndexDto sample) {

    this.sample = sample;

    setMargin(false);/*from   w ww.j av  a  2s.c  o  m*/
    setSpacing(true);
    setWidth(100, Unit.PERCENTAGE);
    addStyleName(CssStyles.SORMAS_LIST_ENTRY);

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

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

    VerticalLayout topLeftLayout = new VerticalLayout();
    {
        topLeftLayout.setMargin(false);
        topLeftLayout.setSpacing(false);

        Label materialLabel = new Label(DataHelper.toStringNullable(sample.getSampleMaterial()));
        CssStyles.style(materialLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        topLeftLayout.addComponent(materialLabel);

        Label dateTimeLabel = new Label(
                I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME) + ": "
                        + DateHelper.formatLocalShortDate(sample.getSampleDateTime()));
        topLeftLayout.addComponent(dateTimeLabel);

        Label labLabel = new Label(DataHelper.toStringNullable(sample.getLab()));
        topLeftLayout.addComponent(labLabel);
    }
    topLayout.addComponent(topLeftLayout);

    VerticalLayout topRightLayout = new VerticalLayout();
    {
        topRightLayout.addStyleName(CssStyles.ALIGN_RIGHT);
        topRightLayout.setMargin(false);
        topRightLayout.setSpacing(false);

        Label resultLabel = new Label();
        CssStyles.style(resultLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        if (sample.getPathogenTestResult() != null) {
            resultLabel.setValue(DataHelper.toStringNullable(sample.getPathogenTestResult()));
            if (sample.getPathogenTestResult() == PathogenTestResultType.POSITIVE) {
                resultLabel.addStyleName(CssStyles.LABEL_CRITICAL);
            } else if (sample.getPathogenTestResult() == PathogenTestResultType.INDETERMINATE) {
                resultLabel.addStyleName(CssStyles.LABEL_WARNING);
            }
        } else if (sample.getSpecimenCondition() == SpecimenCondition.NOT_ADEQUATE) {
            resultLabel.setValue(DataHelper.toStringNullable(sample.getSpecimenCondition()));
            resultLabel.addStyleName(CssStyles.LABEL_WARNING);
        }
        topRightLayout.addComponent(resultLabel);

        Label referredLabel = new Label();
        CssStyles.style(referredLabel, CssStyles.LABEL_BOLD, CssStyles.LABEL_UPPERCASE);
        if (sample.isReferred()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReferredShort));
            referredLabel.addStyleName(CssStyles.LABEL_NOT);
        } else if (sample.isReceived()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleReceived) + " "
                    + DateHelper.formatLocalShortDate(sample.getReceivedDate()));
        } else if (sample.isShipped()) {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleShipped) + " "
                    + DateHelper.formatLocalShortDate(sample.getShipmentDate()));
        } else {
            referredLabel.setValue(I18nProperties.getCaption(Captions.sampleNotShippedLong));
        }
        topRightLayout.addComponent(referredLabel);
    }
    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.TOP_RIGHT);

    if (UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW)) {
        Label labelAdditionalTests = new Label(I18nProperties.getString(Strings.entityAdditionalTests) + " "
                + sample.getAdditionalTestingStatus().toString().toLowerCase());
        mainLayout.addComponent(labelAdditionalTests);
    }
}

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();/* w  w w.j av  a 2s .  c  o  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

private HorizontalLayout createDatabaseTablesLayout() {
    HorizontalLayout databaseTablesLayout = new HorizontalLayout();
    databaseTablesLayout.setMargin(false);
    databaseTablesLayout.setSpacing(true);

    VerticalLayout sormasDataLayout = new VerticalLayout();
    sormasDataLayout.setMargin(false);//from ww  w  .jav a  2  s. c om
    sormasDataLayout.setSpacing(false);
    Label sormasDataHeadline = new Label(I18nProperties.getCaption(Captions.exportSormasData));
    CssStyles.style(sormasDataHeadline, CssStyles.H4);
    sormasDataLayout.addComponent(sormasDataHeadline);

    VerticalLayout infrastructureDataLayout = new VerticalLayout();
    infrastructureDataLayout.setMargin(false);
    infrastructureDataLayout.setSpacing(false);
    Label infrastructureDataHeadline = new Label(I18nProperties.getCaption(Captions.exportInfrastructureData));
    CssStyles.style(infrastructureDataHeadline, CssStyles.H4);
    infrastructureDataLayout.addComponent(infrastructureDataHeadline);

    for (DatabaseTable databaseTable : DatabaseTable.values()) {
        CheckBox checkBox = new CheckBox(databaseTable.toString());
        int indent = getIndent(databaseTable);
        if (indent == 1) {
            CssStyles.style(checkBox, CssStyles.INDENT_LEFT_1);
        } else if (indent == 2) {
            CssStyles.style(checkBox, CssStyles.INDENT_LEFT_2);
        } else if (indent == 3) {
            CssStyles.style(checkBox, CssStyles.INDENT_LEFT_3);
        }

        if (databaseTable.getDatabaseTableType() == DatabaseTableType.SORMAS) {
            sormasDataLayout.addComponent(checkBox);
        } else {
            infrastructureDataLayout.addComponent(checkBox);
        }
        databaseTableToggles.put(checkBox, databaseTable);
    }

    databaseTablesLayout.addComponent(sormasDataLayout);
    databaseTablesLayout.addComponent(infrastructureDataLayout);
    return databaseTablesLayout;
}

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

License:Open Source License

private VerticalLayout createUtilityButtonsLayout() {
    VerticalLayout utilityButtonsLayout = new VerticalLayout();
    utilityButtonsLayout.setMargin(false);
    utilityButtonsLayout.setSpacing(false);
    utilityButtonsLayout.setSizeUndefined();

    Button addAllButton = new Button(I18nProperties.getCaption(Captions.all), VaadinIcons.PLUS_CIRCLE);
    CssStyles.style(addAllButton, ValoTheme.BUTTON_LINK);
    addAllButton.addClickListener(e -> {
        for (TokenizableValue tokenizable : getFilterValues()) {
            tokenField.addTokenizable(tokenizable);
        }/*from   ww  w  .  j a  v  a2 s. c o  m*/
    });

    Button removeAllButton = new Button(I18nProperties.getCaption(Captions.actionClear),
            VaadinIcons.CLOSE_CIRCLE);
    CssStyles.style(removeAllButton, ValoTheme.BUTTON_LINK);
    removeAllButton.addClickListener(e -> {
        for (Tokenizable tokenizable : tokenField.getValue()) {
            tokenField.removeTokenizable(tokenizable);
        }
    });

    utilityButtonsLayout.addComponent(addAllButton);
    utilityButtonsLayout.addComponent(removeAllButton);

    return utilityButtonsLayout;
}

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

License:Open Source License

public StatisticsView() {
    super(VIEW_NAME);
    setWidth(100, Unit.PERCENTAGE);/*from   w  w  w .j  a  va 2s . co  m*/

    emptyResultLabel = new Label(I18nProperties.getString(Strings.infoNoCasesFoundStatistics));

    // Main layout
    VerticalLayout statisticsLayout = new VerticalLayout();
    statisticsLayout.setMargin(true);
    statisticsLayout.setSpacing(true);
    statisticsLayout.setWidth(100, Unit.PERCENTAGE);

    // Filters layout
    addFiltersLayout(statisticsLayout);

    // Visualization layout
    Label visualizationTitle = new Label(I18nProperties.getString(Strings.headingVisualization));
    visualizationTitle.setWidthUndefined();
    CssStyles.style(visualizationTitle, CssStyles.STATISTICS_TITLE);
    statisticsLayout.addComponent(visualizationTitle);

    visualizationComponent = new StatisticsVisualizationComponent();
    CssStyles.style(visualizationComponent, CssStyles.STATISTICS_TITLE_BOX);
    statisticsLayout.addComponent(visualizationComponent);

    // Options layout
    addOptionsLayout(statisticsLayout);

    // Generate button
    addGenerateButton(statisticsLayout);

    // Results layout
    addResultsLayout(statisticsLayout);

    // Disclaimer
    Label disclaimer = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " "
            + I18nProperties.getString(Strings.infoStatisticsDisclaimer), ContentMode.HTML);
    statisticsLayout.addComponent(disclaimer);

    addComponent(statisticsLayout);
}

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);/*w w w . j  a va2s . 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);
}