@Override public String convertToPresentation(T value, Class<? extends String> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { return getProperty().present(value); }
@Override public String convertToPresentation(T value, ValueContext context) { return getProperty().present(value); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected String formatPropertyValue(Object rowId, Object colId, com.vaadin.data.Property<?> itemProperty) { if (colId instanceof Property) { return ((Property) colId).present(itemProperty.getValue()); } return super.formatPropertyValue(rowId, colId, itemProperty); }
/** * Constructor which uses given <code>property</code> for value presentation and configuration parameters source. * The {@link Property#present(Object)} method will be called when value presentation is required. * @param property The property to use (not null) */ public DefaultViewComponentBuilder(Property<T> property) { this(v -> property.present(v)); ObjectUtils.argumentNotNull(property, "Property must be not null"); label(property); }
@SuppressWarnings("unchecked") @Override protected Optional<ValueProvider<?, ?>> getDefaultPropertyPresenter(Property property) { if (property != null) { if (Component.class.isAssignableFrom(property.getType())) { return Optional.empty(); } if (FontIcon.class.isAssignableFrom(property.getType())) { return Optional.of(v -> ((FontIcon) v).getHtml()); } return Optional.of(v -> property.present(v)); } return super.getDefaultPropertyPresenter(property); }
/** * Present given <code>property</code> value, obtained from this PropertyBox, as a {@link String}, using current * {@link PropertyValuePresenterRegistry} if available as {@link Context} resource to obtain a suitable * {@link PropertyValuePresenter}, or default presenter {@link PropertyValuePresenterRegistry#getDefault()} * otherwise. * @param <T> Property type * @param property Property to present * @return String presentation of the given <code>value</code> * @throws PropertyNotFoundException Property is not present in box property set * @throws PropertyAccessException Failed to read property value (value type is not consistent with property type or * other internal errors) */ default <T> String present(Property<T> property) { ObjectUtils.argumentNotNull(property, "Property must be not null"); return property.present(getValue(property)); }
@Override public ViewComponentBuilder<T> forProperty(final com.holonplatform.core.property.Property<T> property) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().setStringConverter(v -> property.present(v)); return builder(); }
@Override public ViewComponentBuilder<T> forProperty(final com.holonplatform.core.property.Property<T> property) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().setStringConverter(v -> property.present(v)); return builder(); }
/** * Constructor. * @param selectionProperty The property to use to represent the selection value (not null) * @param itemConverter the item converter to use (not null) */ protected DefaultPropertySelectModeSingleSelectInputBuilder(Property<T> selectionProperty, ItemConverter<T, PropertyBox> itemConverter) { super(); ObjectUtils.argumentNotNull(selectionProperty, "Selection property must be not null"); this.selectionProperty = selectionProperty; this.builder = new DefaultItemSelectModeSingleSelectInputBuilder<>(selectionProperty.getType(), PropertyBox.class, itemConverter); this.builder.itemCaptionGenerator(item -> { if (item != null) { return selectionProperty.present(item.getValue(selectionProperty)); } return String.valueOf(item); }); if (itemConverter instanceof PropertyItemConverter) { this.propertyItemConverter = (PropertyItemConverter<T>) itemConverter; } }
/** * Constructor. * @param selectionProperty The property to use to represent the selection value (not null) * @param itemConverter The item converter to use (not null) */ protected DefaultPropertyOptionsModeMultiSelectInputBuilder(Property<T> selectionProperty, ItemConverter<T, PropertyBox> itemConverter) { super(); ObjectUtils.argumentNotNull(selectionProperty, "Selection property must be not null"); this.selectionProperty = selectionProperty; this.builder = new DefaultItemOptionsModeMultiSelectInputBuilder<>(selectionProperty.getType(), PropertyBox.class, itemConverter); this.builder.itemCaptionGenerator(item -> { if (item != null) { return selectionProperty.present(item.getValue(selectionProperty)); } return String.valueOf(item); }); if (itemConverter instanceof PropertyItemConverter) { this.propertyItemConverter = (PropertyItemConverter<T>) itemConverter; } }
/** * Constructor. * @param selectionProperty The property to use to represent the selection value (not null) * @param itemConverter The item converter to use (not null) */ protected DefaultPropertyOptionsModeSingleSelectInputBuilder(Property<T> selectionProperty, ItemConverter<T, PropertyBox> itemConverter) { super(); ObjectUtils.argumentNotNull(selectionProperty, "Selection property must be not null"); this.selectionProperty = selectionProperty; this.builder = new DefaultItemOptionsModeSingleSelectInputBuilder<>(selectionProperty.getType(), PropertyBox.class, itemConverter); this.builder.itemCaptionGenerator(item -> { if (item != null) { return selectionProperty.present(item.getValue(selectionProperty)); } return String.valueOf(item); }); if (itemConverter instanceof PropertyItemConverter) { this.propertyItemConverter = (PropertyItemConverter<T>) itemConverter; } }