Search in sources :

Example 96 with ComboBox

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

the class SampleEditForm method fillPathogenTestResult.

public void fillPathogenTestResult() {
    ComboBox pathogenTestResultField = (ComboBox) getFieldGroup().getField(SampleDto.PATHOGEN_TEST_RESULT);
    boolean hasOnlyPendingPathogenTests = FacadeProvider.getPathogenTestFacade().getBySampleUuids(Collections.singletonList(getValue().getUuid())).stream().allMatch(pathogenTest -> pathogenTest.getTestResult() == PathogenTestResultType.PENDING);
    Collection<PathogenTestResultType> pathogenTestResultTypes;
    if (hasOnlyPendingPathogenTests) {
        pathogenTestResultTypes = Arrays.asList(PathogenTestResultType.values());
    } else {
        pathogenTestResultTypes = Arrays.stream(PathogenTestResultType.values()).filter(type -> type != PathogenTestResultType.NOT_DONE).collect(Collectors.toList());
    }
    FieldHelper.updateEnumData(pathogenTestResultField, pathogenTestResultTypes);
    if (pathogenTestResultField.getValue() == null) {
        pathogenTestResultField.setValue(PathogenTestResultType.PENDING);
    }
}
Also used : PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) ComboBox(com.vaadin.v7.ui.ComboBox)

Example 97 with ComboBox

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

the class AbstractEditForm method addDiseaseField.

/**
 * Adds the field to the form by using addField(fieldId, fieldType), but additionally sets up a ValueChangeListener
 * that makes sure the value that is about to be selected is added to the list of allowed values. This is intended
 * to be used for Disease fields that might contain a disease that is no longer active in the system and thus will
 * not be returned by DiseaseHelper.isActivePrimaryDisease(disease).
 *
 * @param showNonPrimaryDiseases
 *            Whether or not diseases that have been configured as non-primary should be included
 * @param setServerDiseaseAsDefault
 *            If only a single diseases is active on the server, set it as the default value
 */
@SuppressWarnings("unchecked")
protected ComboBox addDiseaseField(String fieldId, boolean showNonPrimaryDiseases, boolean setServerDiseaseAsDefault) {
    diseaseField = addField(fieldId, ComboBox.class);
    this.setServerDiseaseAsDefault = setServerDiseaseAsDefault;
    if (showNonPrimaryDiseases) {
        addNonPrimaryDiseasesTo(diseaseField);
    }
    if (setServerDiseaseAsDefault) {
        setDefaultDiseaseValue();
    }
    // Make sure that the ComboBox still contains a pre-selected inactive disease
    diseaseField.addValueChangeListener(e -> {
        Object value = e.getProperty().getValue();
        if (value != null && !diseaseField.containsId(value)) {
            Item newItem = diseaseField.addItem(value);
            newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID).setValue(value.toString());
        }
    });
    return diseaseField;
}
Also used : Item(com.vaadin.v7.data.Item) ComboBox(com.vaadin.v7.ui.ComboBox)

Example 98 with ComboBox

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

the class AbstractFilterForm method applyDistrictDependency.

protected void applyDistrictDependency(DistrictReferenceDto district, String communityFieldId) {
    final UserDto user = UserProvider.getCurrent().getUser();
    final ComboBox communityField = getField(communityFieldId);
    if (user.getDistrict() != null && user.getCommunity() == null) {
        FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(user.getDistrict().getUuid()));
        communityField.setEnabled(true);
    } else {
        if (district != null) {
            FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
            communityField.setEnabled(true);
        } else {
            communityField.setEnabled(false);
        }
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto)

Example 99 with ComboBox

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

the class AbstractFilterForm method applyRegionFilterDependency.

protected void applyRegionFilterDependency(RegionReferenceDto region, String districtFieldId) {
    final UserDto user = UserProvider.getCurrent().getUser();
    final ComboBox districtField = getField(districtFieldId);
    if (user.getRegion() != null && user.getDistrict() == null) {
        FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(user.getRegion().getUuid()));
        districtField.setEnabled(true);
    } else {
        if (region != null) {
            FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
            districtField.setEnabled(true);
        } else {
            districtField.setEnabled(false);
        }
    }
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto)

Example 100 with ComboBox

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

the class ComboBoxHelper method createComboBoxV7.

/**
 * Create a default V7 combobox which uses FilteringMode.CONTAINS
 */
public static ComboBox createComboBoxV7() {
    ComboBox cb = new ComboBox();
    cb.setFilteringMode(FilteringMode.CONTAINS);
    return cb;
}
Also used : ComboBox(com.vaadin.v7.ui.ComboBox)

Aggregations

ComboBox (com.vaadin.v7.ui.ComboBox)113 TextField (com.vaadin.v7.ui.TextField)43 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)31 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)28 Label (com.vaadin.ui.Label)24 Disease (de.symeda.sormas.api.Disease)24 TextArea (com.vaadin.v7.ui.TextArea)19 UserDto (de.symeda.sormas.api.user.UserDto)19 NullableOptionGroup (de.symeda.sormas.ui.utils.NullableOptionGroup)19 DateField (com.vaadin.v7.ui.DateField)18 List (java.util.List)18 CheckBox (com.vaadin.v7.ui.CheckBox)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)17 DateComparisonValidator (de.symeda.sormas.ui.utils.DateComparisonValidator)17 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)16 AbstractEditForm (de.symeda.sormas.ui.utils.AbstractEditForm)16 Field (com.vaadin.v7.ui.Field)15 FieldVisibilityCheckers (de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers)15 Captions (de.symeda.sormas.api.i18n.Captions)14