Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant.

Prototype

public SafeHtmlBuilder appendHtmlConstant(String html) 

Source Link

Document

Appends a compile-time-constant string, which will not be escaped.

Usage

From source file:org.rstudio.core.client.cellview.ImageButtonColumn.java

License:Open Source License

public ImageButtonColumn(final AbstractImagePrototype imagePrototype, final OperationWithInput<T> onClick,
        final String title) {
    super(new ButtonCell() {
        @Override/* w  w  w  . j a  v a2  s. c o  m*/
        public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
            if (value != null) {
                sb.appendHtmlConstant("<span title=\"" + title + "\" " + "style=\"cursor: pointer;\">");
                sb.appendHtmlConstant(imagePrototype.getHTML());
                sb.appendHtmlConstant("</span>");
            }
        }
    });

    setFieldUpdater(new FieldUpdater<T, String>() {
        public void update(int index, T object, String value) {
            if (value != null)
                onClick.execute(object);
        }
    });
}

From source file:org.rstudio.core.client.cellview.LinkColumn.java

License:Open Source License

public LinkColumn(final ListDataProvider<T> dataProvider, final OperationWithInput<T> onClicked,
        final boolean alwaysUnderline) {
    super(new ClickableTextCell() {

        // render anchor using custom styles. detect selection and
        // add selected style to invert text color
        @Override/*from   w w  w  .jav  a2 s.  c  o m*/
        protected void render(Context context, SafeHtml value, SafeHtmlBuilder sb) {
            if (value != null) {
                Styles styles = RESOURCES.styles();
                StringBuilder div = new StringBuilder();
                div.append("<div class=\"");
                div.append(styles.link() + " ");
                div.append(ThemeResources.INSTANCE.themeStyles().handCursor());
                if (alwaysUnderline)
                    div.append(" " + styles.linkUnderlined());
                div.append("\">");

                sb.appendHtmlConstant(div.toString());
                sb.append(value);
                sb.appendHtmlConstant("</div>");
            }
        }

        // click event which occurs on the actual package link div
        // results in showing help for that package
        @Override
        public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event,
                ValueUpdater<String> valueUpdater) {
            super.onBrowserEvent(context, parent, value, event, valueUpdater);
            if ("click".equals(event.getType())) {
                // verify that the click was on the package link
                JavaScriptObject evTarget = event.getEventTarget().cast();
                if (Element.is(evTarget)
                        && Element.as(evTarget).getClassName().startsWith(RESOURCES.styles().link())) {
                    int idx = context.getIndex();
                    if (idx >= 0 && idx < dataProvider.getList().size())
                        onClicked.execute(dataProvider.getList().get(idx));
                }
            }
        }
    });
}

From source file:org.rstudio.core.client.resources.ImageResource2x.java

License:Open Source License

public SafeHtml getSafeHtml() {
    if (html_ == null) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();

        sb.appendHtmlConstant("<img src=\"");
        sb.appendHtmlConstant(getSafeUri().asString());
        sb.appendHtmlConstant("\" width=\"");
        sb.appendHtmlConstant(new Integer(getWidth()).toString());
        sb.appendHtmlConstant("\" height=\"");
        sb.appendHtmlConstant(new Integer(getHeight()).toString());
        sb.appendHtmlConstant("\">");

        html_ = sb.toSafeHtml();/*from   w ww.  j a  v a  2 s.  c o  m*/
    }

    return html_;
}

From source file:org.rstudio.core.client.resources.ImageResourceUrl.java

License:Open Source License

public SafeHtml getSafeHtml() {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();

    sb.appendHtmlConstant("<img src=\"");
    sb.appendHtmlConstant(getSafeUri().asString());
    sb.appendHtmlConstant("\" width=\"");
    sb.appendHtmlConstant(new Integer(getWidth()).toString());
    sb.appendHtmlConstant("\" height=\"");
    sb.appendHtmlConstant(new Integer(getHeight()).toString());
    sb.appendHtmlConstant("\">");

    return sb.toSafeHtml();
}

From source file:org.rstudio.core.client.SafeHtmlUtil.java

License:Open Source License

public static void appendDiv(SafeHtmlBuilder sb, String style, String textContent) {
    sb.append(createOpenTag("div", "class", style));
    sb.appendEscaped(textContent);// ww w.  j  a va  2s . c om
    sb.appendHtmlConstant("</div>");
}

From source file:org.rstudio.core.client.SafeHtmlUtil.java

License:Open Source License

public static void appendDiv(SafeHtmlBuilder sb, String style, SafeHtml htmlContent) {
    sb.append(createOpenTag("div", "class", style));
    sb.append(htmlContent);//  w  w w. j a  va2 s. c  o m
    sb.appendHtmlConstant("</div>");
}

From source file:org.rstudio.core.client.SafeHtmlUtil.java

License:Open Source License

public static void appendSpan(SafeHtmlBuilder sb, String style, String textContent) {
    sb.append(SafeHtmlUtil.createOpenTag("span", "class", style));
    sb.appendEscaped(textContent);//from w w w .  ja  va  2 s  . co  m
    sb.appendHtmlConstant("</span>");
}

From source file:org.rstudio.core.client.SafeHtmlUtil.java

License:Open Source License

public static void appendSpan(SafeHtmlBuilder sb, String style, SafeHtml htmlContent) {
    sb.append(SafeHtmlUtil.createOpenTag("span", "class", style));
    sb.append(htmlContent);/* w w w  .  j  a v  a  2s. c  o m*/
    sb.appendHtmlConstant("</span>");
}

From source file:org.rstudio.core.client.SafeHtmlUtil.java

License:Open Source License

public static void appendImage(SafeHtmlBuilder sb, String style, ImageResource image) {
    sb.append(SafeHtmlUtil.createOpenTag("img", "class", style, "src", image.getSafeUri().asString()));
    sb.appendHtmlConstant("</img>");
}

From source file:org.rstudio.core.client.VirtualConsole.java

License:Open Source License

public SafeHtml toSafeHtml() {
    // convert to a plain-text string
    String plainText = toString();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    String lastClass = null;//from  w w  w .  j av  a  2  s. c  om
    int len = plainText.length();
    padCharClass(len);

    // iterate in lockstep over the plain-text string and character class
    // assignment list; emit the appropriate tags when switching classes
    for (int i = 0; i < len; i++) {
        if (!charClass.get(i).equals(lastClass)) {
            if (lastClass != null)
                sb.appendHtmlConstant("</span>");
            lastClass = charClass.get(i);
            if (lastClass != null)
                sb.appendHtmlConstant("<span class=\"" + lastClass + "\">");
        }
        sb.appendEscaped(plainText.substring(i, i + 1));
    }
    if (lastClass != null)
        sb.appendHtmlConstant("</span>");

    return sb.toSafeHtml();
}