Example usage for com.vaadin.ui AbstractTextField addBlurListener

List of usage examples for com.vaadin.ui AbstractTextField addBlurListener

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractTextField addBlurListener.

Prototype

@Override
public Registration addBlurListener(BlurListener listener) 

Source Link

Document

Adds a BlurListener to this component, which gets fired when this component loses keyboard focus.

Usage

From source file:de.fatalix.bookery.view.admin.ServerSettingsLayout.java

License:Open Source License

private AbstractTextField[] generateFields() {
    fields = new ArrayList<>();
    for (SettingKey key : SettingKey.values()) {
        AbstractTextField field = new TextField(key.getName());
        field.setColumns(25);//from   w  w  w.  j  a  v a2  s.c om
        field.setId(key.getKey());
        field.addBlurListener(this);
        fields.add(field);
    }
    AbstractTextField[] result = new AbstractTextField[fields.size()];
    return fields.toArray(result);
}

From source file:info.magnolia.ui.workbench.tree.InplaceEditingFieldFactory.java

License:Open Source License

/**
 * For partial updates to work, we need to perform a dry run to attach the component to the table beforehand,
 * i.e. before it is actually requested at paint phase by the table.
 *///from  w  w w.  j  a  va  2  s . c  o m
private Field<?> createFieldAndRegister(Container container, Object itemId, Object propertyId) {

    Property<?> containerProperty = container.getContainerProperty(itemId, propertyId);
    // the previous call can return null, i.e. when clicking on an empty cell of a node row (i.e. /config/server and then the "value" cell)
    if (containerProperty == null) {
        return null;
    }

    Class<?> type = containerProperty.getType();
    Field<?> field = createFieldByPropertyType(type);
    if (field != null) {
        field.setCaption(DefaultFieldFactory.createCaptionByPropertyId(propertyId));
        field.setSizeFull();
    }

    // set TextField listeners
    if (field instanceof AbstractTextField) {
        final AbstractTextField tf = (AbstractTextField) field;
        tf.addBlurListener(fieldBlurListener);
        tf.focus();

        tf.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                final Object text = event.getProperty().getValue();
                if (text instanceof String) {
                    tf.selectAll();
                }
                tf.removeValueChangeListener(this);
            }
        });
    }
    return field;
}