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:edu.arizona.biosemantics.gxt.theme.green.client.base.tabs.Css3TabPanelBottomAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.append(template.render((Css3TabPanelBottomStyle) style));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.button.SlicedButtonCellAppearance.java

License:sencha.com license

@Override
public void render(final ButtonCell<C> cell, Context context, C value, SafeHtmlBuilder sb) {
    String constantHtml = cell.getHTML();
    boolean hasConstantHtml = constantHtml != null && constantHtml.length() != 0;
    boolean isBoolean = value != null && value instanceof Boolean;
    // is a boolean always a toggle button?
    String text = hasConstantHtml ? cell.getText()
            : (value != null && !isBoolean) ? SafeHtmlUtils.htmlEscape(value.toString()) : "";

    ImageResource icon = cell.getIcon();
    IconAlign iconAlign = cell.getIconAlign();

    String cls = style.button();//from   w w w.ja va  2 s .c  o m
    String arrowCls = "";
    if (cell.getMenu() != null) {

        if (cell instanceof SplitButtonCell) {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.split();
                break;
            case BOTTOM:
                arrowCls = style.splitBottom();
                break;
            default:
                // empty
            }

        } else {
            switch (cell.getArrowAlign()) {
            case RIGHT:
                arrowCls = style.arrow();
                break;
            case BOTTOM:
                arrowCls = style.arrowBottom();
                break;
            }
        }

    }

    ButtonScale scale = cell.getScale();

    switch (scale) {
    case SMALL:
        cls += " " + style.small();
        break;
    case MEDIUM:
        cls += " " + style.medium();
        break;
    case LARGE:
        cls += " " + style.large();
        break;
    default:
        // empty
    }

    SafeStylesBuilder stylesBuilder = new SafeStylesBuilder();

    int width = -1;

    if (cell.getWidth() != -1) {
        int w = cell.getWidth();
        if (w < cell.getMinWidth()) {
            w = cell.getMinWidth();
        }
        stylesBuilder.appendTrustedString("width:" + w + "px;");
        cls += " " + style.hasWidth() + " x-has-width";
        width = w;
    } else {

        if (cell.getMinWidth() != -1) {
            TextMetrics.get().bind(style.text());
            int length = TextMetrics.get().getWidth(text);
            length += 6; // frames

            if (icon != null) {
                switch (iconAlign) {
                case LEFT:
                case RIGHT:
                    length += icon.getWidth();
                    break;
                default:
                    // empty
                }
            }
        }
    }

    final int height = cell.getHeight();
    if (height != -1) {
        stylesBuilder.appendTrustedString("height:" + height + "px;");
    }

    if (icon != null) {
        switch (iconAlign) {
        case TOP:
            arrowCls += " " + style.iconTop();
            break;
        case BOTTOM:
            arrowCls += " " + style.iconBottom();
            break;
        case LEFT:
            arrowCls += " " + style.iconLeft();
            break;
        case RIGHT:
            arrowCls += " " + style.iconRight();
            break;
        }

    } else {
        arrowCls += " " + style.noIcon();
    }

    // toggle button
    if (value == Boolean.TRUE) {
        cls += " " + frame.pressedClass();
    }

    sb.append(templates.outer(cls, new SafeStylesBuilder().toSafeStyles()));

    SafeHtmlBuilder inside = new SafeHtmlBuilder();

    String innerWrap = arrowCls;
    if (GXT.isIE6() || GXT.isIE7()) {
        arrowCls += " " + CommonStyles.get().inlineBlock();
    }

    inside.appendHtmlConstant("<div class='" + innerWrap + "'>");
    inside.appendHtmlConstant("<table cellpadding=0 cellspacing=0 class='" + style.mainTable() + "'>");

    boolean hasText = text != null && !text.equals("");

    if (icon != null) {
        switch (iconAlign) {
        case LEFT:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            if (hasText) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            inside.appendHtmlConstant("</tr>");
            break;
        case RIGHT:
            inside.appendHtmlConstant("<tr>");
            if (hasText) {
                int w = width - (icon != null ? icon.getWidth() : 0) - 4;
                writeText(inside, text, w, height);
            }
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        case TOP:
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            if (hasText) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            break;
        case BOTTOM:
            if (hasText) {
                inside.appendHtmlConstant("<tr>");
                writeText(inside, text, width, height);
                inside.appendHtmlConstant("</tr>");
            }
            inside.appendHtmlConstant("<tr>");
            writeIcon(inside, icon, height);
            inside.appendHtmlConstant("</tr>");
            break;
        }

    } else {
        inside.appendHtmlConstant("<tr>");
        if (text != null) {
            writeText(inside, text, width, height);
        }
        inside.appendHtmlConstant("</tr>");
    }
    inside.appendHtmlConstant("</table>");
    inside.appendHtmlConstant("</div>");

    frame.render(sb,
            new Frame.FrameOptions(0, CommonStyles.get().noFocusOutline(), stylesBuilder.toSafeStyles()),
            inside.toSafeHtml());

    sb.appendHtmlConstant("</div>");

}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.panel.SlicedFramedPanelFrame.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder, FrameOptions options, SafeHtml content) {
    builder.append(template.render(resources.style(), content));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.tabs.SlicedPlainTabPanelAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.append(template.renderPlain((SlicedPlainTabPanelStyle) resources.style()));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.tabs.SlicedTabPanelAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.append(template.render(resources.style()));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.sliced.tabs.SlicedTabPanelBottomAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.append(template.render((SlicedTabPanelBottomStyle) style));
}

From source file:eu.europeana.uim.gui.cp.client.europeanawidgets.AnchorCell.java

License:EUPL

@Override

public void render(com.google.gwt.cell.client.Cell.Context context,

        Anchor h, SafeHtmlBuilder sb)

{

    sb.append(SafeHtmlUtils.fromTrustedString(h.toString()));

}

From source file:fr.mncc.gwttoolbox.datagrid.client.cells.ClickableImageCell.java

License:Open Source License

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    if (value != null) {
        SafeUri uri = trustUri_ ? UriUtils.fromTrustedString(value) : UriUtils.fromString(value);
        if (width_ == null && height_ != null) // resize with constraint on height
            sb.append(template_.imgByHeight(uri, height_));
        else if (height_ == null && width_ != null) // resize with constraint on width
            sb.append(template_.imgByWidth(uri, width_));
        else if (height_ != null) // resize with constraint on width and height
            sb.append(template_.img(uri, width_, height_));
    }//from w  w w.j  a  v a 2  s .com
}

From source file:fr.mncc.gwttoolbox.datagrid.client.columns.ButtonColumn.java

License:Open Source License

public ButtonColumn(final String tooltip) {
    super(new ButtonCell() {

        @Override/*  www . ja va2  s  . c om*/
        public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<button type=\"button\" tabindex=\"-1\" title=\"" + tooltip + "\">");
            if (data != null) {
                sb.append(data);
            }
            sb.appendHtmlConstant("</button>");
        }
    });
}

From source file:fr.mncc.sandbox.client.layouts.photogallery.PhotoGalleryLayout.java

License:Open Source License

private void fillLayout() {
    SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
    for (int i = 0; i < images_.size(); i++) {
        safeHtmlBuilder.append(createImageWrapper(images_.get(i)));
    }//w ww. j  a  va  2  s . c  o  m
    wrapper.setInnerSafeHtml(safeHtmlBuilder.toSafeHtml());
}