Example usage for com.vaadin.ui Component getLocale

List of usage examples for com.vaadin.ui Component getLocale

Introduction

In this page you can find the example usage for com.vaadin.ui Component getLocale.

Prototype

public Locale getLocale();

Source Link

Document

Gets the locale of the component.

Usage

From source file:com.jain.addon.web.table.JainItemDescriptionGenerator.java

License:Apache License

private String formatText(final Property<?> itemProperty, Component source, Object itemId, Object propertyId) {
    Object item = itemProperty.getValue();
    if (item != null) {
        StringBuilder content = null;

        if (item instanceof JNINamed) {
            String caption = ((JNINamed) item).getDisplayName();
            if (item.getClass().isEnum()) {
                I18NProvider provider = DefaultI18NResourceProvider.instance();
                String value = provider.getText(getLocale(), caption);
                if (caption.equals(value))
                    value = provider.getTitle(getLocale(), caption);
                content = new StringBuilder(value);
            } else {
                content = new StringBuilder(caption);
            }//w  w w  .j  av a  2s. c  o  m
        } else {
            content = new StringBuilder(item.toString());
        }

        if (content.length() > 25)
            return content.toString();
        return JainHelper.getPojoState(source.getLocale(), itemId, properties);
    }
    return null;
}

From source file:v7cr.vaadin.BSONFormFieldFactory.java

License:Open Source License

public Field createField(Item item, Object propertyId, Component uiContext) {

    Property prop = item.getItemProperty(propertyId);

    if (prop instanceof BSONProperty) {
        String caption = schema.getFieldCaption((String) propertyId, uiContext.getLocale());
        TextField text = new TextField(prop);
        if (caption != null) {
            text.setCaption(caption);//from   w  ww. ja v a2  s.  co  m
        }
        text.setNullRepresentation("");
        SchemaDefinition fSchema = schema.getFieldDefinition((String) propertyId);
        if (fSchema != null && fSchema.isRequired())
            text.setRequired(true);
        return text;
    }

    return null;
}