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

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

Introduction

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

Prototype

public SafeHtmlBuilder append(SafeHtml html) 

Source Link

Document

Appends the contents of another SafeHtml object, without applying HTML-escaping to it.

Usage

From source file:org.rstudio.studio.client.workbench.views.output.find.model.FindResult.java

License:Open Source License

public final SafeHtml getLineHTML() {
    SafeHtmlBuilder out = new SafeHtmlBuilder();

    ArrayList<Integer> on = getMatchOns();
    ArrayList<Integer> off = getMatchOffs();
    ArrayList<Pair<Boolean, Integer>> parts = new ArrayList<Pair<Boolean, Integer>>();
    while (on.size() + off.size() > 0) {
        int onVal = on.size() == 0 ? Integer.MAX_VALUE : on.get(0);
        int offVal = off.size() == 0 ? Integer.MAX_VALUE : off.get(0);
        if (onVal <= offVal)
            parts.add(new Pair<Boolean, Integer>(true, on.remove(0)));
        else/*from   w  w  w . j  a v a2 s  .co  m*/
            parts.add(new Pair<Boolean, Integer>(false, off.remove(0)));
    }

    String line = getLineValue();

    // Use a counter to ensure tags are balanced.
    int openTags = 0;

    for (int i = 0; i < line.length(); i++) {
        while (parts.size() > 0 && parts.get(0).second == i) {
            if (parts.remove(0).first) {
                out.appendHtmlConstant("<strong>");
                openTags++;
            } else if (openTags > 0) {
                out.appendHtmlConstant("</strong>");
                openTags--;
            }
        }
        out.append(line.charAt(i));
    }

    while (openTags > 0) {
        openTags--;
        out.appendHtmlConstant("</strong>");
    }

    return out.toSafeHtml();
}

From source file:org.rstudio.studio.client.workbench.views.vcs.common.diff.LineActionButtonRenderer.java

License:Open Source License

public void render(SafeHtmlBuilder builder, String text, String action) {
    {/*  www  .  j a  v  a2s. co  m*/
        builder.append(SafeHtmlUtil.createOpenTag("div", "class",
                resources_.styles().button() + " " + ThemeStyles.INSTANCE.handCursor(), "data-action", action));
        {
            builder.append(SafeHtmlUtil.createOpenTag("div", "class", resources_.styles().left()));
            builder.appendHtmlConstant("<br/></div>");

            builder.append(SafeHtmlUtil.createOpenTag("div", "class", resources_.styles().center()));
            {
                builder.appendEscaped(text);
            }
            builder.appendHtmlConstant("</div>");

            builder.append(SafeHtmlUtil.createOpenTag("div", "class", resources_.styles().right()));
            builder.appendHtmlConstant("<br/></div>");
        }
        builder.appendHtmlConstant("</div>");
    }
}

From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitStatusRenderer.java

License:Open Source License

@Override
public SafeHtml render(String str) {
    if (str.length() != 2)
        return null;

    ImageResource indexImg = imgForStatus(str.charAt(0));
    ImageResource treeImg = imgForStatus(str.charAt(1));

    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status()
            + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">"));

    builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(indexImg).getHTML()));
    builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(treeImg).getHTML()));

    builder.appendHtmlConstant("</span>");

    return builder.toSafeHtml();
}

From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitStatusRenderer.java

License:Open Source License

@Override
public void render(String str, SafeHtmlBuilder builder) {
    SafeHtml safeHtml = render(str);//w  ww. ja v  a  2  s  .  co  m
    if (safeHtml != null)
        builder.append(safeHtml);
}

From source file:org.rstudio.studio.client.workbench.views.vcs.svn.SVNStatusRenderer.java

License:Open Source License

@Override
public SafeHtml render(String str) {
    if (str.length() != 1)
        return SafeHtmlUtils.fromString(str);

    ImageResource img = imgForStatus(str.charAt(0));

    if (img == null)
        return SafeHtmlUtils.fromString(str);

    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(SafeHtmlUtils.fromTrustedString("<span " + "class=\"" + ctRes_.cellTableStyle().status()
            + "\" " + "title=\"" + SafeHtmlUtils.htmlEscape(descForStatus(str)) + "\">"));

    builder.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(img).getHTML()));

    builder.appendHtmlConstant("</span>");

    return builder.toSafeHtml();
}

From source file:org.ssgwt.client.ui.datagrid.column.ActionColumn.SSActionCell.java

License:Apache License

/**
 * This will create a image with the url passed in by the constructor
 *
 * @author Alec Erasmus <alec.erasmus@a24group.com>
 * @since 03 June 2013/*from   w  w w . j  a v  a 2s.  c  o  m*/
 *
 * @param context -The context the cell is in
 * @param value - The value to be added in the cell but not the image thats going to be displayed
 * @param sb -The safe html builder.
 */
@Override
public void render(Context context, T value, SafeHtmlBuilder sb) {
    displayActionList = column.getActions(value);

    // Flag used to indicate the first item
    boolean firstItem = true;
    for (String action : displayActionList) {
        if (!actionList.contains(action)) {
            actionList.add(action);
        }

        if (firstItem) {
            sb.append(template.firstAction(action));
            firstItem = false;
        } else {
            sb.append(template.actionSeparator(this.spacerSize));
            sb.append(template.action(action, this.spacerSize));
        }
    }
}

From source file:org.ssgwt.client.ui.datagrid.column.ImageHoverColumn.SSHoverImageCell.java

License:Apache License

/**
 * This will create a image with the url passed in by the constructor and also on hover
 * of the image display a popup./*from w w  w.  j  a  va 2s  . c o m*/
 *
 * @author Alec Erasmus <alec.erasmus@a24group.com>
 * @since  31 May 2013
 *
 * @param context -The context the cell is in
 * @param value - The value of the object that will be displayed in the popup
 * @param sb -The safe html builder.
 */
@Override
public void render(Context context, T value, SafeHtmlBuilder sb) {

    image = this.column.getImage(value);
    image.getElement().setAttribute("name", CELL_IMAGE_NAME);

    sb.append(template.openContainerTag());
    sb.appendHtmlConstant(image.toString());
    sb.append(template.closeContainerTag());
}

From source file:org.ssgwt.client.ui.datagrid.FilterSortCell.java

License:Apache License

/**
 * The function that renders the content of the Cell
 */// www  .j  a  va  2s  .  co m
@Override
public void render(Context context, HeaderDetails value, SafeHtmlBuilder sb) {
    this.headerDetails = value;
    this.filterActive = headerDetails.filterWidget.isFilterActive();
    if (filterActive) {
        filterImage = new Image(resources.filterIconActive());
    } else {
        filterImage = new Image(resources.filterIconInactive());
    }
    if (value.filterWidget != null) {
        value.filterWidget.setParentHeader(this);
    }
    filterImage.getElement().setAttribute("name", "filterIcon");
    sb.append(template.openContainerTag());
    sb.append(template.openContainerTagWithPadding());
    sb.append(template.openInlineContainerTag());
    sb.appendHtmlConstant(filterImage.toString());
    sb.append(template.closeContainerTag());
    sb.append(template.header(value.label));
    sb.append(template.closeContainerTag());
    sb.append(template.closeContainerTag());
}

From source file:org.ssgwt.client.ui.datagrid.HelpCell.java

License:Apache License

/**
 * The function that renders the content of the Cell
 * /*from   www.  j  a va  2 s.co  m*/
 * @author Ruan Naude<ruan.naude@a24group.com>
 * @since 4 July 2012
 */
@Override
public void render(Context context, Widget value, SafeHtmlBuilder sb) {
    helpImage = new Image(resources.helpIconUp());
    this.helpWidget = value;

    sb.append(template.openContainerTag());
    sb.appendHtmlConstant(helpImage.toString());
    sb.append(template.closeContainerTag());
}