Exemplo n.º 1
0
  /**
   * 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 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);
  }
Exemplo n.º 2
0
 /** @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) {
         sb.appendEscaped(error.getMessage());
         sb.appendHtmlConstant("<br />");
       }
     }
     setErrorLabelText(sb.toSafeHtml().asString());
   } else {
     StyleHelper.removeStyle(decoratedWidget, ControlGroupType.ERROR);
     setErrorLabelText("");
   }
 }