List of usage examples for com.vaadin.v7.ui ComboBox containsId
@Override public boolean containsId(Object itemId)
From source file:de.symeda.sormas.ui.utils.AbstractEditForm.java
License:Open Source License
/** * 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). *///from w ww .j av a 2 s . c om @SuppressWarnings("rawtypes") protected ComboBox addDiseaseField(String fieldId, boolean showNonPrimaryDiseases) { ComboBox field = addField(fieldId, ComboBox.class); if (showNonPrimaryDiseases) { addNonPrimaryDiseasesTo(field); } // Make sure that the ComboBox still contains a pre-selected inactive disease field.addValueChangeListener(e -> { Object value = e.getProperty().getValue(); if (value != null && !field.containsId(value)) { Item newItem = field.addItem(value); newItem.getItemProperty(SormasFieldGroupFieldFactory.CAPTION_PROPERTY_ID) .setValue(value.toString()); } }); return field; }