Search in sources :

Example 1 with ComboBox

use of com.vaadin.v7.ui.ComboBox in project CodenameOne by codenameone.

the class HTMLForm method submit.

/**
 * Called when the a form submit is needed.
 * This querys all form fields, creates a URL accordingly and sets it to the HTMLComponent
 */
void submit(String submitKey, String submitVal) {
    if (action == null) {
        return;
    }
    // If this is turned to true anywhere, the form will not be submitted
    boolean error = false;
    String url = action;
    String params = null;
    if (comps.size() > 0) {
        params = "";
        for (Enumeration e = comps.keys(); e.hasMoreElements(); ) {
            String key = (String) e.nextElement();
            Object input = comps.get(key);
            key = HTMLUtils.encodeString(key);
            String value = "";
            if (input instanceof String) {
                // hidden
                value = HTMLUtils.encodeString((String) input);
                params += key + "=" + value + "&";
            } else if (input instanceof Hashtable) {
                // checkbox / radiobutton
                Hashtable options = (Hashtable) input;
                for (Enumeration e2 = options.keys(); e2.hasMoreElements(); ) {
                    Button b = (Button) e2.nextElement();
                    if (b.isSelected()) {
                        params += key + "=" + HTMLUtils.encodeString((String) options.get(b)) + "&";
                    }
                }
            } else if (input instanceof TextArea) {
                // catches both textareas and text input fields
                TextArea tf = ((TextArea) input);
                String text = tf.getText();
                String errorMsg = null;
                if (HTMLComponent.SUPPORT_INPUT_FORMAT) {
                    boolean ok = false;
                    if (text.equals("")) {
                        // check empty - Note that emptyok/-wap-input-required overrides input format
                        if (emptyNotOk.contains(tf)) {
                            errorMsg = htmlC.getUIManager().localize("html.format.emptynotok", "Field can't be empty");
                            error = true;
                        } else if (emptyOk.contains(tf)) {
                            ok = true;
                        }
                    }
                    if ((!error) && (!ok)) {
                        // If there's already an error or it has been cleared by the emptyOK field, no need to check
                        HTMLInputFormat inputFormat = (HTMLInputFormat) inputFormats.get(tf);
                        if ((inputFormat != null) && (!inputFormat.verifyString(text))) {
                            String emptyStr = "";
                            if (emptyOk.contains(tf)) {
                                emptyStr = htmlC.getUIManager().localize("html.format.oremptyok", " or an empty string");
                            } else if (emptyNotOk.contains(tf)) {
                                emptyStr = htmlC.getUIManager().localize("html.format.andemptynotok", " and cannot be an empty string");
                            }
                            errorMsg = htmlC.getUIManager().localize("html.format.errordesc", "Malformed text. Correct value: ") + inputFormat.toString() + emptyStr;
                            error = true;
                        }
                    }
                }
                if (htmlC.getHTMLCallback() != null) {
                    int type = HTMLCallback.FIELD_TEXT;
                    if ((tf.getConstraint() & TextArea.PASSWORD) != 0) {
                        type = HTMLCallback.FIELD_PASSWORD;
                    }
                    text = htmlC.getHTMLCallback().fieldSubmitted(htmlC, tf, url, key, text, type, errorMsg);
                }
                if (errorMsg == null) {
                    params += key + "=" + HTMLUtils.encodeString(text) + "&";
                }
            } else if (input instanceof ComboBox) {
                // drop down lists (single selection)
                Object item = ((ComboBox) input).getSelectedItem();
                if (item instanceof OptionItem) {
                    value = ((OptionItem) item).getValue();
                    params += key + "=" + HTMLUtils.encodeString(value) + "&";
                }
            // if not - value may be an OPTGROUP label in an only optgroup combobox
            } else if (input instanceof MultiComboBox) {
                // drop down lists (multiple selection)
                Vector selected = ((MultiComboBox) input).getSelected();
                for (int i = 0; i < selected.size(); i++) {
                    Object item = selected.elementAt(i);
                    if (item instanceof OptionItem) {
                        value = ((OptionItem) item).getValue();
                        params += key + "=" + HTMLUtils.encodeString(value) + "&";
                    }
                // if not - value may be an OPTGROUP label in an only optgroup combobox
                }
            }
        }
        if (params.endsWith("&")) {
            // trim the extra &
            params = params.substring(0, params.length() - 1);
        }
    }
    // Add the submit button param, only if the key is non-null (unnamed submit buttons are not passed as parameters)
    if (submitKey != null) {
        if (params == null) {
            params = "";
        }
        if (!params.equals("")) {
            params = params + "&";
        }
        params = params + HTMLUtils.encodeString(submitKey) + "=" + HTMLUtils.encodeString(submitVal);
    }
    if (!error) {
        DocumentInfo docInfo = new DocumentInfo(url, params, isPostMethod);
        if ((encType != null) && (!encType.equals(""))) {
            docInfo.setEncoding(encType);
        }
        htmlC.setPage(docInfo);
    }
}
Also used : Enumeration(java.util.Enumeration) TextArea(com.codename1.ui.TextArea) Hashtable(java.util.Hashtable) ComboBox(com.codename1.ui.ComboBox) RadioButton(com.codename1.ui.RadioButton) Button(com.codename1.ui.Button) Vector(java.util.Vector)

Example 2 with ComboBox

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

the class ImmunizationDataForm method addFields.

@SuppressWarnings("deprecation")
@Override
protected void addFields() {
    TextField immunizationUuuidField = addField(ImmunizationDto.UUID, TextField.class);
    immunizationUuuidField.setReadOnly(true);
    TextField externalIdField = addField(ImmunizationDto.EXTERNAL_ID, TextField.class);
    style(externalIdField, ERROR_COLOR_PRIMARY);
    addField(ImmunizationDto.REPORT_DATE, DateField.class);
    addField(ImmunizationDto.REPORTING_USER, ComboBox.class);
    ComboBox cbDisease = addDiseaseField(ImmunizationDto.DISEASE, false);
    addField(ImmunizationDto.DISEASE_DETAILS, TextField.class);
    ComboBox meansOfImmunizationField = addField(ImmunizationDto.MEANS_OF_IMMUNIZATION, ComboBox.class);
    addField(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS, TextField.class);
    overwriteImmunizationManagementStatus = addCustomField(OVERWRITE_IMMUNIZATION_MANAGEMENT_STATUS, Boolean.class, CheckBox.class);
    overwriteImmunizationManagementStatus.addStyleName(VSPACE_3);
    ComboBox managementStatusField = addField(ImmunizationDto.IMMUNIZATION_MANAGEMENT_STATUS, ComboBox.class);
    managementStatusField.setNullSelectionAllowed(false);
    managementStatusField.setEnabled(false);
    ComboBox immunizationStatusField = addField(ImmunizationDto.IMMUNIZATION_STATUS, ComboBox.class);
    immunizationStatusField.setEnabled(false);
    addField(ImmunizationDto.PREVIOUS_INFECTION, NullableOptionGroup.class);
    addField(ImmunizationDto.LAST_INFECTION_DATE, DateField.class);
    ComboBox country = addInfrastructureField(ImmunizationDto.COUNTRY);
    country.addItems(FacadeProvider.getCountryFacade().getAllActiveAsReference());
    TextArea descriptionField = addField(ImmunizationDto.ADDITIONAL_DETAILS, TextArea.class, new ResizableTextAreaWrapper<>());
    descriptionField.setRows(2);
    descriptionField.setDescription(I18nProperties.getPrefixDescription(ImmunizationDto.I18N_PREFIX, ImmunizationDto.ADDITIONAL_DETAILS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    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);
    facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
    facilityTypeGroup.setId("typeGroup");
    facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
    facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
    facilityTypeGroup.addItems(FacilityTypeGroup.values());
    getContent().addComponent(facilityTypeGroup, FACILITY_TYPE_GROUP_LOC);
    ComboBox facilityType = addField(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);
    MeansOfImmunization meansOfImmunizationValue = (MeansOfImmunization) meansOfImmunizationField.getValue();
    boolean isVaccinationVisibleInitial = shouldShowVaccinationFields(meansOfImmunizationValue);
    Label vaccinationHeadingLabel = new Label(I18nProperties.getString(Strings.headingVaccination));
    vaccinationHeadingLabel.addStyleName(H3);
    getContent().addComponent(vaccinationHeadingLabel, VACCINATION_HEADING_LOC);
    vaccinationHeadingLabel.setVisible(isVaccinationVisibleInitial);
    Field numberOfDosesField = addField(ImmunizationDto.NUMBER_OF_DOSES);
    numberOfDosesField.addValidator(new NumberValidator(I18nProperties.getValidationError(Validations.vaccineDosesFormat), 1, 10, false));
    numberOfDosesField.setVisible(isVaccinationVisibleInitial);
    Field numberOfDosesDetailsField = addField(ImmunizationDto.NUMBER_OF_DOSES_DETAILS);
    numberOfDosesDetailsField.setReadOnly(true);
    numberOfDosesDetailsField.setVisible(isVaccinationVisibleInitial && getValue().getNumberOfDosesDetails() != null);
    VaccinationsField vaccinationsField = addField(ImmunizationDto.VACCINATIONS, VaccinationsField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), ImmunizationDto.VACCINATIONS, ImmunizationDto.MEANS_OF_IMMUNIZATION, Arrays.asList(MeansOfImmunization.VACCINATION, MeansOfImmunization.VACCINATION_RECOVERY), false);
    cbDisease.addValueChangeListener(e -> vaccinationsField.setDisease((Disease) cbDisease.getValue()));
    Label recoveryHeadingLabel = new Label(I18nProperties.getString(Strings.headingRecovery));
    recoveryHeadingLabel.addStyleName(H3);
    getContent().addComponent(recoveryHeadingLabel, RECOVERY_HEADING_LOC);
    recoveryHeadingLabel.setVisible(shouldShowRecoveryFields(meansOfImmunizationValue));
    DateField positiveTestResultDate = addField(ImmunizationDto.POSITIVE_TEST_RESULT_DATE, DateField.class);
    DateField recoveryDate = addField(ImmunizationDto.RECOVERY_DATE, DateField.class);
    Button linkImmunizationToCaseButton;
    if (relatedCase != null) {
        linkImmunizationToCaseButton = ButtonHelper.createButton(Captions.openLinkedCaseToImmunizationButton, e -> ControllerProvider.getCaseController().navigateToCase(relatedCase.getUuid()), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
    } else {
        linkImmunizationToCaseButton = ButtonHelper.createButton(Captions.linkImmunizationToCaseButton, e -> buildAndOpenSearchSpecificCaseWindow(), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
    }
    getContent().addComponent(linkImmunizationToCaseButton, LINK_IMMUNIZATION_TO_CASE_BTN_LOC);
    linkImmunizationToCaseButton.setVisible(shouldShowRecoveryFields(meansOfImmunizationValue));
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    setRequired(true, ImmunizationDto.REPORT_DATE, ImmunizationDto.DISEASE, ImmunizationDto.MEANS_OF_IMMUNIZATION);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ImmunizationDto.DISEASE_DETAILS), ImmunizationDto.DISEASE, Arrays.asList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), ImmunizationDto.DISEASE, Arrays.asList(ImmunizationDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
    FieldHelper.setVisibleWhen(getFieldGroup(), Collections.singletonList(ImmunizationDto.MEANS_OF_IMMUNIZATION_DETAILS), ImmunizationDto.MEANS_OF_IMMUNIZATION, Collections.singletonList(MeansOfImmunization.OTHER), true);
    overwriteImmunizationManagementStatus.addValueChangeListener(valueChangeEvent -> {
        boolean selectedValue = (boolean) valueChangeEvent.getProperty().getValue();
        if (!selectedValue) {
            ImmunizationManagementStatus value = getValue().getImmunizationManagementStatus();
            managementStatusField.setValue(value);
        }
        managementStatusField.setEnabled(selectedValue);
        ignoreMeansOfImmunizationChange = selectedValue;
    });
    meansOfImmunizationField.addValueChangeListener(valueChangeEvent -> {
        MeansOfImmunization meansOfImmunization = (MeansOfImmunization) valueChangeEvent.getProperty().getValue();
        boolean isVaccinationVisible = shouldShowVaccinationFields(meansOfImmunization);
        boolean isRecoveryVisible = shouldShowRecoveryFields(meansOfImmunization);
        if (!ignoreMeansOfImmunizationChange) {
            if (MeansOfImmunization.RECOVERY.equals(meansOfImmunization) || MeansOfImmunization.OTHER.equals(meansOfImmunization)) {
                managementStatusField.setValue(ImmunizationManagementStatus.COMPLETED);
                if (CollectionUtils.isNotEmpty(vaccinationsField.getValue())) {
                    VaadinUiUtil.showConfirmationPopup(I18nProperties.getString(Strings.headingDeleteVaccinations), new Label(I18nProperties.getString(Strings.messageDeleteImmunizationVaccinations)), questionWindow -> {
                        ConfirmationComponent confirmationComponent = new ConfirmationComponent(false) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            protected void onConfirm() {
                                vaccinationsField.clear();
                                previousMeansOfImmunization = meansOfImmunization;
                                if (!isVaccinationVisible) {
                                    numberOfDosesField.setValue(null);
                                }
                                questionWindow.close();
                            }

                            @Override
                            protected void onCancel() {
                                ignoreMeansOfImmunizationChange = true;
                                meansOfImmunizationField.setValue(previousMeansOfImmunization);
                                ignoreMeansOfImmunizationChange = false;
                                questionWindow.close();
                            }
                        };
                        confirmationComponent.getConfirmButton().setCaption(I18nProperties.getCaption(Captions.actionConfirm));
                        confirmationComponent.getCancelButton().setCaption(I18nProperties.getCaption(Captions.actionCancel));
                        return confirmationComponent;
                    }, null);
                } else {
                    previousMeansOfImmunization = meansOfImmunization;
                }
            } else {
                previousMeansOfImmunization = meansOfImmunization;
            }
        }
        vaccinationHeadingLabel.setVisible(isVaccinationVisible);
        numberOfDosesField.setVisible(isVaccinationVisible);
        numberOfDosesDetailsField.setVisible(isVaccinationVisible && getValue().getNumberOfDosesDetails() != null);
        recoveryHeadingLabel.setVisible(isRecoveryVisible);
        positiveTestResultDate.setVisible(isRecoveryVisible);
        recoveryDate.setVisible(isRecoveryVisible);
    });
    managementStatusField.addValueChangeListener(valueChangeEvent -> {
        ImmunizationManagementStatus managementStatusValue = (ImmunizationManagementStatus) valueChangeEvent.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;
        }
    });
    setReadOnly(true, ImmunizationDto.REPORTING_USER);
    FieldHelper.setVisibleWhen(getFieldGroup(), ImmunizationDto.LAST_INFECTION_DATE, ImmunizationDto.PREVIOUS_INFECTION, Collections.singletonList(YesNoUnknown.YES), true);
    meansOfImmunizationField.addValueChangeListener(e -> {
        if (shouldShowRecoveryFields((MeansOfImmunization) e.getProperty().getValue())) {
            positiveTestResultDate.setVisible(true);
            recoveryDate.setVisible(true);
            linkImmunizationToCaseButton.setVisible(true);
        } else {
            positiveTestResultDate.setVisible(false);
            recoveryDate.setVisible(false);
            linkImmunizationToCaseButton.setVisible(false);
        }
    });
    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 -> {
        if (facilityTypeGroup.getValue() == null) {
            facilityType.clear();
        }
        FieldHelper.updateEnumData(facilityType, facilityTypeGroup.getValue() != null ? FacilityType.getTypes((FacilityTypeGroup) facilityTypeGroup.getValue()) : Arrays.stream(FacilityType.values()).collect(Collectors.toList()));
    });
    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);
    });
    addValueChangeListener(e -> {
        FacilityType facilityTypeValue = getValue().getFacilityType();
        if (facilityTypeValue != null) {
            facilityTypeGroup.setValue(facilityTypeValue.getFacilityTypeGroup());
            facilityCombo.setValue(getValue().getHealthFacility());
            facilityDetails.setValue(getValue().getHealthFacilityDetails());
        }
    });
}
Also used : AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) UI(com.vaadin.ui.UI) Window(com.vaadin.ui.Window) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ValoTheme(com.vaadin.ui.themes.ValoTheme) ConfirmationComponent(de.symeda.sormas.ui.utils.ConfirmationComponent) ComboBox(com.vaadin.v7.ui.ComboBox) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Collectors(java.util.stream.Collectors) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) LayoutUtil.fluidColumnLoc(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLoc) TextField(com.vaadin.v7.ui.TextField) Descriptions(de.symeda.sormas.api.i18n.Descriptions) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) VaccinationsField(de.symeda.sormas.ui.vaccination.VaccinationsField) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) SearchSpecificLayout(de.symeda.sormas.ui.SearchSpecificLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) Converter(com.vaadin.v7.data.util.converter.Converter) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) CollectionUtils(org.apache.commons.collections.CollectionUtils) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ResizableTextAreaWrapper(de.symeda.sormas.ui.utils.ResizableTextAreaWrapper) 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) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) TextArea(com.vaadin.v7.ui.TextArea) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) ImmunizationStatus(de.symeda.sormas.api.immunization.ImmunizationStatus) 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) Disease(de.symeda.sormas.api.Disease) TextArea(com.vaadin.v7.ui.TextArea) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) VaccinationsField(de.symeda.sormas.ui.vaccination.VaccinationsField) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ImmunizationManagementStatus(de.symeda.sormas.api.immunization.ImmunizationManagementStatus) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) VaccinationsField(de.symeda.sormas.ui.vaccination.VaccinationsField) DateField(com.vaadin.v7.ui.DateField) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) NumberValidator(de.symeda.sormas.ui.utils.NumberValidator) Button(com.vaadin.ui.Button) CheckBox(com.vaadin.v7.ui.CheckBox) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) ConfirmationComponent(de.symeda.sormas.ui.utils.ConfirmationComponent) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 3 with ComboBox

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

the class EventsFilterForm method addFields.

@Override
protected void addFields() {
    addField(FieldConfiguration.pixelSized(EventCriteria.EVENT_STATUS, 140));
    addField(FieldConfiguration.pixelSized(EventCriteria.RISK_LEVEL, 140));
    List<SpecificRisk> specificRisks = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.SPECIFIC_EVENT_RISK, null);
    if (!specificRisks.isEmpty()) {
        ComboBox specificRiskField = addField(FieldConfiguration.pixelSized(EventCriteria.SPECIFIC_RISK, 140), ComboBox.class);
        FieldHelper.updateItems(specificRiskField, specificRisks);
    }
    addField(FieldConfiguration.pixelSized(EventIndexDto.DISEASE, 140));
    addField(FieldConfiguration.pixelSized(EventIndexDto.DISEASE_VARIANT, 140), ComboBox.class);
    addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.REPORTING_USER_ROLE, I18nProperties.getString(Strings.reportedBy), 140));
    TextField searchField = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT, I18nProperties.getString(Strings.promptEventsSearchField), 200));
    searchField.setNullRepresentation("");
    TextField searchFieldEventParticipants = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT_EVENT_PARTICIPANTS, I18nProperties.getString(Strings.promptEventsSearchFieldEventParticipants), 200));
    searchFieldEventParticipants.setNullRepresentation("");
    TextField searchFieldEventGroups = addField(FieldConfiguration.withCaptionAndPixelSized(EventCriteria.FREE_TEXT_EVENT_GROUPS, I18nProperties.getString(Strings.promptEventsSearchFieldEventGroups), 200));
    searchFieldEventGroups.setNullRepresentation("");
}
Also used : SpecificRisk(de.symeda.sormas.api.event.SpecificRisk) ComboBox(com.vaadin.v7.ui.ComboBox) TextField(com.vaadin.v7.ui.TextField)

Example 4 with ComboBox

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

the class EventsFilterForm method applyRegionFilterDependency.

@Override
protected void applyRegionFilterDependency(RegionReferenceDto region, String districtFieldId) {
    final ComboBox districtField = getField(districtFieldId);
    if (region != null) {
        FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        districtField.setEnabled(true);
    } else {
        districtField.setEnabled(false);
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Example 5 with ComboBox

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

the class EventsFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(EventCriteria criteria) {
    applyDateDependencyOnNewValue(EVENT_WEEK_AND_DATE_FILTER, criteria.getDateFilterOption(), criteria.getEventDateFrom(), criteria.getEventDateTo());
    applyDateDependencyOnNewValue(EVENT_SIGNAL_EVOLUTION_WEEK_AND_DATE_FILTER, criteria.getEvolutionDateFilterOption(), criteria.getEventEvolutionDateFrom(), criteria.getEventEvolutionDateTo());
    applyDateDependencyOnNewValue(ACTION_CHANGE_WEEK_AND_DATE_FILTER, criteria.getActionChangeDateFilterOption(), criteria.getActionChangeDateFrom(), criteria.getActionChangeDateTo());
    applyDateDependencyOnNewValue(ACTION_WEEK_AND_DATE_FILTER, criteria.getActionDateFilterOption(), criteria.getActionDateFrom(), criteria.getActionDateTo());
    RegionReferenceDto region = criteria.getRegion();
    DistrictReferenceDto district = criteria.getDistrict();
    applyRegionAndDistrictFilterDependency(region, LocationDto.DISTRICT, district, LocationDto.COMMUNITY);
    applyFacilityFieldsDependencies(criteria.getTypeOfPlace(), criteria.getDistrict(), criteria.getCommunity());
    updateResponsibleUserFieldItems(criteria.getDistrict(), criteria.getRegion());
    ComboBox diseaseField = getField(CaseDataDto.DISEASE);
    Disease disease = (Disease) diseaseField.getValue();
    applyDiseaseFilterDependency(disease);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)106 TextField (com.vaadin.v7.ui.TextField)39 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)30 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)26 Label (com.vaadin.ui.Label)23 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 CheckBox (com.vaadin.v7.ui.CheckBox)17 DateField (com.vaadin.v7.ui.DateField)17 Disease (de.symeda.sormas.api.Disease)17 TextArea (com.vaadin.v7.ui.TextArea)16 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)15 List (java.util.List)15 Button (com.vaadin.ui.Button)14 Field (com.vaadin.v7.ui.Field)14 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)14 FacadeProvider (de.symeda.sormas.api.FacadeProvider)13 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)13 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)13 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)13