List of usage examples for com.vaadin.v7.ui CheckBox CheckBox
public CheckBox()
From source file:de.symeda.sormas.ui.caze.CasesView.java
License:Open Source License
public VerticalLayout createFilterBar() { VerticalLayout filterLayout = new VerticalLayout(); filterLayout.setSpacing(false);/*from w w w . j av a 2 s . c o m*/ filterLayout.setMargin(false); filterLayout.setWidth(100, Unit.PERCENTAGE); firstFilterRowLayout = new HorizontalLayout(); firstFilterRowLayout.setMargin(false); firstFilterRowLayout.setSpacing(true); firstFilterRowLayout.setSizeUndefined(); { if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) { caseOriginFilter = new ComboBox(); caseOriginFilter.setId(CaseDataDto.CASE_ORIGIN); caseOriginFilter.setWidth(140, Unit.PIXELS); caseOriginFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_ORIGIN)); caseOriginFilter.addItems((Object[]) CaseOrigin.values()); caseOriginFilter.addValueChangeListener(e -> { criteria.caseOrigin(((CaseOrigin) e.getProperty().getValue())); if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { pointOfEntryFilter.setEnabled(e.getProperty().getValue() != CaseOrigin.IN_COUNTRY); portHealthCasesWithoutFacilityFilter .setEnabled(e.getProperty().getValue() != CaseOrigin.IN_COUNTRY); } navigateTo(criteria); }); firstFilterRowLayout.addComponent(caseOriginFilter); } outcomeFilter = new ComboBox(); outcomeFilter.setId(CaseDataDto.OUTCOME); outcomeFilter.setWidth(140, Unit.PIXELS); outcomeFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.OUTCOME)); outcomeFilter.addItems((Object[]) CaseOutcome.values()); outcomeFilter.addValueChangeListener(e -> { criteria.outcome(((CaseOutcome) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(outcomeFilter); diseaseFilter = new ComboBox(); diseaseFilter.setId(CaseDataDto.DISEASE); diseaseFilter.setWidth(140, Unit.PIXELS); diseaseFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE)); diseaseFilter.addItems( FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases().toArray()); diseaseFilter.addValueChangeListener(e -> { criteria.disease(((Disease) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(diseaseFilter); classificationFilter = new ComboBox(); classificationFilter.setId(CaseDataDto.CASE_CLASSIFICATION); classificationFilter.setWidth(140, Unit.PIXELS); classificationFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CASE_CLASSIFICATION)); classificationFilter.addItems((Object[]) CaseClassification.values()); classificationFilter.addValueChangeListener(e -> { criteria.caseClassification(((CaseClassification) e.getProperty().getValue())); navigateTo(criteria); }); firstFilterRowLayout.addComponent(classificationFilter); searchField = new TextField(); searchField.setId("search"); searchField.setWidth(200, Unit.PIXELS); searchField.setNullRepresentation(""); searchField.setInputPrompt(I18nProperties.getString(Strings.promptCasesSearchField)); searchField.addTextChangeListener(e -> { criteria.nameUuidEpidNumberLike(e.getText()); grid.reload(); }); firstFilterRowLayout.addComponent(searchField); addShowMoreOrLessFiltersButtons(firstFilterRowLayout); resetButton = new Button(I18nProperties.getCaption(Captions.actionResetFilters)); resetButton.setId("reset"); resetButton.setVisible(false); resetButton.addClickListener(event -> { ViewModelProviders.of(CasesView.class).remove(CaseCriteria.class); navigateTo(null); }); firstFilterRowLayout.addComponent(resetButton); } filterLayout.addComponent(firstFilterRowLayout); secondFilterRowLayout = new HorizontalLayout(); secondFilterRowLayout.setMargin(false); secondFilterRowLayout.setSpacing(true); secondFilterRowLayout.setSizeUndefined(); { presentConditionFilter = new ComboBox(); presentConditionFilter.setWidth(140, Unit.PIXELS); presentConditionFilter.setInputPrompt( I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION)); presentConditionFilter.addItems((Object[]) PresentCondition.values()); presentConditionFilter.addValueChangeListener(e -> { criteria.presentCondition(((PresentCondition) e.getProperty().getValue())); navigateTo(criteria); }); secondFilterRowLayout.addComponent(presentConditionFilter); UserDto user = UserProvider.getCurrent().getUser(); regionFilter = new ComboBox(); if (user.getRegion() == null) { regionFilter.setWidth(140, Unit.PIXELS); regionFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION)); regionFilter.addItems(FacadeProvider.getRegionFacade().getAllAsReference()); regionFilter.addValueChangeListener(e -> { RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue(); criteria.region(region); navigateTo(criteria); }); secondFilterRowLayout.addComponent(regionFilter); } districtFilter = new ComboBox(); districtFilter.setWidth(140, Unit.PIXELS); districtFilter .setInputPrompt(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT)); districtFilter.setDescription(I18nProperties.getDescription(Descriptions.descDistrictFilter)); districtFilter.addValueChangeListener(e -> { DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); criteria.district(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); if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) { facilityFilter = new ComboBox(); facilityFilter.setWidth(140, Unit.PIXELS); facilityFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY)); facilityFilter.setDescription(I18nProperties.getDescription(Descriptions.descFacilityFilter)); facilityFilter.addValueChangeListener(e -> { criteria.healthFacility(((FacilityReferenceDto) e.getProperty().getValue())); navigateTo(criteria); }); facilityFilter.setEnabled(false); secondFilterRowLayout.addComponent(facilityFilter); } if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { pointOfEntryFilter = new ComboBox(); pointOfEntryFilter.setWidth(140, Unit.PIXELS); pointOfEntryFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.POINT_OF_ENTRY)); pointOfEntryFilter .setDescription(I18nProperties.getDescription(Descriptions.descPointOfEntryFilter)); pointOfEntryFilter.addValueChangeListener(e -> { criteria.pointOfEntry(((PointOfEntryReferenceDto) e.getProperty().getValue())); navigateTo(criteria); }); secondFilterRowLayout.addComponent(pointOfEntryFilter); } districtFilter.addValueChangeListener(e -> { if (facilityFilter != null) { 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); } } if (pointOfEntryFilter != null) { pointOfEntryFilter.removeAllItems(); DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue(); if (district != null) { pointOfEntryFilter.addItems( FacadeProvider.getPointOfEntryFacade().getAllByDistrict(district.getUuid(), true)); pointOfEntryFilter.setEnabled( caseOriginFilter == null || caseOriginFilter.getValue() != CaseOrigin.IN_COUNTRY); } else { pointOfEntryFilter.setEnabled(false); } } }); officerFilter = new ComboBox(); officerFilter.setWidth(140, Unit.PIXELS); officerFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.SURVEILLANCE_OFFICER)); if (user.getRegion() != null) { officerFilter.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.SURVEILLANCE_OFFICER)); } officerFilter.addValueChangeListener(e -> { criteria.surveillanceOfficer(((UserReferenceDto) e.getProperty().getValue())); 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); reportingUserFilter = new TextField(); reportingUserFilter.setWidth(200, Unit.PIXELS); reportingUserFilter.setInputPrompt( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORTING_USER)); reportingUserFilter.setNullRepresentation(""); reportingUserFilter.addTextChangeListener(e -> { criteria.reportingUserLike(e.getText()); grid.reload(); }); secondFilterRowLayout.addComponent(reportingUserFilter); } filterLayout.addComponent(secondFilterRowLayout); secondFilterRowLayout.setVisible(false); thirdFilterRowLayout = new HorizontalLayout(); thirdFilterRowLayout.setMargin(false); thirdFilterRowLayout.setSpacing(true); thirdFilterRowLayout.setSizeUndefined(); CssStyles.style(thirdFilterRowLayout, CssStyles.VSPACE_3); { casesWithoutGeoCoordsFilter = new CheckBox(); CssStyles.style(casesWithoutGeoCoordsFilter, CssStyles.CHECKBOX_FILTER_INLINE); casesWithoutGeoCoordsFilter.setCaption(I18nProperties.getCaption(Captions.caseFilterWithoutGeo)); casesWithoutGeoCoordsFilter .setDescription(I18nProperties.getDescription(Descriptions.descCaseFilterWithoutGeo)); casesWithoutGeoCoordsFilter.addValueChangeListener(e -> { criteria.mustHaveNoGeoCoordinates((Boolean) e.getProperty().getValue()); navigateTo(criteria); }); thirdFilterRowLayout.addComponent(casesWithoutGeoCoordsFilter); if (UserProvider.getCurrent().hasUserRight(UserRight.PORT_HEALTH_INFO_VIEW)) { portHealthCasesWithoutFacilityFilter = new CheckBox(); CssStyles.style(portHealthCasesWithoutFacilityFilter, CssStyles.CHECKBOX_FILTER_INLINE); portHealthCasesWithoutFacilityFilter .setCaption(I18nProperties.getCaption(Captions.caseFilterPortHealthWithoutFacility)); portHealthCasesWithoutFacilityFilter.setDescription( I18nProperties.getDescription(Descriptions.descCaseFilterPortHealthWithoutFacility)); portHealthCasesWithoutFacilityFilter.addValueChangeListener(e -> { criteria.mustBePortHealthCaseWithoutFacility((Boolean) e.getProperty().getValue()); navigateTo(criteria); }); thirdFilterRowLayout.addComponent(portHealthCasesWithoutFacilityFilter); } } filterLayout.addComponent(thirdFilterRowLayout); thirdFilterRowLayout.setVisible(false); dateFilterRowLayout = new HorizontalLayout(); dateFilterRowLayout.setSpacing(true); dateFilterRowLayout.setSizeUndefined(); { Button applyButton = new Button(I18nProperties.getCaption(Captions.actionApplyDateFilter)); weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(applyButton, false, false, I18nProperties.getString(Strings.infoCaseDate), NewCaseDateType.class, I18nProperties.getString(Strings.promptNewCaseDateType), NewCaseDateType.MOST_RELEVANT); weekAndDateFilter.getWeekFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesEpiWeekFrom)); weekAndDateFilter.getWeekToFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesEpiWeekTo)); weekAndDateFilter.getDateFromFilter() .setInputPrompt(I18nProperties.getString(Strings.promptCasesDateFrom)); weekAndDateFilter.getDateToFilter().setInputPrompt(I18nProperties.getString(Strings.promptDateTo)); 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); NewCaseDateType newCaseDateType = (NewCaseDateType) weekAndDateFilter.getDateTypeSelector() .getValue(); criteria.newCaseDateBetween(fromDate, toDate, newCaseDateType != null ? newCaseDateType : NewCaseDateType.MOST_RELEVANT); 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.map.DashboardMapComponent.java
License:Open Source License
private HorizontalLayout createFooter() { HorizontalLayout mapFooterLayout = new HorizontalLayout(); mapFooterLayout.setWidth(100, Unit.PERCENTAGE); mapFooterLayout.setSpacing(true);/*from w ww . ja va2 s .com*/ 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.importer.ImportPersonSelectField.java
License:Open Source License
@Override protected Component initContent() { if (importedCase == null || importedPerson == null) { return null; }//from www . j av a2 s. com VerticalLayout layout = new VerticalLayout(); layout.setSizeUndefined(); layout.setWidth(100, Unit.PERCENTAGE); // Info label Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity)); CssStyles.style(infoLabel, CssStyles.VSPACE_3); layout.addComponent(infoLabel); // Imported case info VerticalLayout outerCaseInfoLayout = new VerticalLayout(); outerCaseInfoLayout.setWidth(100, Unit.PERCENTAGE); CssStyles.style(outerCaseInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable"); Label importedCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo)); CssStyles.style(importedCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4); outerCaseInfoLayout.addComponent(importedCaseLabel); HorizontalLayout caseInfoLayout = new HorizontalLayout(); caseInfoLayout.setSpacing(true); caseInfoLayout.setSizeUndefined(); { Label diseaseField = new Label(); diseaseField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE)); diseaseField .setValue(DiseaseHelper.toString(importedCase.getDisease(), importedCase.getDiseaseDetails())); diseaseField.setWidthUndefined(); caseInfoLayout.addComponent(diseaseField); Label caseDateField = new Label(); if (importedCase.getSymptoms().getOnsetDate() != null) { caseDateField.setCaption( I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE)); caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getSymptoms().getOnsetDate())); } else { caseDateField.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE)); caseDateField.setValue(DateHelper.formatLocalShortDate(importedCase.getReportDate())); } caseDateField.setWidthUndefined(); caseInfoLayout.addComponent(caseDateField); Label regionField = new Label(); regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION)); regionField.setValue(importedCase.getRegion().toString()); regionField.setWidthUndefined(); caseInfoLayout.addComponent(regionField); Label districtField = new Label(); districtField .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT)); districtField.setValue(importedCase.getDistrict().toString()); districtField.setWidthUndefined(); caseInfoLayout.addComponent(districtField); Label communityField = new Label(); communityField .setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.COMMUNITY)); communityField .setValue(importedCase.getCommunity() != null ? importedCase.getCommunity().toString() : ""); communityField.setWidthUndefined(); caseInfoLayout.addComponent(communityField); Label facilityField = new Label(); facilityField.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY)); facilityField.setValue(FacilityHelper.buildFacilityString(null, importedCase.getHealthFacility() != null ? importedCase.getHealthFacility().toString() : "", importedCase.getHealthFacilityDetails())); facilityField.setWidthUndefined(); caseInfoLayout.addComponent(facilityField); } outerCaseInfoLayout.addComponent(caseInfoLayout); layout.addComponent(outerCaseInfoLayout); // Imported person info VerticalLayout outerPersonInfoLayout = new VerticalLayout(); outerPersonInfoLayout.setWidth(100, Unit.PERCENTAGE); CssStyles.style(outerPersonInfoLayout, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable"); Label importedPersonLabel = new Label(I18nProperties.getString(Strings.headingImportedPersonInfo)); CssStyles.style(importedPersonLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4); outerPersonInfoLayout.addComponent(importedPersonLabel); HorizontalLayout personInfoLayout = new HorizontalLayout(); personInfoLayout.setSpacing(true); personInfoLayout.setSizeUndefined(); { Label firstNameField = new Label(); firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME)); firstNameField.setValue(importedPerson.getFirstName()); firstNameField.setWidthUndefined(); personInfoLayout.addComponent(firstNameField); Label lastNameField = new Label(); lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME)); lastNameField.setValue(importedPerson.getLastName()); lastNameField.setWidthUndefined(); personInfoLayout.addComponent(lastNameField); Label nicknameField = new Label(); nicknameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.NICKNAME)); nicknameField.setValue(importedPerson.getNickname()); nicknameField.setWidthUndefined(); personInfoLayout.addComponent(nicknameField); Label ageField = new Label(); ageField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.APPROXIMATE_AGE)); ageField.setValue(ApproximateAgeHelper.formatApproximateAge(importedPerson.getApproximateAge(), importedPerson.getApproximateAgeType())); ageField.setWidthUndefined(); personInfoLayout.addComponent(ageField); Label sexField = new Label(); sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX)); sexField.setValue(importedPerson.getSex() != null ? importedPerson.getSex().toString() : ""); sexField.setWidthUndefined(); personInfoLayout.addComponent(sexField); Label presentConditionField = new Label(); presentConditionField.setCaption( I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.PRESENT_CONDITION)); presentConditionField.setValue( importedPerson.getPresentCondition() != null ? importedPerson.getPresentCondition().toString() : null); presentConditionField.setWidthUndefined(); personInfoLayout.addComponent(presentConditionField); Label regionField = new Label(); regionField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.REGION)); regionField.setValue(importedPerson.getAddress().getRegion() != null ? importedPerson.getAddress().getRegion().toString() : ""); regionField.setWidthUndefined(); personInfoLayout.addComponent(regionField); Label districtField = new Label(); districtField .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.DISTRICT)); districtField.setValue(importedPerson.getAddress().getDistrict() != null ? importedPerson.getAddress().getDistrict().toString() : ""); districtField.setWidthUndefined(); personInfoLayout.addComponent(districtField); Label communityField = new Label(); communityField .setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.COMMUNITY)); communityField.setValue(importedPerson.getAddress().getCommunity() != null ? importedPerson.getAddress().getCommunity().toString() : ""); communityField.setWidthUndefined(); personInfoLayout.addComponent(communityField); Label cityField = new Label(); cityField.setCaption(I18nProperties.getPrefixCaption(LocationDto.I18N_PREFIX, LocationDto.CITY)); cityField.setValue(importedPerson.getAddress().getCity()); cityField.setWidthUndefined(); personInfoLayout.addComponent(cityField); } outerPersonInfoLayout.addComponent(personInfoLayout); layout.addComponent(outerPersonInfoLayout); // Person selection/creation 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); mergeCheckBox.setEnabled(true); if (selectionChangeCallback != null) { selectionChangeCallback.accept(personGrid.getSelectedRow() != null); } } }); layout.addComponent(selectPerson); mergeCheckBox = new CheckBox(); mergeCheckBox.setCaption(I18nProperties.getCaption(Captions.caseImportMergeCase)); CssStyles.style(mergeCheckBox, CssStyles.VSPACE_3); layout.addComponent(mergeCheckBox); initPersonGrid(); // Deselect "create new" when person is selected personGrid.addSelectionListener(e -> { if (e.getSelected().size() > 0) { createNewPerson.setValue(null); } }); CssStyles.style(personGrid, CssStyles.VSPACE_3); 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)); // Deselect grid when "create new" is selected createNewPerson.addValueChangeListener(e -> { if (e.getProperty().getValue() != null) { selectPerson.setValue(null); personGrid.select(null); personGrid.setEnabled(false); mergeCheckBox.setEnabled(false); if (selectionChangeCallback != null) { selectionChangeCallback.accept(true); } } }); layout.addComponent(createNewPerson); // Set field values based on internal value setInternalValue(super.getInternalValue()); return layout; }