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:com.chinarewards.gwt.elt.client.widget.SortableHeader.java

License:Apache License

private void renderUnsortedHtml(int imageWidth, String text, SafeHtmlBuilder sb) {

    sb.appendHtmlConstant("<div style=\"position:relative;cursor:hand;cursor:pointer;" + "padding-right:"
            + imageWidth + "px;\">");
    sb.appendHtmlConstant("<div style=\"position:absolute;display:none;\"></div><div>");
    SafeHtml safeValue = SafeHtmlUtils.fromString(text);
    sb.append(safeValue).appendHtmlConstant("</div></div>");

}

From source file:com.chinarewards.gwt.license.client.ui.HyperLinkCell.java

@Override
public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<a style=\"color:bule;\" href=\"javascript:void(0);\">");
    if (data != null) {
        sb.append(data);
    }//from w  w  w. j a v  a  2s .c  o m
    sb.appendHtmlConstant("</a>");
}

From source file:com.colinalworth.xmlview.client.ElementCell.java

License:Apache License

@Override
public void render(Cell.Context context, Node value, SafeHtmlBuilder sb) {
    Object key = context.getKey();
    ElementCell.ViewState viewData = getViewData(key);
    if (viewData != null && viewData.section != ElementCell.ViewState.Section.None && viewData.value != null
            && viewDataMatchesValue(viewData, value)) {
        clearViewData(key);// w w  w.  ja  v a  2 s.  c o  m
        viewData = null;
    }
    if (viewData != null) {
        if (value instanceof Element) {
            sb.append(template.element(template.input(value.getNodeName())));
        } else if (value instanceof CDATASection) {
            sb.append(template.cdata(template.textarea(value.getNodeValue())));
        } else if (value instanceof Text) {
            sb.append(template.text(template.textarea(value.getNodeValue())));
        } else if (value instanceof Attr) {
            sb.append(template.attribute(template.input(((Attr) value).getName()),
                    template.input(value.getNodeValue())));
        } else if (value instanceof Comment) {
            sb.append(template.comment(((Comment) value).getData()));
        }
    } else {
        if (value instanceof Element) {
            sb.append(template.element(SafeHtmlUtils.fromString(value.getNodeName())));
        } else if (value instanceof CDATASection) {
            sb.append(template.cdata(SafeHtmlUtils.fromString(value.getNodeValue())));
        } else if (value instanceof Text) {
            sb.append(template.text(SafeHtmlUtils.fromString(value.getNodeValue())));
        } else if (value instanceof Attr) {
            sb.append(template.attribute(SafeHtmlUtils.fromString(((Attr) value).getName()),
                    SafeHtmlUtils.fromString(value.getNodeValue())));
        } else if (value instanceof Comment) {
            sb.append(template.comment(((Comment) value).getData()));
        }
    }
}

From source file:com.dianaui.universal.core.client.ui.base.helper.SourceCodeHelper.java

License:Apache License

/**
 * If source code contains "\n" it will be replaced by a {@code <br>} element and "\s" will be replaced by a whitespace.
 *
 * @param code Unformatted source code//from w  w  w .jav a2s. c  o m
 * @return Formatted source code in HTML for use in {@link com.dianaui.universal.core.client.ui.Pre} or {@link com.dianaui.universal.core.client.ui.Code}
 */
public static SafeHtml parseCode(final String code) {
    final SafeHtmlBuilder builder = new SafeHtmlBuilder();
    final String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");

    for (final String s : splitted) {
        builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
        builder.appendHtmlConstant("<br>");
    }

    return builder.toSafeHtml();
}

From source file:com.dianaui.universal.core.client.ui.ButtonCell.java

License:Apache License

@Override
public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<button type=\"button\" class=\"btn " + (type != null ? type.getCssName() : "")
            + (size != null ? " " + size.getCssName() : "") + "\" tabindex=\"-1\">");
    if (data != null) {
        String iconHtml = "";

        if (fontAwesomeIcon != null || glyphicon != null) {
            String iconClasses = fontAwesomeIcon != null
                    ? Styles.FONT_AWESOME_BASE + " " + fontAwesomeIcon.getCssName()
                    : Styles.GLYPHICON_BASE + " " + glyphicon.getCssName();

            if (fontAwesomeIcon != null) {
                if (iconSize != null)
                    iconClasses += iconSize.getCssName() + " ";
                if (iconFlip != null)
                    iconClasses += iconFlip.getCssName() + " ";
                if (iconRotate != null)
                    iconClasses += iconRotate.getCssName() + " ";
                if (iconBordered)
                    iconClasses += Styles.ICON_BORDER + " ";
                if (iconMuted)
                    iconClasses += Styles.ICON_MUTED + " ";
                if (iconLight)
                    iconClasses += Styles.ICON_LIGHT + " ";
                if (iconSpin)
                    iconClasses += Styles.ICON_SPIN + " ";
                if (iconFixedWidth)
                    iconClasses += Styles.ICON_FIXED_WIDTH;
            }// w w  w .  j  a  v a2 s.  co m

            iconHtml = "<i class=\"" + iconClasses + "\"></i> ";
        }

        if (iconPosition == IconPosition.LEFT) {
            sb.appendHtmlConstant(iconHtml);
            sb.appendEscapedLines(separator);
        }

        sb.append(data);

        if (iconPosition == IconPosition.RIGHT) {
            sb.appendEscapedLines(separator);
            sb.appendHtmlConstant(iconHtml);
        }
    }
    sb.appendHtmlConstant("</button>");
}

From source file:com.dingziran.effective.client.Showcase.java

License:Apache License

/**
 * Create a hidden site map for crawlability.
 * /*from   www.ja va2s  .  com*/
 * @param contentWidgets the {@link ContentWidget}s used in Showcase
 */
private void createSiteMap(Set<ContentWidget> contentWidgets) {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    for (ContentWidget cw : contentWidgets) {
        String token = getContentWidgetToken(cw);
        sb.append(SafeHtmlUtils.fromTrustedString("<a href=\"#" + token + "\">" + token + "</a>"));
    }

    // Add the site map to the page.
    HTML siteMap = new HTML(sb.toSafeHtml());
    siteMap.setVisible(false);
    RootPanel.get().add(siteMap, 0, 0);
}

From source file:com.eas.grid.cells.RenderedEditorCell.java

@Override
public void render(final Context context, final T value, SafeHtmlBuilder sb) {
    String viewDataId = "";
    if (isEditing(context, null, value)) {
        final ViewData<T> viewData = getViewData(context.getKey());
        viewDataId = viewData.id;/*  ww w . java2s.  c om*/
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            @Override
            public void execute() {
                if (isEditing(context, null, value)) {
                    Element identifiedCellTextSection = Document.get().getElementById(viewData.id);
                    if (identifiedCellTextSection != null) {
                        identifiedCellTextSection.blur();
                        Element table = identifiedCellTextSection;
                        while (table != null && !"table".equalsIgnoreCase(table.getTagName())) {
                            table = table.getParentElement();
                        }
                        final Element table1 = table;
                        if (identifiedCellTextSection.getOwnerDocument() == Document.get()) {
                            startEditing(context, identifiedCellTextSection.getParentElement(),
                                    table1.getParentElement(), value, viewData.updater, new Runnable() {

                                        public void run() {
                                            if (onEditorClose != null && table1 != null) {
                                                onEditorClose.closed(table1);
                                            }
                                        }

                                    });
                        }
                    }
                }
            }

        });
    }
    if (renderer == null || !renderer.render(context, viewDataId, value, sb)) {
        SafeHtmlBuilder content = new SafeHtmlBuilder();
        renderCell(context, value, content);
        sb.append(PaddedCell.INSTANCE.generate(new SafeStylesBuilder().toSafeStyles(), viewDataId,
                content.toSafeHtml()));
    }
}

From source file:com.eas.grid.cells.TreeExpandableCell.java

@Override
public void render(Context context, C value, SafeHtmlBuilder sb) {
    if (treeProvider != null) {
        SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder();
        cell.render(context, value, cellBuilder);
        int deepness = getDeepness(context);
        int outerDivPadding = indent * deepness;
        SafeStylesBuilder styles = new SafeStylesBuilder();
        if (deepness > 0) {
            styles.paddingLeft(outerDivPadding, Style.Unit.PX);
        }/*from w  ww.  java 2  s  .co m*/
        styles.position(Style.Position.RELATIVE).height(100, Style.Unit.PCT).toSafeStyles();
        sb.append(template.outerDiv(outerDivClasses(context), styles.toSafeStyles(), cellBuilder.toSafeHtml()));
    } else {
        cell.render(context, value, sb);
    }
}

From source file:com.eucalyptus.www.X509Download.java

License:Open Source License

public static String getError(String message) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(SafeHtmlUtils.fromTrustedString(
            "<html><title>Getting credentials failed</title><body><div align=\"center\"><p><h1>Getting credentails failed</h1></p><p><img src=\"themes/active/logo.png\" /></p><p><h3 style=\"font-color: red;\">"));
    builder.appendEscaped(message);/*from   w  w w.j a  va  2 s  .co  m*/
    builder.append(SafeHtmlUtils.fromTrustedString("</h3></p></div></body></html>"));
    return builder.toSafeHtml().asString();
}

From source file:com.gafactory.core.client.ui.grids.ActionCell.java

License:Open Source License

@Override
public void render(Context context, C value, SafeHtmlBuilder sb) {
    sb.append(html);
}