@Override public ValueSource<V> getValueSource() { return valueBinding != null ? valueBinding.getSource() : null; }
@Override public ValueSource<V> getValueSource() { return valueBinding != null ? valueBinding.getSource() : null; }
@Override public ValueSource<V> getValueSource() { return valueBinding != null ? valueBinding.getSource() : null; }
@Override protected Collection<V> convertToModel(Set<V> componentRawValue) throws ConversionException { if (valueBinding != null) { Class<?> targetType = valueBinding.getSource().getType(); if (List.class.isAssignableFrom(targetType)) { return new ArrayList<>(componentRawValue != null ? componentRawValue : Collections.emptyList()); } else if (Set.class.isAssignableFrom(targetType)) { return new LinkedHashSet<>(componentRawValue != null ? componentRawValue : Collections.emptySet()); } } return new LinkedHashSet<>(componentRawValue != null ? componentRawValue : Collections.emptySet()); }
@Override protected Collection<V> convertToModel(Set<V> componentRawValue) throws ConversionException { Stream<V> items = optionsBinding == null ? Stream.empty() : optionsBinding.getSource().getOptions().filter(componentRawValue::contains); if (valueBinding != null) { Class<?> targetType = valueBinding.getSource().getType(); if (List.class.isAssignableFrom(targetType)) { return items.collect(Collectors.toList()); } else if (Set.class.isAssignableFrom(targetType)) { return items.collect(Collectors.toCollection(LinkedHashSet::new)); } } return items.collect(Collectors.toCollection(LinkedHashSet::new)); }
protected String convertToPresentation(V modelValue) { if (formatter != null) { return formatter.apply(modelValue); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); MetaProperty metaProperty = entityValueSource.getMetaPropertyPath().getMetaProperty(); return metadataTools.format(modelValue, metaProperty); } return metadataTools.format(modelValue); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(I item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(V item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
protected String generateDefaultItemCaption(I item) { if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); return metadataTools.format(item, entityValueSource.getMetaPropertyPath().getMetaProperty()); } return metadataTools.format(item); }
@SuppressWarnings("unchecked") @Override protected V convertToModel(Object componentRawValue) { if (isMultiSelect()) { Set collectionValue = (Set) componentRawValue; List<I> itemIds = getCurrentItems(); Stream<I> selectedItemsStream = itemIds.stream() .filter(collectionValue::contains); if (valueBinding != null) { Class<V> targetType = valueBinding.getSource().getType(); if (List.class.isAssignableFrom(targetType)) { return (V) selectedItemsStream.collect(Collectors.toList()); } if (Set.class.isAssignableFrom(targetType)) { return (V) selectedItemsStream.collect(Collectors.toCollection(LinkedHashSet::new)); } } return (V) selectedItemsStream.collect(Collectors.toCollection(LinkedHashSet::new)); } return super.convertToModel(componentRawValue); }
@SuppressWarnings("unchecked") @Override protected V convertToModel(Object componentRawValue) { if (isMultiSelect()) { Set collectionValue = (Set) componentRawValue; List<I> itemIds = getCurrentItems(); Stream<I> selectedItemsStream = itemIds.stream() .filter(collectionValue::contains); if (valueBinding != null) { Class<V> targetType = valueBinding.getSource().getType(); if (List.class.isAssignableFrom(targetType)) { return (V) selectedItemsStream.collect(Collectors.toList()); } if (Set.class.isAssignableFrom(targetType)) { return (V) selectedItemsStream.collect(Collectors.toCollection(LinkedHashSet::new)); } } return (V) selectedItemsStream.collect(Collectors.toCollection(LinkedHashSet::new)); } return super.convertToModel(componentRawValue); }
@Override protected String convertToPresentation(V modelValue) throws ConversionException { // Vaadin TextField does not permit `null` value if (datatype != null) { return nullToEmpty(datatype.format(modelValue, locale)); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype(); return nullToEmpty(propertyDataType.format(modelValue)); } return nullToEmpty(super.convertToPresentation(modelValue)); }
@Override protected String convertToPresentation(V modelValue) throws ConversionException { Datatype<V> datatype = getDatatypeInternal(); // Vaadin TextField does not permit `null` value if (datatype != null) { return nullToEmpty(datatype.format(modelValue, locale)); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); Datatype<V> propertyDataType = entityValueSource.getMetaPropertyPath().getRange().asDatatype(); return nullToEmpty(propertyDataType.format(modelValue, locale)); } return nullToEmpty(super.convertToPresentation(modelValue)); }
@Override protected String convertToPresentation(V modelValue) throws ConversionException { if (datatype != null) { return nullToEmpty(datatype.format(modelValue, locale)); } if (valueBinding != null && valueBinding.getSource() instanceof EntityValueSource) { EntityValueSource entityValueSource = (EntityValueSource) valueBinding.getSource(); Range range = entityValueSource.getMetaPropertyPath().getRange(); if (range.isDatatype()) { Datatype<V> propertyDataType = range.asDatatype(); return nullToEmpty(propertyDataType.format(modelValue, locale)); } } return nullToEmpty(super.convertToPresentation(modelValue)); }