Search in sources :

Example 36 with CheckBox

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

the class BulkContactDataForm method addFields.

@Override
protected void addFields() {
    if (!initialized) {
        return;
    }
    classificationCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkContactClassification));
    getContent().addComponent(classificationCheckBox, CLASSIFICATION_CHECKBOX);
    NullableOptionGroup contactClassification = addField(ContactBulkEditData.CONTACT_CLASSIFICATION, NullableOptionGroup.class);
    contactClassification.setEnabled(false);
    if (singleSelectedDistrict != null) {
        contactOfficerCheckBox = new CheckBox(I18nProperties.getCaption(Captions.bulkContactOfficer));
        getContent().addComponent(contactOfficerCheckBox, CONTACT_OFFICER_CHECKBOX);
        ComboBox contactOfficer = addField(ContactBulkEditData.CONTACT_OFFICER, ComboBox.class);
        contactOfficer.setEnabled(false);
        FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), contactOfficerCheckBox, Arrays.asList(ContactBulkEditData.CONTACT_OFFICER), Arrays.asList(true), null);
        Set<Disease> selectedDiseases = this.selectedContacts.stream().map(c -> c.getDisease()).collect(Collectors.toSet());
        List<UserReferenceDto> assignableContactOfficers = null;
        if (selectedDiseases.size() == 1) {
            Disease selectedDisease = selectedDiseases.iterator().next();
            assignableContactOfficers = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, selectedDisease, UserRight.CONTACT_RESPONSIBLE);
        } else {
            assignableContactOfficers = FacadeProvider.getUserFacade().getUserRefsByDistrict(singleSelectedDistrict, true, UserRight.CONTACT_RESPONSIBLE);
        }
        FieldHelper.updateItems(contactOfficer, assignableContactOfficers);
        contactOfficerCheckBox.addValueChangeListener(e -> {
            contactOfficer.setEnabled((boolean) e.getProperty().getValue());
        });
    }
    FieldHelper.setRequiredWhen(getFieldGroup(), classificationCheckBox, Arrays.asList(ContactBulkEditData.CONTACT_CLASSIFICATION), Arrays.asList(true));
    classificationCheckBox.addValueChangeListener(e -> {
        contactClassification.setEnabled((boolean) e.getProperty().getValue());
    });
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocsCss(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocsCss) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) Arrays(java.util.Arrays) CheckBox(com.vaadin.v7.ui.CheckBox) ComboBox(com.vaadin.v7.ui.ComboBox) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Collection(java.util.Collection) Set(java.util.Set) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) Collectors(java.util.stream.Collectors) Captions(de.symeda.sormas.api.i18n.Captions) ContactBulkEditData(de.symeda.sormas.api.contact.ContactBulkEditData) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) Disease(de.symeda.sormas.api.Disease) ContactIndexDto(de.symeda.sormas.api.contact.ContactIndexDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) VSPACE_4(de.symeda.sormas.ui.utils.CssStyles.VSPACE_4) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) Disease(de.symeda.sormas.api.Disease) CheckBox(com.vaadin.v7.ui.CheckBox) ComboBox(com.vaadin.v7.ui.ComboBox)

Example 37 with CheckBox

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

the class PathogenTestForm method addFields.

@Override
protected void addFields() {
    if (sample == null) {
        return;
    }
    pathogenTestHeadingLabel = new Label();
    pathogenTestHeadingLabel.addStyleName(H3);
    getContent().addComponent(pathogenTestHeadingLabel, PATHOGEN_TEST_HEADING_LOC);
    addDateField(PathogenTestDto.REPORT_DATE, DateField.class, 0);
    addField(PathogenTestDto.VIA_LIMS);
    addField(PathogenTestDto.EXTERNAL_ID);
    addField(PathogenTestDto.EXTERNAL_ORDER_ID);
    ComboBox testTypeField = addField(PathogenTestDto.TEST_TYPE, ComboBox.class);
    testTypeField.setItemCaptionMode(ItemCaptionMode.ID_TOSTRING);
    testTypeField.setImmediate(true);
    pcrTestSpecification = addField(PathogenTestDto.PCR_TEST_SPECIFICATION, ComboBox.class);
    testTypeTextField = addField(PathogenTestDto.TEST_TYPE_TEXT, TextField.class);
    FieldHelper.addSoftRequiredStyle(testTypeTextField);
    DateTimeField sampleTestDateField = addField(PathogenTestDto.TEST_DATE_TIME, DateTimeField.class);
    sampleTestDateField.addValidator(new DateComparisonValidator(sampleTestDateField, sample.getSampleDateTime(), false, false, I18nProperties.getValidationError(Validations.afterDateWithDate, sampleTestDateField.getCaption(), I18nProperties.getPrefixCaption(SampleDto.I18N_PREFIX, SampleDto.SAMPLE_DATE_TIME), DateFormatHelper.formatDate(sample.getSampleDateTime()))));
    ComboBox lab = addInfrastructureField(PathogenTestDto.LAB);
    lab.addItems(FacadeProvider.getFacilityFacade().getAllActiveLaboratories(true));
    TextField labDetails = addField(PathogenTestDto.LAB_DETAILS, TextField.class);
    labDetails.setVisible(false);
    typingIdField = addField(PathogenTestDto.TYPING_ID, TextField.class);
    typingIdField.setVisible(false);
    ComboBox diseaseField = addDiseaseField(PathogenTestDto.TESTED_DISEASE, true, create);
    ComboBox diseaseVariantField = addField(PathogenTestDto.TESTED_DISEASE_VARIANT, ComboBox.class);
    diseaseVariantField.setNullSelectionAllowed(true);
    addField(PathogenTestDto.TESTED_DISEASE_DETAILS, TextField.class);
    TextField diseaseVariantDetailsField = addField(PathogenTestDto.TESTED_DISEASE_VARIANT_DETAILS, TextField.class);
    diseaseVariantDetailsField.setVisible(false);
    ComboBox testResultField = addField(PathogenTestDto.TEST_RESULT, ComboBox.class);
    testResultField.removeItem(PathogenTestResultType.NOT_DONE);
    addField(PathogenTestDto.SEROTYPE, TextField.class);
    TextField cqValueField = addField(PathogenTestDto.CQ_VALUE, TextField.class);
    cqValueField.setConversionError(I18nProperties.getValidationError(Validations.onlyNumbersAllowed, cqValueField.getCaption()));
    NullableOptionGroup testResultVerifiedField = addField(PathogenTestDto.TEST_RESULT_VERIFIED, NullableOptionGroup.class);
    testResultVerifiedField.setRequired(true);
    CheckBox fourFoldIncrease = addField(PathogenTestDto.FOUR_FOLD_INCREASE_ANTIBODY_TITER, CheckBox.class);
    CssStyles.style(fourFoldIncrease, VSPACE_3, VSPACE_TOP_4);
    fourFoldIncrease.setVisible(false);
    fourFoldIncrease.setEnabled(false);
    addField(PathogenTestDto.TEST_RESULT_TEXT, TextArea.class).setRows(6);
    addField(PathogenTestDto.PRELIMINARY).addStyleName(CssStyles.VSPACE_4);
    addField(PathogenTestDto.DELETION_REASON);
    addField(PathogenTestDto.OTHER_DELETION_REASON, TextArea.class).setRows(3);
    setVisible(false, PathogenTestDto.DELETION_REASON, PathogenTestDto.OTHER_DELETION_REASON);
    initializeAccessAndAllowedAccesses();
    initializeVisibilitiesAndAllowedVisibilities();
    pcrTestSpecification.setVisible(false);
    Map<Object, List<Object>> pcrTestSpecificationVisibilityDependencies = new HashMap<Object, List<Object>>() {

        {
            put(PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.CORONAVIRUS));
            put(PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR));
        }
    };
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.PCR_TEST_SPECIFICATION, pcrTestSpecificationVisibilityDependencies, true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TEST_TYPE_TEXT, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TESTED_DISEASE_DETAILS, PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.OTHER), true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.TYPING_ID, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.PCR_RT_PCR, PathogenTestType.DNA_MICROARRAY, PathogenTestType.SEQUENCING), true);
    Map<Object, List<Object>> serotypeVisibilityDependencies = new HashMap<Object, List<Object>>() {

        private static final long serialVersionUID = 1967952323596082247L;

        {
            put(PathogenTestDto.TESTED_DISEASE, Arrays.asList(Disease.CSM));
            put(PathogenTestDto.TEST_RESULT, Arrays.asList(PathogenTestResultType.POSITIVE));
        }
    };
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.SEROTYPE, serotypeVisibilityDependencies, true);
    FieldHelper.setVisibleWhen(getFieldGroup(), PathogenTestDto.CQ_VALUE, PathogenTestDto.TEST_TYPE, Arrays.asList(PathogenTestType.CQ_VALUE_DETECTION), true);
    Consumer<Disease> updateDiseaseVariantField = disease -> {
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        diseaseVariantField.setVisible(disease != null && isVisibleAllowed(PathogenTestDto.TESTED_DISEASE_VARIANT) && CollectionUtils.isNotEmpty(diseaseVariants));
    };
    // trigger the update, as the disease may already be set
    updateDiseaseVariantField.accept((Disease) diseaseField.getValue());
    diseaseField.addValueChangeListener((ValueChangeListener) valueChangeEvent -> {
        Disease disease = (Disease) valueChangeEvent.getProperty().getValue();
        updateDiseaseVariantField.accept(disease);
        FieldHelper.updateItems(testTypeField, Arrays.asList(PathogenTestType.values()), FieldVisibilityCheckers.withDisease(disease), PathogenTestType.class);
    });
    diseaseVariantField.addValueChangeListener(e -> {
        DiseaseVariant diseaseVariant = (DiseaseVariant) e.getProperty().getValue();
        diseaseVariantDetailsField.setVisible(diseaseVariant != null && diseaseVariant.matchPropertyValue(DiseaseVariant.HAS_DETAILS, true));
    });
    testTypeField.addValueChangeListener(e -> {
        PathogenTestType testType = (PathogenTestType) e.getProperty().getValue();
        if (testType == PathogenTestType.IGM_SERUM_ANTIBODY || testType == PathogenTestType.IGG_SERUM_ANTIBODY) {
            fourFoldIncrease.setVisible(true);
            fourFoldIncrease.setEnabled(caseSampleCount >= 2);
        } else {
            fourFoldIncrease.setVisible(false);
            fourFoldIncrease.setEnabled(false);
        }
    });
    lab.addValueChangeListener(event -> {
        if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue()).getUuid().equals(FacilityDto.OTHER_FACILITY_UUID)) {
            labDetails.setVisible(true);
            labDetails.setRequired(true);
        } else {
            labDetails.setVisible(false);
            labDetails.setRequired(false);
            labDetails.clear();
        }
    });
    testTypeField.addValueChangeListener(e -> {
        PathogenTestType testType = (PathogenTestType) e.getProperty().getValue();
        if ((testType == PathogenTestType.PCR_RT_PCR && testResultField.getValue() == PathogenTestResultType.POSITIVE) || testType == PathogenTestType.CQ_VALUE_DETECTION) {
            cqValueField.setVisible(true);
        } else {
            cqValueField.setVisible(false);
            cqValueField.clear();
        }
    });
    testResultField.addValueChangeListener(e -> {
        PathogenTestResultType testResult = (PathogenTestResultType) e.getProperty().getValue();
        if ((testTypeField.getValue() == PathogenTestType.PCR_RT_PCR && testResult == PathogenTestResultType.POSITIVE) || testTypeField.getValue() == PathogenTestType.CQ_VALUE_DETECTION) {
            cqValueField.setVisible(true);
        } else {
            cqValueField.setVisible(false);
            cqValueField.clear();
        }
    });
    if (sample.getSamplePurpose() != SamplePurpose.INTERNAL) {
        // this only works for already saved samples
        setRequired(true, PathogenTestDto.LAB);
    }
    setRequired(true, PathogenTestDto.TEST_TYPE, PathogenTestDto.TESTED_DISEASE, PathogenTestDto.TEST_RESULT);
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) SamplePurpose(de.symeda.sormas.api.sample.SamplePurpose) AbstractEditForm(de.symeda.sormas.ui.utils.AbstractEditForm) H3(de.symeda.sormas.ui.utils.CssStyles.H3) Arrays(java.util.Arrays) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) CheckBox(com.vaadin.v7.ui.CheckBox) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) DateFormatHelper(de.symeda.sormas.ui.utils.DateFormatHelper) HashMap(java.util.HashMap) Converter(com.vaadin.v7.data.util.converter.Converter) CustomizableEnumType(de.symeda.sormas.api.customizableenum.CustomizableEnumType) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) LayoutUtil.loc(de.symeda.sormas.ui.utils.LayoutUtil.loc) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) Label(com.vaadin.ui.Label) VSPACE_3(de.symeda.sormas.ui.utils.CssStyles.VSPACE_3) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) LayoutUtil.fluidRowLocs(de.symeda.sormas.ui.utils.LayoutUtil.fluidRowLocs) DateField(com.vaadin.v7.ui.DateField) Validations(de.symeda.sormas.api.i18n.Validations) ComboBox(com.vaadin.v7.ui.ComboBox) FieldHelper(de.symeda.sormas.ui.utils.FieldHelper) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) ItemCaptionMode(com.vaadin.v7.ui.AbstractSelect.ItemCaptionMode) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Consumer(java.util.function.Consumer) List(java.util.List) Disease(de.symeda.sormas.api.Disease) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SampleDto(de.symeda.sormas.api.sample.SampleDto) TextArea(com.vaadin.v7.ui.TextArea) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) VSPACE_TOP_4(de.symeda.sormas.ui.utils.CssStyles.VSPACE_TOP_4) TextField(com.vaadin.v7.ui.TextField) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) TextArea(com.vaadin.v7.ui.TextArea) HashMap(java.util.HashMap) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) ComboBox(com.vaadin.v7.ui.ComboBox) Label(com.vaadin.ui.Label) DateTimeField(de.symeda.sormas.ui.utils.DateTimeField) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) DateComparisonValidator(de.symeda.sormas.ui.utils.DateComparisonValidator) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) CheckBox(com.vaadin.v7.ui.CheckBox) TextField(com.vaadin.v7.ui.TextField) List(java.util.List)

Example 38 with CheckBox

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

the class AbstractSampleForm method initializeRequestedTestFields.

protected void initializeRequestedTestFields() {
    // Information texts for users that can edit the requested tests
    Label requestedPathogenInfoLabel = new Label(I18nProperties.getString(Strings.infoSamplePathogenTesting));
    getContent().addComponent(requestedPathogenInfoLabel, PATHOGEN_TESTING_INFO_LOC);
    Label requestedAdditionalInfoLabel = new Label(I18nProperties.getString(Strings.infoSampleAdditionalTesting));
    getContent().addComponent(requestedAdditionalInfoLabel, ADDITIONAL_TESTING_INFO_LOC);
    // Yes/No fields for requesting pathogen/additional tests
    CheckBox pathogenTestingRequestedField = addField(SampleDto.PATHOGEN_TESTING_REQUESTED, CheckBox.class);
    pathogenTestingRequestedField.setWidthUndefined();
    pathogenTestingRequestedField.addValueChangeListener(e -> updateRequestedTestFields());
    CheckBox additionalTestingRequestedField = addField(SampleDto.ADDITIONAL_TESTING_REQUESTED, CheckBox.class);
    additionalTestingRequestedField.setWidthUndefined();
    additionalTestingRequestedField.addValueChangeListener(e -> updateRequestedTestFields());
    // CheckBox groups to select the requested pathogen/additional tests
    OptionGroup requestedPathogenTestsField = addField(SampleDto.REQUESTED_PATHOGEN_TESTS, OptionGroup.class);
    CssStyles.style(requestedPathogenTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL);
    requestedPathogenTestsField.setMultiSelect(true);
    requestedPathogenTestsField.addItems(Arrays.stream(PathogenTestType.values()).filter(c -> fieldVisibilityCheckers.isVisible(PathogenTestType.class, c.name())).collect(Collectors.toList()));
    requestedPathogenTestsField.removeItem(PathogenTestType.OTHER);
    requestedPathogenTestsField.setCaption(null);
    OptionGroup requestedAdditionalTestsField = addField(SampleDto.REQUESTED_ADDITIONAL_TESTS, OptionGroup.class);
    CssStyles.style(requestedAdditionalTestsField, CssStyles.OPTIONGROUP_CHECKBOXES_HORIZONTAL);
    requestedAdditionalTestsField.setMultiSelect(true);
    requestedAdditionalTestsField.addItems((Object[]) AdditionalTestType.values());
    requestedAdditionalTestsField.setCaption(null);
    // Text fields to type in other tests
    TextField requestedOtherPathogenTests = addField(SampleDto.REQUESTED_OTHER_PATHOGEN_TESTS, TextField.class);
    TextField requestedOtherAdditionalTests = addField(SampleDto.REQUESTED_OTHER_ADDITIONAL_TESTS, TextField.class);
    // header for read view
    Label pathogenTestsHeading = new Label(I18nProperties.getString(Strings.headingRequestedPathogenTests));
    CssStyles.style(pathogenTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, VSPACE_4);
    getContent().addComponent(pathogenTestsHeading, PATHOGEN_TESTING_READ_HEADLINE_LOC);
    Label additionalTestsHeading = new Label(I18nProperties.getString(Strings.headingRequestedAdditionalTests));
    CssStyles.style(additionalTestsHeading, CssStyles.LABEL_BOLD, CssStyles.LABEL_SECONDARY, VSPACE_4);
    getContent().addComponent(additionalTestsHeading, ADDITIONAL_TESTING_READ_HEADLINE_LOC);
    updateRequestedTestFields();
}
Also used : OptionGroup(com.vaadin.v7.ui.OptionGroup) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) TextField(com.vaadin.v7.ui.TextField) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType)

Example 39 with CheckBox

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

the class DashboardMapComponent method createFooter.

private HorizontalLayout createFooter() {
    HorizontalLayout mapFooterLayout = new HorizontalLayout();
    mapFooterLayout.setWidth(100, Unit.PERCENTAGE);
    mapFooterLayout.setSpacing(true);
    CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
    // Map key dropdown button
    legendDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapKey, null, CssStyles.BUTTON_SUBTLE);
    legendDropdown.setContent(createLegend());
    mapFooterLayout.addComponent(legendDropdown);
    mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT);
    mapFooterLayout.setExpandRatio(legendDropdown, 1);
    // Layers dropdown button
    VerticalLayout layersLayout = new VerticalLayout();
    {
        layersLayout.setMargin(true);
        layersLayout.setSpacing(false);
        layersLayout.setSizeUndefined();
        // Add check boxes and apply button
        {
            // case classifications
            OptionGroup caseClassificationOptions = new OptionGroup();
            caseClassificationOptions.addItems((Object[]) MapCaseClassificationOption.values());
            caseClassificationOptions.setValue(caseClassificationOption);
            caseClassificationOptions.addValueChangeListener(event -> {
                caseClassificationOption = (MapCaseClassificationOption) event.getProperty().getValue();
                refreshMap(true);
            });
            // Optiongroup to select what property the coordinates should be based on
            OptionGroup mapCaseDisplayModeSelect = new OptionGroup();
            mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE);
            mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values());
            mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
            mapCaseDisplayModeSelect.addValueChangeListener(event -> {
                mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue();
                refreshMap(true);
            });
            HorizontalLayout showCasesLayout = new HorizontalLayout();
            {
                showCasesLayout.setMargin(false);
                showCasesLayout.setSpacing(false);
                CheckBox showCasesCheckBox = new CheckBox();
                showCasesCheckBox.setId(Captions.dashboardShowCases);
                showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases));
                showCasesCheckBox.setValue(showCases);
                showCasesCheckBox.addValueChangeListener(e -> {
                    showCases = (boolean) e.getProperty().getValue();
                    mapCaseDisplayModeSelect.setEnabled(showCases);
                    mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
                    caseClassificationOptions.setEnabled(showCases);
                    refreshMap(true);
                });
                showCasesLayout.addComponent(showCasesCheckBox);
                Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap));
                CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                infoLabel.setHeightUndefined();
                showCasesLayout.addComponent(infoLabel);
                showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
            }
            layersLayout.addComponent(showCasesLayout);
            layersLayout.addComponent(mapCaseDisplayModeSelect);
            mapCaseDisplayModeSelect.setEnabled(showCases);
            layersLayout.addComponent(caseClassificationOptions);
            caseClassificationOptions.setEnabled(showCases);
            CheckBox showConfirmedContactsCheckBox = new CheckBox();
            showConfirmedContactsCheckBox.setId(Captions.dashboardShowConfirmedContacts);
            CheckBox showUnconfirmedContactsCheckBox = new CheckBox();
            showUnconfirmedContactsCheckBox.setId(Captions.dashboardShowUnconfirmedContacts);
            CheckBox showContactsCheckBox = new CheckBox();
            showContactsCheckBox.setId(Captions.dashboardShowContacts);
            showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts));
            showContactsCheckBox.setValue(showContacts);
            showContactsCheckBox.addValueChangeListener(e -> {
                showContacts = (boolean) e.getProperty().getValue();
                showConfirmedContactsCheckBox.setEnabled(showContacts);
                showConfirmedContactsCheckBox.setValue(true);
                showUnconfirmedContactsCheckBox.setEnabled(showContacts);
                showUnconfirmedContactsCheckBox.setValue(true);
                refreshMap(true);
            });
            layersLayout.addComponent(showContactsCheckBox);
            showConfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts));
            showConfirmedContactsCheckBox.setValue(showConfirmedContacts);
            showConfirmedContactsCheckBox.addValueChangeListener(e -> {
                showConfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showConfirmedContactsCheckBox);
            CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3);
            showUnconfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts));
            showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts);
            showUnconfirmedContactsCheckBox.addValueChangeListener(e -> {
                showUnconfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showUnconfirmedContactsCheckBox);
            showConfirmedContactsCheckBox.setEnabled(showContacts);
            showUnconfirmedContactsCheckBox.setEnabled(showContacts);
            CheckBox showEventsCheckBox = new CheckBox();
            showEventsCheckBox.setId(Captions.dashboardShowEvents);
            CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3);
            showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents));
            showEventsCheckBox.setValue(showEvents);
            showEventsCheckBox.addValueChangeListener(e -> {
                showEvents = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showEventsCheckBox);
            if (nonNull(UserProvider.getCurrent()) && UserProvider.getCurrent().hasNationJurisdictionLevel()) {
                OptionGroup regionMapVisualizationSelect = new OptionGroup();
                regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE);
                regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values());
                regionMapVisualizationSelect.setValue(caseMeasure);
                regionMapVisualizationSelect.addValueChangeListener(event -> {
                    caseMeasure = (CaseMeasure) event.getProperty().getValue();
                    refreshMap(true);
                });
                HorizontalLayout showRegionsLayout = new HorizontalLayout();
                {
                    showRegionsLayout.setMargin(false);
                    showRegionsLayout.setSpacing(false);
                    CheckBox showRegionsCheckBox = new CheckBox();
                    showRegionsCheckBox.setId(Captions.dashboardShowRegions);
                    showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions));
                    showRegionsCheckBox.setValue(showRegions);
                    showRegionsCheckBox.addValueChangeListener(e -> {
                        showRegions = (boolean) e.getProperty().getValue();
                        regionMapVisualizationSelect.setEnabled(showRegions);
                        regionMapVisualizationSelect.setValue(caseMeasure);
                        refreshMap(true);
                    });
                    showRegionsLayout.addComponent(showRegionsCheckBox);
                    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                    infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence));
                    CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                    infoLabel.setHeightUndefined();
                    showRegionsLayout.addComponent(infoLabel);
                    showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
                }
                layersLayout.addComponent(showRegionsLayout);
                layersLayout.addComponent(regionMapVisualizationSelect);
                regionMapVisualizationSelect.setEnabled(showRegions);
            }
            CheckBox hideOtherCountriesCheckBox = new CheckBox();
            hideOtherCountriesCheckBox.setId(Captions.dashboardHideOtherCountries);
            hideOtherCountriesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardHideOtherCountries));
            hideOtherCountriesCheckBox.setValue(hideOtherCountries);
            hideOtherCountriesCheckBox.addValueChangeListener(e -> {
                hideOtherCountries = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            CssStyles.style(hideOtherCountriesCheckBox, CssStyles.VSPACE_3);
            layersLayout.addComponent(hideOtherCountriesCheckBox);
            CheckBox showCurrentEpiSituationCB = new CheckBox();
            showCurrentEpiSituationCB.setId(Captions.dashboardMapShowEpiSituation);
            showCurrentEpiSituationCB.setCaption(I18nProperties.getCaption(Captions.dashboardMapShowEpiSituation));
            showCurrentEpiSituationCB.setValue(false);
            showCurrentEpiSituationCB.addValueChangeListener(e -> {
                showCurrentEpiSituation = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showCurrentEpiSituationCB);
        }
    }
    PopupButton layersDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapLayers, layersLayout, CssStyles.BUTTON_SUBTLE);
    mapFooterLayout.addComponent(layersDropdown);
    mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT);
    return mapFooterLayout;
}
Also used : Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) Window(com.vaadin.ui.Window) LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GeoShapeProvider(de.symeda.sormas.api.geo.GeoShapeProvider) BigDecimal(java.math.BigDecimal) CssStyles(de.symeda.sormas.ui.utils.CssStyles) GeoLatLon(de.symeda.sormas.api.geo.GeoLatLon) VaadinIcons(com.vaadin.icons.VaadinIcons) LeafletMap(de.symeda.sormas.ui.map.LeafletMap) LeafletMapUtil(de.symeda.sormas.ui.map.LeafletMapUtil) UserProvider(de.symeda.sormas.ui.UserProvider) RoundingMode(java.math.RoundingMode) ValoTheme(com.vaadin.ui.themes.ValoTheme) InfrastructureHelper(de.symeda.sormas.api.infrastructure.InfrastructureHelper) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) DashboardCssStyles(de.symeda.sormas.ui.dashboard.DashboardCssStyles) DashboardType(de.symeda.sormas.ui.dashboard.DashboardType) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) DashboardDataProvider(de.symeda.sormas.ui.dashboard.DashboardDataProvider) List(java.util.List) ExternalResource(com.vaadin.server.ExternalResource) AbstractComponent(com.vaadin.ui.AbstractComponent) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) Optional(java.util.Optional) Objects.nonNull(java.util.Objects.nonNull) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) CaseMeasure(de.symeda.sormas.api.CaseMeasure) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CssLayout(com.vaadin.ui.CssLayout) LeafletPolygon(de.symeda.sormas.ui.map.LeafletPolygon) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OptionGroup(com.vaadin.v7.ui.OptionGroup) Image(com.vaadin.ui.Image) Label(com.vaadin.ui.Label) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) Pair(de.symeda.sormas.api.utils.DataHelper.Pair) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) Captions(de.symeda.sormas.api.i18n.Captions) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Consumer(java.util.function.Consumer) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) OptionGroup(com.vaadin.v7.ui.OptionGroup) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 40 with CheckBox

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

the class SurveillanceDiseaseCarouselLayout method createCarouselMenuLayout.

private HorizontalLayout createCarouselMenuLayout() {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setMargin(false);
    CssStyles.style(layout, CssStyles.HSPACE_LEFT_2);
    CheckBox autoSlide = this.setupSlideShow();
    layout.addComponent(autoSlide);
    layout.setComponentAlignment(autoSlide, Alignment.MIDDLE_LEFT);
    carouselMenu = new SubMenu();
    for (Disease disease : diseases) {
        carouselMenu.addView(disease.getName(), disease.toShortString(), (e) -> {
            this.changeSelectedDisease(disease, true);
        });
    }
    if (diseases.size() > 0) {
        this.setActiveDisease(diseases.get(0), false);
    }
    layout.addComponent(carouselMenu);
    return layout;
}
Also used : Disease(de.symeda.sormas.api.Disease) CheckBox(com.vaadin.v7.ui.CheckBox) SubMenu(de.symeda.sormas.ui.SubMenu) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

CheckBox (com.vaadin.v7.ui.CheckBox)40 CheckBox (com.codename1.ui.CheckBox)18 Label (com.vaadin.ui.Label)15 ComboBox (com.vaadin.v7.ui.ComboBox)14 Button (com.codename1.ui.Button)12 TextField (com.vaadin.v7.ui.TextField)12 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)12 Form (com.codename1.ui.Form)11 Disease (de.symeda.sormas.api.Disease)11 Captions (de.symeda.sormas.api.i18n.Captions)11 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)11 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)11 List (java.util.List)11 Container (com.codename1.ui.Container)10 FacadeProvider (de.symeda.sormas.api.FacadeProvider)10 Strings (de.symeda.sormas.api.i18n.Strings)10 Label (com.codename1.ui.Label)9 TextField (com.codename1.ui.TextField)9 HorizontalLayout (com.vaadin.ui.HorizontalLayout)9 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)9