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

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

Introduction

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

Prototype

Editor<?> getEditor();

Source Link

Document

Returns the Editor that holds the invalid value.

Usage

From source file:com.gafactory.core.client.ui.editors.BaseEditorView.java

License:Open Source License

@Override
public void showErrors(List<EditorError> errors) {

    for (FormGroup formGroup : groupMap.values()) {
        formGroup.setValidationState(ValidationState.SUCCESS);
    }/*from   w ww  .j a v  a  2s .c  o  m*/

    if (errors != null) {
        for (EditorError error : errors) {
            Editor<?> editor = error.getEditor();

            final FormGroup group = groupMap.get(editor);

            if (group != null) {
                group.setValidationState(ValidationState.ERROR);
            }
        }
    }
}

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  ww w  . j  a v  a  2 s  .  com
 *            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  av a2 s  .  co  m*/
 * @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 www  .  ja va  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());
        }/* w ww . j  a v a 2s  .  c om*/
    }

    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}.//from   w w w  .  ja va2  s .  co 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  w w  .j  a  v a2 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 showErrors(List<EditorError> errors) {
    for (EditorError error : errors) {
        assert error.getEditor() == this;
        // skip the error if sent by a field (this field)
        if (error.getUserData() == this) {
            continue;
        }//from   ww w.  j ava 2  s .  co  m
        error.setConsumed(true);
    }

    if (errors.size() > 0) {
        errorSupport.markInvalid(errors);
    } else {
        clearInvalid();
    }
}

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

License:sencha.com license

@Override
public void showErrors(List<EditorError> errors) {
    // all errors should apply to this element only

    for (EditorError error : errors) {
        assert error.getEditor() == this;
        // skip the error if sent by a field (this field)
        if (error.getUserData() == this) {
            continue;
        }/*from w w w .  jav  a  2 s .com*/
        error.setConsumed(true);
    }

    if (errors.size() > 0) {
        markInvalid(errors);
    } else {
        clearInvalid();
    }
}

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

License:Apache License

/**
 * Checks if a error belongs to this widget.
 *
 * @param perror editor error to check//  ww w.jav a2s . com
 * @return true if the error belongs to this widget
 */
protected boolean editorErrorMatches(final EditorError perror) {
    return perror != null && perror.getEditor() != null
            && (this.equals(perror.getEditor()) || perror.getEditor().equals(this.editor));
}