Search in sources :

Example 21 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.

the class EventDataForm method addFields.

@Override
protected void addFields() {
    if (isCreateForm == null) {
        return;
    }
    Label eventDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingEventData));
    eventDataHeadingLabel.addStyleName(H3);
    getContent().addComponent(eventDataHeadingLabel, EVENT_DATA_HEADING_LOC);
    Label informationSourceHeadingLabel = new Label(I18nProperties.getString(Strings.headingInformationSource));
    informationSourceHeadingLabel.addStyleName(H3);
    getContent().addComponent(informationSourceHeadingLabel, INFORMATION_SOURCE_HEADING_LOC);
    Label locationHeadingLabel = new Label(I18nProperties.getString(Strings.headingLocation));
    locationHeadingLabel.addStyleName(H3);
    getContent().addComponent(locationHeadingLabel, LOCATION_HEADING_LOC);
    addField(EventDto.UUID, TextField.class);
    ComboBox diseaseField = addDiseaseField(EventDto.DISEASE, false, isCreateForm);
    addField(EventDto.DISEASE_DETAILS, TextField.class);
    ComboBox diseaseVariantField = addField(EventDto.DISEASE_VARIANT, ComboBox.class);
    diseaseVariantField.setNullSelectionAllowed(true);
    addFields(EventDto.EXTERNAL_ID);
    TextField diseaseVariantDetailsField = addField(EventDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    TextField externalTokenField = addField(EventDto.EXTERNAL_TOKEN);
    Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageEventExternalTokenWarning));
    externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
    getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
    addField(EventDto.INTERNAL_TOKEN);
    DateTimeField startDate = addField(EventDto.START_DATE, DateTimeField.class);
    CheckBox multiDayCheckbox = addField(EventDto.MULTI_DAY_EVENT, CheckBox.class);
    DateTimeField endDate = addField(EventDto.END_DATE, DateTimeField.class);
    initEventDateValidation(startDate, endDate, multiDayCheckbox);
    addField(EventDto.EVENT_STATUS, NullableOptionGroup.class);
    addField(EventDto.RISK_LEVEL);
    ComboBox specificRiskField = addField(EventDto.SPECIFIC_RISK, ComboBox.class);
    specificRiskField.setNullSelectionAllowed(true);
    addField(EventDto.EVENT_MANAGEMENT_STATUS, NullableOptionGroup.class);
    addField(EventDto.EVENT_IDENTIFICATION_SOURCE, NullableOptionGroup.class);
    addField(EventDto.EVENT_INVESTIGATION_STATUS, NullableOptionGroup.class);
    addField(EventDto.EVENT_INVESTIGATION_START_DATE, DateField.class);
    addField(EventDto.EVENT_INVESTIGATION_END_DATE, DateField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.EVENT_INVESTIGATION_START_DATE, EventDto.EVENT_INVESTIGATION_END_DATE), EventDto.EVENT_INVESTIGATION_STATUS, Arrays.asList(EventInvestigationStatus.ONGOING, EventInvestigationStatus.DONE, EventInvestigationStatus.DISCARDED), true);
    TextField title = addField(EventDto.EVENT_TITLE, TextField.class);
    title.addStyleName(CssStyles.SOFT_REQUIRED);
    TextArea descriptionField = addField(EventDto.EVENT_DESC, TextArea.class, new ResizableTextAreaWrapper<>());
    descriptionField.setRows(2);
    descriptionField.setDescription(I18nProperties.getPrefixDescription(EventDto.I18N_PREFIX, EventDto.EVENT_DESC, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    addField(EventDto.DISEASE_TRANSMISSION_MODE, ComboBox.class);
    addField(EventDto.NOSOCOMIAL, NullableOptionGroup.class);
    addFields(EventDto.HUMAN_TRANSMISSION_MODE, EventDto.INFECTION_PATH_CERTAINTY);
    addFields(EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE);
    final NullableOptionGroup epidemiologicalEvidence = addField(EventDto.EPIDEMIOLOGICAL_EVIDENCE, NullableOptionGroup.class);
    final NullableOptionGroup laboratoryDiagnosticEvidence = addField(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, NullableOptionGroup.class);
    epidemiologicalEvidenceCheckBoxTree = new EpidemiologicalEvidenceCheckBoxTree(Arrays.stream(EpidemiologicalEvidenceDetail.values()).map(epidemiologicalEvidenceDetail -> epidemiologicalEvidenceDetailToCheckBoxElement(epidemiologicalEvidenceDetail)).collect(Collectors.toList()));
    getContent().addComponent(epidemiologicalEvidenceCheckBoxTree, EventDto.EPIDEMIOLOGICAL_EVIDENCE_DETAILS);
    epidemiologicalEvidenceCheckBoxTree.setVisible(false);
    laboratoryDiagnosticEvidenceCheckBoxTree = new LaboratoryDiagnosticEvidenceCheckBoxTree(Arrays.stream(LaboratoryDiagnosticEvidenceDetail.values()).map(laboratoryDiagnosticEvidenceDetail -> laboratoryDiagnosticEvidenceDetailToCheckBoxElement(laboratoryDiagnosticEvidenceDetail)).collect(Collectors.toList()));
    getContent().addComponent(laboratoryDiagnosticEvidenceCheckBoxTree, EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE_DETAILS);
    laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
    DateField evolutionDateField = addField(EventDto.EVOLUTION_DATE, DateField.class);
    TextField evolutionCommentField = addField(EventDto.EVOLUTION_COMMENT, TextField.class);
    Field<?> statusField = getField(EventDto.EVENT_STATUS);
    statusField.addValueChangeListener(e -> {
        if (statusField.getValue() == null) {
            return;
        }
        EventStatus eventStatus = (EventStatus) statusField.getValue();
        // The status will be used to modify the caption of the field
        // However we don't want to have somthing like "Dropped evolution date"
        // So let's ignore the DROPPED status and use the Event entity caption instead
        String statusCaption;
        if (eventStatus == EventStatus.DROPPED) {
            statusCaption = I18nProperties.getCaption(EVENT_ENTITY);
        } else {
            statusCaption = I18nProperties.getEnumCaption(eventStatus);
        }
        evolutionDateField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_DATE_WITH_STATUS), statusCaption));
        evolutionCommentField.setCaption(String.format(I18nProperties.getCaption(EVOLUTION_COMMENT_WITH_STATUS), statusCaption));
    });
    FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Collections.singletonList(EventDto.EVOLUTION_COMMENT), EventDto.EVOLUTION_DATE, true);
    ComboBox typeOfPlace = addField(EventDto.TYPE_OF_PLACE, ComboBox.class);
    typeOfPlace.setNullSelectionAllowed(true);
    addField(EventDto.TYPE_OF_PLACE_TEXT, TextField.class);
    addField(EventDto.WORK_ENVIRONMENT);
    ComboBox meansOfTransport = addField(EventDto.MEANS_OF_TRANSPORT);
    TextField connectionNumber = addField(EventDto.CONNECTION_NUMBER);
    DateField travelDate = addField(EventDto.TRAVEL_DATE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
    TextField meansOfTransportDetails = addField(EventDto.MEANS_OF_TRANSPORT_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.MEANS_OF_TRANSPORT_DETAILS), EventDto.MEANS_OF_TRANSPORT, Collections.singletonList(MeansOfTransport.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.CONNECTION_NUMBER, EventDto.TRAVEL_DATE), EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.MEANS_OF_TRANSPORT), true);
    getField(EventDto.MEANS_OF_TRANSPORT).addValueChangeListener(e -> {
        if (e.getProperty().getValue() == MeansOfTransport.PLANE) {
            getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getCaption(Captions.exposureFlightNumber));
        } else {
            getField(EventDto.CONNECTION_NUMBER).setCaption(I18nProperties.getPrefixCaption(EventDto.I18N_PREFIX, EventDto.CONNECTION_NUMBER));
        }
    });
    DateField reportDate = addField(EventDto.REPORT_DATE_TIME, DateField.class);
    addField(EventDto.REPORTING_USER, ComboBox.class);
    addField(EventDto.TRANSREGIONAL_OUTBREAK, NullableOptionGroup.class);
    ComboBox srcType = addField(EventDto.SRC_TYPE);
    TextField srcFirstName = addField(EventDto.SRC_FIRST_NAME, TextField.class);
    TextField srcLastName = addField(EventDto.SRC_LAST_NAME, TextField.class);
    TextField srcTelNo = addField(EventDto.SRC_TEL_NO, TextField.class);
    addField(EventDto.SRC_EMAIL, TextField.class);
    TextField srcMediaWebsite = addField(EventDto.SRC_MEDIA_WEBSITE, TextField.class);
    TextField srcMediaName = addField(EventDto.SRC_MEDIA_NAME, TextField.class);
    TextArea srcMediaDetails = addField(EventDto.SRC_MEDIA_DETAILS, TextArea.class);
    srcMediaDetails.setRows(4);
    ComboBox srcInstitutionalPartnerType = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.INSTITUTIONAL_PARTNER), true);
    TextField srcInstitutionalPartnerTypeDetails = addField(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE_DETAILS), EventDto.SRC_INSTITUTIONAL_PARTNER_TYPE, Collections.singletonList(InstitutionalPartnerType.OTHER), true);
    addField(EventDto.EVENT_LOCATION, new LocationEditForm(fieldVisibilityCheckers, createFieldAccessCheckers(isPseudonymized, false))).setCaption(null);
    locationForm = (LocationEditForm) getFieldGroup().getField(EventDto.EVENT_LOCATION);
    locationForm.setDistrictRequiredOnDefaultCountry(true);
    ComboBox regionField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.REGION);
    ComboBox districtField = (ComboBox) locationForm.getFieldGroup().getField(LocationDto.DISTRICT);
    ComboBox responsibleUserField = addField(EventDto.RESPONSIBLE_USER, ComboBox.class);
    responsibleUserField.setNullSelectionAllowed(true);
    addField(EventDto.DELETION_REASON);
    addField(EventDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, EventDto.DELETION_REASON, EventDto.OTHER_DELETION_REASON);
    if (isCreateForm) {
        locationForm.hideValidationUntilNextCommit();
    }
    setReadOnly(true, EventDto.UUID, EventDto.REPORTING_USER);
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.WORK_ENVIRONMENT, locationForm.getFacilityTypeGroup(), Collections.singletonList(FacilityTypeGroup.WORKING_PLACE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(EventDto.DISEASE_DETAILS), EventDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), EventDto.DISEASE, Collections.singletonList(EventDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
    // Customizable enum fields visibilities
    diseaseVariantField.setVisible(false);
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        diseaseVariantField.setVisible(disease != null && CollectionUtils.isNotEmpty(diseaseVariants));
        List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, disease);
        FieldHelper.updateItems(specificRiskField, specificRiskValues);
        specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    setRequired(true, EventDto.EVENT_STATUS, EventDto.UUID, EventDto.EVENT_TITLE, EventDto.REPORT_DATE_TIME, EventDto.REPORTING_USER);
    reportDate.addValidator(new DateComparisonValidator(reportDate, startDate, false, false, I18nProperties.getValidationError(Validations.afterDate, reportDate.getCaption(), startDate.getCaption())));
    startDate.addValidator(new DateComparisonValidator(startDate, reportDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), reportDate.getCaption())));
    reportDate.addValueChangeListener(e -> startDate.setValidationVisible(!startDate.isValid()));
    startDate.addValueChangeListener(e -> reportDate.setValidationVisible(!reportDate.isValid()));
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.END_DATE, EventDto.MULTI_DAY_EVENT, Collections.singletonList(true), true);
    FieldHelper.setCaptionWhen(multiDayCheckbox, startDate, false, I18nProperties.getCaption(Captions.singleDayEventDate), I18nProperties.getCaption(Captions.Event_startDate));
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.NOSOCOMIAL, EventDto.TRANSREGIONAL_OUTBREAK, EventDto.DISEASE_TRANSMISSION_MODE), EventDto.EVENT_STATUS, Collections.singletonList(EventStatus.CLUSTER), true);
    if (isVisibleAllowed(EventDto.INFECTION_PATH_CERTAINTY)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.INFECTION_PATH_CERTAINTY, EventDto.NOSOCOMIAL, Collections.singletonList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(EventDto.HUMAN_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.HUMAN_TRANSMISSION_MODE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
    }
    if (isVisibleAllowed(EventDto.PARENTERAL_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.PARENTERAL_TRANSMISSION_MODE, EventDto.HUMAN_TRANSMISSION_MODE, Collections.singletonList(HumanTransmissionMode.PARENTERAL), true);
    }
    if (isVisibleAllowed(EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.MEDICALLY_ASSOCIATED_TRANSMISSION_MODE, EventDto.PARENTERAL_TRANSMISSION_MODE, Collections.singletonList(ParenteralTransmissionMode.MEDICALLY_ASSOCIATED), true);
    }
    if (isVisibleAllowed(EventDto.EPIDEMIOLOGICAL_EVIDENCE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.EPIDEMIOLOGICAL_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
        epidemiologicalEvidence.addValueChangeListener(valueChangeEvent -> {
            if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
                epidemiologicalEvidenceCheckBoxTree.setVisible(true);
            } else {
                epidemiologicalEvidenceCheckBoxTree.clearCheckBoxTree();
                epidemiologicalEvidenceCheckBoxTree.setVisible(false);
            }
        });
    }
    if (isVisibleAllowed(EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.LABORATORY_DIAGNOSTIC_EVIDENCE, EventDto.DISEASE_TRANSMISSION_MODE, Collections.singletonList(DiseaseTransmissionMode.HUMAN_TO_HUMAN), true);
        laboratoryDiagnosticEvidence.addValueChangeListener(valueChangeEvent -> {
            if (((NullableOptionGroup) valueChangeEvent.getProperty()).getNullableValue() == YesNoUnknown.YES) {
                laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(true);
            } else {
                laboratoryDiagnosticEvidenceCheckBoxTree.clearCheckBoxTree();
                laboratoryDiagnosticEvidenceCheckBoxTree.setVisible(false);
            }
        });
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_FIRST_NAME, EventDto.SRC_LAST_NAME, EventDto.SRC_TEL_NO, EventDto.SRC_EMAIL), EventDto.SRC_TYPE, Arrays.asList(EventSourceType.HOTLINE_PERSON, EventSourceType.INSTITUTIONAL_PARTNER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(EventDto.SRC_MEDIA_WEBSITE, EventDto.SRC_MEDIA_NAME, EventDto.SRC_MEDIA_DETAILS), EventDto.SRC_TYPE, Collections.singletonList(EventSourceType.MEDIA_NEWS), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), EventDto.TYPE_OF_PLACE_TEXT, EventDto.TYPE_OF_PLACE, Collections.singletonList(TypeOfPlace.OTHER), true);
    setTypeOfPlaceTextRequirement();
    locationForm.setFacilityFieldsVisible(getField(EventDto.TYPE_OF_PLACE).getValue() == TypeOfPlace.FACILITY, true);
    typeOfPlace.addValueChangeListener(e -> locationForm.setFacilityFieldsVisible(e.getProperty().getValue() == TypeOfPlace.FACILITY, true));
    regionField.addValueChangeListener(e -> {
        RegionReferenceDto region = (RegionReferenceDto) regionField.getValue();
        if (region != null) {
            regionEventResponsibles = FacadeProvider.getUserFacade().getUsersByRegionAndRights(region, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
        } else {
            regionEventResponsibles.clear();
        }
    });
    districtField.addValueChangeListener(e -> {
        DistrictReferenceDto district = (DistrictReferenceDto) districtField.getValue();
        if (district != null) {
            List<UserReferenceDto> districtEventResponsibles = FacadeProvider.getUserFacade().getUserRefsByDistrict(district, getValue().getDisease(), UserRight.EVENT_RESPONSIBLE);
            List<UserReferenceDto> responsibleUsers = new ArrayList<>();
            responsibleUsers.addAll(districtEventResponsibles);
            responsibleUsers.addAll(regionEventResponsibles);
            FieldHelper.updateItems(responsibleUserField, responsibleUsers);
        } else {
            responsibleUserField.removeAllItems();
        }
    });
    FieldHelper.addSoftRequiredStyle(startDate, endDate, typeOfPlace, meansOfTransport, meansOfTransportDetails, connectionNumber, travelDate, responsibleUserField, srcType, srcInstitutionalPartnerType, srcInstitutionalPartnerTypeDetails, srcFirstName, srcLastName, srcTelNo, srcMediaWebsite, srcMediaName);
    // Make external ID field read-only when SORMAS is connected to a SurvNet instance
    if (StringUtils.isNotEmpty(FacadeProvider.getConfigFacade().getExternalSurveillanceToolGatewayUrl())) {
        setEnabled(false, EventDto.EXTERNAL_ID);
        ((TextField) getField(EventDto.EXTERNAL_ID)).setInputPrompt(I18nProperties.getString(Strings.promptExternalIdExternalSurveillanceTool));
    }
    addValueChangeListener((e) -> {
        ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getEventFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
        epidemiologicalEvidenceCheckBoxTree.initCheckboxes();
        laboratoryDiagnosticEvidenceCheckBoxTree.initCheckboxes();
        // Initialize specific risk field if disease is null
        if (getValue().getDisease() == null) {
            List<SpecificRisk> specificRiskValues = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, null);
            FieldHelper.updateItems(specificRiskField, specificRiskValues);
            specificRiskField.setVisible(isVisibleAllowed(EventDto.SPECIFIC_RISK) && CollectionUtils.isNotEmpty(specificRiskValues));
        }
    });
}
Also used : AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) CheckBoxTree(de.symeda.sormas.ui.utils.CheckBoxTree) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) DiseaseTransmissionMode(de.symeda.sormas.api.event.DiseaseTransmissionMode) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) LayoutUtil.locs(de.symeda.sormas.ui.utils.LayoutUtil.locs) StringUtils(org.apache.commons.lang3.StringUtils) SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) EpidemiologicalEvidenceDetail(de.symeda.sormas.api.event.EpidemiologicalEvidenceDetail) HumanTransmissionMode(de.symeda.sormas.api.event.HumanTransmissionMode) CssStyles(de.symeda.sormas.ui.utils.CssStyles) EventInvestigationStatus(de.symeda.sormas.api.event.EventInvestigationStatus) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ComboBox(com.vaadin.v7.ui.ComboBox) LaboratoryDiagnosticEvidenceDetail(de.symeda.sormas.api.event.LaboratoryDiagnosticEvidenceDetail) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Field(com.vaadin.v7.ui.Field) EventDto(de.symeda.sormas.api.event.EventDto) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Collectors(java.util.stream.Collectors) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) List(java.util.List) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) InstitutionalPartnerType(de.symeda.sormas.api.event.InstitutionalPartnerType) TextField(com.vaadin.v7.ui.TextField) MeansOfTransport(de.symeda.sormas.api.event.MeansOfTransport) Descriptions(de.symeda.sormas.api.i18n.Descriptions) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) Converter(com.vaadin.v7.data.util.converter.Converter) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) CollectionUtils(org.apache.commons.collections.CollectionUtils) Label(com.vaadin.ui.Label) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) LocationDto(de.symeda.sormas.api.location.LocationDto) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ResizableTextAreaWrapper(de.symeda.sormas.ui.utils.ResizableTextAreaWrapper) Captions(de.symeda.sormas.api.i18n.Captions) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ParenteralTransmissionMode(de.symeda.sormas.api.event.ParenteralTransmissionMode) FieldGroup(com.vaadin.v7.data.fieldgroup.FieldGroup) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) Disease(de.symeda.sormas.api.Disease) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) TextArea(com.vaadin.v7.ui.TextArea) EventSourceType(de.symeda.sormas.api.event.EventSourceType) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) LayoutUtil.fluidColumn(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumn) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) 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) TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) TextField(com.vaadin.v7.ui.TextField) List(java.util.List) ArrayList(java.util.ArrayList) LocationEditForm(de.symeda.sormas.ui.location.LocationEditForm) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) CheckBox(com.vaadin.v7.ui.CheckBox) DateField(com.vaadin.v7.ui.DateField)

Example 22 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationCreationForm method addFields.

@SuppressWarnings("deprecation")
@Override
protected void addFields() {
    addField(ImmunizationDto.REPORT_DATE, DateField.class);
    TextField externalIdField = addField(ImmunizationDto.EXTERNAL_ID, TextField.class);
    style(externalIdField, ERROR_COLOR_PRIMARY);
    ComboBox diseaseField = addDiseaseField(ImmunizationDto.DISEASE, false, true);
    addField(ImmunizationDto.DISEASE_DETAILS, TextField.class);
    ComboBox meansOfImmunizationField = addField(ImmunizationDto.MEANS_OF_IMMUNIZATION, ComboBox.class);
    addField(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS, TextField.class);
    CheckBox overwriteImmunizationManagementStatus = addCustomField(OVERWRITE_IMMUNIZATION_MANAGEMENT_STATUS, Boolean.class, CheckBox.class);
    overwriteImmunizationManagementStatus.addStyleName(VSPACE_3);
    ComboBox managementStatusField = addCustomField(ImmunizationDto.IMMUNIZATION_MANAGEMENT_STATUS, ImmunizationManagementStatus.class, ComboBox.class);
    managementStatusField.setValue(ImmunizationManagementStatus.SCHEDULED);
    managementStatusField.setEnabled(false);
    managementStatusField.setNullSelectionAllowed(false);
    ComboBox immunizationStatusField = addCustomField(ImmunizationDto.IMMUNIZATION_STATUS, ImmunizationStatus.class, ComboBox.class);
    immunizationStatusField.setValue(ImmunizationStatus.PENDING);
    immunizationStatusField.setEnabled(false);
    Label jurisdictionHeadingLabel = new Label(I18nProperties.getString(Strings.headingResponsibleJurisdiction));
    jurisdictionHeadingLabel.addStyleName(H3);
    getContent().addComponent(jurisdictionHeadingLabel, RESPONSIBLE_JURISDICTION_HEADING_LOC);
    ComboBox responsibleRegion = addInfrastructureField(ImmunizationDto.RESPONSIBLE_REGION);
    responsibleRegion.setRequired(true);
    ComboBox responsibleDistrictCombo = addInfrastructureField(ImmunizationDto.RESPONSIBLE_DISTRICT);
    responsibleDistrictCombo.setRequired(true);
    ComboBox responsibleCommunityCombo = addInfrastructureField(ImmunizationDto.RESPONSIBLE_COMMUNITY);
    responsibleCommunityCombo.setNullSelectionAllowed(true);
    responsibleCommunityCombo.addStyleName(SOFT_REQUIRED);
    InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrictCombo, responsibleCommunityCombo);
    ComboBox 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);
    ComboBox facilityType = ComboBoxHelper.createComboBoxV7();
    facilityType.setId("type");
    facilityType.setCaption(I18nProperties.getCaption(Captions.facilityType));
    facilityType.setWidth(100, Unit.PERCENTAGE);
    getContent().addComponent(facilityType, ImmunizationDto.FACILITY_TYPE);
    ComboBox facilityCombo = addInfrastructureField(ImmunizationDto.HEALTH_FACILITY);
    facilityCombo.setImmediate(true);
    TextField facilityDetails = addField(ImmunizationDto.HEALTH_FACILITY_DETAILS, TextField.class);
    facilityDetails.setVisible(false);
    DateField startDate = addField(ImmunizationDto.START_DATE, DateField.class);
    DateField endDate = addDateField(ImmunizationDto.END_DATE, DateField.class, -1);
    DateComparisonValidator.addStartEndValidators(startDate, endDate);
    DateField validFrom = addDateField(ImmunizationDto.VALID_FROM, DateField.class, -1);
    DateField validUntil = addDateField(ImmunizationDto.VALID_UNTIL, DateField.class, -1);
    DateComparisonValidator.addStartEndValidators(validFrom, validUntil);
    Field numberOfDosesField = addField(ImmunizationDto.NUMBER_OF_DOSES);
    numberOfDosesField.addValidator(new NumberValidator(I18nProperties.getValidationError(Validations.vaccineDosesFormat), 1, 10, false));
    numberOfDosesField.setVisible(false);
    personCreateForm = new PersonCreateForm(false, true, false);
    personCreateForm.setWidth(100, Unit.PERCENTAGE);
    personCreateForm.setValue(new PersonDto());
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> personCreateForm.updatePresentConditionEnum((Disease) valueChangeEvent.getProperty().getValue()));
    getContent().addComponent(personCreateForm, TravelEntryDto.PERSON);
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    setRequired(true, ImmunizationDto.REPORT_DATE, ImmunizationDto.MEANS_OF_IMMUNIZATION);
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(ImmunizationDto.DISEASE_DETAILS), ImmunizationDto.DISEASE, Collections.singletonList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), ImmunizationDto.DISEASE, Collections.singletonList(ImmunizationDto.DISEASE_DETAILS), Collections.singletonList(Disease.OTHER));
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS), ImmunizationDto.MEANS_OF_IMMUNIZATION, Collections.singletonList(MeansOfImmunization.OTHER), true);
    overwriteImmunizationManagementStatus.addValueChangeListener(e -> {
        boolean selectedValue = (boolean) e.getProperty().getValue();
        if (!selectedValue) {
            managementStatusField.setValue(ImmunizationManagementStatus.SCHEDULED);
        }
        managementStatusField.setEnabled(selectedValue);
    });
    meansOfImmunizationField.addValueChangeListener(e -> {
        MeansOfImmunization meansOfImmunization = (MeansOfImmunization) e.getProperty().getValue();
        if (MeansOfImmunization.RECOVERY.equals(meansOfImmunization) || MeansOfImmunization.OTHER.equals(meansOfImmunization)) {
            managementStatusField.setValue(ImmunizationManagementStatus.COMPLETED);
        } else {
            managementStatusField.setValue(ImmunizationManagementStatus.SCHEDULED);
        }
        boolean isVaccinationVisible = MeansOfImmunization.VACCINATION.equals(meansOfImmunization) || MeansOfImmunization.VACCINATION_RECOVERY.equals(meansOfImmunization);
        numberOfDosesField.setVisible(isVaccinationVisible);
        if (!isVaccinationVisible) {
            numberOfDosesField.setValue(null);
        }
    });
    managementStatusField.addValueChangeListener(e -> {
        ImmunizationManagementStatus managementStatusValue = (ImmunizationManagementStatus) e.getProperty().getValue();
        switch(managementStatusValue) {
            case SCHEDULED:
            case ONGOING:
                immunizationStatusField.setValue(ImmunizationStatus.PENDING);
                break;
            case COMPLETED:
                immunizationStatusField.setValue(ImmunizationStatus.ACQUIRED);
                break;
            case CANCELED:
                immunizationStatusField.setValue(ImmunizationStatus.NOT_ACQUIRED);
                break;
            default:
                break;
        }
    });
    responsibleDistrictCombo.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        if (districtDto != null && facilityType.getValue() != null) {
            FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(districtDto, (FacilityType) facilityType.getValue(), true, false));
        }
    });
    responsibleCommunityCombo.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        CommunityReferenceDto communityDto = (CommunityReferenceDto) e.getProperty().getValue();
        if (facilityType.getValue() != null) {
            FieldHelper.updateItems(facilityCombo, communityDto != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(communityDto, (FacilityType) facilityType.getValue(), true, false) : responsibleDistrictCombo.getValue() != null ? FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) responsibleDistrictCombo.getValue(), (FacilityType) facilityType.getValue(), true, false) : null);
        }
    });
    facilityTypeGroup.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        FieldHelper.updateEnumData(facilityType, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue()));
    });
    facilityType.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        if (facilityType.getValue() != null && responsibleDistrictCombo.getValue() != null) {
            if (responsibleCommunityCombo.getValue() != null) {
                FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType((CommunityReferenceDto) responsibleCommunityCombo.getValue(), (FacilityType) facilityType.getValue(), true, false));
            } else {
                FieldHelper.updateItems(facilityCombo, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType((DistrictReferenceDto) responsibleDistrictCombo.getValue(), (FacilityType) facilityType.getValue(), true, false));
            }
        }
    });
    facilityCombo.addValueChangeListener(e -> {
        updateFacilityFields(facilityCombo, facilityDetails);
        this.getValue().setFacilityType((FacilityType) facilityType.getValue());
    });
    addValueChangeListener(e -> {
        if (disease != null) {
            setVisible(false, ImmunizationDto.DISEASE, ImmunizationDto.DISEASE_DETAILS);
            setReadOnly(false, ImmunizationDto.DISEASE, ImmunizationDto.DISEASE_DETAILS);
        } else {
            setRequired(true, ImmunizationDto.DISEASE);
        }
        if (personDto != null) {
            personCreateForm.setVisible(false);
            personCreateForm.setReadOnly(false);
        } else {
            personCreateForm.enablePersonFields(true);
        }
    });
}
Also used : AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) H3(de.symeda.sormas.ui.utils.CssStyles.H3) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) CheckBox(com.vaadin.v7.ui.CheckBox) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) PersonDto(de.symeda.sormas.api.person.PersonDto) Label(com.vaadin.ui.Label) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) Validations(de.symeda.sormas.api.i18n.Validations) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) 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) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) Disease(de.symeda.sormas.api.Disease) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) TextField(com.vaadin.v7.ui.TextField) ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) NumberValidator(de.symeda.sormas.ui.utils.NumberValidator) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) ComboBox(com.vaadin.v7.ui.ComboBox) PersonDto(de.symeda.sormas.api.person.PersonDto) Label(com.vaadin.ui.Label) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) PersonCreateForm(de.symeda.sormas.ui.person.PersonCreateForm) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) DateField(com.vaadin.v7.ui.DateField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) NumberValidator(de.symeda.sormas.ui.utils.NumberValidator) CheckBox(com.vaadin.v7.ui.CheckBox) TextField(com.vaadin.v7.ui.TextField) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) DateField(com.vaadin.v7.ui.DateField) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 23 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsFileExplorer method createSiteSelect.

/**
 * Creates the site selector combo box.<p>
 *
 * @param cms the current cms context
 *
 * @return the combo box
 */
private ComboBox createSiteSelect(CmsObject cms) {
    final List<CmsExtendedSiteSelector.SiteSelectorOption> sites = CmsExtendedSiteSelector.getExplorerSiteSelectorOptions(cms, true);
    final BeanItemContainer<CmsExtendedSiteSelector.SiteSelectorOption> container = new BeanItemContainer<>(CmsExtendedSiteSelector.SiteSelectorOption.class);
    for (CmsExtendedSiteSelector.SiteSelectorOption option : sites) {
        container.addItem(option);
    }
    ComboBox combo = new ComboBox(null, container);
    combo.setTextInputAllowed(true);
    combo.setNullSelectionAllowed(false);
    combo.setWidth("200px");
    combo.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
    combo.setItemCaptionPropertyId("label");
    combo.select(new CmsExtendedSiteSelector.SiteSelectorOption(cms.getRequestContext().getSiteRoot(), null, null));
    combo.setFilteringMode(FilteringMode.CONTAINS);
    combo.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        /**
         * Flag used to temporarily disable the standard listener behavior, used when we change the combo box's value programatically.
         */
        private boolean m_disabled;

        public void valueChange(ValueChangeEvent event) {
            if (m_disabled) {
                return;
            }
            CmsExtendedSiteSelector.SiteSelectorOption option = (CmsExtendedSiteSelector.SiteSelectorOption) (event.getProperty().getValue());
            if (container.containsId(option)) {
                changeSite(option.getSite(), option.getPath());
                m_appContext.updateOnChange();
                container.removeAllContainerFilters();
                if (option.getPath() != null) {
                    try {
                        m_disabled = true;
                        combo.select(new CmsExtendedSiteSelector.SiteSelectorOption(option.getSite(), null, null));
                    } finally {
                        m_disabled = false;
                    }
                }
            }
        }
    });
    if (Page.getCurrent().getBrowserWindowHeight() > 650) {
        combo.setPageLength(20);
    }
    return combo;
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) CmsExtendedSiteSelector(org.opencms.ui.components.CmsExtendedSiteSelector) ComboBox(com.vaadin.v7.ui.ComboBox) BeanItemContainer(com.vaadin.v7.data.util.BeanItemContainer)

Example 24 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsGitToolOptionsPanel method configureConfigurationSelector.

/**
 * Configures the configuration selector.
 */
private void configureConfigurationSelector() {
    if (m_checkinBean.getConfigurations().size() < 2) {
        // Do not show the configuration selection at all.
        removeComponent(m_configurationSelectionPanel);
    } else {
        for (CmsGitConfiguration configuration : m_checkinBean.getConfigurations()) {
            m_configurationSelector.addItem(configuration);
            m_configurationSelector.setItemCaption(configuration, configuration.getName());
        }
        m_configurationSelector.setNullSelectionAllowed(false);
        m_configurationSelector.setNewItemsAllowed(false);
        m_configurationSelector.setWidth("350px");
        m_configurationSelector.select(m_checkinBean.getCurrentConfiguration());
        // There is really a choice between configurations
        m_configurationSelector.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void valueChange(ValueChangeEvent event) {
                updateForNewConfiguration((CmsGitConfiguration) event.getProperty().getValue());
                restoreFieldsFromUserInfo();
            }
        });
    }
}
Also used : ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener)

Example 25 with ValueChangeListener

use of com.vaadin.v7.data.Property.ValueChangeListener in project opencms-core by alkacon.

the class CmsMessageBundleEditorOptions method initModeSwitch.

/**
 * Initializes the mode switcher.
 * @param current the current edit mode
 */
private void initModeSwitch(final EditMode current) {
    FormLayout modes = new FormLayout();
    modes.setHeight("100%");
    modes.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    m_modeSelect = new ComboBox();
    m_modeSelect.setCaption(m_messages.key(Messages.GUI_VIEW_SWITCHER_LABEL_0));
    // add Modes
    m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.DEFAULT);
    m_modeSelect.setItemCaption(CmsMessageBundleEditorTypes.EditMode.DEFAULT, m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_DEFAULT_0));
    m_modeSelect.addItem(CmsMessageBundleEditorTypes.EditMode.MASTER);
    m_modeSelect.setItemCaption(CmsMessageBundleEditorTypes.EditMode.MASTER, m_messages.key(Messages.GUI_VIEW_SWITCHER_EDITMODE_MASTER_0));
    // set current mode as selected
    m_modeSelect.setValue(current);
    m_modeSelect.setNewItemsAllowed(false);
    m_modeSelect.setTextInputAllowed(false);
    m_modeSelect.setNullSelectionAllowed(false);
    m_modeSelect.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            m_listener.handleModeChange((EditMode) event.getProperty().getValue());
        }
    });
    modes.addComponent(m_modeSelect);
    m_modeSwitch = modes;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) ComboBox(com.vaadin.v7.ui.ComboBox) EditMode(org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorTypes.EditMode)

Aggregations

ValueChangeListener (com.vaadin.v7.data.Property.ValueChangeListener)21 ValueChangeEvent (com.vaadin.v7.data.Property.ValueChangeEvent)20 ComboBox (com.vaadin.v7.ui.ComboBox)17 TextField (com.vaadin.v7.ui.TextField)11 Label (com.vaadin.ui.Label)10 DateField (com.vaadin.v7.ui.DateField)8 FacadeProvider (de.symeda.sormas.api.FacadeProvider)8 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)8 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)8 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)8 FieldHelper (de.symeda.sormas.ui.utils.FieldHelper)8 List (java.util.List)8 Converter (com.vaadin.v7.data.util.converter.Converter)7 Captions (de.symeda.sormas.api.i18n.Captions)7 Strings (de.symeda.sormas.api.i18n.Strings)7 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)7 CheckBox (com.vaadin.v7.ui.CheckBox)6 Field (com.vaadin.v7.ui.Field)6 Disease (de.symeda.sormas.api.Disease)6 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)6