Package org.waveprotocol.wave.client.common.safehtml

Examples of org.waveprotocol.wave.client.common.safehtml.SafeHtmlBuilder


    }
  }

  @Override
  public SafeHtml getResult() {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    for (ResultProducingRenderHelper<? extends UiBuilder> h : helpers) {
      h.getResult().outputHtml(builder);
    }
    return builder.toSafeHtml();
  }
View Full Code Here


    void add(String name) {
      events.put(name, duration.elapsedMillis());
    }

    void dump(Element timeBox) {
      final SafeHtmlBuilder timeHtml = new SafeHtmlBuilder();
      timeHtml.appendHtmlConstant("<table cellpadding='0' cellspacing='0'>");
      events.each(new ProcV<Integer>() {
        @Override
        public void apply(String key, Integer value) {
          timeHtml.appendHtmlConstant("<tr><td>");
          timeHtml.appendEscaped(key);
          timeHtml.appendHtmlConstant(":</td><td>");
          timeHtml.appendEscaped("" + value);
          timeHtml.appendHtmlConstant("</td></tr>");
        }
      });
      timeHtml.appendHtmlConstant("</table>");
      timeBox.setInnerHTML(timeHtml.toSafeHtml().asString());

    }
View Full Code Here

    for (int i = 0; i < 100; i++) {
      String content = Integer.toString(i);
      collection.add(new SimpleUiBuilder(content));
      expected.append(content);
    }
    SafeHtmlBuilder output = new SafeHtmlBuilder();
    collection.outputHtml(output);
    assertEquals(expected.toString(), output.toSafeHtml().asString());
  }
View Full Code Here

  /**
   * Renders an HTML closure to HTML.
   */
  public static String render(HtmlClosure html) {
    SafeHtmlBuilder output = new SafeHtmlBuilder();
    html.outputHtml(output);
    return output.toSafeHtml().asString();
  }
View Full Code Here

   * Convert a string to safehtml string, only used for testing.
   *
   * @param str
   */
  public static SafeHtml toSafeHtml(String str) {
    return new SafeHtmlBuilder().appendPlainText(str).toSafeHtml();
  }
View Full Code Here

    self.removeClassName(css.selected());
  }

  @Override
  public void setAvatars(Iterable<Profile> profiles) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    for (Profile profile : profiles) {
      renderAvatar(html, profile);
    }
    avatars.setInnerHTML(html.toSafeHtml().asString());
  }
View Full Code Here

      time.addClassName(css.unread());
    }
  }

  private SafeHtml renderUnreadMessages(int unread, int total) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<span class='" + css.unreadCount() + "'>");
    html.appendHtmlConstant(String.valueOf(unread));
    html.appendHtmlConstant("</span>");
    html.appendHtmlConstant(" " + messages.of(total));
    return html.toSafeHtml();
  }
View Full Code Here

    html.appendHtmlConstant(" " + messages.of(total));
    return html.toSafeHtml();
  }

  private SafeHtml renderReadMessages(int total) {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant(String.valueOf(total));
    html.appendHtmlConstant(" " + messages.msgs());
    return html.toSafeHtml();
  }
View Full Code Here

      // Also, this code could potentially be put behind a runAsync boundary, to
      // save whatever dependencies it uses from the initial download.
      new Timer() {
        @Override
        public void run() {
          SafeHtmlBuilder stack = new SafeHtmlBuilder();

          Throwable error = t;
          while (error != null) {
            String token = String.valueOf((new Date()).getTime());
            stack.appendHtmlConstant("Token:  " + token + "<br> ");
            stack.appendEscaped(String.valueOf(error.getMessage())).appendHtmlConstant("<br>");
            for (StackTraceElement elt : error.getStackTrace()) {
              stack.appendHtmlConstant("  ")
                  .appendEscaped(maybe(elt.getClassName(), "??")).appendHtmlConstant(".") //
                  .appendEscaped(maybe(elt.getMethodName(), "??")).appendHtmlConstant(" (") //
                  .appendEscaped(maybe(elt.getFileName(), "??")).appendHtmlConstant(":") //
                  .appendEscaped(maybe(elt.getLineNumber(), "??")).appendHtmlConstant(")") //
                  .appendHtmlConstant("<br>");
            }
            error = error.getCause();
            if (error != null) {
              stack.appendHtmlConstant("Caused by: ");
            }
          }

          whenReady.use(stack.toSafeHtml());
        }
      }.schedule(1);
    }
View Full Code Here

  /** Turns a UiBuilder rendering into a DOM element. */
  private Element parseHtml(UiBuilder ui) {
    if (ui == null) {
      return null;
    }
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    ui.outputHtml(html);
    Element div = com.google.gwt.dom.client.Document.get().createDivElement();
    div.setInnerHTML(html.toSafeHtml().asString());
    Element ret = div.getFirstChildElement();
    // Detach, in order that this element looks free-floating (required by some
    // preconditions).
    ret.removeFromParent();
    return ret;
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.common.safehtml.SafeHtmlBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.