}
private class OneOfProviderPropertyFactory implements PropertyFactory<OneOf.Provider> {
@Override
public Property create(final FieldMetadata<Object, ?> fieldMetadata, String id, OneOf.Provider info) {
UIDropdown dropdown = new UIDropdown();
OneOfProviderFactory factory = CoreRegistry.get(OneOfProviderFactory.class);
dropdown.bindOptions(factory.get(info.name()));
ItemRenderer<?> itemRenderer = factory.getItemRenderer(info.name());
if (itemRenderer != null) {
dropdown.setOptionRenderer(itemRenderer);
}
Binding binding = new Binding() {
@Override
public Object get() {
return fieldMetadata.getValueChecked(target);
}
@Override
public void set(Object value) {
fieldMetadata.setValue(target, value);
}
};
dropdown.bindSelection(binding);
String label = fromLabelOrId(info.label(), id);
return new Property<>(label, binding, dropdown, info.description());
}