Example usage for com.vaadin.ui AbstractField focus

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

Introduction

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

Prototype

@Override
    public void focus() 

Source Link

Usage

From source file:org.abstractform.binding.vaadin.internal.VaadinBindingFormInstanceImpl.java

License:Apache License

@Override
public void refreshValidationSummary() {
    validationSummaryComponent.removeAllComponents();
    for (ValidationError error : validationErrosSummaryList) {
        if (error != null) {
            Component errorComponent = null;
            if (error.getFieldId() != null) {
                errorComponent = getComponentById(error.getFieldId());
            }//from  w  ww. ja  va2 s  .c  o m
            if (errorComponent != null) {
                HorizontalLayout layout = new HorizontalLayout();
                if (errorComponent instanceof AbstractField) {
                    final AbstractField component = (AbstractField) errorComponent;
                    Button but = new Button(errorComponent.getCaption());
                    but.setStyleName(BaseTheme.BUTTON_LINK);

                    but.addListener(new Button.ClickListener() {

                        private static final long serialVersionUID = -635674369175495232L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            component.focus();
                            if (component instanceof AbstractField) {
                                AbstractTextField field = (AbstractTextField) component;
                                field.selectAll();
                            }
                        }
                    });
                    layout.addComponent(but);
                } else {
                    layout.addComponent(new Label(errorComponent.getCaption()));
                }
                layout.addComponent(new Label(" : " + error.getMessage()));
                validationSummaryComponent.addComponent(layout);

            } else {
                validationSummaryComponent.addComponent(new Label(error.getMessage()));
            }
        }
    }

}