use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.SelectorFieldBaseDefinition in project kie-wb-common by kiegroup.
the class SelectorOptionsProvider method getSelectorData.
@Override
public SelectorData getSelectorData(FormRenderingContext context) {
SelectorData data = new SelectorData<>();
Map<Object, String> values = new HashMap<>();
Object selectedValue = null;
if (context.getModel() instanceof SelectorFieldBaseDefinition) {
SelectorFieldBaseDefinition selector = (SelectorFieldBaseDefinition) context.getModel();
selectedValue = selector.getDefaultValue();
List<SelectorOption> options = selector.getOptions();
options.forEach(option -> values.put(option.getValue(), option.getText()));
if (!values.containsKey(selectedValue)) {
selectedValue = null;
selector.setDefaultValue(null);
}
}
data.setValues(values);
data.setSelectedValue(selectedValue);
return data;
}
Aggregations