Search in sources :

Example 1 with Converter

use of com.vaadin.data.Converter in project cia by Hack23.

the class FormFactoryImpl method createDisplayPropertyConverters.

/**
 * Creates the display property converters.
 *
 * @param                     <T> the generic type
 * @param displayProperties   the display properties
 * @param formContent         the form content
 * @param binder              the binder
 * @param propertyDescriptors the property descriptors
 */
private static <T extends Serializable> void createDisplayPropertyConverters(final List<String> displayProperties, final ComponentContainer formContent, final Binder<T> binder, final PropertyDescriptor[] propertyDescriptors) {
    for (final String property : displayProperties) {
        final Class<?> typeOfProperty = getTypeOfProperty(propertyDescriptors, property);
        if (typeOfProperty != null) {
            final AbstractField<?> field = new TextField();
            field.setReadOnly(true);
            field.setCaption(property);
            field.setWidth(ContentSize.FULL_SIZE);
            formContent.addComponent(field);
            final Converter converter = getConverterForType(typeOfProperty);
            if (converter != null) {
                binder.forField(field).withConverter(converter).bind(property);
            } else {
                binder.forField(field).bind(property);
            }
        }
    }
}
Also used : TextField(com.vaadin.ui.TextField) StringToBooleanConverter(com.vaadin.data.converter.StringToBooleanConverter) Converter(com.vaadin.data.Converter) StringToDateConverter(com.vaadin.data.converter.StringToDateConverter) StringToBigIntegerConverter(com.vaadin.data.converter.StringToBigIntegerConverter) StringToLongConverter(com.vaadin.data.converter.StringToLongConverter) StringToBigDecimalConverter(com.vaadin.data.converter.StringToBigDecimalConverter) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter)

Example 2 with Converter

use of com.vaadin.data.Converter in project cia by Hack23.

the class FormFactoryImpl method createDisplayPropertyConverters.

/**
 * Creates the display property converters.
 *
 * @param <T>
 *            the generic type
 * @param displayProperties
 *            the display properties
 * @param formContent
 *            the form content
 * @param binder
 *            the binder
 * @param propertyDescriptors
 *            the property descriptors
 */
private static <T extends Serializable> void createDisplayPropertyConverters(final List<String> displayProperties, final FormLayout formContent, final Binder<T> binder, final PropertyDescriptor[] propertyDescriptors) {
    for (final String property : displayProperties) {
        final Class<?> typeOfProperty = getTypeOfProperty(propertyDescriptors, property);
        if (typeOfProperty != null) {
            final AbstractField<?> field = new TextField();
            field.setReadOnly(true);
            field.setCaption(property);
            field.setWidth(ContentSize.FULL_SIZE);
            formContent.addComponent(field);
            final Converter converter = getConverterForType(typeOfProperty);
            if (converter != null) {
                binder.forField(field).withConverter(converter).bind(property);
            } else if (String.class.equals(typeOfProperty)) {
                binder.forField(field).bind(property);
            } else {
                LOGGER.warn("No fieldtype for property: {}, type: {}", property, typeOfProperty);
            }
        }
    }
}
Also used : TextField(com.vaadin.ui.TextField) StringToBooleanConverter(com.vaadin.data.converter.StringToBooleanConverter) Converter(com.vaadin.data.Converter) StringToDateConverter(com.vaadin.data.converter.StringToDateConverter) StringToDoubleConverter(com.vaadin.data.converter.StringToDoubleConverter) StringToBigIntegerConverter(com.vaadin.data.converter.StringToBigIntegerConverter) StringToLongConverter(com.vaadin.data.converter.StringToLongConverter) StringToBigDecimalConverter(com.vaadin.data.converter.StringToBigDecimalConverter) StringToFloatConverter(com.vaadin.data.converter.StringToFloatConverter) StringToIntegerConverter(com.vaadin.data.converter.StringToIntegerConverter)

Aggregations

Converter (com.vaadin.data.Converter)2 StringToBigDecimalConverter (com.vaadin.data.converter.StringToBigDecimalConverter)2 StringToBigIntegerConverter (com.vaadin.data.converter.StringToBigIntegerConverter)2 StringToBooleanConverter (com.vaadin.data.converter.StringToBooleanConverter)2 StringToDateConverter (com.vaadin.data.converter.StringToDateConverter)2 StringToIntegerConverter (com.vaadin.data.converter.StringToIntegerConverter)2 StringToLongConverter (com.vaadin.data.converter.StringToLongConverter)2 TextField (com.vaadin.ui.TextField)2 StringToDoubleConverter (com.vaadin.data.converter.StringToDoubleConverter)1 StringToFloatConverter (com.vaadin.data.converter.StringToFloatConverter)1