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.contact.ContactsView.java

License:Open Source License

public ContactsView() {
    super(VIEW_NAME);

    originalViewTitle = getViewTitleLabel().getValue();

    criteria = ViewModelProviders.of(ContactsView.class).get(ContactCriteria.class);
    if (criteria.getArchived() == null) {
        criteria.archived(false);//from ww w  . j  a  va 2  s.  co m
    }

    grid = new ContactGrid();
    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.CONTACT_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.getDescription(Descriptions.descExportButton));
        basicExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        basicExportButton.setIcon(VaadinIcons.TABLE);
        basicExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(basicExportButton);

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

        Button extendedExportButton = new Button(I18nProperties.getCaption(Captions.exportDetailed));
        extendedExportButton
                .setDescription(I18nProperties.getDescription(Descriptions.descDetailedExportButton));
        extendedExportButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
        extendedExportButton.setIcon(VaadinIcons.FILE_TEXT);
        extendedExportButton.setWidth(100, Unit.PERCENTAGE);
        exportLayout.addComponent(extendedExportButton);

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

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

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

    addComponent(gridLayout);
}

From source file:de.symeda.sormas.ui.contact.ContactsView.java

License:Open Source License

public VerticalLayout createFilterBar() {
    VerticalLayout filterLayout = new VerticalLayout();
    filterLayout.setSpacing(false);
    filterLayout.setMargin(false);/*from w w w  . j  av  a  2 s.c o m*/
    filterLayout.setWidth(100, Unit.PERCENTAGE);

    firstFilterRowLayout = new HorizontalLayout();
    firstFilterRowLayout.setMargin(false);
    firstFilterRowLayout.setSpacing(true);
    firstFilterRowLayout.setSizeUndefined();
    {
        classificationFilter = new ComboBox();
        classificationFilter.setWidth(140, Unit.PIXELS);
        classificationFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CONTACT_CLASSIFICATION));
        classificationFilter.addItems((Object[]) ContactClassification.values());
        classificationFilter.addValueChangeListener(e -> {
            criteria.contactClassification((ContactClassification) e.getProperty().getValue());
            navigateTo(criteria);
        });
        firstFilterRowLayout.addComponent(classificationFilter);

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

        followUpStatusFilter = new ComboBox();
        followUpStatusFilter.setWidth(140, Unit.PIXELS);
        followUpStatusFilter.setInputPrompt(
                I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX, ContactIndexDto.FOLLOW_UP_STATUS));
        followUpStatusFilter.addItems((Object[]) FollowUpStatus.values());
        followUpStatusFilter.addValueChangeListener(e -> {
            criteria.followUpStatus(((FollowUpStatus) e.getProperty().getValue()));
            navigateTo(criteria);
        });
        firstFilterRowLayout.addComponent(followUpStatusFilter);

        searchField = new TextField();
        searchField.setWidth(200, Unit.PIXELS);
        searchField.setNullRepresentation("");
        searchField.setInputPrompt(I18nProperties.getString(Strings.promptContactsSearchField));
        searchField.addTextChangeListener(e -> {
            criteria.nameUuidCaseLike(e.getText());
            grid.reload();
        });
        firstFilterRowLayout.addComponent(searchField);

        addShowMoreOrLessFiltersButtons(firstFilterRowLayout);

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

    secondFilterRowLayout = new HorizontalLayout();
    secondFilterRowLayout.setMargin(false);
    secondFilterRowLayout.setSpacing(true);
    secondFilterRowLayout.setSizeUndefined();
    {
        UserDto user = UserProvider.getCurrent().getUser();
        regionFilter = new ComboBox();
        if (user.getRegion() == null) {
            regionFilter.setWidth(140, Unit.PIXELS);
            regionFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                    ContactIndexDto.CASE_REGION_UUID));
            regionFilter.addItems(FacadeProvider.getRegionFacade().getAllAsReference());
            regionFilter.addValueChangeListener(e -> {
                RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
                criteria.caseRegion(region);
                navigateTo(criteria);
            });
            secondFilterRowLayout.addComponent(regionFilter);
        }

        districtFilter = new ComboBox();
        districtFilter.setWidth(140, Unit.PIXELS);
        districtFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CASE_DISTRICT_UUID));
        districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter));
        districtFilter.addValueChangeListener(e -> {
            DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
            criteria.caseDistrict(district);
            navigateTo(criteria);
        });

        if (user.getRegion() != null && user.getDistrict() == null) {
            districtFilter
                    .addItems(FacadeProvider.getDistrictFacade().getAllByRegion(user.getRegion().getUuid()));
            districtFilter.setEnabled(true);
        } else {
            regionFilter.addValueChangeListener(e -> {
                RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
                districtFilter.removeAllItems();
                if (region != null) {
                    districtFilter
                            .addItems(FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid()));
                    districtFilter.setEnabled(true);
                } else {
                    districtFilter.setEnabled(false);
                }
            });
            districtFilter.setEnabled(false);
        }
        secondFilterRowLayout.addComponent(districtFilter);

        facilityFilter = new ComboBox();
        facilityFilter.setWidth(140, Unit.PIXELS);
        facilityFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CASE_HEALTH_FACILITY_UUID));
        facilityFilter.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter));
        facilityFilter.addValueChangeListener(e -> {
            FacilityReferenceDto facility = (FacilityReferenceDto) e.getProperty().getValue();
            criteria.caseFacility(facility);
            navigateTo(criteria);
        });
        facilityFilter.setEnabled(false);
        secondFilterRowLayout.addComponent(facilityFilter);

        districtFilter.addValueChangeListener(e -> {
            facilityFilter.removeAllItems();
            DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
            if (district != null) {
                facilityFilter.addItems(
                        FacadeProvider.getFacilityFacade().getHealthFacilitiesByDistrict(district, true));
                facilityFilter.setEnabled(true);
            } else {
                facilityFilter.setEnabled(false);
            }
        });

        officerFilter = new ComboBox();
        officerFilter.setWidth(140, Unit.PIXELS);
        officerFilter.setInputPrompt(I18nProperties.getPrefixCaption(ContactIndexDto.I18N_PREFIX,
                ContactIndexDto.CONTACT_OFFICER_UUID));
        if (user.getRegion() != null) {
            officerFilter.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(),
                    UserRole.CONTACT_OFFICER));
        }
        officerFilter.addValueChangeListener(e -> {
            UserReferenceDto officer = (UserReferenceDto) e.getProperty().getValue();
            criteria.contactOfficer(officer);
            navigateTo(criteria);
        });
        secondFilterRowLayout.addComponent(officerFilter);

        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);
        });
        secondFilterRowLayout.addComponent(reportedByFilter);
    }
    filterLayout.addComponent(secondFilterRowLayout);
    secondFilterRowLayout.setVisible(false);

    dateFilterRowLayout = new HorizontalLayout();
    dateFilterRowLayout.setSpacing(true);
    dateFilterRowLayout.setSizeUndefined();
    {
        Button applyButton = new Button(I18nProperties.getCaption(Captions.actionApplyDateFilter));

        weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(applyButton, false, false, null,
                ContactDateType.class, I18nProperties.getString(Strings.promptContactDateType),
                ContactDateType.REPORT_DATE);
        weekAndDateFilter.getWeekFromFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekFrom));
        weekAndDateFilter.getWeekToFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactEpiWeekTo));
        weekAndDateFilter.getDateFromFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactDateFrom));
        weekAndDateFilter.getDateToFilter()
                .setInputPrompt(I18nProperties.getString(Strings.promptContactDateTo));
        dateFilterRowLayout.addComponent(weekAndDateFilter);
        dateFilterRowLayout.addComponent(applyButton);

        applyButton.addClickListener(e -> {
            DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter()
                    .getValue();
            Date fromDate, toDate;
            if (dateFilterOption == DateFilterOption.DATE) {
                fromDate = DateHelper.getStartOfDay(weekAndDateFilter.getDateFromFilter().getValue());
                toDate = DateHelper.getEndOfDay(weekAndDateFilter.getDateToFilter().getValue());
            } else {
                fromDate = DateHelper
                        .getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
                toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
            }
            if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
                applyButton.removeStyleName(ValoTheme.BUTTON_PRIMARY);
                ContactDateType contactDateType = (ContactDateType) weekAndDateFilter.getDateTypeSelector()
                        .getValue();
                if (contactDateType == ContactDateType.LAST_CONTACT_DATE) {
                    criteria.lastContactDateBetween(fromDate, toDate);
                    criteria.reportDateBetween(null, null);
                } else {
                    criteria.reportDateBetween(fromDate, toDate);
                    criteria.lastContactDateBetween(null, null);
                }
                navigateTo(criteria);
            } else {
                if (dateFilterOption == DateFilterOption.DATE) {
                    Notification notification = new Notification(
                            I18nProperties.getString(Strings.headingMissingDateFilter),
                            I18nProperties.getString(Strings.messageMissingDateFilter), Type.WARNING_MESSAGE,
                            false);
                    notification.setDelayMsec(-1);
                    notification.show(Page.getCurrent());
                } else {
                    Notification notification = new Notification(
                            I18nProperties.getString(Strings.headingMissingEpiWeekFilter),
                            I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.WARNING_MESSAGE,
                            false);
                    notification.setDelayMsec(-1);
                    notification.show(Page.getCurrent());
                }
            }
        });
    }
    filterLayout.addComponent(dateFilterRowLayout);
    dateFilterRowLayout.setVisible(false);

    return filterLayout;
}

From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java

License:Open Source License

protected VerticalLayout createEpiCurveLayout() {
    if (epiCurveComponent == null) {
        throw new UnsupportedOperationException(
                "EpiCurveComponent needs to be initialized before calling createEpiCurveLayout");
    }/*from w w w.  j a  va  2  s. com*/

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

    epiCurveComponent.setSizeFull();

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

    epiCurveComponent.setExpandListener(expanded -> {
        if (expanded) {
            dashboardLayout.removeComponent(statisticsComponent);
            epiCurveAndMapLayout.removeComponent(mapLayout);
            ContactsDashboardView.this.setHeight(100, Unit.PERCENTAGE);
            epiCurveAndMapLayout.setHeight(100, Unit.PERCENTAGE);
            epiCurveLayout.setSizeFull();
        } else {
            dashboardLayout.addComponent(statisticsComponent, 1);
            epiCurveAndMapLayout.addComponent(mapLayout, 1);
            epiCurveLayout.setHeight(400, Unit.PIXELS);
            ContactsDashboardView.this.setHeightUndefined();
            epiCurveAndMapLayout.setHeightUndefined();
        }
    });

    return layout;
}

From source file:de.symeda.sormas.ui.dashboard.contacts.ContactsDashboardView.java

License:Open Source License

protected VerticalLayout createMapLayout() {
    if (mapComponent == null) {
        throw new UnsupportedOperationException(
                "MapComponent needs to be initialized before calling createMapLayout");
    }/*from  ww w  .  ja v  a2 s.co  m*/
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeight(555, Unit.PIXELS);

    mapComponent.setSizeFull();

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

    mapComponent.setExpandListener(expanded -> {
        if (expanded) {
            dashboardLayout.removeComponent(statisticsComponent);
            epiCurveAndMapLayout.removeComponent(epiCurveLayout);
            ContactsDashboardView.this.setHeight(100, Unit.PERCENTAGE);
            epiCurveAndMapLayout.setHeight(100, Unit.PERCENTAGE);
            mapLayout.setSizeFull();
        } else {
            dashboardLayout.addComponent(statisticsComponent, 1);
            epiCurveAndMapLayout.addComponent(epiCurveLayout, 0);
            mapLayout.setHeight(400, Unit.PIXELS);
            ContactsDashboardView.this.setHeightUndefined();
            epiCurveAndMapLayout.setHeightUndefined();
        }
    });

    return layout;
}

From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java

License:Open Source License

private HorizontalLayout createFooter() {
    HorizontalLayout mapFooterLayout = new HorizontalLayout();
    mapFooterLayout.setWidth(100, Unit.PERCENTAGE);
    mapFooterLayout.setSpacing(true);/* w w w .j a v  a  2  s. c o  m*/
    CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);

    // Map key dropdown button
    legendDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapKey));
    CssStyles.style(legendDropdown, CssStyles.BUTTON_SUBTLE);
    legendDropdown.setContent(createLegend());
    mapFooterLayout.addComponent(legendDropdown);
    mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT);
    mapFooterLayout.setExpandRatio(legendDropdown, 1);

    // Layers dropdown button
    PopupButton layersDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardMapLayers));
    {
        CssStyles.style(layersDropdown, CssStyles.BUTTON_SUBTLE);

        VerticalLayout layersLayout = new VerticalLayout();
        layersLayout.setMargin(true);
        layersLayout.setSpacing(false);
        layersLayout.setSizeUndefined();
        layersDropdown.setContent(layersLayout);

        // Add check boxes and apply button
        {
            OptionGroup mapCaseDisplayModeSelect = new OptionGroup();
            mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE);
            mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values());
            mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
            mapCaseDisplayModeSelect.addValueChangeListener(event -> {
                mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue();
                refreshMap();
            });

            HorizontalLayout showCasesLayout = new HorizontalLayout();
            {
                showCasesLayout.setMargin(false);
                showCasesLayout.setSpacing(false);
                CheckBox showCasesCheckBox = new CheckBox();
                showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases));
                showCasesCheckBox.setValue(showCases);
                showCasesCheckBox.addValueChangeListener(e -> {
                    showCases = (boolean) e.getProperty().getValue();
                    mapCaseDisplayModeSelect.setEnabled(showCases);
                    mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
                    refreshMap();
                });
                showCasesLayout.addComponent(showCasesCheckBox);

                Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap));
                CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY,
                        CssStyles.HSPACE_LEFT_3);
                infoLabel.setHeightUndefined();
                showCasesLayout.addComponent(infoLabel);
                showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
            }
            layersLayout.addComponent(showCasesLayout);

            layersLayout.addComponent(mapCaseDisplayModeSelect);
            mapCaseDisplayModeSelect.setEnabled(showCases);

            CheckBox showConfirmedContactsCheckBox = new CheckBox();
            CheckBox showUnconfirmedContactsCheckBox = new CheckBox();

            CheckBox showContactsCheckBox = new CheckBox();
            showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts));
            showContactsCheckBox.setValue(showContacts);
            showContactsCheckBox.addValueChangeListener(e -> {
                showContacts = (boolean) e.getProperty().getValue();
                showConfirmedContactsCheckBox.setEnabled(showContacts);
                showConfirmedContactsCheckBox.setValue(true);
                showUnconfirmedContactsCheckBox.setEnabled(showContacts);
                showUnconfirmedContactsCheckBox.setValue(true);
                refreshMap();
            });
            layersLayout.addComponent(showContactsCheckBox);

            showConfirmedContactsCheckBox
                    .setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts));
            showConfirmedContactsCheckBox.setValue(showConfirmedContacts);
            showConfirmedContactsCheckBox.addValueChangeListener(e -> {
                showConfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showConfirmedContactsCheckBox);

            CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3);
            showUnconfirmedContactsCheckBox
                    .setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts));
            showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts);
            showUnconfirmedContactsCheckBox.addValueChangeListener(e -> {
                showUnconfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showUnconfirmedContactsCheckBox);

            showConfirmedContactsCheckBox.setEnabled(showContacts);
            showUnconfirmedContactsCheckBox.setEnabled(showContacts);

            CheckBox showEventsCheckBox = new CheckBox();
            CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3);
            showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents));
            showEventsCheckBox.setValue(showEvents);
            showEventsCheckBox.addValueChangeListener(e -> {
                showEvents = (boolean) e.getProperty().getValue();
                refreshMap();
            });
            layersLayout.addComponent(showEventsCheckBox);

            if (UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_USER)
                    || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_CLINICIAN)
                    || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_OBSERVER)) {
                OptionGroup regionMapVisualizationSelect = new OptionGroup();
                regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE);
                regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values());
                regionMapVisualizationSelect.setValue(caseMeasure);
                regionMapVisualizationSelect.addValueChangeListener(event -> {
                    caseMeasure = (CaseMeasure) event.getProperty().getValue();
                    refreshMap();
                });

                HorizontalLayout showRegionsLayout = new HorizontalLayout();
                {
                    showRegionsLayout.setMargin(false);
                    showRegionsLayout.setSpacing(false);
                    CheckBox showRegionsCheckBox = new CheckBox();
                    showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions));
                    showRegionsCheckBox.setValue(showRegions);
                    showRegionsCheckBox.addValueChangeListener(e -> {
                        showRegions = (boolean) e.getProperty().getValue();
                        regionMapVisualizationSelect.setEnabled(showRegions);
                        regionMapVisualizationSelect.setValue(caseMeasure);
                        refreshMap();
                    });
                    showRegionsLayout.addComponent(showRegionsCheckBox);

                    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                    infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence));
                    CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY,
                            CssStyles.HSPACE_LEFT_3);
                    infoLabel.setHeightUndefined();
                    showRegionsLayout.addComponent(infoLabel);
                    showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
                }
                layersLayout.addComponent(showRegionsLayout);
                layersLayout.addComponent(regionMapVisualizationSelect);
                regionMapVisualizationSelect.setEnabled(showRegions);
            }
        }
    }
    mapFooterLayout.addComponent(layersDropdown);
    mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT);

    return mapFooterLayout;
}

From source file:de.symeda.sormas.ui.dashboard.map.DashboardMapComponent.java

License:Open Source License

private VerticalLayout createLegend() {
    VerticalLayout legendLayout = new VerticalLayout();
    legendLayout.setSpacing(false);
    legendLayout.setMargin(true);/*from  w w  w.  j  a v  a  2  s .co m*/
    legendLayout.setSizeUndefined();

    // Disable map key dropdown if no layers have been selected
    if (showCases || showContacts || showEvents || showRegions) {
        legendDropdown.setEnabled(true);
    } else {
        legendDropdown.setEnabled(false);
        return legendLayout;
    }

    // Health facilities

    // Cases
    if (showCases) {
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            Label facilitiesKeyLabel = new Label(I18nProperties.getCaption(Captions.dashboardHealthFacilities));
            CssStyles.style(facilitiesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
            legendLayout.addComponent(facilitiesKeyLabel);

            HorizontalLayout facilitiesKeyLayout = new HorizontalLayout();
            {
                facilitiesKeyLayout.setSpacing(false);
                facilitiesKeyLayout.setMargin(false);
                HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_UNCLASSIFIED,
                        I18nProperties.getCaption(Captions.dashboardNotYetClassifiedOnly));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_SUSPECT,
                        I18nProperties.getCaption(Captions.dashboardGt1SuspectCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_PROBABLE,
                        I18nProperties.getCaption(Captions.dashboardGt1ProbableCases));
                CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
                facilitiesKeyLayout.addComponent(legendEntry);
                legendEntry = buildMarkerLegendEntry(MarkerIcon.FACILITY_CONFIRMED,
                        I18nProperties.getCaption(Captions.dashboardGt1ConfirmedCases));
                facilitiesKeyLayout.addComponent(legendEntry);
            }
            legendLayout.addComponent(facilitiesKeyLayout);
        }

        Label casesKeyLabel = new Label(I18nProperties.getString(Strings.entityCases));
        if (mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY
                || mapCaseDisplayMode == MapCaseDisplayMode.HEALTH_FACILITY_OR_CASE_ADDRESS) {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(casesKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(casesKeyLabel);

        HorizontalLayout casesKeyLayout = new HorizontalLayout();
        {
            casesKeyLayout.setSpacing(false);
            casesKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_UNCLASSIFIED,
                    I18nProperties.getCaption(Captions.dashboardNotYetClassified));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_SUSPECT,
                    I18nProperties.getCaption(Captions.dashboardSuspect));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_PROBABLE,
                    I18nProperties.getCaption(Captions.dashboardProbable));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            casesKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CASE_CONFIRMED,
                    I18nProperties.getCaption(Captions.dashboardConfirmed));
            casesKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(casesKeyLayout);
    }

    // Contacts
    if (showContacts) {
        Label contactsKeyLabel = new Label(I18nProperties.getString(Strings.entityContacts));
        if (showCases) {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(contactsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(contactsKeyLabel);

        HorizontalLayout contactsKeyLayout = new HorizontalLayout();
        {
            contactsKeyLayout.setSpacing(false);
            contactsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OK,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt24));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitLt48));
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            contactsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.CONTACT_LONG_OVERDUE,
                    I18nProperties.getCaption(Captions.dashboardLastVisitGt48));
            contactsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(contactsKeyLayout);
    }

    // Events
    if (showEvents) {
        Label eventsKeyLabel = new Label(I18nProperties.getString(Strings.entityEvents));
        if (showCases || showContacts) {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(eventsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(eventsKeyLabel);

        HorizontalLayout eventsKeyLayout = new HorizontalLayout();
        {
            eventsKeyLayout.setSpacing(false);
            eventsKeyLayout.setMargin(false);
            HorizontalLayout legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_RUMOR,
                    EventStatus.POSSIBLE.toString());
            CssStyles.style(legendEntry, CssStyles.HSPACE_RIGHT_3);
            eventsKeyLayout.addComponent(legendEntry);
            legendEntry = buildMarkerLegendEntry(MarkerIcon.EVENT_OUTBREAK, EventStatus.CONFIRMED.toString());
            eventsKeyLayout.addComponent(legendEntry);
        }
        legendLayout.addComponent(eventsKeyLayout);
    }

    // Districts
    if (showRegions && districtValuesLowerQuartile != null && districtValuesMedian != null
            && districtValuesUpperQuartile != null) {
        Label districtsKeyLabel = new Label(I18nProperties.getString(Strings.entityDistricts));
        if (showCases || showContacts || showEvents) {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
        } else {
            CssStyles.style(districtsKeyLabel, CssStyles.H4, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        }
        legendLayout.addComponent(districtsKeyLabel);
        legendLayout.addComponent(buildRegionLegend(false, caseMeasure, emptyPopulationDistrictPresent,
                districtValuesLowerQuartile, districtValuesMedian, districtValuesUpperQuartile));

        Label descLabel = new Label(I18nProperties.getString(Strings.infoDashboardIncidence));
        CssStyles.style(descLabel, CssStyles.LABEL_SMALL);
        legendLayout.addComponent(descLabel);
    }

    return legendLayout;
}

From source file:de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent.java

License:Open Source License

public void addHeader(String headline, Image icon, boolean showTotalCount) {
    HorizontalLayout headerLayout = new HorizontalLayout();
    headerLayout.setWidth(100, Unit.PERCENTAGE);
    headerLayout.setSpacing(true);//from   w  ww.  j ava2  s.  c  om
    headerLayout.setMargin(false);
    CssStyles.style(headerLayout, CssStyles.VSPACE_4);

    VerticalLayout labelAndTotalLayout = new VerticalLayout();
    {
        labelAndTotalLayout.setMargin(false);
        labelAndTotalLayout.setSpacing(false);
        Label headlineLabel = new Label(headline);
        CssStyles.style(headlineLabel, CssStyles.H2, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
        labelAndTotalLayout.addComponent(headlineLabel);

        if (showTotalCount) {
            totalCountLabel = new Label();
            CssStyles.style(totalCountLabel, CssStyles.LABEL_PRIMARY, CssStyles.LABEL_XXXLARGE,
                    CssStyles.LABEL_BOLD, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_NONE);
            labelAndTotalLayout.addComponent(totalCountLabel);
        } else {
            CssStyles.style(labelAndTotalLayout, CssStyles.VSPACE_4);
        }

    }
    headerLayout.addComponent(labelAndTotalLayout);
    headerLayout.setComponentAlignment(labelAndTotalLayout, Alignment.BOTTOM_LEFT);
    headerLayout.setHeightUndefined();
    headerLayout.setExpandRatio(labelAndTotalLayout, 1);

    if (icon != null) {
        headerLayout.addComponent(icon);
        headerLayout.setComponentAlignment(icon, Alignment.TOP_RIGHT);
    }

    addComponent(headerLayout);
    setExpandRatio(headerLayout, 0);
}

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);/*from  www.jav a2 s .  c  o  m*/
    layout.setSpacing(false);
    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

void addStatsLayout(Long fatalities, Long events, String community) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setMargin(false);//from w  w w  .  j  a  v  a 2  s.c o m
    layout.setSpacing(false);
    CssStyles.style(layout, CssStyles.BACKGROUND_HIGHLIGHT);

    HorizontalLayout statsItem = createStatsItem("Last report", community.length() == 0 ? "None" : community,
            false);
    CssStyles.style(statsItem, CssStyles.VSPACE_TOP_4);
    layout.addComponent(statsItem);
    layout.addComponent(createStatsItem(I18nProperties.getCaption(Captions.dashboardFatalities),
            fatalities.toString(), fatalities > 0));
    statsItem = createStatsItem(I18nProperties.getCaption(Captions.DiseaseBurden_eventCount), events.toString(),
            false);
    CssStyles.style(statsItem, CssStyles.VSPACE_4);
    layout.addComponent(statsItem);

    addComponent(layout);
}

From source file:de.symeda.sormas.ui.person.PersonSelectField.java

License:Open Source License

@Override
protected Component initContent() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeUndefined();/*from   w  w w. ja v  a 2 s.co  m*/
    layout.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout nameLayout = new HorizontalLayout();
    nameLayout.setSpacing(true);
    nameLayout.setWidth(100, Unit.PERCENTAGE);

    firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
    firstNameField.setWidth(100, Unit.PERCENTAGE);
    firstNameField.setRequired(true);
    nameLayout.addComponent(firstNameField);

    lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
    lastNameField.setWidth(100, Unit.PERCENTAGE);
    lastNameField.setRequired(true);
    nameLayout.addComponent(lastNameField);

    CssStyles.style(searchMatchesButton, CssStyles.FORCE_CAPTION, ValoTheme.BUTTON_PRIMARY);
    searchMatchesButton.addClickListener(e -> {
        personGrid.reload(firstNameField.getValue(), lastNameField.getValue());
        selectBestMatch();
    });
    nameLayout.addComponent(searchMatchesButton);

    layout.addComponent(nameLayout);

    selectPerson = new OptionGroup(null);
    selectPerson.addItem(SELECT_PERSON);
    selectPerson.setItemCaption(SELECT_PERSON, I18nProperties.getCaption(Captions.personSelect));
    CssStyles.style(selectPerson, CssStyles.VSPACE_NONE);
    selectPerson.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            createNewPerson.setValue(null);
            personGrid.setEnabled(true);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(personGrid.getSelectedRow() != null);
            }
        }
    });
    layout.addComponent(selectPerson);

    initPersonGrid();
    // unselect "create new" when person is selected
    personGrid.addSelectionListener(e -> {
        if (e.getSelected().size() > 0) {
            createNewPerson.setValue(null);
        }
    });
    layout.addComponent(personGrid);

    personGrid.addSelectionListener(e -> {
        if (selectionChangeCallback != null) {
            selectionChangeCallback.accept(!e.getSelected().isEmpty());
        }
    });

    createNewPerson = new OptionGroup(null);
    createNewPerson.addItem(CREATE_PERSON);
    createNewPerson.setItemCaption(CREATE_PERSON, I18nProperties.getCaption(Captions.personCreateNew));
    // unselect grid when "create new" is selected
    createNewPerson.addValueChangeListener(e -> {
        if (e.getProperty().getValue() != null) {
            selectPerson.setValue(null);
            personGrid.select(null);
            personGrid.setEnabled(false);
            if (selectionChangeCallback != null) {
                selectionChangeCallback.accept(true);
            }
        }
    });
    layout.addComponent(createNewPerson);

    // set field values based on internal value
    setInternalValue(super.getInternalValue());

    return layout;
}