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:com.sencha.gxt.theme.base.client.field.TextAreaDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    int width = options.getWidth();
    int height = options.getHeight();

    boolean empty = false;

    String name = options.getName() != null ? " name='" + options.getName() + "' " : "";
    String disabled = options.isDisabled() ? " disabled=true" : "";
    String ro = options.isReadonly() ? " readonly" : "";
    String placeholder = options.getEmptyText() != null
            ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' "
            : "";

    if ((value == null || value.equals("")) && options.getEmptyText() != null) {
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }/*from w w  w .j  ava 2 s  .c om*/
        empty = true;
    }

    if (width == -1) {
        width = 150;
    }

    String inputStyles = "";
    String wrapStyles = "";

    Size adjusted = adjustTextAreaSize(width, height);

    if (width != -1) {
        wrapStyles += "width:" + width + "px;";
        width = adjusted.getWidth();
        inputStyles += "width:" + width + "px;";
    }

    if (height != -1) {
        height = adjusted.getHeight();
        inputStyles += "height: " + height + "px;";
    }

    String cls = style.area() + " " + style.field();
    if (empty) {
        cls += " " + style.empty();
    }

    if (options instanceof TextAreaCellOptions) {
        TextAreaCellOptions opts = (TextAreaCellOptions) options;
        inputStyles += "resize:" + opts.getResizable().name().toLowerCase() + ";";
    }

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>");
    sb.appendHtmlConstant("<textarea " + name + disabled + " style='" + inputStyles + "' type='text' class='"
            + cls + "'" + ro + placeholder + ">");
    sb.append(SafeHtmlUtils.fromString(value));
    sb.appendHtmlConstant("</textarea></div>");
}

From source file:com.sencha.gxt.theme.base.client.field.TextFieldDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String type, String value, FieldAppearanceOptions options) {
    String inputStyles = "";
    String wrapStyles = "";

    int width = options.getWidth();

    String name = options.getName() != null ? " name='" + options.getName() + "' " : "";
    String disabled = options.isDisabled() ? "disabled=true" : "";
    String placeholder = options.getEmptyText() != null
            ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' "
            : "";

    boolean empty = false;

    if ((value == null || value.equals("")) && options.getEmptyText() != null) {
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }/*  w w  w.  ja v a2s.  c om*/
        empty = true;
    }

    if (width != -1) {
        wrapStyles += "width:" + width + "px;";
        width = adjustTextAreaWidth(width);
        inputStyles += "width:" + width + "px;";
    }

    String cls = style.text() + " " + style.field();
    if (empty) {
        cls += " " + style.empty();
    }

    String ro = options.isReadonly() ? " readonly" : "";

    value = SafeHtmlUtils.htmlEscape(value);

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>");
    sb.appendHtmlConstant("<input " + name + disabled + " value='" + value + "' style='" + inputStyles
            + "' type='" + type + "' class='" + cls + "'" + ro + placeholder + ">");
    sb.appendHtmlConstant("</div>");

}

From source file:com.sencha.gxt.theme.base.client.field.TriggerFieldDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    int width = options.getWidth();
    boolean hideTrigger = options.isHideTrigger();

    if (width == -1) {
        width = 150;//from  ww  w . j a  v a  2  s  .  c o m
    }

    String wrapStyles = "width:" + width + "px;";

    // 6px margin, 2px border
    width -= 8;

    if (!hideTrigger) {
        width -= getResources().triggerArrow().getWidth();
    }
    width = Math.max(0, width);
    SafeStyles inputStyles = SafeStylesUtils.fromTrustedString("width:" + width + "px;");

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + getStyle().wrap() + "'>");

    if (!hideTrigger) {
        sb.appendHtmlConstant("<table cellpadding=0 cellspacing=0><tr><td>");
        renderInput(sb, value, inputStyles, options);
        sb.appendHtmlConstant("</td>");
        sb.appendHtmlConstant("<td><div class='" + getStyle().trigger() + "' /></td>");
        sb.appendHtmlConstant("</table>");
    } else {
        renderInput(sb, value, inputStyles, options);
    }

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

From source file:com.sencha.gxt.theme.base.client.field.TwinTriggerFieldDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, String value, FieldAppearanceOptions options) {
    int width = options.getWidth();
    boolean hideTrigger = options.isHideTrigger();
    String name = options.getName() != null ? " name='" + options.getName() + "' " : "";
    String disabled = options.isDisabled() ? "disabled=true" : "";

    if (width == -1) {
        width = 150;/*from  www . j a  v  a  2  s .com*/
    }

    String inputStyles = "";
    String wrapStyles = "";

    if (width != -1) {
        wrapStyles += "width:" + width + "px;";
        // 6px margin, 2px border
        width -= 8;
        if (!hideTrigger) {
            width -= resources.triggerArrow().getWidth();
        }
        inputStyles += "width:" + width + "px;";
    }

    String cls = style.field() + " " + style.text();

    String placeholder = options.getEmptyText() != null
            ? " placeholder='" + SafeHtmlUtils.htmlEscape(options.getEmptyText()) + "' "
            : "";

    if (value.equals("") && options.getEmptyText() != null) {
        cls += " " + style.empty();
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }
    }

    if (!options.isEditable()) {
        cls += " " + getStyle().noedit();
    }

    String ro = options.isReadonly() || !options.isEditable() ? " readonly " : " ";

    String input = "<input " + name + disabled + ro + placeholder + " style='" + inputStyles
            + "' type='text' value='" + value + "' class='" + cls + "'/>";

    sb.appendHtmlConstant("<div style='" + wrapStyles + "' class='" + style.wrap() + "'>");

    if (!options.isHideTrigger()) {

        sb.appendHtmlConstant("<table width=100% cellpadding=0 cellspacing=0><tr><td>");
        sb.appendHtmlConstant(input);
        sb.appendHtmlConstant("</td>");

        sb.appendHtmlConstant("<td>");
        sb.appendHtmlConstant("<div class='" + style.trigger() + "'></div>");
        sb.appendHtmlConstant("<div class='" + style.twinTrigger() + "'></div>");
        sb.appendHtmlConstant("</td></table>");
    } else {
        sb.appendHtmlConstant(input);
    }

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

}

From source file:com.sencha.gxt.theme.base.client.grid.RowExpanderDefaultAppearance.java

License:sencha.com license

@Override
public void renderExpander(Context context, M value, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<div class='" + style.rowExpander() + "'>&nbsp;</div>");
}

From source file:com.sencha.gxt.theme.base.client.grid.RowNumbererDefaultAppearance.java

License:sencha.com license

@Override
public void renderCell(int rowNumber, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<div class='" + resources.styles().numberer() + "'>").append(rowNumber)
            .appendHtmlConstant("</div>");
}

From source file:com.sencha.gxt.theme.base.client.info.DefaultInfoConfigDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, SafeHtml title, SafeHtml message) {

    if (title != SafeHtmlUtils.EMPTY_SAFE_HTML) {
        sb.appendHtmlConstant("<div class='" + style.infoTitle() + "'>");
        sb.append(title);/*w w  w.  j a  v a  2s. co  m*/
        sb.appendHtmlConstant("</div>");
    }
    if (message != SafeHtmlUtils.EMPTY_SAFE_HTML) {
        sb.appendHtmlConstant("<div class='" + style.infoMessage() + "'>");
        sb.append(message);
        sb.appendHtmlConstant("</div>");
    }
}

From source file:com.sencha.gxt.theme.base.client.listview.ListViewCustomAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.appendHtmlConstant("<div class='" + resources.css().view() + "'></div>");
}

From source file:com.sencha.gxt.theme.base.client.listview.ListViewDefaultAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.appendHtmlConstant("<div class=\"" + style.view() + "\"></div>");
}

From source file:com.sencha.gxt.theme.base.client.listview.ListViewDefaultAppearance.java

License:sencha.com license

@Override
public void renderItem(SafeHtmlBuilder sb, SafeHtml content) {
    sb.appendHtmlConstant("<div class='" + style.item() + "'>");
    sb.append(content);// w  w w  .  j  a  v a  2s .c  o m
    sb.appendHtmlConstant("</div>");

}