private void extendOptionsIfNecessary() { // don't add null or empty string, only for list types if (!canExtendOptions()) { return; } // find the correct option SettingDto listValuesOption = getSettingByName(FORM_VALUES); // add the value if (listValuesOption != null) { if (listValuesOption.getValue() instanceof List) { // copy current values to avoid running into unmodifiable lists List listValues = new ArrayList((List) listValuesOption.getValue()); // for lists, we add all not included if (List.class.isAssignableFrom(value.getClass())) { for (Object objectFromValueList : (List) value) { if (!listValues.contains(objectFromValueList.toString())) { listValues.add(objectFromValueList); } } // a case for single select comboboxes, just add the value } else { if (!listValues.contains(value.toString())) { listValues.add(value); } } listValuesOption.setValue(listValues); } } }
private boolean isMultiSelect() { SettingDto setting = getSettingByName(MULTISELECT); return setting != null && Boolean.TRUE.equals(setting.getValue()); }