Example usage for com.vaadin.v7.ui ComboBox removeItem

List of usage examples for com.vaadin.v7.ui ComboBox removeItem

Introduction

In this page you can find the example usage for com.vaadin.v7.ui ComboBox removeItem.

Prototype

@Override
    public boolean removeItem(Object itemId) throws UnsupportedOperationException 

Source Link

Usage

From source file:de.symeda.sormas.ui.symptoms.SymptomsForm.java

License:Open Source License

@SuppressWarnings("rawtypes")
private void addListenerForOnsetFields(ComboBox onsetSymptom, DateField onsetDateField) {
    List<String> allPropertyIds = Stream
            .concat(unconditionalSymptomFieldIds.stream(), conditionalBleedingSymptomFieldIds.stream())
            .collect(Collectors.toList());
    allPropertyIds.add(SymptomsDto.LESIONS_THAT_ITCH);

    for (Object sourcePropertyId : allPropertyIds) {
        Field sourceField = getFieldGroup().getField(sourcePropertyId);
        sourceField.addValueChangeListener(event -> {
            if (sourceField.getValue() == SymptomState.YES) {
                onsetSymptom.addItem(sourceField.getCaption());
                onsetDateField.setEnabled(true);
            } else {
                onsetSymptom.removeItem(sourceField.getCaption());
                onsetDateField.setEnabled(
                        isAnySymptomSetToYes(getFieldGroup(), allPropertyIds, Arrays.asList(SymptomState.YES)));
            }//from w ww. j ava2s  .co  m
            onsetSymptom.setEnabled(!onsetSymptom.getItemIds().isEmpty());
        });
    }
    onsetSymptom.setEnabled(false); // will be updated by listener if needed
    onsetDateField.setEnabled(false); // will be updated by listener if needed
}