Example usage for com.google.gwt.editor.client EditorError getMessage

List of usage examples for com.google.gwt.editor.client EditorError getMessage

Introduction

In this page you can find the example usage for com.google.gwt.editor.client EditorError getMessage.

Prototype

String getMessage();

Source Link

Document

Returns a message associated with the error.

Usage

From source file:com.github.apetrelli.gwtintegration.editor.client.widget.LeafValueEditorDecorator.java

License:Apache License

/**
 * The default implementation will display, but not consume, received errors
 * whose {@link EditorError#getEditor() getEditor()} method returns the
 * Editor passed into {@link #setEditor}.
 *
 * @param errors/*from  w ww. j a  v  a 2  s . c  o m*/
 *            a List of {@link EditorError} instances
 */
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        Editor<?> errorEditor = error.getEditor();
        if (errorEditor.equals(this)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    if (sb.length() == 0) {
        errorLabel.setInnerText("");
        errorLabel.getStyle().setDisplay(Display.NONE);
        return;
    }

    errorLabel.setInnerText(sb.substring(1));
    errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
}

From source file:com.github.gwtbootstrap.client.ui.base.ValueBoxBase.java

License:Apache License

/**
 * /*from  w w  w  .  j a v  a2 s.  c om*/
 * @see com.google.gwt.editor.client.HasEditorErrors#showErrors(java.util.List)
 */
@Override
public void showErrors(List<EditorError> errors) {
    Widget decoratedWidget = controlGroup != null ? controlGroup : this;
    if (errors != null && !errors.isEmpty()) {
        StyleHelper.addStyle(decoratedWidget, ControlGroupType.ERROR);
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        for (EditorError error : errors) {
            if (error.getEditor() == this) {
                error.setConsumed(true);
                sb.appendEscaped(error.getMessage());
                sb.appendHtmlConstant("<br />");
            }
        }
        setErrorLabelText(sb.toSafeHtml().asString());
    } else {
        StyleHelper.removeStyle(decoratedWidget, ControlGroupType.ERROR);
        setErrorLabelText("");
    }
}

From source file:com.google.gerrit.client.admin.ValueEditor.java

License:Apache License

public void showErrors(List<EditorError> errors) {
    StringBuilder buf = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(editProxy)) {
            buf.append("\n");
            if (error.getUserData() instanceof ParseException) {
                buf.append(((ParseException) error.getUserData()).getMessage());
            } else {
                buf.append(error.getMessage());
            }//from w ww . java 2s.com
        }
    }

    if (0 < buf.length()) {
        errorLabel.setInnerText(buf.substring(1));
        errorLabel.getStyle().setDisplay(Display.BLOCK);
    } else {
        errorLabel.setInnerText("");
        errorLabel.getStyle().setDisplay(Display.NONE);
    }
}

From source file:com.google.gwt.sample.mobilewebapp.client.ui.EditorDecorator.java

License:Apache License

public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        Editor<?> errorEditor = error.getEditor();
        if (this.equals(errorEditor) || editor.equals(errorEditor)) {
            sb.append("\n").append(error.getMessage());
        }/*  ww  w.  j  a  v a  2s. c  o m*/
    }

    if (sb.length() == 0) {
        errorLabel.setInnerText("");
        errorLabel.getStyle().setDisplay(Display.NONE);
        return;
    }

    errorLabel.setInnerText(sb.substring(1));
    errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
}

From source file:com.google.gwt.sample.validation.client.widget.BetterValueBoxEditorDecorator.java

/**
 * The default implementation will display, but not consume, received errors
 * whose {@link EditorError#getEditor() getEditor()} method returns the Editor
 * passed into {@link #setEditor}.//  ww w.  j a  v  a2  s  . c o m
 * 
 * @param errors a List of {@link EditorError} instances
 */
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(editor)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    if (sb.length() == 0) {
        errorLabel.setInnerText("");
        errorLabel.getStyle().setDisplay(Display.NONE);
        return;
    }

    errorLabel.setInnerText(sb.substring(1));
    errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
}

From source file:com.googlecode.mgwt.ui.client.editor.MValueBoxEditorDecorator.java

License:Apache License

/**
 * The default implementation will display, but not consume, received errors
 * whose {@link EditorError#getEditor() getEditor()} method returns the Editor
 * passed into {@link #setEditor}.//from  w  ww  . j  a va2  s.c  o m
 *
 * @param errors
 *          a List of {@link EditorError} instances
 */
@Override
public void showErrors(List<EditorError> errors) {
    StringBuilder sb = new StringBuilder();
    for (EditorError error : errors) {
        if (error.getEditor().equals(editor)) {
            sb.append("\n").append(error.getMessage());
        }
    }

    if (sb.length() == 0) {
        errorLabel.setInnerText("");
        errorLabel.getStyle().setDisplay(Display.NONE);
        return;
    }

    errorLabel.setInnerText(sb.substring(1));
    errorLabel.getStyle().setDisplay(Display.INLINE_BLOCK);
}

From source file:com.sencha.gxt.widget.core.client.form.AdapterField.java

License:sencha.com license

@Override
public void flush() {
    if (delegate == null) {
        return;//from  w ww . j a va  2  s.  co m
    }
    if (forceInvalidText != null) {
        delegate.recordError(forceInvalidText, "", this);
    } else {
        validate();
        if (errors != null) {
            for (EditorError e : errors) {
                delegate.recordError(e.getMessage(), e.getValue(), this);
            }
        }
    }
}

From source file:com.sencha.gxt.widget.core.client.form.Field.java

License:sencha.com license

@Override
public void flush() {
    if (delegate == null) {
        return;//from  w  w w . j  a  v  a2 s.co  m
    }
    if (parseError != null) {
        delegate.recordError(parseError, "", this);
    } else if (forceInvalidText != null) {
        delegate.recordError(forceInvalidText, "", this);
    } else {
        validate();
        if (errors != null) {
            for (EditorError e : errors) {
                delegate.recordError(e.getMessage(), e.getValue(), this);
            }
        }
    }
}

From source file:de.knightsoftnet.validators.client.decorators.AbstractDecorator.java

License:Apache License

/**
 * The default implementation will display, but not consume, received errors whose
 * {@link EditorError#getEditor() getEditor()} method returns the Editor passed into
 * {@link #setEditor}.//from w w  w.  j a  v  a  2 s.  c  o  m
 *
 * @param errors a List of {@link EditorError} instances
 */
@Override
public void showErrors(final List<EditorError> errors) {
    final Set<String> messages = new HashSet<String>();
    for (final EditorError error : errors) {
        if (this.editorErrorMatches(error)) {
            messages.add(error.getMessage());
        }
    }
    if (messages.isEmpty()) {
        this.errorLabel.setText(StringUtils.EMPTY);
        this.errorLabel.getElement().getStyle().setDisplay(Display.NONE);
        if (this.contents.getWidget() != null) {
            this.contents.getWidget().removeStyleName(this.decoratorStyle.errorInputStyle());
            this.contents.getWidget().addStyleName(this.decoratorStyle.validInputStyle());
        }
    } else {
        if (this.contents.getWidget() != null) {
            this.contents.getWidget().removeStyleName(this.decoratorStyle.validInputStyle());
            this.contents.getWidget().addStyleName(this.decoratorStyle.errorInputStyle());
            if (this.focusOnError) {
                this.setFocus(true);
            }
        }
        final SafeHtmlBuilder sb = new SafeHtmlBuilder();
        for (final String message : messages) {
            sb.appendEscaped(message);
            sb.appendHtmlConstant("<br />");
        }
        this.errorLabel.setHTML(sb.toSafeHtml());
        this.errorLabel.getElement().getStyle().setDisplay(Display.TABLE);
    }
}

From source file:gwt.material.design.client.ui.MaterialValueBox.java

License:Apache License

public void showErrors(List<EditorError> errors) {
    if (errors == null || errors.isEmpty()) {
        setSuccess("");
    } else {//from  w  ww.j  ava2 s .co m
        StringBuilder sb = new StringBuilder();
        for (EditorError error : errors) {
            if (error.getEditor().equals(this)) {
                sb.append("\n").append(error.getMessage());
            }
        }

        if (sb.length() == 0) {
            setSuccess("");
            return;
        }
        setError(sb.substring(1));
    }
}