Search in sources :

Example 1 with ErrorMessage

use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.

the class ReportParameterTable method validateMe.

public void validateMe() {
    grid.setComponentError(null);
    setComponentErrorForValidateListener(null);
    grid.setComponentError(null);
    setComponentErrorForValidateListener(null);
    Collection<Long> ids = getSelectedIds();
    if (ids.size() == 0) {
        ErrorMessage error = new ErrorMessage() {

            private static final long serialVersionUID = -6437991860908562482L;

            @Override
            public ErrorLevel getErrorLevel() {
                return ErrorLevel.ERROR;
            }

            @Override
            public String getFormattedHtmlMessage() {
                return "You must select at least one " + caption;
            }
        };
        grid.setComponentError(error);
        setComponentErrorForValidateListener(error);
    }
}
Also used : ErrorMessage(com.vaadin.server.ErrorMessage)

Example 2 with ErrorMessage

use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.

the class TimePicker method buildUI.

protected void buildUI(String title) {
    field = new TextField();
    field.setWidth("125");
    field.setImmediate(true);
    displayTime.setImmediate(true);
    displayTime.addValidator(timeValidator);
    field.addValidator(timeValidator);
    field.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("deprecation")
        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            try {
                final Date parsedDate = parseDate((String) event.getProperty().getValue());
                if (parsedDate != null) {
                    dateTime.set(Calendar.HOUR_OF_DAY, parsedDate.getHours());
                    dateTime.set(Calendar.MINUTE, parsedDate.getMinutes());
                    isSet = true;
                    setNewValue();
                }
                TimePicker.this.valueChange(event);
                field.setComponentError(null);
            } catch (final InvalidValueException e) {
                field.setComponentError(new ErrorMessage() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public String getFormattedHtmlMessage() {
                        return e.getMessage();
                    }

                    @Override
                    public ErrorLevel getErrorLevel() {
                        return ErrorLevel.ERROR;
                    }
                });
            }
        }
    });
    this.title = title;
    CssLayout hl = new CssLayout();
    hl.addStyleName("v-component-group");
    hl.setWidth("100%");
    hl.setHeight("35");
    pickerButton = new Button();
    pickerButton.setIcon(FontAwesome.CLOCK_O);
    hl.addComponent(pickerButton);
    hl.addComponent(field);
    pickerButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            showPopupTimePicker();
        }
    });
    addComponent(hl);
}
Also used : ClickEvent(com.vaadin.ui.Button.ClickEvent) Date(java.util.Date) InvalidValueException(com.vaadin.data.Validator.InvalidValueException) CssLayout(com.vaadin.ui.CssLayout) NativeButton(com.vaadin.ui.NativeButton) Button(com.vaadin.ui.Button) TextField(com.vaadin.ui.TextField) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 3 with ErrorMessage

use of com.vaadin.server.ErrorMessage in project cuba by cuba-platform.

the class WebSearchField method createComponent.

@Override
protected void createComponent() {
    this.component = new CubaSearchSelect() {

        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null) {
                super.setPropertyDataSource(null);
            } else {
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
            }
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null) {
                handled = componentErrorHandler.handleError(componentError);
            }
            if (!handled) {
                super.setComponentError(componentError);
            }
        }
    };
    getSearchComponent().setFilterHandler(this::executeSearch);
}
Also used : CubaSearchSelect(com.haulmont.cuba.web.toolkit.ui.CubaSearchSelect) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property)

Example 4 with ErrorMessage

use of com.vaadin.server.ErrorMessage in project cuba by cuba-platform.

the class WebLookupField method createComponent.

protected void createComponent() {
    this.component = new CubaComboBox() {

        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null)
                super.setPropertyDataSource(null);
            else
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null)
                handled = componentErrorHandler.handleError(componentError);
            if (!handled)
                super.setComponentError(componentError);
        }
    };
}
Also used : CubaComboBox(com.haulmont.cuba.web.toolkit.ui.CubaComboBox) ErrorMessage(com.vaadin.server.ErrorMessage) Property(com.vaadin.data.Property)

Example 5 with ErrorMessage

use of com.vaadin.server.ErrorMessage in project VaadinUtils by rlsutton1.

the class ReportFilterUIBuilder method buildLayout.

@Override
public List<ExpanderComponent> buildLayout(Boolean hideDateFields) {
    List<ExpanderComponent> components = new LinkedList<ExpanderComponent>();
    boolean hasExpandingComponents = false;
    Accordion accordian = null;
    if (hasFilters()) {
        for (ReportParameter<?> rparam : rparams) {
            if (rparam.showFilter()) {
                // scheduler
                if (!hideDateFields || !rparam.isDateField()) {
                    if (rparam.shouldExpand()) {
                        if (accordian == null) {
                            accordian = new Accordion();
                            accordian.setSizeFull();
                        }
                        final Tab tab = accordian.addTab(rparam.getComponent(), rparam.getLabel(""));
                        rparam.addValidateListener(new ValidateListener() {

                            @Override
                            public void setComponentError(ErrorMessage componentError) {
                                tab.setComponentError(componentError);
                            }
                        });
                        rparam.validate();
                    } else {
                        components.add(new ExpanderComponent(rparam.getComponent(), rparam.shouldExpand()));
                    }
                }
            }
        }
    }
    if (accordian != null) {
        hasExpandingComponents = true;
        components.add(new ExpanderComponent(accordian, true));
    }
    if (!hasExpandingComponents) {
        // there are no expanding components, so add an empty expanding
        // component so the fields will group together at the top
        components.add(new ExpanderComponent(new VerticalLayout(), true));
    }
    // add 15px high layout to pack up the bottom of the layout, otherwise
    // on
    // some sets of filters the last component is hidden
    VerticalLayout spacer = new VerticalLayout();
    spacer.setHeight("15");
    components.add(new ExpanderComponent(spacer, false));
    return components;
}
Also used : Accordion(com.vaadin.ui.Accordion) Tab(com.vaadin.ui.TabSheet.Tab) VerticalLayout(com.vaadin.ui.VerticalLayout) ErrorMessage(com.vaadin.server.ErrorMessage) LinkedList(java.util.LinkedList)

Aggregations

ErrorMessage (com.vaadin.server.ErrorMessage)6 Property (com.vaadin.data.Property)3 InvalidValueException (com.vaadin.data.Validator.InvalidValueException)2 CubaComboBox (com.haulmont.cuba.web.toolkit.ui.CubaComboBox)1 CubaSearchSelect (com.haulmont.cuba.web.toolkit.ui.CubaSearchSelect)1 Accordion (com.vaadin.ui.Accordion)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 CssLayout (com.vaadin.ui.CssLayout)1 NativeButton (com.vaadin.ui.NativeButton)1 Tab (com.vaadin.ui.TabSheet.Tab)1 TextField (com.vaadin.ui.TextField)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1