@Test public void testShowErrors() throws Exception { EditorError e1 = mockEditorError(presenter, "m1"); EditorError e2 = mockEditorError(presenter, "m2"); List<EditorError> errors = new ArrayList<EditorError>(2); errors.add(e1); errors.add(e2); presenter.showErrors(errors); final ArgumentCaptor<SafeHtml> errorSafeHtmlCaptor = ArgumentCaptor.forClass(SafeHtml.class); verify(view, times(1)).showError(errorSafeHtmlCaptor.capture()); verify(view, times(0)).init(presenter); verify(view, times(0)).clearError(); verify(view, times(0)).setValue(anyString()); final SafeHtml value = errorSafeHtmlCaptor.getValue(); Assert.assertEquals("m1\nm2", value.asString()); }
@Override public void showErrors(List<EditorError> errors) { StringBuilder sb = new StringBuilder(); for (final EditorError error : errors) { if (error.getEditor() == this) { sb.append("\n").append(error.getMessage()); } } boolean hasErrors = sb.length() > 0; if (!hasErrors) { view.clearError(); return; } view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml()); }
ValueBoxEditor implements IsWidget, LeafAttributeEditor<T> { @Override public void showErrors(List<EditorError> errors) { StringBuilder sb = new StringBuilder(); for (final EditorError error : errors) { if (error.getEditor() == this) { sb.append("\n").append(error.getMessage()); } } boolean hasErrors = sb.length() > 0; if (!hasErrors) { view.clearError(); return; } view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml()); } }
ValueBoxEditor implements IsWidget, LeafAttributeEditor<T> { @Override public void showErrors(List<EditorError> errors) { StringBuilder sb = new StringBuilder(); for (final EditorError error : errors) { if (error.getEditor() == this) { sb.append("\n").append(error.getMessage()); } } boolean hasErrors = sb.length() > 0; if (!hasErrors) { view.clearError(); return; } view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml()); } @Inject  ValueBoxEditor(final View<T> view,
                          final Event<org.dashbuilder.common.client.event.ValueChangeEvent<T>> valueChangeEvent); }
ValueBoxEditor implements IsWidget, LeafAttributeEditor<T> { @Override public void showErrors(List<EditorError> errors) { StringBuilder sb = new StringBuilder(); for (final EditorError error : errors) { if (error.getEditor() == this) { sb.append("\n").append(error.getMessage()); } } boolean hasErrors = sb.length() > 0; if (!hasErrors) { view.clearError(); return; } view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml()); } @Inject  ValueBoxEditor(final View<T> view,
                          final Event<org.dashbuilder.common.client.event.ValueChangeEvent<T>> valueChangeEvent); @PostConstruct void init(); void addHelpContent(final String title, final String content, final Placement placement); @Override void showErrors(List<EditorError> errors); @Override Widget asWidget(); @Override void setValue(T value); @Override T getValue(); }
ValueBoxEditor implements IsWidget, LeafAttributeEditor<T> { @Override public void showErrors(List<EditorError> errors) { StringBuilder sb = new StringBuilder(); for (final EditorError error : errors) { if (error.getEditor() == this) { sb.append("\n").append(error.getMessage()); } } boolean hasErrors = sb.length() > 0; if (!hasErrors) { view.clearError(); return; } view.showError(new SafeHtmlBuilder().appendEscaped(sb.substring(1)).toSafeHtml()); } @Inject  ValueBoxEditor(final View<T> view,
                          final Event<org.dashbuilder.common.client.event.ValueChangeEvent<T>> valueChangeEvent); @PostConstruct void init(); void addHelpContent(final String title, final String content, final Placement placement); @Override void showErrors(List<EditorError> errors); @Override Widget asWidget(); @Override void setValue(T value); @Override T getValue(); public View<T> view; }