Example usage for com.vaadin.ui AbstractField setWidth

List of usage examples for com.vaadin.ui AbstractField setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractField setWidth.

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:info.magnolia.ui.form.field.factory.AbstractFieldFactory.java

License:Open Source License

@Override
public Field<T> createField() {
    if (locale == null) {
        if (uiContext instanceof SubAppContext) {
            final Locale authoringLocale = ((SubAppContext) uiContext).getAuthoringLocale();
            setLocale(authoringLocale == null ? i18NAuthoringSupport.getDefaultLocale(item) : authoringLocale);
        }/*from  w  w  w  .  j a v  a 2s. co m*/
    }

    if (field == null) {
        // Create the Vaadin field
        this.field = createFieldComponent();

        if (field instanceof AbstractField) {
            final AbstractField field = (AbstractField) this.field;
            if (definition.getConverterClass() != null) {
                Converter<?, ?> converter = initializeConverter(definition.getConverterClass());
                field.setConverter(converter);
            }
            field.setLocale(locale);
        }

        Property<?> property = initializeProperty();
        // Set the created property with the default value as field Property datasource.
        setPropertyDataSourceAndDefaultValue(property);

        if (StringUtils.isNotBlank(definition.getStyleName())) {
            this.field.addStyleName(definition.getStyleName());
        }

        field.setWidth(100, Unit.PERCENTAGE);

        setFieldCaption();
        setConstraints();

    }
    return this.field;
}