Search in sources :

Example 86 with Label

use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.

the class CaseCreateForm method addFields.

@Override
protected void addFields() {
    NullableOptionGroup ogCaseOrigin = addField(CaseDataDto.CASE_ORIGIN, NullableOptionGroup.class);
    ogCaseOrigin.setRequired(true);
    TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
    epidField.setInvalidCommitted(true);
    style(epidField, ERROR_COLOR_PRIMARY);
    if (!FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
        TextField externalIdField = addField(CaseDataDto.EXTERNAL_ID, TextField.class);
        style(externalIdField, ERROR_COLOR_PRIMARY);
    } else {
        CheckBox dontShareCheckbox = addField(CaseDataDto.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
        CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC);
    }
    addField(CaseDataDto.REPORT_DATE, DateField.class);
    ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false, true);
    diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
    diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    diseaseVariantField.setNullSelectionAllowed(true);
    diseaseVariantField.setVisible(false);
    addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
    NullableOptionGroup plagueType = addField(CaseDataDto.PLAGUE_TYPE, NullableOptionGroup.class);
    addField(CaseDataDto.DENGUE_FEVER_TYPE, NullableOptionGroup.class);
    addField(CaseDataDto.RABIES_TYPE, NullableOptionGroup.class);
    personCreateForm = new PersonCreateForm(showHomeAddressForm, true, true, showPersonSearchButton);
    personCreateForm.setWidth(100, Unit.PERCENTAGE);
    getContent().addComponent(personCreateForm, CaseDataDto.PERSON);
    differentPlaceOfStayJurisdiction = addCustomField(DIFFERENT_PLACE_OF_STAY_JURISDICTION, Boolean.class, CheckBox.class);
    differentPlaceOfStayJurisdiction.addStyleName(VSPACE_3);
    Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.casePlaceOfStay));
    placeOfStayHeadingLabel.addStyleName(H3);
    getContent().addComponent(placeOfStayHeadingLabel, PLACE_OF_STAY_HEADING_LOC);
    ComboBox region = addInfrastructureField(CaseDataDto.REGION);
    districtCombo = addInfrastructureField(CaseDataDto.DISTRICT);
    communityCombo = addInfrastructureField(CaseDataDto.COMMUNITY);
    communityCombo.setNullSelectionAllowed(true);
    // jurisdictionfields
    Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingCaseResponsibleJurisidction));
    jurisdictionHeadingLabel.addStyleName(H3);
    getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
    ComboBox responsibleRegion = addInfrastructureField(CaseDataDto.RESPONSIBLE_REGION);
    responsibleRegion.setRequired(true);
    responsibleDistrictCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_DISTRICT);
    responsibleDistrictCombo.setRequired(true);
    responsibleCommunityCombo = addInfrastructureField(CaseDataDto.RESPONSIBLE_COMMUNITY);
    responsibleCommunityCombo.setNullSelectionAllowed(true);
    responsibleCommunityCombo.addStyleName(SOFT_REQUIRED);
    InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrictCombo, responsibleCommunityCombo);
    differentPointOfEntryJurisdiction = addCustomField(DIFFERENT_POINT_OF_ENTRY_JURISDICTION, Boolean.class, CheckBox.class);
    differentPointOfEntryJurisdiction.addStyleName(VSPACE_3);
    ComboBox pointOfEntryRegionCombo = addCustomField(POINT_OF_ENTRY_REGION, RegionReferenceDto.class, ComboBox.class);
    pointOfEntryDistrictCombo = addCustomField(POINT_OF_ENTRY_DISTRICT, DistrictReferenceDto.class, ComboBox.class);
    InfrastructureFieldsHelper.initInfrastructureFields(pointOfEntryRegionCombo, pointOfEntryDistrictCombo, null);
    pointOfEntryDistrictCombo.addValueChangeListener(e -> updatePOEs());
    FieldHelper.setVisibleWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo, communityCombo), Collections.singletonList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(differentPointOfEntryJurisdiction, Arrays.asList(pointOfEntryRegionCombo, pointOfEntryDistrictCombo), Collections.singletonList(Boolean.TRUE), true);
    FieldHelper.setRequiredWhen(differentPlaceOfStayJurisdiction, Arrays.asList(region, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
    ogCaseOrigin.addValueChangeListener(e -> {
        boolean pointOfEntryRegionDistrictVisible = CaseOrigin.POINT_OF_ENTRY.equals(ogCaseOrigin.getValue()) && Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue());
        pointOfEntryRegionCombo.setVisible(pointOfEntryRegionDistrictVisible);
        pointOfEntryDistrictCombo.setVisible(pointOfEntryRegionDistrictVisible);
    });
    facilityOrHome = addCustomField(FACILITY_OR_HOME_LOC, TypeOfPlace.class, NullableOptionGroup.class, I18nProperties.getCaption(Captions.casePlaceOfStay));
    facilityOrHome.removeAllItems();
    for (TypeOfPlace place : TypeOfPlace.FOR_CASES) {
        facilityOrHome.addItem(place);
        facilityOrHome.setItemCaption(place, I18nProperties.getEnumCaption(place));
    }
    facilityOrHome.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    facilityOrHome.setId("facilityOrHome");
    facilityOrHome.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
    facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
    facilityTypeGroup.setId("typeGroup");
    facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
    facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
    facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
    getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
    facilityType = ComboBoxHelper.createComboBoxV7();
    facilityType.setId("type");
    facilityType.setCaption(I18nProperties.getCaption(Captions.facilityType));
    facilityType.setWidth(100, Unit.PERCENTAGE);
    getContent().addComponent(facilityType, CaseDataDto.FACILITY_TYPE);
    facilityCombo = addInfrastructureField(CaseDataDto.HEALTH_FACILITY);
    facilityCombo.setImmediate(true);
    TextField facilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
    facilityDetails.setVisible(false);
    ComboBox cbPointOfEntry = addInfrastructureField(CaseDataDto.POINT_OF_ENTRY);
    cbPointOfEntry.setImmediate(true);
    TextField tfPointOfEntryDetails = addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);
    tfPointOfEntryDetails.setVisible(false);
    if (convertedTravelEntry != null) {
        differentPointOfEntryJurisdiction.setValue(true);
        RegionReferenceDto regionReferenceDto = convertedTravelEntry.getPointOfEntryRegion() != null ? convertedTravelEntry.getPointOfEntryRegion() : convertedTravelEntry.getResponsibleRegion();
        pointOfEntryRegionCombo.setValue(regionReferenceDto);
        DistrictReferenceDto districtReferenceDto = convertedTravelEntry.getPointOfEntryDistrict() != null ? convertedTravelEntry.getPointOfEntryDistrict() : convertedTravelEntry.getResponsibleDistrict();
        pointOfEntryDistrictCombo.setValue(districtReferenceDto);
        differentPointOfEntryJurisdiction.setReadOnly(true);
        pointOfEntryRegionCombo.setReadOnly(true);
        pointOfEntryDistrictCombo.setReadOnly(true);
        updatePOEs();
        cbPointOfEntry.setReadOnly(true);
        tfPointOfEntryDetails.setReadOnly(true);
        ogCaseOrigin.setReadOnly(true);
    }
    region.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    districtCombo.addValueChangeListener(e -> {
        FieldHelper.removeItems(communityCombo);
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(communityCombo, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
        updateFacility();
        if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
            updatePOEs();
        }
    });
    communityCombo.addValueChangeListener(e -> {
        updateFacility();
    });
    facilityOrHome.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.FACILITY.equals(facilityOrHome.getNullableValue()))) {
            if (facilityTypeGroup.getValue() == null) {
                facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
            }
            if (facilityType.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue())) {
                facilityType.setValue(FacilityType.HOSPITAL);
            }
            if (facilityType.getValue() != null) {
                updateFacility();
            }
            if (CaseOrigin.IN_COUNTRY.equals(ogCaseOrigin.getValue())) {
                facilityCombo.setRequired(true);
            }
            updateFacilityFields(facilityCombo, facilityDetails);
        } else if (TypeOfPlace.HOME.equals(facilityOrHome.getValue()) || ((facilityOrHome.getValue() instanceof java.util.Set) && TypeOfPlace.HOME.equals(facilityOrHome.getNullableValue()))) {
            setNoneFacility();
        } else {
            facilityCombo.removeAllItems();
            facilityCombo.setValue(null);
            updateFacilityFields(facilityCombo, facilityDetails);
        }
    });
    facilityTypeGroup.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
    });
    facilityType.addValueChangeListener(e -> updateFacility());
    region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    JurisdictionLevel userJurisdictionLevel = UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles());
    if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
        region.setReadOnly(true);
        responsibleRegion.setReadOnly(true);
        districtCombo.setReadOnly(true);
        responsibleDistrictCombo.setReadOnly(true);
        communityCombo.setReadOnly(true);
        responsibleCommunityCombo.setReadOnly(true);
        differentPlaceOfStayJurisdiction.setVisible(false);
        differentPlaceOfStayJurisdiction.setEnabled(false);
        facilityOrHome.setImmediate(true);
        // [FACILITY]
        facilityOrHome.setValue(Sets.newHashSet(TypeOfPlace.FACILITY));
        facilityOrHome.setReadOnly(true);
        facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
        facilityTypeGroup.setReadOnly(true);
        facilityType.setValue(FacilityType.HOSPITAL);
        facilityType.setReadOnly(true);
        facilityCombo.setValue(UserProvider.getCurrent().getUser().getHealthFacility());
        facilityCombo.setReadOnly(true);
    }
    if (!UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
        ogCaseOrigin.addValueChangeListener(ev -> {
            if (ev.getProperty().getValue() == CaseOrigin.IN_COUNTRY) {
                setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
                differentPointOfEntryJurisdiction.setVisible(false);
                setRequired(true, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
                setRequired(false, CaseDataDto.POINT_OF_ENTRY);
                updateFacilityFields(facilityCombo, facilityDetails);
            } else {
                setVisible(true, CaseDataDto.POINT_OF_ENTRY);
                differentPointOfEntryJurisdiction.setVisible(true);
                setRequired(true, CaseDataDto.POINT_OF_ENTRY);
                if (userJurisdictionLevel != JurisdictionLevel.HEALTH_FACILITY) {
                    facilityOrHome.clear();
                    setRequired(false, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY);
                }
                updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
            }
        });
    }
    // jurisdiction field valuechangelisteners
    responsibleDistrictCombo.addValueChangeListener(e -> {
        Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
        if (!Boolean.TRUE.equals(differentPlaceOfStay)) {
            updateFacility();
            if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
                updatePOEs();
            }
        }
    });
    responsibleCommunityCombo.addValueChangeListener((e) -> {
        Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
        if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
            updateFacility();
        }
    });
    differentPlaceOfStayJurisdiction.addValueChangeListener(e -> {
        updateFacility();
        if (!Boolean.TRUE.equals(differentPointOfEntryJurisdiction.getValue())) {
            updatePOEs();
        }
    });
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.DISEASE, FACILITY_OR_HOME_LOC, FACILITY_TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE);
    FieldHelper.addSoftRequiredStyle(plagueType, communityCombo, facilityDetails);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DISEASE_DETAILS), CaseDataDto.DISEASE, Arrays.asList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.DISEASE, Arrays.asList(CaseDataDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
    FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.HEALTH_FACILITY), Arrays.asList(CaseOrigin.IN_COUNTRY));
    FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.CASE_ORIGIN, Arrays.asList(CaseDataDto.POINT_OF_ENTRY), Arrays.asList(CaseOrigin.POINT_OF_ENTRY));
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DENGUE_FEVER_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.DENGUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.RABIES_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.RABIES), true);
    FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false);
    FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityType, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
    facilityCombo.addValueChangeListener(e -> {
        updateFacilityFields(facilityCombo, facilityDetails);
        this.getValue().setFacilityType((FacilityType) facilityType.getValue());
    });
    cbPointOfEntry.addValueChangeListener(e -> {
        updatePointOfEntryFields(cbPointOfEntry, tfPointOfEntryDetails);
    });
    addValueChangeListener(e -> {
        if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
            setVisible(false, CaseDataDto.CASE_ORIGIN, CaseDataDto.DISEASE, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY);
            setVisible(true, CaseDataDto.POINT_OF_ENTRY);
        }
    });
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        updateDiseaseVariant((Disease) valueChangeEvent.getProperty().getValue());
        personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue());
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    if (diseaseField.getValue() != null) {
        Disease disease = (Disease) diseaseField.getValue();
        updateDiseaseVariant(disease);
        personCreateForm.updatePresentConditionEnum(disease);
    }
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) LayoutUtil.locs(de.symeda.sormas.ui.utils.LayoutUtil.locs) PersonDto(de.symeda.sormas.api.person.PersonDto) CssStyles(de.symeda.sormas.ui.utils.CssStyles) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) UserRole(de.symeda.sormas.api.user.UserRole) UserProvider(de.symeda.sormas.ui.UserProvider) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ValoTheme(com.vaadin.ui.themes.ValoTheme) ComboBox(com.vaadin.v7.ui.ComboBox) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Sets(com.google.common.collect.Sets) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) List(java.util.List) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) TextField(com.vaadin.v7.ui.TextField) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) FacadeProvider(de.symeda.sormas.api.FacadeProvider) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) Converter(com.vaadin.v7.data.util.converter.Converter) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) CollectionUtils(org.apache.commons.collections.CollectionUtils) Label(com.vaadin.ui.Label) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) SOFT_REQUIRED(de.symeda.sormas.ui.utils.CssStyles.SOFT_REQUIRED) Captions(de.symeda.sormas.api.i18n.Captions) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) ItemCaptionMode(com.vaadin.v7.ui.AbstractSelect.ItemCaptionMode) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Disease(de.symeda.sormas.api.Disease) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) LayoutUtil.fluidColumn(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumn) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CheckBox(com.vaadin.v7.ui.CheckBox) TextField(com.vaadin.v7.ui.TextField) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)

Example 87 with Label

use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.

the class ClinicalCourseView method createClinicalVisitsHeader.

private VerticalLayout createClinicalVisitsHeader() {
    VerticalLayout clinicalVisitsHeader = new VerticalLayout();
    clinicalVisitsHeader.setMargin(false);
    clinicalVisitsHeader.setSpacing(false);
    clinicalVisitsHeader.setWidth(100, Unit.PERCENTAGE);
    HorizontalLayout headlineRow = new HorizontalLayout();
    headlineRow.setMargin(false);
    headlineRow.setSpacing(true);
    headlineRow.setWidth(100, Unit.PERCENTAGE);
    {
        Label clinicalVisitsLabel = new Label(I18nProperties.getString(Strings.entityClinicalVisits));
        CssStyles.style(clinicalVisitsLabel, CssStyles.H3);
        headlineRow.addComponent(clinicalVisitsLabel);
        headlineRow.setExpandRatio(clinicalVisitsLabel, 1);
        // Bulk operations
        if (UserProvider.getCurrent().hasUserRight(UserRight.PERFORM_BULK_OPERATIONS)) {
            MenuBar bulkOperationsDropdown = MenuBarHelper.createDropDown(Captions.bulkActions, new MenuBarHelper.MenuBarItem(I18nProperties.getCaption(Captions.bulkDelete), VaadinIcons.TRASH, selectedItem -> {
                ControllerProvider.getClinicalCourseController().deleteAllSelectedClinicalVisits(clinicalVisitGrid.getSelectedRows(), new Runnable() {

                    public void run() {
                        clinicalVisitGrid.reload();
                    }
                });
            }));
            headlineRow.addComponent(bulkOperationsDropdown);
            headlineRow.setComponentAlignment(bulkOperationsDropdown, Alignment.MIDDLE_RIGHT);
        }
        Button newClinicalVisitButton = ButtonHelper.createButton(Captions.clinicalVisitNewClinicalVisit, e -> {
            ControllerProvider.getClinicalCourseController().openClinicalVisitCreateForm(clinicalVisitCriteria.getClinicalCourse(), getCaseRef().getUuid(), this::reloadClinicalVisitGrid);
        }, ValoTheme.BUTTON_PRIMARY);
        headlineRow.addComponent(newClinicalVisitButton);
        headlineRow.setComponentAlignment(newClinicalVisitButton, Alignment.MIDDLE_RIGHT);
    }
    clinicalVisitsHeader.addComponent(headlineRow);
    return clinicalVisitsHeader;
}
Also used : FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) ClinicalVisitCriteria(de.symeda.sormas.api.clinicalcourse.ClinicalVisitCriteria) AbstractCaseView(de.symeda.sormas.ui.caze.AbstractCaseView) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) MenuBarHelper(de.symeda.sormas.ui.utils.MenuBarHelper) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) UserProvider(de.symeda.sormas.ui.UserProvider) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ValoTheme(com.vaadin.ui.themes.ValoTheme) MenuBar(com.vaadin.ui.MenuBar) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Captions(de.symeda.sormas.api.i18n.Captions) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) ClinicalCourseDto(de.symeda.sormas.api.clinicalcourse.ClinicalCourseDto) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) MenuBar(com.vaadin.ui.MenuBar) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 88 with Label

use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.

the class HealthConditionsForm method addFields.

@Override
protected void addFields() {
    Label healthConditionsHeadingLabel = new Label(I18nProperties.getString(Strings.headingHealthConditions));
    healthConditionsHeadingLabel.addStyleName(H3);
    getContent().addComponent(healthConditionsHeadingLabel, HEALTH_CONDITIONS_HEADINGS_LOC);
    addFields(TUBERCULOSIS, ASPLENIA, HEPATITIS, DIABETES, HIV, HIV_ART, CHRONIC_LIVER_DISEASE, MALIGNANCY_CHEMOTHERAPY, CHRONIC_HEART_FAILURE, CHRONIC_PULMONARY_DISEASE, CHRONIC_KIDNEY_DISEASE, CHRONIC_NEUROLOGIC_CONDITION, DOWN_SYNDROME, CONGENITAL_SYPHILIS, IMMUNODEFICIENCY_OTHER_THAN_HIV, CARDIOVASCULAR_DISEASE_INCLUDING_HYPERTENSION, OBESITY, CURRENT_SMOKER, FORMER_SMOKER, ASTHMA, SICKLE_CELL_DISEASE, IMMUNODEFICIENCY_INCLUDING_HIV);
    TextArea otherConditions = addField(OTHER_CONDITIONS, TextArea.class);
    otherConditions.setRows(6);
    otherConditions.setDescription(I18nProperties.getPrefixDescription(HealthConditionsDto.I18N_PREFIX, OTHER_CONDITIONS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    FieldHelper.setVisibleWhen(getFieldGroup(), HIV_ART, HIV, Arrays.asList(YesNoUnknown.YES), true);
}
Also used : TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label)

Example 89 with Label

use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.

the class CasePickOrImportField method addInfoComponent.

@Override
protected void addInfoComponent() {
    HorizontalLayout infoLayout = new HorizontalLayout();
    infoLayout.setWidth(100, Unit.PERCENTAGE);
    infoLayout.setSpacing(true);
    Image icon = new Image(null, new ThemeResource("img/info-icon.png"));
    icon.setHeight(35, Unit.PIXELS);
    icon.setWidth(35, Unit.PIXELS);
    infoLayout.addComponent(icon);
    Label infoLabel = new Label(I18nProperties.getString(Strings.infoImportSimilarity));
    infoLayout.addComponent(infoLabel);
    infoLayout.setExpandRatio(infoLabel, 1);
    mainLayout.addComponent(infoLayout);
    CssStyles.style(infoLayout, CssStyles.VSPACE_3);
    // Imported case info
    VerticalLayout caseInfoContainer = new VerticalLayout();
    caseInfoContainer.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(caseInfoContainer, CssStyles.BACKGROUND_ROUNDED_CORNERS, CssStyles.BACKGROUND_SUB_CRITERIA, CssStyles.VSPACE_3, "v-scrollable");
    Label newCaseLabel = new Label(I18nProperties.getString(Strings.headingImportedCaseInfo));
    CssStyles.style(newCaseLabel, CssStyles.LABEL_BOLD, CssStyles.VSPACE_4);
    caseInfoContainer.addComponent(newCaseLabel);
    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(newCase.getDisease(), newCase.getDiseaseDetails()));
        diseaseField.setWidthUndefined();
        caseInfoLayout.addComponent(diseaseField);
        Label reportDateField = new Label();
        reportDateField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE));
        reportDateField.setValue(DateFormatHelper.formatDate(newCase.getReportDate()));
        reportDateField.setWidthUndefined();
        caseInfoLayout.addComponent(reportDateField);
        Label responsibleRegionField = new Label();
        responsibleRegionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_REGION));
        responsibleRegionField.setValue(newCase.getResponsibleRegion().toString());
        responsibleRegionField.setWidthUndefined();
        caseInfoLayout.addComponent(responsibleRegionField);
        Label responsibleDistrictField = new Label();
        responsibleDistrictField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.RESPONSIBLE_DISTRICT));
        responsibleDistrictField.setValue(newCase.getResponsibleDistrict().toString());
        responsibleDistrictField.setWidthUndefined();
        caseInfoLayout.addComponent(responsibleDistrictField);
        if (newCase.getRegion() != null) {
            Label regionField = new Label();
            regionField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REGION));
            regionField.setValue(newCase.getRegion().toString());
            regionField.setWidthUndefined();
            caseInfoLayout.addComponent(regionField);
        }
        if (newCase.getDistrict() != null) {
            Label districtField = new Label();
            districtField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISTRICT));
            districtField.setValue(newCase.getDistrict().toString());
            districtField.setWidthUndefined();
            caseInfoLayout.addComponent(districtField);
        }
        Label facilityField = new Label();
        facilityField.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY));
        facilityField.setValue(FacilityHelper.buildFacilityString(null, newCase.getHealthFacility() != null ? newCase.getHealthFacility().toString() : "", newCase.getHealthFacilityDetails()));
        facilityField.setWidthUndefined();
        caseInfoLayout.addComponent(facilityField);
        Label firstNameField = new Label();
        firstNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.FIRST_NAME));
        firstNameField.setValue(newPerson.getFirstName());
        firstNameField.setWidthUndefined();
        caseInfoLayout.addComponent(firstNameField);
        Label lastNameField = new Label();
        lastNameField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.LAST_NAME));
        lastNameField.setValue(newPerson.getLastName());
        lastNameField.setWidthUndefined();
        caseInfoLayout.addComponent(lastNameField);
        Label ageAndBirthDateField = new Label();
        ageAndBirthDateField.setCaption(I18nProperties.getCaption(Captions.personAgeAndBirthdate));
        ageAndBirthDateField.setValue(PersonHelper.getAgeAndBirthdateString(newPerson.getApproximateAge(), newPerson.getApproximateAgeType(), newPerson.getBirthdateDD(), newPerson.getBirthdateMM(), newPerson.getBirthdateYYYY()));
        ageAndBirthDateField.setWidthUndefined();
        caseInfoLayout.addComponent(ageAndBirthDateField);
        Label sexField = new Label();
        sexField.setCaption(I18nProperties.getPrefixCaption(PersonDto.I18N_PREFIX, PersonDto.SEX));
        sexField.setValue(newPerson.getSex() != null ? newPerson.getSex().toString() : "");
        sexField.setWidthUndefined();
        caseInfoLayout.addComponent(sexField);
    }
    caseInfoContainer.addComponent(caseInfoLayout);
    mainLayout.addComponent(caseInfoContainer);
}
Also used : Label(com.vaadin.v7.ui.Label) ThemeResource(com.vaadin.server.ThemeResource) VerticalLayout(com.vaadin.ui.VerticalLayout) Image(com.vaadin.ui.Image) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 90 with Label

use of com.vaadin.v7.ui.Label in project SORMAS-Project by hzi-braunschweig.

the class MaternalHistoryForm method addFields.

@Override
protected void addFields() {
    Label maternalHistoryHeadingLabel = new Label(I18nProperties.getString(Strings.headingMaternalHistory));
    maternalHistoryHeadingLabel.addStyleName(H3);
    getContent().addComponent(maternalHistoryHeadingLabel, MATERNAL_HISTORY_HEADING_LOC);
    TextField tfChildrenNumber = addField(MaternalHistoryDto.CHILDREN_NUMBER, TextField.class);
    tfChildrenNumber.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfChildrenNumber.getCaption()));
    TextField tfAgeAtBirth = addField(MaternalHistoryDto.AGE_AT_BIRTH, TextField.class);
    tfAgeAtBirth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfAgeAtBirth.getCaption()));
    TextField tfConjunctivitisMonth = addField(MaternalHistoryDto.CONJUNCTIVITIS_MONTH, TextField.class);
    tfConjunctivitisMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfConjunctivitisMonth.getCaption()));
    TextField tfMaculopapularRashMonth = addField(MaternalHistoryDto.MACULOPAPULAR_RASH_MONTH, TextField.class);
    tfMaculopapularRashMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfMaculopapularRashMonth.getCaption()));
    TextField tfSwollenLymphsMonth = addField(MaternalHistoryDto.SWOLLEN_LYMPHS_MONTH, TextField.class);
    tfSwollenLymphsMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfSwollenLymphsMonth.getCaption()));
    TextField tfArthralgiaArthritisMonth = addField(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_MONTH, TextField.class);
    tfArthralgiaArthritisMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, tfArthralgiaArthritisMonth.getCaption()));
    TextField otherComplicationsMonth = addField(MaternalHistoryDto.OTHER_COMPLICATIONS_MONTH, TextField.class);
    otherComplicationsMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, otherComplicationsMonth.getCaption()));
    TextField rashExposureMonth = addField(MaternalHistoryDto.RASH_EXPOSURE_MONTH, TextField.class);
    rashExposureMonth.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, rashExposureMonth.getCaption()));
    addFields(MaternalHistoryDto.CONJUNCTIVITIS_ONSET, MaternalHistoryDto.MACULOPAPULAR_RASH_ONSET, MaternalHistoryDto.SWOLLEN_LYMPHS_ONSET, MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_DETAILS, MaternalHistoryDto.RUBELLA_ONSET, MaternalHistoryDto.RASH_EXPOSURE_DATE);
    addField(MaternalHistoryDto.CONJUNCTIVITIS, NullableOptionGroup.class);
    addField(MaternalHistoryDto.MACULOPAPULAR_RASH, NullableOptionGroup.class);
    addField(MaternalHistoryDto.SWOLLEN_LYMPHS, NullableOptionGroup.class);
    addField(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS, NullableOptionGroup.class);
    addField(MaternalHistoryDto.OTHER_COMPLICATIONS, NullableOptionGroup.class);
    addField(MaternalHistoryDto.RUBELLA, NullableOptionGroup.class);
    addField(MaternalHistoryDto.RASH_EXPOSURE, NullableOptionGroup.class);
    ComboBox cbRashExposureRegion = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_REGION);
    ComboBox cbRashExposureDistrict = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_DISTRICT);
    ComboBox cbRashExposureCommunity = addInfrastructureField(MaternalHistoryDto.RASH_EXPOSURE_COMMUNITY);
    initializeAccessAndAllowedAccesses();
    cbRashExposureRegion.addValueChangeListener(e -> {
        RegionReferenceDto region = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(cbRashExposureDistrict, region != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()) : null);
    });
    cbRashExposureDistrict.addValueChangeListener(e -> {
        FieldHelper.removeItems(cbRashExposureCommunity);
        DistrictReferenceDto district = (DistrictReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(cbRashExposureCommunity, district != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()) : null);
    });
    cbRashExposureRegion.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.CONJUNCTIVITIS_ONSET, MaternalHistoryDto.CONJUNCTIVITIS_MONTH), MaternalHistoryDto.CONJUNCTIVITIS, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.MACULOPAPULAR_RASH_ONSET, MaternalHistoryDto.MACULOPAPULAR_RASH_MONTH), MaternalHistoryDto.MACULOPAPULAR_RASH, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.SWOLLEN_LYMPHS_ONSET, MaternalHistoryDto.SWOLLEN_LYMPHS_MONTH), MaternalHistoryDto.SWOLLEN_LYMPHS, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_ONSET, MaternalHistoryDto.ARTHRALGIA_ARTHRITIS_MONTH), MaternalHistoryDto.ARTHRALGIA_ARTHRITIS, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.OTHER_COMPLICATIONS_ONSET, MaternalHistoryDto.OTHER_COMPLICATIONS_MONTH, MaternalHistoryDto.OTHER_COMPLICATIONS_DETAILS), MaternalHistoryDto.OTHER_COMPLICATIONS, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.RUBELLA_ONSET), MaternalHistoryDto.RUBELLA, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(MaternalHistoryDto.RASH_EXPOSURE_DATE, MaternalHistoryDto.RASH_EXPOSURE_MONTH, MaternalHistoryDto.RASH_EXPOSURE_REGION, MaternalHistoryDto.RASH_EXPOSURE_DISTRICT, MaternalHistoryDto.RASH_EXPOSURE_COMMUNITY), MaternalHistoryDto.RASH_EXPOSURE, Arrays.asList(YesNoUnknown.YES), true);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) TextField(com.vaadin.v7.ui.TextField) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Aggregations

Label (com.codename1.ui.Label)129 Form (com.codename1.ui.Form)85 Label (com.vaadin.ui.Label)56 Container (com.codename1.ui.Container)45 Button (com.codename1.ui.Button)41 Label (com.vaadin.v7.ui.Label)40 TextField (com.vaadin.v7.ui.TextField)32 BorderLayout (com.codename1.ui.layouts.BorderLayout)31 Button (com.vaadin.ui.Button)31 ComboBox (com.vaadin.v7.ui.ComboBox)31 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)31 Captions (de.symeda.sormas.api.i18n.Captions)29 Strings (de.symeda.sormas.api.i18n.Strings)28 VerticalLayout (com.vaadin.ui.VerticalLayout)26 FacadeProvider (de.symeda.sormas.api.FacadeProvider)26 HorizontalLayout (com.vaadin.ui.HorizontalLayout)24 Window (com.vaadin.ui.Window)24 CssStyles (de.symeda.sormas.ui.utils.CssStyles)24 ValoTheme (com.vaadin.ui.themes.ValoTheme)21 List (java.util.List)21