Search in sources :

Example 66 with TextArea

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

the class IOSImplementation method editString.

public void editString(final Component cmp, final int maxSize, final int constraint, final String text, final int i) {
    // The very first time we try to edit a string, let's determine if the
    // system default is to do async editing.  If the system default
    // is not yet set, we set it here, and it will be used as the default from now on
    // We do this because the nativeInstance.isAsyncEditMode() value changes
    // to reflect the currently edited field so it isn't a good way to keep a
    // system default.
    pendingEditingText = false;
    String defaultAsyncEditingSetting = Display.getInstance().getProperty("ios.VKBAlwaysOpen", null);
    if (defaultAsyncEditingSetting == null) {
        defaultAsyncEditingSetting = nativeInstance.isAsyncEditMode() ? "true" : "false";
        Display.getInstance().setProperty("ios.VKBAlwaysOpen", defaultAsyncEditingSetting);
    }
    boolean asyncEdit = "true".equals(defaultAsyncEditingSetting) ? true : false;
    try {
        if (currentEditing != cmp && currentEditing != null && currentEditing instanceof TextArea) {
            Display.getInstance().onEditingComplete(currentEditing, ((TextArea) currentEditing).getText());
            currentEditing = null;
            callHideTextEditor();
            if (nativeInstance.isAsyncEditMode()) {
                nativeInstance.setNativeEditingComponentVisible(false);
            }
            synchronized (EDITING_LOCK) {
                EDITING_LOCK.notify();
            }
            Display.getInstance().callSerially(new Runnable() {

                public void run() {
                    pendingEditingText = true;
                    Display.getInstance().editString(cmp, maxSize, constraint, text, i);
                }
            });
            return;
        }
        if (cmp.isFocusable() && !cmp.hasFocus()) {
            doNotHideTextEditorSemaphore++;
            try {
                cmp.requestFocus();
            } finally {
                doNotHideTextEditorSemaphore--;
            }
            // of our upcoming field.
            if (isAsyncEditMode()) {
                // flush the EDT so the focus will work...
                Display.getInstance().callSerially(new Runnable() {

                    public void run() {
                        pendingEditingText = true;
                        Display.getInstance().editString(cmp, maxSize, constraint, text, i);
                    }
                });
                return;
            }
        }
        // Check if the form has any setting for asyncEditing that should override
        // the application defaults.
        Form parentForm = cmp.getComponentForm();
        if (parentForm == null) {
            // Log.p("Attempt to edit text area that is not on a form.  This is not supported");
            return;
        }
        if (parentForm.getClientProperty("asyncEditing") != null) {
            Object async = parentForm.getClientProperty("asyncEditing");
            if (async instanceof Boolean) {
                asyncEdit = ((Boolean) async).booleanValue();
            // Log.p("Form overriding asyncEdit due to asyncEditing client property: "+asyncEdit);
            }
        }
        if (parentForm.getClientProperty("ios.asyncEditing") != null) {
            Object async = parentForm.getClientProperty("ios.asyncEditing");
            if (async instanceof Boolean) {
                asyncEdit = ((Boolean) async).booleanValue();
            // Log.p("Form overriding asyncEdit due to ios.asyncEditing client property: "+asyncEdit);
            }
        }
        // editing - and should instead revert to legacy editing mode.
        if (asyncEdit && !parentForm.isFormBottomPaddingEditingMode()) {
            Container p = cmp.getParent();
            // A crude estimate of how far the component needs to be able to scroll to make
            // async editing viable.  We start with half-way down the screen.
            int keyboardClippingThresholdY = Display.getInstance().getDisplayWidth() / 2;
            while (p != null) {
                if (Accessor.scrollableYFlag(p) && p.getAbsoluteY() < keyboardClippingThresholdY) {
                    break;
                }
                p = p.getParent();
            }
            // no scrollabel parent automatically configure the text field for legacy mode
            // nativeInstance.setAsyncEditMode(p != null);
            asyncEdit = p != null;
        // Log.p("Overriding asyncEdit due to form scrollability: "+asyncEdit);
        } else if (parentForm.isFormBottomPaddingEditingMode()) {
            // If form uses bottom padding mode, then we will always
            // use async edit (unless the field explicitly overrides it).
            asyncEdit = true;
        // Log.p("Overriding asyncEdit due to form bottom padding edit mode: "+asyncEdit);
        }
        // then this will override all other settings.
        if (cmp.getClientProperty("asyncEditing") != null) {
            Object async = cmp.getClientProperty("asyncEditing");
            if (async instanceof Boolean) {
                asyncEdit = ((Boolean) async).booleanValue();
            // Log.p("Overriding asyncEdit due to field asyncEditing client property: "+asyncEdit);
            }
        }
        if (cmp.getClientProperty("ios.asyncEditing") != null) {
            Object async = cmp.getClientProperty("ios.asyncEditing");
            if (async instanceof Boolean) {
                asyncEdit = ((Boolean) async).booleanValue();
            // Log.p("Overriding asyncEdit due to field ios.asyncEditing client property: "+asyncEdit);
            }
        }
        // Finally we set the async edit mode for this field.
        // System.out.println("Async edit mode is "+asyncEdit);
        nativeInstance.setAsyncEditMode(asyncEdit);
        textEditorHidden = false;
        currentEditing = (TextArea) cmp;
        // register the edited TextArea to support moving to the next field
        TextEditUtil.setCurrentEditComponent(cmp);
        final NativeFont fnt = f(cmp.getStyle().getFont().getNativeFont());
        boolean forceSlideUpTmp = false;
        final Form current = Display.getInstance().getCurrent();
        if (current instanceof Dialog && !isTablet()) {
            // special case, if we are editing a small dialog we want to move it
            // so the bottom of the dialog shows within the screen. This is
            // described in issue 505
            Dialog dlg = (Dialog) current;
            Component c = dlg.getDialogComponent();
            if (c.getHeight() < Display.getInstance().getDisplayHeight() / 2 && c.getAbsoluteY() + c.getHeight() > Display.getInstance().getDisplayHeight() / 2) {
                forceSlideUpTmp = true;
            }
        }
        final boolean forceSlideUp = forceSlideUpTmp;
        cmp.repaint();
        // give the repaint one cycle to "do its magic...
        final Style stl = currentEditing.getStyle();
        final boolean rtl = UIManager.getInstance().getLookAndFeel().isRTL();
        final Style hintStyle = currentEditing.getHintLabel() != null ? currentEditing.getHintLabel().getStyle() : stl;
        if (current != null) {
            Component nextComponent = current.getNextComponent(cmp);
            TextEditUtil.setNextEditComponent(nextComponent);
        }
        Display.getInstance().callSerially(new Runnable() {

            @Override
            public void run() {
                int x = cmp.getAbsoluteX() + cmp.getScrollX();
                int y = cmp.getAbsoluteY() + cmp.getScrollY();
                int w = cmp.getWidth();
                int h = cmp.getHeight();
                int pt = stl.getPaddingTop();
                int pb = stl.getPaddingBottom();
                int pl = stl.getPaddingLeft(rtl);
                int pr = stl.getPaddingRight(rtl);
                /*
                    if(currentEditing != null && currentEditing.isSingleLineTextArea()) {
                        switch(currentEditing.getVerticalAlignment()) {
                            case TextArea.CENTER:
                                if(h > cmp.getPreferredH()) {
                                    y += (h / 2 - cmp.getPreferredH() / 2);
                                }
                                break;
                            case TextArea.BOTTOM:
                                if(h > cmp.getPreferredH()) {
                                    y += (h - cmp.getPreferredH());
                                }
                                break;
                        }
                    }
                    */
                String hint = null;
                if (currentEditing != null && currentEditing.getUIManager().isThemeConstant("nativeHintBool", true) && currentEditing.getHint() != null) {
                    hint = currentEditing.getHint();
                }
                int hintColor = hintStyle.getFgColor();
                if (isAsyncEditMode()) {
                    // request focus triggers a scroll which flicks the textEditorHidden flag
                    doNotHideTextEditorSemaphore++;
                    try {
                        cmp.requestFocus();
                    } finally {
                        doNotHideTextEditorSemaphore--;
                    }
                    textEditorHidden = false;
                }
                boolean showToolbar = cmp.getClientProperty("iosHideToolbar") == null;
                if (showToolbar && Display.getInstance().getProperty("iosHideToolbar", "false").equalsIgnoreCase("true")) {
                    showToolbar = false;
                }
                if (currentEditing != null) {
                    nativeInstance.editStringAt(x, y, w, h, fnt.peer, currentEditing.isSingleLineTextArea(), currentEditing.getRows(), maxSize, constraint, text, forceSlideUp, // peer,
                    stl.getFgColor(), // peer,
                    0, pt, pb, pl, pr, hint, hintColor, showToolbar, Boolean.TRUE.equals(cmp.getClientProperty("blockCopyPaste")), currentEditing.getStyle().getAlignment(), currentEditing.getVerticalAlignment());
                }
            }
        });
        if (isAsyncEditMode()) {
            return;
        }
        editNext = false;
        Display.getInstance().invokeAndBlock(new Runnable() {

            @Override
            public void run() {
                synchronized (EDITING_LOCK) {
                    while (instance.currentEditing == cmp) {
                        try {
                            EDITING_LOCK.wait(20);
                        } catch (InterruptedException ex) {
                        }
                    }
                }
            }
        });
        if (cmp instanceof TextArea && !((TextArea) cmp).isSingleLineTextArea()) {
            Form form = cmp.getComponentForm();
            if (form != null) {
                form.revalidate();
            }
        }
        if (editNext) {
            editNext = false;
            TextEditUtil.editNextTextArea();
        }
    } finally {
    }
}
Also used : TextArea(com.codename1.ui.TextArea) Form(com.codename1.ui.Form) Container(com.codename1.ui.Container) Dialog(com.codename1.ui.Dialog) Style(com.codename1.ui.plaf.Style) BrowserComponent(com.codename1.ui.BrowserComponent) Component(com.codename1.ui.Component) PeerComponent(com.codename1.ui.PeerComponent)

Example 67 with TextArea

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

the class ContactDataForm method addFields.

@SuppressWarnings("deprecation")
@Override
protected void addFields() {
    if (viewMode == null) {
        return;
    }
    Label contactDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingContactData));
    contactDataHeadingLabel.addStyleName(H3);
    getContent().addComponent(contactDataHeadingLabel, CONTACT_DATA_HEADING_LOC);
    Label followUpStausHeadingLabel = new Label(I18nProperties.getString(Strings.headingFollowUpStatus));
    followUpStausHeadingLabel.addStyleName(H3);
    getContent().addComponent(followUpStausHeadingLabel, FOLLOW_UP_STATUS_HEADING_LOC);
    addField(ContactDto.CONTACT_CLASSIFICATION, NullableOptionGroup.class);
    addField(ContactDto.CONTACT_STATUS, NullableOptionGroup.class);
    addField(ContactDto.UUID, TextField.class);
    addField(ContactDto.EXTERNAL_ID, TextField.class);
    TextField externalTokenField = addField(ContactDto.EXTERNAL_TOKEN, TextField.class);
    Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageContactExternalTokenWarning));
    externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
    getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
    addField(ContactDto.INTERNAL_TOKEN, TextField.class);
    addField(ContactDto.REPORTING_USER, ComboBox.class);
    multiDayContact = addField(ContactDto.MULTI_DAY_CONTACT, CheckBox.class);
    firstContactDate = addDateField(ContactDto.FIRST_CONTACT_DATE, DateField.class, 0);
    lastContactDate = addField(ContactDto.LAST_CONTACT_DATE, DateField.class);
    reportDate = addField(ContactDto.REPORT_DATE_TIME, DateField.class);
    List<AbstractField<Date>> validatedFields = Arrays.asList(firstContactDate, lastContactDate, reportDate);
    validatedFields.forEach(field -> field.addValueChangeListener(r -> {
        validatedFields.forEach(otherField -> {
            otherField.setValidationVisible(!otherField.isValid());
        });
    }));
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.FIRST_CONTACT_DATE, ContactDto.MULTI_DAY_CONTACT, Collections.singletonList(true), true);
    initContactDateValidation();
    addInfrastructureField(ContactDto.REPORTING_DISTRICT).addItems(FacadeProvider.getDistrictFacade().getAllActiveAsReference());
    addField(ContactDto.CONTACT_IDENTIFICATION_SOURCE, ComboBox.class);
    TextField contactIdentificationSourceDetails = addField(ContactDto.CONTACT_IDENTIFICATION_SOURCE_DETAILS, TextField.class);
    contactIdentificationSourceDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    // contactIdentificationSourceDetails.setVisible(false);
    ComboBox tracingApp = addField(ContactDto.TRACING_APP, ComboBox.class);
    TextField tracingAppDetails = addField(ContactDto.TRACING_APP_DETAILS, TextField.class);
    tracingAppDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    // tracingAppDetails.setVisible(false);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.CONTACT_IDENTIFICATION_SOURCE_DETAILS, ContactDto.CONTACT_IDENTIFICATION_SOURCE, Arrays.asList(ContactIdentificationSource.OTHER), true);
        FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.TRACING_APP, ContactDto.CONTACT_IDENTIFICATION_SOURCE, Arrays.asList(ContactIdentificationSource.TRACING_APP), true);
        FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.TRACING_APP_DETAILS, ContactDto.TRACING_APP, Arrays.asList(TracingApp.OTHER), true);
    }
    contactProximity = addField(ContactDto.CONTACT_PROXIMITY, NullableOptionGroup.class);
    contactProximity.setCaption(I18nProperties.getCaption(Captions.Contact_contactProximityLongForm));
    contactProximity.removeStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
        addField(ContactDto.CONTACT_PROXIMITY_DETAILS, TextField.class);
        contactCategory = addField(ContactDto.CONTACT_CATEGORY, NullableOptionGroup.class);
        contactProximity.addValueChangeListener(e -> {
            if (getInternalValue().getContactProximity() != e.getProperty().getValue() || contactCategory.isModified()) {
                updateContactCategory((ContactProximity) contactProximity.getNullableValue());
            }
        });
    }
    ComboBox relationToCase = addField(ContactDto.RELATION_TO_CASE, ComboBox.class);
    addField(ContactDto.RELATION_DESCRIPTION, TextField.class);
    cbDisease = addDiseaseField(ContactDto.DISEASE, false);
    cbDisease.setNullSelectionAllowed(false);
    addField(ContactDto.DISEASE_DETAILS, TextField.class);
    addField(ContactDto.PROHIBITION_TO_WORK, NullableOptionGroup.class).addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    DateField prohibitionToWorkFrom = addField(ContactDto.PROHIBITION_TO_WORK_FROM);
    DateField prohibitionToWorkUntil = addDateField(ContactDto.PROHIBITION_TO_WORK_UNTIL, DateField.class, -1);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ContactDto.PROHIBITION_TO_WORK_FROM, ContactDto.PROHIBITION_TO_WORK_UNTIL), ContactDto.PROHIBITION_TO_WORK, YesNoUnknown.YES, true);
    prohibitionToWorkFrom.addValidator(new DateComparisonValidator(prohibitionToWorkFrom, prohibitionToWorkUntil, true, false, I18nProperties.getValidationError(Validations.beforeDate, prohibitionToWorkFrom.getCaption(), prohibitionToWorkUntil.getCaption())));
    prohibitionToWorkUntil.addValidator(new DateComparisonValidator(prohibitionToWorkUntil, prohibitionToWorkFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, prohibitionToWorkUntil.getCaption(), prohibitionToWorkFrom.getCaption())));
    quarantine = addField(ContactDto.QUARANTINE);
    quarantine.addValueChangeListener(e -> onQuarantineValueChange());
    quarantineFrom = addField(ContactDto.QUARANTINE_FROM, DateField.class);
    dfQuarantineTo = addDateField(ContactDto.QUARANTINE_TO, DateField.class, -1);
    quarantineFrom.addValidator(new DateComparisonValidator(quarantineFrom, dfQuarantineTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, quarantineFrom.getCaption(), dfQuarantineTo.getCaption())));
    dfQuarantineTo.addValidator(new DateComparisonValidator(dfQuarantineTo, quarantineFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, dfQuarantineTo.getCaption(), quarantineFrom.getCaption())));
    quarantineChangeComment = addField(ContactDto.QUARANTINE_CHANGE_COMMENT);
    dfPreviousQuarantineTo = addDateField(ContactDto.PREVIOUS_QUARANTINE_TO, DateField.class, -1);
    setReadOnly(true, ContactDto.PREVIOUS_QUARANTINE_TO);
    setVisible(false, ContactDto.QUARANTINE_CHANGE_COMMENT, ContactDto.PREVIOUS_QUARANTINE_TO);
    quarantineOrderedVerbally = addField(ContactDto.QUARANTINE_ORDERED_VERBALLY, CheckBox.class);
    CssStyles.style(quarantineOrderedVerbally, CssStyles.FORCE_CAPTION);
    addField(ContactDto.QUARANTINE_ORDERED_VERBALLY_DATE, DateField.class);
    quarantineOrderedOfficialDocument = addField(ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CheckBox.class);
    CssStyles.style(quarantineOrderedOfficialDocument, CssStyles.FORCE_CAPTION);
    addField(ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, DateField.class);
    CheckBox quarantineOfficialOrderSent = addField(ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT, CheckBox.class);
    CssStyles.style(quarantineOfficialOrderSent, FORCE_CAPTION);
    addField(ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, DateField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT, ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Collections.singletonList(Boolean.TRUE), true);
    cbQuarantineExtended = addField(ContactDto.QUARANTINE_EXTENDED, CheckBox.class);
    cbQuarantineExtended.setEnabled(false);
    cbQuarantineExtended.setVisible(false);
    CssStyles.style(cbQuarantineExtended, CssStyles.FORCE_CAPTION);
    cbQuarantineReduced = addField(ContactDto.QUARANTINE_REDUCED, CheckBox.class);
    cbQuarantineReduced.setEnabled(false);
    cbQuarantineReduced.setVisible(false);
    CssStyles.style(cbQuarantineReduced, CssStyles.FORCE_CAPTION);
    TextField quarantineHelpNeeded = addField(ContactDto.QUARANTINE_HELP_NEEDED, TextField.class);
    quarantineHelpNeeded.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    TextField quarantineTypeDetails = addField(ContactDto.QUARANTINE_TYPE_DETAILS, TextField.class);
    quarantineTypeDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    addField(ContactDto.QUARANTINE_HOME_POSSIBLE, NullableOptionGroup.class);
    addField(ContactDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TextField.class);
    addField(ContactDto.QUARANTINE_HOME_SUPPLY_ENSURED, NullableOptionGroup.class);
    addField(ContactDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TextField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ContactDto.QUARANTINE_FROM, ContactDto.QUARANTINE_TO, ContactDto.QUARANTINE_HELP_NEEDED), ContactDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) || isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ContactDto.QUARANTINE_ORDERED_VERBALLY, ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT), ContactDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_HOME_POSSIBLE_COMMENT, ContactDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_HOME_SUPPLY_ENSURED, ContactDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, ContactDto.QUARANTINE_HOME_SUPPLY_ENSURED, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_TYPE_DETAILS, ContactDto.QUARANTINE, Arrays.asList(QuarantineType.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_ORDERED_VERBALLY_DATE, ContactDto.QUARANTINE_ORDERED_VERBALLY, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT, Collections.singletonList(Boolean.TRUE), true);
    addField(ContactDto.DESCRIPTION, TextArea.class).setRows(6);
    addField(ContactDto.VACCINATION_STATUS);
    addField(ContactDto.RETURNING_TRAVELER, NullableOptionGroup.class);
    addField(ContactDto.CASE_ID_EXTERNAL_SYSTEM, TextField.class);
    addField(ContactDto.CASE_OR_EVENT_INFORMATION, TextArea.class).setRows(4);
    addField(ContactDto.FOLLOW_UP_STATUS, ComboBox.class);
    addField(ContactDto.FOLLOW_UP_STATUS_CHANGE_DATE);
    addField(ContactDto.FOLLOW_UP_STATUS_CHANGE_USER);
    addField(ContactDto.FOLLOW_UP_COMMENT, TextArea.class).setRows(3);
    dfFollowUpUntil = addDateField(ContactDto.FOLLOW_UP_UNTIL, DateField.class, -1);
    dfFollowUpUntil.addValueChangeListener(v -> onFollowUpUntilChanged(v, dfQuarantineTo, cbQuarantineExtended, cbQuarantineReduced));
    cbOverwriteFollowUpUntil = addField(ContactDto.OVERWRITE_FOLLOW_UP_UTIL, CheckBox.class);
    cbOverwriteFollowUpUntil.addValueChangeListener(e -> {
        if (!(Boolean) e.getProperty().getValue()) {
            dfFollowUpUntil.discard();
        }
    });
    dfQuarantineTo.addValueChangeListener(e -> onQuarantineEndChange());
    addValueChangeListener(e -> {
        ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getContactFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
        onQuarantineValueChange();
    });
    ComboBox contactOfficerField = addField(ContactDto.CONTACT_OFFICER, ComboBox.class);
    contactOfficerField.setNullSelectionAllowed(true);
    ComboBox region = addInfrastructureField(ContactDto.REGION);
    region.setDescription(I18nProperties.getPrefixDescription(ContactDto.I18N_PREFIX, ContactDto.REGION));
    ComboBox district = addInfrastructureField(ContactDto.DISTRICT);
    district.setDescription(I18nProperties.getPrefixDescription(ContactDto.I18N_PREFIX, ContactDto.DISTRICT));
    ComboBox community = addInfrastructureField(ContactDto.COMMUNITY);
    community.setDescription(I18nProperties.getPrefixDescription(ContactDto.I18N_PREFIX, ContactDto.COMMUNITY));
    region.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(district, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    district.addValueChangeListener(e -> {
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(community, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
        List<DistrictReferenceDto> officerDistricts = new ArrayList<>();
        officerDistricts.add(districtDto);
        if (districtDto == null && getValue().getCaze() != null) {
            CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(getValue().getCaze().getUuid());
            FieldHelper.updateOfficersField(contactOfficerField, caseDto, UserRight.CONTACT_RESPONSIBLE);
        } else {
            FieldHelper.updateItems(contactOfficerField, districtDto != null ? FacadeProvider.getUserFacade().getUserRefsByDistrict(districtDto, getSelectedDisease(), UserRight.CONTACT_RESPONSIBLE) : null);
        }
    });
    region.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    CheckBox cbHighPriority = addField(ContactDto.HIGH_PRIORITY, CheckBox.class);
    tfExpectedFollowUpUntilDate = new TextField();
    tfExpectedFollowUpUntilDate.setCaption(I18nProperties.getCaption(Captions.Contact_expectedFollowUpUntil));
    getContent().addComponent(tfExpectedFollowUpUntilDate, EXPECTED_FOLLOW_UP_UNTIL_DATE_LOC);
    NullableOptionGroup ogImmunosuppressiveTherapyBasicDisease = addField(ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE, NullableOptionGroup.class);
    addField(ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE_DETAILS, TextField.class);
    NullableOptionGroup ogCareForPeopleOver60 = addField(ContactDto.CARE_FOR_PEOPLE_OVER_60, NullableOptionGroup.class);
    cbDisease.addValueChangeListener(e -> updateDiseaseConfiguration((Disease) e.getProperty().getValue()));
    HealthConditionsForm clinicalCourseForm = addField(ContactDto.HEALTH_CONDITIONS, HealthConditionsForm.class);
    clinicalCourseForm.setCaption(null);
    Label generalCommentLabel = new Label(I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, ContactDto.ADDITIONAL_DETAILS));
    generalCommentLabel.addStyleName(H3);
    getContent().addComponent(generalCommentLabel, GENERAL_COMMENT_LOC);
    TextArea additionalDetails = addField(ContactDto.ADDITIONAL_DETAILS, TextArea.class);
    additionalDetails.setRows(6);
    additionalDetails.setDescription(I18nProperties.getPrefixDescription(ContactDto.I18N_PREFIX, ContactDto.ADDITIONAL_DETAILS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    CssStyles.style(additionalDetails, CssStyles.CAPTION_HIDDEN);
    addField(ContactDto.DELETION_REASON);
    addField(ContactDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, ContactDto.DELETION_REASON, ContactDto.OTHER_DELETION_REASON);
    addFields(ContactDto.END_OF_QUARANTINE_REASON, ContactDto.END_OF_QUARANTINE_REASON_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.END_OF_QUARANTINE_REASON_DETAILS, ContactDto.END_OF_QUARANTINE_REASON, Collections.singletonList(EndOfQuarantineReason.OTHER), true);
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    setReadOnly(true, ContactDto.UUID, ContactDto.REPORTING_USER, ContactDto.CONTACT_STATUS, ContactDto.FOLLOW_UP_STATUS, ContactDto.FOLLOW_UP_STATUS_CHANGE_DATE, ContactDto.FOLLOW_UP_STATUS_CHANGE_USER);
    FieldHelper.setRequiredWhen(getFieldGroup(), ContactDto.FOLLOW_UP_STATUS, Arrays.asList(ContactDto.FOLLOW_UP_COMMENT), Arrays.asList(FollowUpStatus.CANCELED, FollowUpStatus.LOST));
    FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Arrays.asList(ContactDto.FOLLOW_UP_STATUS_CHANGE_DATE, ContactDto.FOLLOW_UP_STATUS_CHANGE_USER), ContactDto.FOLLOW_UP_STATUS_CHANGE_DATE, true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.RELATION_DESCRIPTION, ContactDto.RELATION_TO_CASE, Arrays.asList(ContactRelation.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE_DETAILS, ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), ContactDto.DISEASE_DETAILS, ContactDto.DISEASE, Arrays.asList(Disease.OTHER), true);
    FieldHelper.setRequiredWhen(getFieldGroup(), ContactDto.DISEASE, Arrays.asList(ContactDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER));
    FieldHelper.setReadOnlyWhen(getFieldGroup(), Arrays.asList(ContactDto.FOLLOW_UP_UNTIL), ContactDto.OVERWRITE_FOLLOW_UP_UTIL, Arrays.asList(Boolean.FALSE), false, true);
    FieldHelper.setRequiredWhen(getFieldGroup(), ContactDto.OVERWRITE_FOLLOW_UP_UTIL, Arrays.asList(ContactDto.FOLLOW_UP_UNTIL), Arrays.asList(Boolean.TRUE));
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(ContactDto.FOLLOW_UP_UNTIL, ContactDto.OVERWRITE_FOLLOW_UP_UTIL), ContactDto.FOLLOW_UP_STATUS, Arrays.asList(FollowUpStatus.CANCELED, FollowUpStatus.COMPLETED, FollowUpStatus.FOLLOW_UP, FollowUpStatus.LOST), true);
    initializeVisibilitiesAndAllowedVisibilities();
    addValueChangeListener(e -> {
        if (getValue() != null) {
            CaseDataDto caseDto = null;
            if (getValue().getCaze() != null) {
                setVisible(false, ContactDto.DISEASE, ContactDto.CASE_ID_EXTERNAL_SYSTEM, ContactDto.CASE_OR_EVENT_INFORMATION);
                caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(getValue().getCaze().getUuid());
            } else {
                setRequired(true, ContactDto.DISEASE, ContactDto.REGION, ContactDto.DISTRICT);
            }
            updateDateComparison();
            updateDiseaseConfiguration(getValue().getDisease());
            updateFollowUpStatusComponents();
            DistrictReferenceDto referenceDistrict = getValue().getDistrict() != null ? getValue().getDistrict() : caseDto != null ? caseDto.getDistrict() : null;
            if (referenceDistrict != null) {
                contactOfficerField.addItems(FacadeProvider.getUserFacade().getUserRefsByDistrict(referenceDistrict, getSelectedDisease(), UserRight.CONTACT_RESPONSIBLE));
            }
            getContent().removeComponent(TO_CASE_BTN_LOC);
            if (getValue().getResultingCase() != null) {
                // link to case
                Link linkToData = ControllerProvider.getCaseController().createLinkToData(getValue().getResultingCase().getUuid(), I18nProperties.getCaption(Captions.contactOpenContactCase));
                getContent().addComponent(linkToData, TO_CASE_BTN_LOC);
            } else if (!ContactClassification.NO_CONTACT.equals(getValue().getContactClassification())) {
                if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CONVERT)) {
                    toCaseButton = ButtonHelper.createButton(Captions.contactCreateContactCase);
                    toCaseButton.addStyleName(ValoTheme.BUTTON_LINK);
                    getContent().addComponent(toCaseButton, TO_CASE_BTN_LOC);
                }
            }
            if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
                setVisible(false, ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE, ContactDto.IMMUNOSUPPRESSIVE_THERAPY_BASIC_DISEASE_DETAILS, ContactDto.CARE_FOR_PEOPLE_OVER_60);
            } else {
                ogImmunosuppressiveTherapyBasicDisease.addValueChangeListener(getHighPriorityValueChangeListener(cbHighPriority));
                ogCareForPeopleOver60.addValueChangeListener(getHighPriorityValueChangeListener(cbHighPriority));
            }
            // Add follow-up until validator
            FollowUpPeriodDto followUpPeriod = ContactLogic.getFollowUpStartDate(lastContactDate.getValue(), reportDate.getValue(), FacadeProvider.getSampleFacade().getByContactUuids(Collections.singletonList(getValue().getUuid())));
            Date minimumFollowUpUntilDate = FollowUpLogic.calculateFollowUpUntilDate(followUpPeriod, null, FacadeProvider.getVisitFacade().getVisitsByContact(new ContactReferenceDto(getValue().getUuid())), FacadeProvider.getDiseaseConfigurationFacade().getFollowUpDuration(getSelectedDisease()), FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CONTACT_TRACING, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)).getFollowUpEndDate();
            if (FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CONTACT_TRACING, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)) {
                dfFollowUpUntil.addValueChangeListener(valueChangeEvent -> {
                    if (DateHelper.getEndOfDay(dfFollowUpUntil.getValue()).before(minimumFollowUpUntilDate)) {
                        dfFollowUpUntil.setComponentError(new ErrorMessage() {

                            @Override
                            public ErrorLevel getErrorLevel() {
                                return ErrorLevel.INFO;
                            }

                            @Override
                            public String getFormattedHtmlMessage() {
                                return I18nProperties.getValidationError(Validations.contactFollowUpUntilDateSoftValidation, I18nProperties.getPrefixCaption(ContactDto.I18N_PREFIX, ContactDto.FOLLOW_UP_UNTIL));
                            }
                        });
                    }
                });
            } else {
                dfFollowUpUntil.addValidator(new DateRangeValidator(I18nProperties.getValidationError(Validations.contactFollowUpUntilDate), minimumFollowUpUntilDate, null, Resolution.DAY));
            }
        }
        // Overwrite visibility for quarantine fields
        if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
            setVisible(false, ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, ContactDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, ContactDto.QUARANTINE_ORDERED_VERBALLY, ContactDto.QUARANTINE_ORDERED_VERBALLY_DATE, ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT, ContactDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE);
        }
    });
    setRequired(true, ContactDto.CONTACT_CLASSIFICATION, ContactDto.CONTACT_STATUS, ContactDto.REPORT_DATE_TIME);
    FieldHelper.addSoftRequiredStyle(firstContactDate, lastContactDate, contactProximity, relationToCase);
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) FeatureType(de.symeda.sormas.api.feature.FeatureType) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) LAYOUT_COL_HIDE_INVSIBLE(de.symeda.sormas.ui.utils.CssStyles.LAYOUT_COL_HIDE_INVSIBLE) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) ContactRelation(de.symeda.sormas.api.contact.ContactRelation) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) AbstractField(com.vaadin.v7.ui.AbstractField) Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) EndOfQuarantineReason(de.symeda.sormas.api.contact.EndOfQuarantineReason) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) TracingApp(de.symeda.sormas.api.contact.TracingApp) ContactProximity(de.symeda.sormas.api.contact.ContactProximity) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) CssStyles(de.symeda.sormas.ui.utils.CssStyles) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) UserProvider(de.symeda.sormas.ui.UserProvider) ValoTheme(com.vaadin.ui.themes.ValoTheme) Property(com.vaadin.v7.data.Property) ViewMode(de.symeda.sormas.ui.utils.ViewMode) ComboBox(com.vaadin.v7.ui.ComboBox) Link(com.vaadin.ui.Link) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) Sets(com.google.common.collect.Sets) List(java.util.List) ContactDto(de.symeda.sormas.api.contact.ContactDto) TextField(com.vaadin.v7.ui.TextField) 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) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) Converter(com.vaadin.v7.data.util.converter.Converter) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) LayoutUtil.locCss(de.symeda.sormas.ui.utils.LayoutUtil.locCss) Resolution(com.vaadin.v7.shared.ui.datefield.Resolution) Label(com.vaadin.ui.Label) CountryHelper(de.symeda.sormas.api.CountryHelper) 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) ContactIdentificationSource(de.symeda.sormas.api.contact.ContactIdentificationSource) Validations(de.symeda.sormas.api.i18n.Validations) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) ErrorMessage(com.vaadin.server.ErrorMessage) Captions(de.symeda.sormas.api.i18n.Captions) ExtendedReduced(de.symeda.sormas.api.utils.ExtendedReduced) UserRight(de.symeda.sormas.api.user.UserRight) Button(com.vaadin.ui.Button) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) Disease(de.symeda.sormas.api.Disease) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) TextArea(com.vaadin.v7.ui.TextArea) ContactCategory(de.symeda.sormas.api.contact.ContactCategory) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) DiseasesConfiguration(de.symeda.sormas.api.utils.Diseases.DiseasesConfiguration) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) AbstractField(com.vaadin.v7.ui.AbstractField) Disease(de.symeda.sormas.api.Disease) TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label) ArrayList(java.util.ArrayList) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) TextField(com.vaadin.v7.ui.TextField) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CheckBox(com.vaadin.v7.ui.CheckBox) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) DateField(com.vaadin.v7.ui.DateField) ErrorMessage(com.vaadin.server.ErrorMessage) Link(com.vaadin.ui.Link)

Example 68 with TextArea

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

the class CaseDataForm method addFields.

@SuppressWarnings("deprecation")
@Override
protected void addFields() {
    if (person == null || disease == null) {
        return;
    }
    Label caseDataHeadingLabel = new Label(I18nProperties.getString(Strings.headingCaseData));
    caseDataHeadingLabel.addStyleName(H3);
    getContent().addComponent(caseDataHeadingLabel, CASE_DATA_HEADING_LOC);
    if (caseFollowUpEnabled) {
        Label followUpStatusHeadingLabel = new Label(I18nProperties.getString(Strings.headingFollowUpStatus));
        followUpStatusHeadingLabel.addStyleName(H3);
        getContent().addComponent(followUpStatusHeadingLabel, FOLLOW_UP_STATUS_HEADING_LOC);
    }
    // Add fields
    DateField reportDate = addField(CaseDataDto.REPORT_DATE, DateField.class);
    addFields(CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.DISTRICT_LEVEL_DATE, CaseDataDto.REGION_LEVEL_DATE, CaseDataDto.NATIONAL_LEVEL_DATE, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_COMMENT, CaseDataDto.NOTIFYING_CLINIC, CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL);
    TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class);
    epidField.setInvalidCommitted(true);
    epidField.setMaxLength(24);
    style(epidField, ERROR_COLOR_PRIMARY);
    // Button to automatically assign a new epid number
    Button assignNewEpidNumberButton = ButtonHelper.createButton(Captions.actionAssignNewEpidNumber, e -> epidField.setValue(FacadeProvider.getCaseFacade().getGenerateEpidNumber(getValue())), ValoTheme.BUTTON_DANGER, FORCE_CAPTION);
    getContent().addComponent(assignNewEpidNumberButton, ASSIGN_NEW_EPID_NUMBER_LOC);
    assignNewEpidNumberButton.setVisible(false);
    Label epidNumberWarningLabel = new Label(I18nProperties.getString(Strings.messageEpidNumberWarning));
    epidNumberWarningLabel.addStyleName(VSPACE_3);
    addField(CaseDataDto.EXTERNAL_ID, TextField.class);
    if (FacadeProvider.getExternalSurveillanceToolFacade().isFeatureEnabled()) {
        CheckBox dontShareCheckbox = addField(CaseDataDto.DONT_SHARE_WITH_REPORTING_TOOL, CheckBox.class);
        CaseFormHelper.addDontShareWithReportingTool(getContent(), () -> dontShareCheckbox, DONT_SHARE_WARNING_LOC);
    }
    TextField externalTokenField = addField(CaseDataDto.EXTERNAL_TOKEN, TextField.class);
    Label externalTokenWarningLabel = new Label(I18nProperties.getString(Strings.messageCaseExternalTokenWarning));
    externalTokenWarningLabel.addStyleNames(VSPACE_3, LABEL_WHITE_SPACE_NORMAL);
    getContent().addComponent(externalTokenWarningLabel, EXTERNAL_TOKEN_WARNING_LOC);
    addField(CaseDataDto.INTERNAL_TOKEN, TextField.class);
    addField(CaseDataDto.INVESTIGATION_STATUS, NullableOptionGroup.class);
    addField(CaseDataDto.OUTCOME, NullableOptionGroup.class);
    addField(CaseDataDto.BLOOD_ORGAN_OR_TISSUE_DONATED, NullableOptionGroup.class);
    addField(CaseDataDto.SEQUELAE, NullableOptionGroup.class);
    addFields(CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.SEQUELAE_DETAILS);
    addField(CaseDataDto.CASE_IDENTIFICATION_SOURCE);
    addField(CaseDataDto.SCREENING_TYPE);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SCREENING_TYPE, CaseDataDto.CASE_IDENTIFICATION_SOURCE, Collections.singletonList(CaseIdentificationSource.SCREENING), true);
    ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false);
    ComboBox diseaseVariantField = addField(CaseDataDto.DISEASE_VARIANT, ComboBox.class);
    TextField diseaseVariantDetailsField = addField(CaseDataDto.DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    diseaseVariantField.setNullSelectionAllowed(true);
    addField(CaseDataDto.DISEASE_DETAILS, TextField.class);
    addField(CaseDataDto.PLAGUE_TYPE, NullableOptionGroup.class);
    addField(CaseDataDto.DENGUE_FEVER_TYPE, NullableOptionGroup.class);
    addField(CaseDataDto.RABIES_TYPE, NullableOptionGroup.class);
    addField(CaseDataDto.CASE_ORIGIN, TextField.class);
    quarantine = addField(CaseDataDto.QUARANTINE);
    quarantine.addValueChangeListener(e -> onValueChange());
    quarantineFrom = addField(CaseDataDto.QUARANTINE_FROM, DateField.class);
    dfQuarantineTo = addDateField(CaseDataDto.QUARANTINE_TO, DateField.class, -1);
    quarantineFrom.addValidator(new DateComparisonValidator(quarantineFrom, dfQuarantineTo, true, false, I18nProperties.getValidationError(Validations.beforeDate, quarantineFrom.getCaption(), dfQuarantineTo.getCaption())));
    dfQuarantineTo.addValidator(new DateComparisonValidator(dfQuarantineTo, quarantineFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, dfQuarantineTo.getCaption(), quarantineFrom.getCaption())));
    quarantineChangeComment = addField(CaseDataDto.QUARANTINE_CHANGE_COMMENT);
    dfPreviousQuarantineTo = addDateField(CaseDataDto.PREVIOUS_QUARANTINE_TO, DateField.class, -1);
    setReadOnly(true, CaseDataDto.PREVIOUS_QUARANTINE_TO);
    setVisible(false, CaseDataDto.QUARANTINE_CHANGE_COMMENT, CaseDataDto.PREVIOUS_QUARANTINE_TO);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY)) {
        final ComboBox cbCaseClassification = addField(CaseDataDto.CASE_CLASSIFICATION, ComboBox.class);
        cbCaseClassification.addValidator(new GermanCaseClassificationValidator(caseUuid, I18nProperties.getValidationError(Validations.caseClassificationInvalid)));
        ComboBox caseReferenceDefinition = addField(CaseDataDto.CASE_REFERENCE_DEFINITION, ComboBox.class);
        caseReferenceDefinition.setReadOnly(true);
        if (diseaseClassificationExists()) {
            Button caseClassificationCalculationButton = ButtonHelper.createButton(Captions.caseClassificationCalculationButton, e -> {
                CaseClassification classification = FacadeProvider.getCaseClassificationFacade().getClassification(getValue());
                ((Field<CaseClassification>) getField(CaseDataDto.CASE_CLASSIFICATION)).setValue(classification);
            }, ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
            getContent().addComponent(caseClassificationCalculationButton, CASE_CLASSIFICATION_CALCULATE_BTN_LOC);
            if (!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY)) {
                caseClassificationCalculationButton.setEnabled(false);
            }
        }
        // if(cbCaseClassification.getCaption())
        addField(CaseDataDto.NOT_A_CASE_REASON_NEGATIVE_TEST, CheckBox.class);
        addField(CaseDataDto.NOT_A_CASE_REASON_PHYSICIAN_INFORMATION, CheckBox.class);
        addField(CaseDataDto.NOT_A_CASE_REASON_DIFFERENT_PATHOGEN, CheckBox.class);
        addField(CaseDataDto.NOT_A_CASE_REASON_OTHER, CheckBox.class);
        addField(CaseDataDto.NOT_A_CASE_REASON_DETAILS, TextField.class);
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.NOT_A_CASE_REASON_NEGATIVE_TEST, CaseDataDto.NOT_A_CASE_REASON_PHYSICIAN_INFORMATION, CaseDataDto.NOT_A_CASE_REASON_DIFFERENT_PATHOGEN, CaseDataDto.NOT_A_CASE_REASON_OTHER), CaseDataDto.CASE_CLASSIFICATION, CaseClassification.NO_CASE, true);
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOT_A_CASE_REASON_DETAILS, CaseDataDto.NOT_A_CASE_REASON_OTHER, true, true);
    } else {
        final NullableOptionGroup caseClassificationGroup = addField(CaseDataDto.CASE_CLASSIFICATION, NullableOptionGroup.class);
        caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_NO_SYMPTOMS);
        caseClassificationGroup.removeItem(CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS);
    }
    boolean extendedClassification = FacadeProvider.getDiseaseConfigurationFacade().usesExtendedClassification(disease);
    if (extendedClassification) {
        ComboBox clinicalConfirmationCombo = addField(CaseDataDto.CLINICAL_CONFIRMATION, ComboBox.class);
        ComboBox epidemiologicalConfirmationCombo = addField(CaseDataDto.EPIDEMIOLOGICAL_CONFIRMATION, ComboBox.class);
        ComboBox laboratoryConfirmationCombo = addField(CaseDataDto.LABORATORY_DIAGNOSTIC_CONFIRMATION, ComboBox.class);
        ComboBox caseConfirmationBasisCombo = addCustomField(CASE_CONFIRMATION_BASIS, CaseConfirmationBasis.class, ComboBox.class);
        boolean extendedClassificationMulti = FacadeProvider.getDiseaseConfigurationFacade().usesExtendedClassificationMulti(disease);
        if (extendedClassificationMulti) {
            caseConfirmationBasisCombo.setVisible(false);
        } else {
            caseConfirmationBasisCombo.addValueChangeListener(field -> {
                clinicalConfirmationCombo.setValue(null);
                epidemiologicalConfirmationCombo.setValue(null);
                laboratoryConfirmationCombo.setValue(null);
                if (caseConfirmationBasisCombo.getValue() != null) {
                    switch((CaseConfirmationBasis) caseConfirmationBasisCombo.getValue()) {
                        case CLINICAL_CONFIRMATION:
                            clinicalConfirmationCombo.setValue(YesNoUnknown.YES);
                            break;
                        case EPIDEMIOLOGICAL_CONFIRMATION:
                            epidemiologicalConfirmationCombo.setValue(YesNoUnknown.YES);
                            break;
                        case LABORATORY_DIAGNOSTIC_CONFIRMATION:
                            laboratoryConfirmationCombo.setValue(YesNoUnknown.YES);
                            break;
                    }
                }
            });
            FieldHelper.setVisibleWhen(getField(CaseDataDto.CASE_CLASSIFICATION), Collections.singletonList(caseConfirmationBasisCombo), Collections.singletonList(CaseClassification.CONFIRMED), true);
            clinicalConfirmationCombo.setVisible(false);
            epidemiologicalConfirmationCombo.setVisible(false);
            laboratoryConfirmationCombo.setVisible(false);
        }
    }
    quarantineOrderedVerbally = addField(CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CheckBox.class);
    CssStyles.style(quarantineOrderedVerbally, CssStyles.FORCE_CAPTION);
    addField(CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, DateField.class);
    quarantineOrderedOfficialDocument = addField(CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CheckBox.class);
    CssStyles.style(quarantineOrderedOfficialDocument, CssStyles.FORCE_CAPTION);
    addField(CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, DateField.class);
    CheckBox quarantineOfficialOrderSent = addField(CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CheckBox.class);
    CssStyles.style(quarantineOfficialOrderSent, FORCE_CAPTION);
    addField(CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, DateField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Collections.singletonList(Boolean.TRUE), true);
    cbQuarantineExtended = addField(CaseDataDto.QUARANTINE_EXTENDED, CheckBox.class);
    cbQuarantineExtended.setEnabled(false);
    cbQuarantineExtended.setVisible(false);
    CssStyles.style(cbQuarantineExtended, CssStyles.FORCE_CAPTION);
    cbQuarantineReduced = addField(CaseDataDto.QUARANTINE_REDUCED, CheckBox.class);
    cbQuarantineReduced.setEnabled(false);
    cbQuarantineReduced.setVisible(false);
    CssStyles.style(cbQuarantineReduced, CssStyles.FORCE_CAPTION);
    TextField quarantineHelpNeeded = addField(CaseDataDto.QUARANTINE_HELP_NEEDED, TextField.class);
    quarantineHelpNeeded.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    TextField quarantineTypeDetails = addField(CaseDataDto.QUARANTINE_TYPE_DETAILS, TextField.class);
    quarantineTypeDetails.setInputPrompt(I18nProperties.getString(Strings.pleaseSpecify));
    addField(CaseDataDto.NOSOCOMIAL_OUTBREAK).addStyleNames(CssStyles.FORCE_CAPTION_CHECKBOX);
    addField(CaseDataDto.INFECTION_SETTING);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.INFECTION_SETTING, CaseDataDto.NOSOCOMIAL_OUTBREAK, true, true);
    // Reinfection
    {
        NullableOptionGroup ogReinfection = addField(CaseDataDto.RE_INFECTION, NullableOptionGroup.class);
        addField(CaseDataDto.PREVIOUS_INFECTION_DATE);
        ComboBox tfReinfectionStatus = addField(CaseDataDto.REINFECTION_STATUS, ComboBox.class);
        tfReinfectionStatus.setReadOnly(true);
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.PREVIOUS_INFECTION_DATE, CaseDataDto.RE_INFECTION, YesNoUnknown.YES, true);
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.REINFECTION_STATUS, CaseDataDto.RE_INFECTION, YesNoUnknown.YES, false);
        final Label reinfectionInfoLabel = new Label(VaadinIcons.EYE.getHtml(), ContentMode.HTML);
        CssStyles.style(reinfectionInfoLabel, CssStyles.LABEL_XLARGE, CssStyles.VSPACE_TOP_3);
        getContent().addComponent(reinfectionInfoLabel, REINFECTION_INFO_LOC);
        reinfectionInfoLabel.setVisible(false);
        final VerticalLayout reinfectionDetailsLeftLayout = new VerticalLayout();
        CssStyles.style(reinfectionDetailsLeftLayout, CssStyles.VSPACE_3);
        final VerticalLayout reinfectionDetailsRightLayout = new VerticalLayout();
        CssStyles.style(reinfectionDetailsRightLayout, CssStyles.VSPACE_3);
        for (ReinfectionDetailGroup group : ReinfectionDetailGroup.values()) {
            CaseReinfectionCheckBoxTree reinfectionTree = new CaseReinfectionCheckBoxTree(ReinfectionDetail.values(group).stream().map(e -> new CheckBoxTree.CheckBoxElement<>(null, e)).collect(Collectors.toList()), () -> {
                tfReinfectionStatus.setReadOnly(false);
                tfReinfectionStatus.setValue(CaseLogic.calculateReinfectionStatus(mergeReinfectionTrees()));
                tfReinfectionStatus.setReadOnly(true);
            });
            reinfectionTrees.put(group, reinfectionTree);
            if (StringUtils.isNotBlank(group.toString())) {
                Label heading = new Label(group.toString());
                CssStyles.style(heading, CssStyles.H4);
                if (group.ordinal() < 2) {
                    reinfectionDetailsLeftLayout.addComponent(heading);
                } else {
                    reinfectionDetailsRightLayout.addComponent(heading);
                }
            }
            if (group.ordinal() < 2) {
                reinfectionDetailsLeftLayout.addComponent(reinfectionTree);
            } else {
                reinfectionDetailsRightLayout.addComponent(reinfectionTree);
            }
        }
        getContent().addComponent(reinfectionDetailsLeftLayout, REINFECTION_DETAILS_COL_1_LOC);
        getContent().addComponent(reinfectionDetailsRightLayout, REINFECTION_DETAILS_COL_2_LOC);
        reinfectionDetailsLeftLayout.setVisible(false);
        reinfectionDetailsRightLayout.setVisible(false);
        ogReinfection.addValueChangeListener(e -> {
            if (((NullableOptionGroup) e.getProperty()).getNullableValue() == YesNoUnknown.YES) {
                PreviousCaseDto previousCase = FacadeProvider.getCaseFacade().getMostRecentPreviousCase(getValue().getPerson(), getValue().getDisease(), CaseLogic.getStartDate(getValue()));
                if (previousCase != null) {
                    String reinfectionInfoTemplate = "<b>Previous case:</b><br/><br/>%s: %s<br/>%s: %s<br/>%s: %s<br/>%s: %s<br/>%s: %s";
                    String reinfectionInfo = String.format(reinfectionInfoTemplate, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, EntityDto.UUID), DataHelper.getShortUuid(previousCase.getUuid()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.REPORT_DATE), DateHelper.formatLocalDate(previousCase.getReportDate(), I18nProperties.getUserLanguage()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.EXTERNAL_TOKEN), DataHelper.toStringNullable(previousCase.getExternalToken()), I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.DISEASE_VARIANT), DataHelper.toStringNullable(previousCase.getDiseaseVariant()), I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, SymptomsDto.ONSET_DATE), previousCase.getOnsetDate() != null ? DateHelper.formatLocalDate(previousCase.getOnsetDate(), I18nProperties.getUserLanguage()) : "");
                    reinfectionInfoLabel.setDescription(reinfectionInfo, ContentMode.HTML);
                    reinfectionInfoLabel.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
                } else {
                    reinfectionInfoLabel.setDescription(null);
                    reinfectionInfoLabel.setVisible(false);
                }
                reinfectionDetailsLeftLayout.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
                reinfectionDetailsRightLayout.setVisible(isVisibleAllowed(CaseDataDto.RE_INFECTION));
            } else {
                reinfectionInfoLabel.setDescription(null);
                reinfectionInfoLabel.setVisible(false);
                for (CaseReinfectionCheckBoxTree reinfectionTree : reinfectionTrees.values()) {
                    reinfectionTree.clearCheckBoxTree();
                }
                reinfectionDetailsLeftLayout.setVisible(false);
                reinfectionDetailsRightLayout.setVisible(false);
            }
        });
    }
    addField(CaseDataDto.QUARANTINE_HOME_POSSIBLE, NullableOptionGroup.class);
    addField(CaseDataDto.QUARANTINE_HOME_POSSIBLE_COMMENT, TextField.class);
    addField(CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, NullableOptionGroup.class);
    addField(CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, TextField.class);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.QUARANTINE_FROM, CaseDataDto.QUARANTINE_TO, CaseDataDto.QUARANTINE_HELP_NEEDED), CaseDataDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    if (isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) || isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT), CaseDataDto.QUARANTINE, QuarantineType.QUARANTINE_IN_EFFECT, true);
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_POSSIBLE_COMMENT, CaseDataDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, CaseDataDto.QUARANTINE_HOME_POSSIBLE, Arrays.asList(YesNoUnknown.YES), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED_COMMENT, CaseDataDto.QUARANTINE_HOME_SUPPLY_ENSURED, Arrays.asList(YesNoUnknown.NO), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_TYPE_DETAILS, CaseDataDto.QUARANTINE, Arrays.asList(QuarantineType.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, CaseDataDto.QUARANTINE_ORDERED_VERBALLY, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, Arrays.asList(Boolean.TRUE), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, Collections.singletonList(Boolean.TRUE), true);
    ComboBox surveillanceOfficerField = addField(CaseDataDto.SURVEILLANCE_OFFICER, ComboBox.class);
    surveillanceOfficerField.setNullSelectionAllowed(true);
    differentPlaceOfStayJurisdiction = addCustomField(DIFFERENT_PLACE_OF_STAY_JURISDICTION, Boolean.class, CheckBox.class);
    differentPlaceOfStayJurisdiction.addStyleName(VSPACE_3);
    if (UserRole.getJurisdictionLevel(UserProvider.getCurrent().getUserRoles()) == JurisdictionLevel.HEALTH_FACILITY) {
        differentPlaceOfStayJurisdiction.setEnabled(false);
        differentPlaceOfStayJurisdiction.setVisible(false);
    }
    ComboBox regionCombo = addInfrastructureField(CaseDataDto.REGION);
    districtCombo = addInfrastructureField(CaseDataDto.DISTRICT);
    communityCombo = addInfrastructureField(CaseDataDto.COMMUNITY);
    communityCombo.setNullSelectionAllowed(true);
    communityCombo.addStyleName(SOFT_REQUIRED);
    FieldHelper.setVisibleWhen(differentPlaceOfStayJurisdiction, Arrays.asList(regionCombo, districtCombo, communityCombo), Collections.singletonList(Boolean.TRUE), true);
    FieldHelper.setRequiredWhen(differentPlaceOfStayJurisdiction, Arrays.asList(regionCombo, districtCombo), Collections.singletonList(Boolean.TRUE), false, null);
    Label placeOfStayHeadingLabel = new Label(I18nProperties.getCaption(Captions.casePlaceOfStay));
    placeOfStayHeadingLabel.addStyleName(H3);
    getContent().addComponent(placeOfStayHeadingLabel, PLACE_OF_STAY_HEADING_LOC);
    facilityOrHome = new OptionGroup(I18nProperties.getCaption(Captions.casePlaceOfStay), TypeOfPlace.FOR_CASES);
    facilityOrHome.setId("facilityOrHome");
    facilityOrHome.setWidth(100, Unit.PERCENTAGE);
    CssStyles.style(facilityOrHome, ValoTheme.OPTIONGROUP_HORIZONTAL);
    getContent().addComponent(facilityOrHome, FACILITY_OR_HOME_LOC);
    facilityTypeGroup = ComboBoxHelper.createComboBoxV7();
    facilityTypeGroup.setId("typeGroup");
    facilityTypeGroup.setCaption(I18nProperties.getCaption(Captions.Facility_typeGroup));
    facilityTypeGroup.setWidth(100, Unit.PERCENTAGE);
    facilityTypeGroup.addItems(FacilityTypeGroup.getAccomodationGroups());
    facilityTypeGroup.setVisible(false);
    getContent().addComponent(facilityTypeGroup, TYPE_GROUP_LOC);
    facilityTypeCombo = addField(CaseDataDto.FACILITY_TYPE);
    facilityCombo = addInfrastructureField(CaseDataDto.HEALTH_FACILITY);
    facilityCombo.setImmediate(true);
    facilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class);
    facilityDetails.setVisible(false);
    regionCombo.addValueChangeListener(e -> {
        RegionReferenceDto regionDto = (RegionReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(districtCombo, regionDto != null ? FacadeProvider.getDistrictFacade().getAllActiveByRegion(regionDto.getUuid()) : null);
    });
    districtCombo.addValueChangeListener(e -> {
        DistrictReferenceDto districtDto = (DistrictReferenceDto) e.getProperty().getValue();
        FieldHelper.updateItems(communityCombo, districtDto != null ? FacadeProvider.getCommunityFacade().getAllActiveByDistrict(districtDto.getUuid()) : null);
        updateFacility();
    });
    communityCombo.addValueChangeListener(e -> updateFacility());
    facilityOrHome.addValueChangeListener(e -> {
        FieldHelper.removeItems(facilityCombo);
        if (TypeOfPlace.FACILITY.equals(facilityOrHome.getValue())) {
            // default values
            if (facilityTypeGroup.getValue() == null && !facilityTypeGroup.isReadOnly()) {
                facilityTypeGroup.setValue(FacilityTypeGroup.MEDICAL_FACILITY);
            }
            if (facilityTypeCombo.getValue() == null && FacilityTypeGroup.MEDICAL_FACILITY.equals(facilityTypeGroup.getValue()) && !facilityTypeCombo.isReadOnly()) {
                facilityTypeCombo.setValue(FacilityType.HOSPITAL);
            }
            if (facilityTypeCombo.getValue() != null) {
                updateFacility();
            }
            if (CaseOrigin.IN_COUNTRY.equals(getField(CaseDataDto.CASE_ORIGIN).getValue())) {
                facilityCombo.setRequired(true);
            }
            updateFacilityDetails(facilityCombo, facilityDetails);
        } else {
            // switched from facility to home
            if (!facilityCombo.isReadOnly()) {
                FacilityReferenceDto noFacilityRef = FacadeProvider.getFacilityFacade().getByUuid(FacilityDto.NONE_FACILITY_UUID).toReference();
                facilityCombo.addItem(noFacilityRef);
                facilityCombo.setValue(noFacilityRef);
            }
            facilityTypeGroup.clear();
            facilityTypeCombo.clear();
        }
    });
    facilityTypeGroup.addValueChangeListener(e -> FieldHelper.updateEnumData(facilityTypeCombo, FacilityType.getAccommodationTypes((FacilityTypeGroup) facilityTypeGroup.getValue())));
    facilityTypeCombo.addValueChangeListener(e -> updateFacility());
    facilityCombo.addValueChangeListener(e -> updateFacilityDetails(facilityCombo, facilityDetails));
    regionCombo.addItems(FacadeProvider.getRegionFacade().getAllActiveByServerCountry());
    if (!FacadeProvider.getFeatureConfigurationFacade().isFeatureDisabled(FeatureType.NATIONAL_CASE_SHARING)) {
        addField(CaseDataDto.SHARED_TO_COUNTRY, CheckBox.class);
        setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_SHARE), CaseDataDto.SHARED_TO_COUNTRY);
    }
    ComboBox pointOfEntry = addInfrastructureField(CaseDataDto.POINT_OF_ENTRY);
    addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class);
    addField(CaseDataDto.PROHIBITION_TO_WORK, NullableOptionGroup.class).addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    DateField prohibitionToWorkFrom = addField(CaseDataDto.PROHIBITION_TO_WORK_FROM, DateField.class);
    DateField prohibitionToWorkUntil = addDateField(CaseDataDto.PROHIBITION_TO_WORK_UNTIL, DateField.class, -1);
    FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PROHIBITION_TO_WORK_FROM, CaseDataDto.PROHIBITION_TO_WORK_UNTIL), CaseDataDto.PROHIBITION_TO_WORK, YesNoUnknown.YES, true);
    prohibitionToWorkFrom.addValidator(new DateComparisonValidator(prohibitionToWorkFrom, prohibitionToWorkUntil, true, false, I18nProperties.getValidationError(Validations.beforeDate, prohibitionToWorkFrom.getCaption(), prohibitionToWorkUntil.getCaption())));
    prohibitionToWorkUntil.addValidator(new DateComparisonValidator(prohibitionToWorkUntil, prohibitionToWorkFrom, false, false, I18nProperties.getValidationError(Validations.afterDate, prohibitionToWorkUntil.getCaption(), prohibitionToWorkFrom.getCaption())));
    AccessibleTextField tfReportLat = addField(CaseDataDto.REPORT_LAT, AccessibleTextField.class);
    tfReportLat.setConverter(new StringToAngularLocationConverter());
    AccessibleTextField tfReportLon = addField(CaseDataDto.REPORT_LON, AccessibleTextField.class);
    tfReportLon.setConverter(new StringToAngularLocationConverter());
    addField(CaseDataDto.REPORT_LAT_LON_ACCURACY, TextField.class);
    dfFollowUpUntil = null;
    cbOverwriteFollowUpUntil = null;
    if (caseFollowUpEnabled) {
        addField(CaseDataDto.FOLLOW_UP_STATUS, ComboBox.class);
        addField(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE);
        addField(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER);
        addField(CaseDataDto.FOLLOW_UP_COMMENT, TextArea.class).setRows(3);
        dfFollowUpUntil = addDateField(CaseDataDto.FOLLOW_UP_UNTIL, DateField.class, -1);
        dfFollowUpUntil.addValueChangeListener(v -> onFollowUpUntilChanged());
        tfExpectedFollowUpUntilDate = new TextField();
        tfExpectedFollowUpUntilDate.setCaption(I18nProperties.getCaption(Captions.CaseData_expectedFollowUpUntil));
        getContent().addComponent(tfExpectedFollowUpUntilDate, EXPECTED_FOLLOW_UP_UNTIL_DATE_LOC);
        cbOverwriteFollowUpUntil = addField(ContactDto.OVERWRITE_FOLLOW_UP_UTIL, CheckBox.class);
        setReadOnly(true, CaseDataDto.FOLLOW_UP_STATUS, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER);
        FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.FOLLOW_UP_STATUS, Arrays.asList(CaseDataDto.FOLLOW_UP_COMMENT), Arrays.asList(FollowUpStatus.CANCELED, FollowUpStatus.LOST));
        FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.OVERWRITE_FOLLOW_UP_UNTIL, Arrays.asList(CaseDataDto.FOLLOW_UP_UNTIL), Arrays.asList(Boolean.TRUE));
        FieldHelper.setVisibleWhenSourceNotNull(getFieldGroup(), Arrays.asList(CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, CaseDataDto.FOLLOW_UP_STATUS_CHANGE_USER), CaseDataDto.FOLLOW_UP_STATUS_CHANGE_DATE, true);
    }
    if (cbOverwriteFollowUpUntil != null) {
        cbOverwriteFollowUpUntil.addValueChangeListener(e -> {
            if (!(Boolean) e.getProperty().getValue()) {
                dfFollowUpUntil.discard();
            }
        });
        FieldHelper.setReadOnlyWhen(getFieldGroup(), Arrays.asList(CaseDataDto.FOLLOW_UP_UNTIL), CaseDataDto.OVERWRITE_FOLLOW_UP_UNTIL, Arrays.asList(Boolean.FALSE), false, true);
    }
    dfQuarantineTo.addValueChangeListener(e -> onQuarantineEndChange());
    this.addValueChangeListener(e -> onValueChange());
    Label generalCommentLabel = new Label(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.ADDITIONAL_DETAILS));
    generalCommentLabel.addStyleName(H3);
    getContent().addComponent(generalCommentLabel, GENERAL_COMMENT_LOC);
    TextArea additionalDetails = addField(CaseDataDto.ADDITIONAL_DETAILS, TextArea.class);
    additionalDetails.setRows(6);
    additionalDetails.setDescription(I18nProperties.getPrefixDescription(CaseDataDto.I18N_PREFIX, CaseDataDto.ADDITIONAL_DETAILS, "") + "\n" + I18nProperties.getDescription(Descriptions.descGdpr));
    CssStyles.style(additionalDetails, CssStyles.CAPTION_HIDDEN);
    addField(CaseDataDto.PREGNANT, NullableOptionGroup.class);
    addField(CaseDataDto.POSTPARTUM, NullableOptionGroup.class);
    addField(CaseDataDto.TRIMESTER, NullableOptionGroup.class);
    addField(CaseDataDto.VACCINATION_STATUS);
    addFields(CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED);
    addDateField(CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE, DateField.class, 0);
    // Swiss fields
    AccessibleTextField caseIdIsmField = addField(CaseDataDto.CASE_ID_ISM, AccessibleTextField.class);
    caseIdIsmField.setConversionError(I18nProperties.getValidationError(Validations.onlyIntegerNumbersAllowed, caseIdIsmField.getCaption()));
    if (fieldVisibilityCheckers.isVisible(CaseDataDto.class, CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_TYPE)) {
        Label contactTracingFirstContactHeadingLabel = new Label(I18nProperties.getString(Strings.headingContactTracingFirstContact));
        contactTracingFirstContactHeadingLabel.addStyleName(H3);
        getContent().addComponent(contactTracingFirstContactHeadingLabel, CONTACT_TRACING_FIRST_CONTACT_HEADER_LOC);
        addFields(CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_TYPE, CaseDataDto.CONTACT_TRACING_FIRST_CONTACT_DATE);
    }
    addField(CaseDataDto.WAS_IN_QUARANTINE_BEFORE_ISOLATION).setStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
    addFields(CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION, CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION_DETAILS, CaseDataDto.QUARANTINE_REASON_BEFORE_ISOLATION, Arrays.asList(QuarantineReason.OTHER_REASON), true);
    addFields(CaseDataDto.END_OF_ISOLATION_REASON, CaseDataDto.END_OF_ISOLATION_REASON_DETAILS);
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.END_OF_ISOLATION_REASON_DETAILS, CaseDataDto.END_OF_ISOLATION_REASON, Arrays.asList(EndOfIsolationReason.OTHER), true);
    // jurisdiction fields
    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);
    responsibleDistrict = addInfrastructureField(CaseDataDto.RESPONSIBLE_DISTRICT);
    responsibleDistrict.setRequired(true);
    responsibleCommunity = addInfrastructureField(CaseDataDto.RESPONSIBLE_COMMUNITY);
    responsibleCommunity.setNullSelectionAllowed(true);
    responsibleCommunity.addStyleName(SOFT_REQUIRED);
    InfrastructureFieldsHelper.initInfrastructureFields(responsibleRegion, responsibleDistrict, responsibleCommunity);
    InfrastructureFieldsHelper.initPointOfEntry(responsibleDistrict, pointOfEntry);
    responsibleDistrict.addValueChangeListener(e -> {
        Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
        if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
            updateFacility();
        }
    });
    responsibleCommunity.addValueChangeListener((e) -> {
        Boolean differentPlaceOfStay = differentPlaceOfStayJurisdiction.getValue();
        if (differentPlaceOfStay == null || Boolean.FALSE.equals(differentPlaceOfStay)) {
            updateFacility();
        }
    });
    differentPlaceOfStayJurisdiction.addValueChangeListener(e -> {
        if (!ignoreDifferentPlaceOfStayJurisdiction) {
            updateFacility();
        }
    });
    // Set initial visibilities & accesses
    initializeVisibilitiesAndAllowedVisibilities();
    initializeAccessAndAllowedAccesses();
    // Set requirements that don't need visibility changes and read only status
    setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.OUTCOME, CaseDataDto.DISEASE);
    setSoftRequired(true, CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.PLAGUE_TYPE, CaseDataDto.SURVEILLANCE_OFFICER);
    if (isEditableAllowed(CaseDataDto.INVESTIGATED_DATE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.INVESTIGATED_DATE, CaseDataDto.INVESTIGATION_STATUS, Arrays.asList(InvestigationStatus.DONE, InvestigationStatus.DISCARDED), true);
    }
    setReadOnly(true, CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS, CaseDataDto.CASE_ORIGIN);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CHANGE_DISEASE), CaseDataDto.DISEASE);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_INVESTIGATE), CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.INVESTIGATED_DATE);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY), CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.OUTCOME, CaseDataDto.OUTCOME_DATE);
    setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_TRANSFER), CaseDataDto.RESPONSIBLE_REGION, CaseDataDto.RESPONSIBLE_DISTRICT, CaseDataDto.RESPONSIBLE_COMMUNITY, DIFFERENT_PLACE_OF_STAY_JURISDICTION, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY, FACILITY_OR_HOME_LOC, TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS);
    if (!isEditableAllowed(CaseDataDto.COMMUNITY)) {
        setEnabled(false, CaseDataDto.REGION, CaseDataDto.DISTRICT);
    }
    if (!isEditableAllowed(CaseDataDto.RESPONSIBLE_COMMUNITY)) {
        setEnabled(false, CaseDataDto.RESPONSIBLE_REGION, CaseDataDto.RESPONSIBLE_DISTRICT);
    }
    FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.TRIMESTER, CaseDataDto.PREGNANT, Arrays.asList(YesNoUnknown.YES), true);
    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 && isVisibleAllowed(CaseDataDto.DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    if (isVisibleAllowed(CaseDataDto.DISEASE_DETAILS)) {
        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));
    }
    if (isVisibleAllowed(CaseDataDto.PLAGUE_TYPE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true);
    }
    if (isVisibleAllowed(CaseDataDto.DENGUE_FEVER_TYPE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DENGUE_FEVER_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.DENGUE), true);
    }
    if (isVisibleAllowed(CaseDataDto.RABIES_TYPE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.RABIES_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.RABIES), true);
    }
    if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_SCAR)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE)) {
        if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED)) {
            FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_LAST_VACCINATION_DATE, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Collections.singletonList(YesNoUnknown.YES), true);
        }
    }
    if (isVisibleAllowed(CaseDataDto.OUTCOME_DATE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.OUTCOME_DATE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.DECEASED, CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
    }
    if (isVisibleAllowed(CaseDataDto.SEQUELAE)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true);
    }
    if (isVisibleAllowed(CaseDataDto.SEQUELAE_DETAILS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE_DETAILS, CaseDataDto.SEQUELAE, Arrays.asList(YesNoUnknown.YES), true);
    }
    if (isVisibleAllowed(CaseDataDto.NOTIFYING_CLINIC_DETAILS)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.NOTIFYING_CLINIC, Arrays.asList(HospitalWardType.OTHER), true);
    }
    FieldHelper.setVisibleWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityTypeCombo, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false);
    FieldHelper.setRequiredWhen(facilityOrHome, Arrays.asList(facilityTypeGroup, facilityTypeCombo, facilityCombo), Collections.singletonList(TypeOfPlace.FACILITY), false, null);
    // / CLINICIAN FIELDS
    if (isVisibleAllowed(CaseDataDto.CLINICIAN_NAME)) {
        FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL), CaseDataDto.FACILITY_TYPE, Arrays.asList(FacilityType.HOSPITAL, FacilityType.OTHER_MEDICAL_FACILITY), true);
    }
    // Other initializations
    if (disease == Disease.MONKEYPOX) {
        Image smallpoxVaccinationScarImg = new Image(null, new ThemeResource("img/smallpox-vaccination-scar.jpg"));
        style(smallpoxVaccinationScarImg, VSPACE_3);
        getContent().addComponent(smallpoxVaccinationScarImg, SMALLPOX_VACCINATION_SCAR_IMG);
        // Set up initial image visibility
        getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).getValue() == YesNoUnknown.YES);
        // Set up image visibility listener
        getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e -> getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(e.getProperty().getValue() == YesNoUnknown.YES));
    }
    List<String> medicalInformationFields = Arrays.asList(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION_STATUS, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED);
    addField(CaseDataDto.HEALTH_CONDITIONS, HealthConditionsForm.class).setCaption(null);
    for (String medicalInformationField : medicalInformationFields) {
        if (getFieldGroup().getField(medicalInformationField).isVisible()) {
            Label medicalInformationCaptionLabel = new Label(I18nProperties.getString(Strings.headingMedicalInformation));
            medicalInformationCaptionLabel.addStyleName(H3);
            getContent().addComponent(medicalInformationCaptionLabel, MEDICAL_INFORMATION_LOC);
            break;
        }
    }
    if (!shouldHidePaperFormDates()) {
        Label paperFormDatesLabel = new Label(I18nProperties.getString(Strings.headingPaperFormDates));
        paperFormDatesLabel.addStyleName(H3);
        getContent().addComponent(paperFormDatesLabel, PAPER_FORM_DATES_LOC);
    }
    // Automatic case classification rules button - invisible for other diseases
    DiseaseClassificationCriteriaDto diseaseClassificationCriteria = FacadeProvider.getCaseClassificationFacade().getByDisease(disease);
    if (diseaseClassificationExists()) {
        Button classificationRulesButton = ButtonHelper.createIconButton(Captions.info, VaadinIcons.INFO_CIRCLE, e -> ControllerProvider.getCaseController().openClassificationRulesPopup(diseaseClassificationCriteria), ValoTheme.BUTTON_PRIMARY, FORCE_CAPTION);
        getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC);
    }
    addField(CaseDataDto.DELETION_REASON);
    addField(CaseDataDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, CaseDataDto.DELETION_REASON, CaseDataDto.OTHER_DELETION_REASON);
    addValueChangeListener(e -> {
        diseaseField.addValueChangeListener(new DiseaseChangeListener(diseaseField, getValue().getDisease()));
        FieldHelper.updateOfficersField(surveillanceOfficerField, getValue(), UserRight.CASE_RESPONSIBLE);
        // Replace classification user if case has been automatically classified
        if (getValue().getClassificationDate() != null && getValue().getClassificationUser() == null) {
            getField(CaseDataDto.CLASSIFICATION_USER).setVisible(false);
            Label classifiedBySystemLabel = new Label(I18nProperties.getCaption(Captions.system));
            classifiedBySystemLabel.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLASSIFIED_BY));
            // ensure correct formatting
            GridLayout tempLayout = new GridLayout();
            tempLayout.addComponent(classifiedBySystemLabel);
            getContent().addComponent(tempLayout, CLASSIFIED_BY_SYSTEM_LOC);
        }
        updateFollowUpStatusComponents();
        setEpidNumberError(epidField, assignNewEpidNumberButton, epidNumberWarningLabel, getValue().getEpidNumber());
        epidField.addValueChangeListener(f -> {
            setEpidNumberError(epidField, assignNewEpidNumberButton, epidNumberWarningLabel, (String) f.getProperty().getValue());
        });
        ValidationUtils.initComponentErrorValidator(externalTokenField, getValue().getExternalToken(), Validations.duplicateExternalToken, externalTokenWarningLabel, (externalToken) -> FacadeProvider.getCaseFacade().doesExternalTokenExist(externalToken, getValue().getUuid()));
        updateFacilityOrHome();
        // Set health facility/point of entry visibility based on case origin
        if (getValue().getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY) {
            setVisible(true, CaseDataDto.POINT_OF_ENTRY);
            if (getValue().getPointOfEntry() != null) {
                setVisible(getValue().getPointOfEntry().isOtherPointOfEntry(), CaseDataDto.POINT_OF_ENTRY_DETAILS);
            }
            if (getValue().getHealthFacility() == null) {
                setVisible(false, DIFFERENT_PLACE_OF_STAY_JURISDICTION, CaseDataDto.COMMUNITY, FACILITY_OR_HOME_LOC, TYPE_GROUP_LOC, CaseDataDto.FACILITY_TYPE, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS);
                setReadOnly(true, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY);
            }
        } else {
            facilityOrHome.setRequired(true);
            setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS);
        }
        // take over the value that has been set based on access rights
        facilityTypeGroup.setReadOnly(facilityTypeCombo.isReadOnly());
        facilityOrHome.setReadOnly(facilityTypeCombo.isReadOnly());
        // Hide case origin from port health users
        if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) {
            setVisible(false, CaseDataDto.CASE_ORIGIN);
        }
        if (caseFollowUpEnabled) {
            // Add follow-up until validator
            List<SampleDto> samples = Collections.emptyList();
            if (UserProvider.getCurrent().hasAllUserRights(UserRight.SAMPLE_VIEW)) {
                samples = FacadeProvider.getSampleFacade().getByCaseUuids(Collections.singletonList(caseUuid));
            }
            FollowUpPeriodDto followUpPeriod = CaseLogic.getFollowUpStartDate(symptoms.getOnsetDate(), reportDate.getValue(), samples);
            Date minimumFollowUpUntilDate = FollowUpLogic.calculateFollowUpUntilDate(followUpPeriod, null, FacadeProvider.getVisitFacade().getVisitsByCase(new CaseReferenceDto(caseUuid)), FacadeProvider.getDiseaseConfigurationFacade().getCaseFollowUpDuration((Disease) diseaseField.getValue()), FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CASE_FOLLOWUP, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)).getFollowUpEndDate();
            if (FacadeProvider.getFeatureConfigurationFacade().isPropertyValueTrue(FeatureType.CASE_FOLLOWUP, FeatureTypeProperty.ALLOW_FREE_FOLLOW_UP_OVERWRITE)) {
                dfFollowUpUntil.addValueChangeListener(valueChangeEvent -> {
                    if (DateHelper.getEndOfDay(dfFollowUpUntil.getValue()).before(minimumFollowUpUntilDate)) {
                        dfFollowUpUntil.setComponentError(new ErrorMessage() {

                            @Override
                            public ErrorLevel getErrorLevel() {
                                return ErrorLevel.INFO;
                            }

                            @Override
                            public String getFormattedHtmlMessage() {
                                return I18nProperties.getValidationError(Validations.contactFollowUpUntilDateSoftValidation, I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.FOLLOW_UP_UNTIL));
                            }
                        });
                    }
                });
            } else {
                dfFollowUpUntil.addValidator(new DateRangeValidator(I18nProperties.getValidationError(Validations.contactFollowUpUntilDate), minimumFollowUpUntilDate, null, Resolution.DAY));
            }
        }
        // Overwrite visibility for quarantine fields
        if (!isConfiguredServer(CountryHelper.COUNTRY_CODE_GERMANY) && !isConfiguredServer(CountryHelper.COUNTRY_CODE_SWITZERLAND)) {
            setVisible(false, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT, CaseDataDto.QUARANTINE_ORDERED_OFFICIAL_DOCUMENT_DATE, CaseDataDto.QUARANTINE_ORDERED_VERBALLY, CaseDataDto.QUARANTINE_ORDERED_VERBALLY_DATE, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT, CaseDataDto.QUARANTINE_OFFICIAL_ORDER_SENT_DATE);
        }
        // Make external ID field read-only when SORMAS is connected to a SurvNet instance
        if (StringUtils.isNotEmpty(FacadeProvider.getConfigFacade().getExternalSurveillanceToolGatewayUrl())) {
            setEnabled(false, CaseDataDto.EXTERNAL_ID);
            ((TextField) getField(CaseDataDto.EXTERNAL_ID)).setInputPrompt(I18nProperties.getString(Strings.promptExternalIdExternalSurveillanceTool));
        }
        for (CaseReinfectionCheckBoxTree reinfectionTree : reinfectionTrees.values()) {
            reinfectionTree.initCheckboxes();
        }
    });
}
Also used : ThemeResource(com.vaadin.server.ThemeResource) FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) Arrays(java.util.Arrays) ConversionException(com.vaadin.v7.data.util.converter.Converter.ConversionException) ValidationUtils(de.symeda.sormas.ui.utils.ValidationUtils) ReinfectionDetailGroup(de.symeda.sormas.api.caze.ReinfectionDetailGroup) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) InfrastructureFieldsHelper(de.symeda.sormas.ui.utils.InfrastructureFieldsHelper) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) EntityDto(de.symeda.sormas.api.EntityDto) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Map(java.util.Map) ComboBoxHelper(de.symeda.sormas.ui.utils.ComboBoxHelper) QuarantineReason(de.symeda.sormas.api.caze.QuarantineReason) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) ValoTheme(com.vaadin.ui.themes.ValoTheme) Property(com.vaadin.v7.data.Property) EnumMap(java.util.EnumMap) Field(com.vaadin.v7.ui.Field) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) TextField(com.vaadin.v7.ui.TextField) Descriptions(de.symeda.sormas.api.i18n.Descriptions) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) LABEL_WHITE_SPACE_NORMAL(de.symeda.sormas.ui.utils.CssStyles.LABEL_WHITE_SPACE_NORMAL) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) OutbreakFieldVisibilityChecker(de.symeda.sormas.ui.utils.OutbreakFieldVisibilityChecker) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) OptionGroup(com.vaadin.v7.ui.OptionGroup) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) Image(com.vaadin.ui.Image) LayoutUtil.locCss(de.symeda.sormas.ui.utils.LayoutUtil.locCss) CountryHelper(de.symeda.sormas.api.CountryHelper) ERROR_COLOR_PRIMARY(de.symeda.sormas.ui.utils.CssStyles.ERROR_COLOR_PRIMARY) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) ContentMode(com.vaadin.shared.ui.ContentMode) CssStyles.style(de.symeda.sormas.ui.utils.CssStyles.style) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) Captions(de.symeda.sormas.api.i18n.Captions) ExtendedReduced(de.symeda.sormas.api.utils.ExtendedReduced) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) EndOfIsolationReason(de.symeda.sormas.api.caze.EndOfIsolationReason) TextArea(com.vaadin.v7.ui.TextArea) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) StringToAngularLocationConverter(de.symeda.sormas.ui.utils.StringToAngularLocationConverter) FollowUpLogic(de.symeda.sormas.api.followup.FollowUpLogic) CaseConfirmationBasis(de.symeda.sormas.api.caze.CaseConfirmationBasis) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto) FeatureType(de.symeda.sormas.api.feature.FeatureType) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) CheckBoxTree(de.symeda.sormas.ui.utils.CheckBoxTree) LAYOUT_COL_HIDE_INVSIBLE(de.symeda.sormas.ui.utils.CssStyles.LAYOUT_COL_HIDE_INVSIBLE) LayoutUtil.inlineLocs(de.symeda.sormas.ui.utils.LayoutUtil.inlineLocs) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) CountryFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.CountryFieldVisibilityChecker) Window(com.vaadin.ui.Window) LayoutUtil.locs(de.symeda.sormas.ui.utils.LayoutUtil.locs) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) VaadinIcons(com.vaadin.icons.VaadinIcons) UserRole(de.symeda.sormas.api.user.UserRole) GridLayout(com.vaadin.ui.GridLayout) FORCE_CAPTION(de.symeda.sormas.ui.utils.CssStyles.FORCE_CAPTION) UserProvider(de.symeda.sormas.ui.UserProvider) LayoutUtil.fluidRow(de.symeda.sormas.ui.utils.LayoutUtil.fluidRow) ConfirmationComponent(de.symeda.sormas.ui.utils.ConfirmationComponent) CloseListener(com.vaadin.ui.Window.CloseListener) ViewMode(de.symeda.sormas.ui.utils.ViewMode) ComboBox(com.vaadin.v7.ui.ComboBox) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) Collectors(java.util.stream.Collectors) 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) ContactDto(de.symeda.sormas.api.contact.ContactDto) CaseIdentificationSource(de.symeda.sormas.api.caze.CaseIdentificationSource) UserError(com.vaadin.server.UserError) AbstractSelect(com.vaadin.v7.ui.AbstractSelect) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) LayoutUtil.fluidRowLocsCss(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocsCss) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) HospitalWardType(de.symeda.sormas.api.caze.HospitalWardType) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) ReinfectionDetail(de.symeda.sormas.api.caze.ReinfectionDetail) QuarantineType(de.symeda.sormas.api.contact.QuarantineType) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) CollectionUtils(org.apache.commons.collections.CollectionUtils) Resolution(com.vaadin.v7.shared.ui.datefield.Resolution) PreviousCaseDto(de.symeda.sormas.api.caze.PreviousCaseDto) Label(com.vaadin.ui.Label) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) DateField(com.vaadin.v7.ui.DateField) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) Validations(de.symeda.sormas.api.i18n.Validations) CaseReinfectionCheckBoxTree(de.symeda.sormas.ui.caze.surveillancereport.CaseReinfectionCheckBoxTree) UserRightFieldVisibilityChecker(de.symeda.sormas.api.utils.fieldvisibility.checkers.UserRightFieldVisibilityChecker) ErrorMessage(com.vaadin.server.ErrorMessage) SOFT_REQUIRED(de.symeda.sormas.ui.utils.CssStyles.SOFT_REQUIRED) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) LayoutUtil.fluidColumnLocCss(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumnLocCss) LayoutUtil.fluidColumn(de.symeda.sormas.ui.utils.LayoutUtil.fluidColumn) Strings(de.symeda.sormas.api.i18n.Strings) Collections(java.util.Collections) Disease(de.symeda.sormas.api.Disease) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label) CaseConfirmationBasis(de.symeda.sormas.api.caze.CaseConfirmationBasis) Image(com.vaadin.ui.Image) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) GridLayout(com.vaadin.ui.GridLayout) OptionGroup(com.vaadin.v7.ui.OptionGroup) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) HealthConditionsForm(de.symeda.sormas.ui.clinicalcourse.HealthConditionsForm) Button(com.vaadin.ui.Button) DateRangeValidator(com.vaadin.v7.data.validator.DateRangeValidator) StringToAngularLocationConverter(de.symeda.sormas.ui.utils.StringToAngularLocationConverter) AccessibleTextField(de.symeda.sormas.ui.location.AccessibleTextField) TextField(com.vaadin.v7.ui.TextField) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) List(java.util.List) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) ComboBox(com.vaadin.v7.ui.ComboBox) CaseReinfectionCheckBoxTree(de.symeda.sormas.ui.caze.surveillancereport.CaseReinfectionCheckBoxTree) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) ReinfectionDetailGroup(de.symeda.sormas.api.caze.ReinfectionDetailGroup) Date(java.util.Date) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CheckBox(com.vaadin.v7.ui.CheckBox) ThemeResource(com.vaadin.server.ThemeResource) ErrorLevel(com.vaadin.shared.ui.ErrorLevel) DateField(com.vaadin.v7.ui.DateField) ErrorMessage(com.vaadin.server.ErrorMessage) SampleDto(de.symeda.sormas.api.sample.SampleDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) PreviousCaseDto(de.symeda.sormas.api.caze.PreviousCaseDto)

Example 69 with TextArea

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

the class CampaignEditForm method addFields.

@Override
protected void addFields() {
    if (isCreateForm == null) {
        return;
    }
    Label campaignBasicHeadingLabel = new Label(I18nProperties.getString(Strings.headingCampaignBasics));
    campaignBasicHeadingLabel.addStyleName(H3);
    getContent().addComponent(campaignBasicHeadingLabel, CAMPAIGN_BASIC_HEADING_LOC);
    addField(CampaignDto.UUID, TextField.class);
    addField(CampaignDto.CREATING_USER);
    DateField startDate = addField(CampaignDto.START_DATE, DateField.class);
    startDate.removeAllValidators();
    DateField endDate = addField(CampaignDto.END_DATE, DateField.class);
    endDate.removeAllValidators();
    startDate.addValidator(new DateComparisonValidator(startDate, endDate, true, true, I18nProperties.getValidationError(Validations.beforeDate, startDate.getCaption(), endDate.getCaption())));
    endDate.addValidator(new DateComparisonValidator(endDate, startDate, false, true, I18nProperties.getValidationError(Validations.afterDate, endDate.getCaption(), startDate.getCaption())));
    addField(CampaignDto.NAME);
    TextArea description = addField(CampaignDto.DESCRIPTION, TextArea.class);
    description.setRows(6);
    setReadOnly(true, CampaignDto.UUID, CampaignDto.CREATING_USER);
    setVisible(!isCreateForm, CampaignDto.UUID, CampaignDto.CREATING_USER);
    setRequired(true, CampaignDto.UUID, CampaignDto.CREATING_USER, CampaignDto.START_DATE, CampaignDto.END_DATE, CampaignDto.NAME);
    FieldHelper.addSoftRequiredStyle(description);
    final HorizontalLayout usageLayout = new HorizontalLayout();
    usageLayout.setWidthFull();
    Label usageLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoUsageOfEditableCampaignGrids), ContentMode.HTML);
    usageLabel.setWidthFull();
    usageLayout.addComponent(usageLabel);
    usageLayout.setSpacing(true);
    usageLayout.setMargin(new MarginInfo(true, false, true, false));
    getContent().addComponent(usageLayout, USAGE_INFO);
    campaignFormsGridComponent = new CampaignFormsGridComponent(this.campaignDto == null ? Collections.EMPTY_LIST : new ArrayList<>(campaignDto.getCampaignFormMetas()), FacadeProvider.getCampaignFormMetaFacade().getAllCampaignFormMetasAsReferences());
    getContent().addComponent(campaignFormsGridComponent, CAMPAIGN_DATA_LOC);
    final List<CampaignDashboardElement> campaignDashboardElements = FacadeProvider.getCampaignFacade().getCampaignDashboardElements(null);
    campaignDashboardGridComponent = new CampaignDashboardElementsGridComponent(this.campaignDto == null ? Collections.EMPTY_LIST : FacadeProvider.getCampaignFacade().getCampaignDashboardElements(campaignDto.getUuid()), campaignDashboardElements);
    getContent().addComponent(campaignDashboardGridComponent, CAMPAIGN_DASHBOARD_LOC);
    final Label spacer = new Label();
    getContent().addComponent(spacer, SPACE_LOC);
    addField(CampaignDto.DELETION_REASON);
    addField(CampaignDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, CampaignDto.DELETION_REASON, CampaignDto.OTHER_DELETION_REASON);
}
Also used : CampaignDashboardElement(de.symeda.sormas.api.campaign.diagram.CampaignDashboardElement) TextArea(com.vaadin.v7.ui.TextArea) MarginInfo(com.vaadin.shared.ui.MarginInfo) Label(com.vaadin.ui.Label) DateField(com.vaadin.v7.ui.DateField) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 70 with TextArea

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

the class SmsComponent method initContent.

@Override
protected Component initContent() {
    final VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSpacing(false);
    mainLayout.setMargin(false);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(100, Unit.PERCENTAGE);
    if (missingPhoneNumbers > 0) {
        mainLayout.addComponent(new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + String.format(I18nProperties.getCaption(Captions.messagesNumberOfMissingPhoneNumbers), missingPhoneNumbers), ContentMode.HTML));
        mainLayout.addComponent(new Label());
    }
    mainLayout.addComponent(new Label(I18nProperties.getString(Strings.messageEnterSms)));
    final ResizableTextAreaWrapper<TextArea> resizableTextAreaWrapper = new ResizableTextAreaWrapper<>();
    smsTextArea = new TextArea();
    smsTextArea.setWidth(100, Unit.PERCENTAGE);
    smsTextArea.setRows(4);
    mainLayout.addComponent(resizableTextAreaWrapper.wrap(smsTextArea, Captions.messagesCharacters, false));
    final Label numberOfMessagesLabel = new Label(String.format(I18nProperties.getCaption(Captions.messagesNumberOfMessages), 0));
    numberOfMessagesLabel.addStyleNames(CssStyles.ALIGN_RIGHT, CssStyles.FIELD_EXTRA_INFO, CssStyles.LABEL_ITALIC);
    mainLayout.addComponent(numberOfMessagesLabel);
    mainLayout.setComponentAlignment(numberOfMessagesLabel, Alignment.BOTTOM_RIGHT);
    smsTextArea.addTextChangeListener(e -> setNumberOfMessagesLabel(numberOfMessagesLabel, e.getText().length()));
    smsTextArea.addValueChangeListener(e -> setNumberOfMessagesLabel(numberOfMessagesLabel, smsTextArea.getValue().length()));
    return mainLayout;
}
Also used : TextArea(com.vaadin.v7.ui.TextArea) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) ResizableTextAreaWrapper(de.symeda.sormas.ui.utils.ResizableTextAreaWrapper)

Aggregations

TextArea (com.codename1.ui.TextArea)60 Form (com.codename1.ui.Form)23 Component (com.codename1.ui.Component)21 Button (com.codename1.ui.Button)16 Label (com.codename1.ui.Label)16 TextArea (com.vaadin.v7.ui.TextArea)15 Container (com.codename1.ui.Container)13 BorderLayout (com.codename1.ui.layouts.BorderLayout)12 Label (com.vaadin.ui.Label)11 ComboBox (com.vaadin.v7.ui.ComboBox)10 TextField (com.codename1.ui.TextField)9 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)9 DateField (com.vaadin.v7.ui.DateField)8 TextField (com.vaadin.v7.ui.TextField)8 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)7 RadioButton (com.codename1.ui.RadioButton)6 Field (com.vaadin.v7.ui.Field)6 BoxLayout (com.codename1.ui.layouts.BoxLayout)5 Paint (android.graphics.Paint)4 CheckBox (com.codename1.ui.CheckBox)4