List of usage examples for com.vaadin.ui VerticalLayout setMargin
@Override public void setMargin(boolean enabled)
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 v a 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);/*from w ww .j av a2 s . c o m*/ filterLayout.setMargin(false); 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"); }//w ww . j ava 2 s . c o m 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 w w w. j a 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.contacts.ContactsEpiCurveComponent.java
License:Open Source License
@Override protected PopupButton createEpiCurveModeSelector() { if (epiCurveContactsMode == null) { epiCurveContactsMode = ContactsEpiCurveMode.FOLLOW_UP_STATUS; epiCurveLabel.setValue(epiCurveContactsMode.toString() + " Chart"); }// w w w . j a va 2s . c o m PopupButton dataDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardData)); CssStyles.style(dataDropdown, CssStyles.BUTTON_SUBTLE); VerticalLayout groupingLayout = new VerticalLayout(); groupingLayout.setMargin(true); groupingLayout.setSizeUndefined(); dataDropdown.setContent(groupingLayout); OptionGroup dataSelect = new OptionGroup(); dataSelect.setWidth(100, Unit.PERCENTAGE); dataSelect.addItems((Object[]) ContactsEpiCurveMode.values()); dataSelect.setValue(epiCurveContactsMode); dataSelect.select(epiCurveContactsMode); dataSelect.addValueChangeListener(e -> { epiCurveContactsMode = (ContactsEpiCurveMode) e.getProperty().getValue(); epiCurveLabel.setValue(epiCurveContactsMode.toString() + " Chart"); clearAndFillEpiCurveChart(); }); groupingLayout.addComponent(dataSelect); return dataDropdown; }
From source file:de.symeda.sormas.ui.dashboard.diagram.AbstractEpiCurveComponent.java
License:Open Source License
private HorizontalLayout createFooter() { HorizontalLayout epiCurveFooterLayout = new HorizontalLayout(); epiCurveFooterLayout.setWidth(100, Unit.PERCENTAGE); epiCurveFooterLayout.setSpacing(true); CssStyles.style(epiCurveFooterLayout, CssStyles.VSPACE_4); // Grouping/*from w w w. java 2 s. c o m*/ PopupButton groupingDropdown = new PopupButton(I18nProperties.getCaption(Captions.dashboardGrouping)); CssStyles.style(groupingDropdown, CssStyles.BUTTON_SUBTLE); { VerticalLayout groupingLayout = new VerticalLayout(); groupingLayout.setMargin(true); groupingLayout.setSizeUndefined(); groupingDropdown.setContent(groupingLayout); // Grouping option group OptionGroup groupingSelect = new OptionGroup(); groupingSelect.setWidth(100, Unit.PERCENTAGE); groupingSelect.addItems((Object[]) EpiCurveGrouping.values()); groupingSelect.setValue(epiCurveGrouping); groupingSelect.addValueChangeListener(e -> { epiCurveGrouping = (EpiCurveGrouping) e.getProperty().getValue(); clearAndFillEpiCurveChart(); }); groupingLayout.addComponent(groupingSelect); // "Always show at least 7 entries" checkbox CheckBox minimumEntriesCheckbox = new CheckBox( I18nProperties.getCaption(Captions.dashboardShowMinimumEntries)); CssStyles.style(minimumEntriesCheckbox, CssStyles.VSPACE_NONE); minimumEntriesCheckbox.setValue(showMinimumEntries); minimumEntriesCheckbox.addValueChangeListener(e -> { showMinimumEntries = (boolean) e.getProperty().getValue(); clearAndFillEpiCurveChart(); }); groupingLayout.addComponent(minimumEntriesCheckbox); groupingDropdown.setContent(groupingLayout); } epiCurveFooterLayout.addComponent(groupingDropdown); epiCurveFooterLayout.setComponentAlignment(groupingDropdown, Alignment.MIDDLE_RIGHT); epiCurveFooterLayout.setExpandRatio(groupingDropdown, 1); // Epi curve mode AbstractComponent epiCurveModeSelector = createEpiCurveModeSelector(); epiCurveFooterLayout.addComponent(epiCurveModeSelector); epiCurveFooterLayout.setComponentAlignment(epiCurveModeSelector, Alignment.MIDDLE_RIGHT); epiCurveFooterLayout.setExpandRatio(epiCurveModeSelector, 0); return epiCurveFooterLayout; }
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);//from w w w. j a va 2s . c om 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);// w w w . java 2s . c o m legendLayout.setMargin(true); 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.map.DashboardMapComponent.java
License:Open Source License
private void onMarkerClicked(String groupId, int markerIndex) { switch (groupId) { case CASES_GROUP_ID: if (markerIndex < markerCaseFacilities.size()) { FacilityReferenceDto facility = markerCaseFacilities.get(markerIndex); VerticalLayout layout = new VerticalLayout(); Window window = VaadinUiUtil.showPopupWindow(layout); CasePopupGrid caseGrid = new CasePopupGrid(window, facility, DashboardMapComponent.this); caseGrid.setHeightMode(HeightMode.ROW); layout.addComponent(caseGrid); layout.setMargin(true); FacilityDto facilityDto = FacadeProvider.getFacilityFacade().getByUuid(facility.getUuid()); window.setCaption(/*w w w.ja va 2 s.c o m*/ I18nProperties.getCaption(Captions.dashboardCasesIn) + " " + facilityDto.toString()); } else { markerIndex -= markerCaseFacilities.size(); MapCaseDto caze = mapCaseDtos.get(markerIndex); ControllerProvider.getCaseController().navigateToCase(caze.getUuid(), true); } break; case CONTACTS_GROUP_ID: { MapContactDto contact = markerContacts.get(markerIndex); ControllerProvider.getContactController().navigateToData(contact.getUuid(), true); } break; case EVENTS_GROUP_ID: { DashboardEventDto event = markerEvents.get(markerIndex); ControllerProvider.getEventController().navigateToData(event.getUuid(), true); } break; } }
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);/*w w w . java2 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); }