|
32 | 32 |
|
33 | 33 | import java.util.Arrays; |
34 | 34 | import java.util.List; |
| 35 | +import java.util.Set; |
35 | 36 | import java.util.stream.Collectors; |
36 | 37 | import java.util.stream.Stream; |
37 | 38 |
|
|
50 | 51 | import com.vaadin.v7.ui.ComboBox; |
51 | 52 | import com.vaadin.v7.ui.DateField; |
52 | 53 | import com.vaadin.v7.ui.Field; |
53 | | -import com.vaadin.v7.ui.OptionGroup; |
54 | 54 | import com.vaadin.v7.ui.TextField; |
55 | 55 |
|
56 | 56 | import de.symeda.sormas.api.Disease; |
@@ -1037,27 +1037,35 @@ public Button createButtonSetClearedToSymptomState(String caption, SymptomState |
1037 | 1037 |
|
1038 | 1038 | Button button = ButtonHelper.createButton(caption, event -> { |
1039 | 1039 | for (Object symptomId : unconditionalSymptomFieldIds) { |
1040 | | - Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); |
1041 | | - if (symptom.isVisible() && symptom.getValue() == null) { |
1042 | | - symptom.setValue(symptomState); |
| 1040 | + Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId); |
| 1041 | + if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) { |
| 1042 | + Set<SymptomState> value = (Set<SymptomState>) symptom.getValue(); |
| 1043 | + value.add(symptomState); |
| 1044 | + symptom.setValue(value); |
1043 | 1045 | } |
1044 | 1046 | } |
1045 | 1047 | for (Object symptomId : conditionalBleedingSymptomFieldIds) { |
1046 | | - Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); |
1047 | | - if (symptom.isVisible() && symptom.getValue() == null) { |
1048 | | - symptom.setValue(symptomState); |
| 1048 | + Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId); |
| 1049 | + if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) { |
| 1050 | + Set<SymptomState> value = (Set<SymptomState>) symptom.getValue(); |
| 1051 | + value.add(symptomState); |
| 1052 | + symptom.setValue(value); |
1049 | 1053 | } |
1050 | 1054 | } |
1051 | 1055 | for (Object symptomId : lesionsFieldIds) { |
1052 | | - Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); |
1053 | | - if (symptom.isVisible() && symptom.getValue() == null) { |
1054 | | - symptom.setValue(symptomState); |
| 1056 | + Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId); |
| 1057 | + if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) { |
| 1058 | + Set<SymptomState> value = (Set<SymptomState>) symptom.getValue(); |
| 1059 | + value.add(symptomState); |
| 1060 | + symptom.setValue(value); |
1055 | 1061 | } |
1056 | 1062 | } |
1057 | 1063 | for (Object symptomId : monkeypoxImageFieldIds) { |
1058 | | - Field<SymptomState> symptom = (Field<SymptomState>) getFieldGroup().getField(symptomId); |
1059 | | - if (symptom.isVisible() && symptom.getValue() == null) { |
1060 | | - symptom.setValue(symptomState); |
| 1064 | + Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId); |
| 1065 | + if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) { |
| 1066 | + Set<SymptomState> value = (Set<SymptomState>) symptom.getValue(); |
| 1067 | + value.add(symptomState); |
| 1068 | + symptom.setValue(value); |
1061 | 1069 | } |
1062 | 1070 | } |
1063 | 1071 | }, ValoTheme.BUTTON_LINK); |
|
0 commit comments