@Override public Property create( Object target, FieldMetadata<Object, ?> fieldMetadata, String id, OneOf.List info) { UIDropdown<String> dropdown = new UIDropdown<>(); dropdown.bindOptions(new DefaultBinding<>(Arrays.asList(info.items()))); Binding<String> binding = createTextBinding(target, (FieldMetadata<Object, String>) fieldMetadata); dropdown.bindSelection(binding); String label = fromLabelOrId(info.label(), id); return new Property<>(label, binding, dropdown, info.description()); }
@Override public Property create( Object target, final FieldMetadata<Object, ?> fieldMetadata, String id, OneOf.Enum info) { Class<?> cls = fieldMetadata.getType(); Object[] items = cls.getEnumConstants(); UIDropdown dropdown = new UIDropdown(); dropdown.bindOptions(new DefaultBinding(Arrays.asList(items))); Binding binding = createTextBinding(target, fieldMetadata); dropdown.bindSelection(binding); String label = fromLabelOrId(info.label(), id); return new Property<>(label, binding, dropdown, info.description()); }
@Override public Property create( Object target, final FieldMetadata<Object, ?> fieldMetadata, String id, OneOf.Provider info) { UIDropdown dropdown = new UIDropdown(); OneOfProviderFactory factory = CoreRegistry.get(OneOfProviderFactory.class); Binding<?> listBinding = factory.get(info.name()); if (listBinding != null) { dropdown.bindOptions(listBinding); } ItemRenderer<?> itemRenderer = factory.getItemRenderer(info.name()); if (itemRenderer != null) { dropdown.setOptionRenderer(itemRenderer); } Binding binding = createTextBinding(target, fieldMetadata); dropdown.bindSelection(binding); String label = fromLabelOrId(info.label(), id); return new Property<>(label, binding, dropdown, info.description()); }