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.field.Css3TextAreaAppearance.java

License:sencha.com license

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

    int width = options.getWidth();
    int height = options.getHeight();

    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();
        }/*from  w  ww.  java  2 s.co  m*/
        empty = true;
    }

    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();
    }

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

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

License:sencha.com license

protected void renderInput(SafeHtmlBuilder shb, String value, SafeStyles inputStyles,
        FieldAppearanceOptions options) {
    StringBuilder sb = new StringBuilder();
    sb.append("<input ");

    if (options.isDisabled()) {
        sb.append("disabled=true");
    }/*from w w  w .ja v  a  2  s .c  om*/

    if (options.getName() != null) {
        sb.append("name='").append(SafeHtmlUtils.htmlEscape(options.getName())).append("' ");
    }

    if (options.isReadonly() || !options.isEditable()) {
        sb.append("readonly ");
    }

    if (inputStyles != null) {
        sb.append("style='").append(inputStyles.asString()).append("' ");
    }

    sb.append("class='").append(getStyle().field()).append(" ").append(getStyle().text());

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

    if ("".equals(value) && options.getEmptyText() != null) {
        sb.append(" ").append(getStyle().empty());
        if (GXT.isIE8() || GXT.isIE9()) {
            value = options.getEmptyText();
        }
    }

    if (!options.isEditable()) {
        sb.append(" ").append(getStyle().noedit());
    }

    sb.append("' ");
    sb.append(placeholder);

    sb.append("type='text' value='").append(SafeHtmlUtils.htmlEscape(value)).append("' ");

    sb.append("/>");

    shb.append(SafeHtmlUtils.fromTrustedString(sb.toString()));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.info.Css3DefaultInfoConfigAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, SafeHtml title, SafeHtml message) {
    sb.append(template.render(style, title, message));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.info.Css3InfoAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb) {
    sb.append(template.render(styles));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.listview.Css3ListViewAppearance.java

License:sencha.com license

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

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.listview.Css3ListViewAppearance.java

License:sencha.com license

@Override
public void renderItem(SafeHtmlBuilder sb, SafeHtml content) {
    sb.append(template.renderItem(style, content));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.menu.Css3MenuBarAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder builder) {
    builder.append(template.render(style.menuBar() + " " + CommonStyles.get().noFocusOutline()));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.progressbar.Css3ProgressBarAppearance.java

License:sencha.com license

@Override
public void render(SafeHtmlBuilder sb, Double value, ProgressBarAppearanceOptions options) {
    value = value == null ? 0 : value;/*  ww w.j a va  2 s .co  m*/

    String text = options.getProgressText();

    if (text != null) {
        int v = (int) Math.round(value * 100);
        text = Format.substitute(text, v);
    }

    SafeHtml txt;
    if (text == null) {
        txt = SafeHtmlUtils.fromSafeConstant("&#160;");
    } else {
        txt = SafeHtmlUtils.fromString(text);
    }

    SafeStyles widthStyles = SafeStylesUtils.fromTrustedNameAndValue("width", options.getWidth() + "px");

    final SafeStyles progressBarStyles;
    if (value <= 0) {
        progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("visibility", "hidden");
    } else {
        progressBarStyles = SafeStylesUtils.fromTrustedNameAndValue("width", value * 100 + "%");
    }

    sb.append(template.render(txt, styles, null, progressBarStyles, null, widthStyles));

}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.slider.Css3HorizontalSliderAppearance.java

License:sencha.com license

@Override
public void render(double fractionalValue, int width, int height, SafeHtmlBuilder sb) {
    if (width == -1) {
        // default
        width = 200;/*from ww  w .  j av a2  s . co  m*/
    }

    FieldDetails fieldDetails = resources.theme().field();

    int thumbWidth = fieldDetails.slider().thumbWidth();
    int thumbHeight = fieldDetails.slider().thumbHeight();

    int fieldHeight = Math.max(fieldDetails.height(), thumbHeight);
    fieldHeight = Math.max(fieldHeight, fieldDetails.slider().trackHeight());

    int halfThumbWidth = thumbWidth / 2;
    int maxTrackLength = width - thumbWidth;

    int offset = (int) (fractionalValue * maxTrackLength) - halfThumbWidth;
    offset = Math.max(-halfThumbWidth, offset);
    offset = Math.min(maxTrackLength + halfThumbWidth, offset);

    SafeStylesBuilder sliderStyleBuilder = new SafeStylesBuilder();
    sliderStyleBuilder.appendTrustedString("width:" + width + "px;");
    sliderStyleBuilder.appendTrustedString("height:" + fieldHeight + "px;");

    SafeStylesBuilder trackStyleBuilder = new SafeStylesBuilder();
    trackStyleBuilder.appendTrustedString("width: " + width + "px;");
    trackStyleBuilder
            .appendTrustedString("top:" + ((fieldHeight - fieldDetails.slider().trackHeight()) / 2) + "px;");

    SafeStylesBuilder thumbStyleBuilder = new SafeStylesBuilder();
    thumbStyleBuilder.appendTrustedString("left:" + offset + "px;");
    int thumbTop = ((fieldDetails.slider().trackHeight() - thumbHeight) / 2)
            - (fieldDetails.slider().trackBorder().top() + fieldDetails.slider().trackBorder().bottom());
    thumbStyleBuilder.appendTrustedString("top:" + thumbTop + "px;");
    thumbStyleBuilder.appendTrustedString("margin-left:" + halfThumbWidth + "px;");

    SafeStylesBuilder thumbCenterStyleBuilder = new SafeStylesBuilder();
    updateThumbCenterStyle(thumbCenterStyleBuilder, "left", "width", thumbWidth,
            fieldDetails.slider().thumbBorder().left(), fieldDetails.slider().thumbBorder().right());
    updateThumbCenterStyle(thumbCenterStyleBuilder, "top", "height", thumbHeight,
            fieldDetails.slider().thumbBorder().top(), fieldDetails.slider().thumbBorder().bottom());

    sb.append(template.render(resources.style(), sliderStyleBuilder.toSafeStyles(),
            trackStyleBuilder.toSafeStyles(), thumbStyleBuilder.toSafeStyles(),
            thumbCenterStyleBuilder.toSafeStyles()));
}

From source file:edu.arizona.biosemantics.gxt.theme.green.client.base.slider.Css3VerticalSliderAppearance.java

License:sencha.com license

@Override
public void render(double fractionalValue, int width, int height, SafeHtmlBuilder sb) {
    if (height == -1) {
        // default
        height = 200;//from  ww w  .  jav  a  2s  .  c o  m
    }

    FieldDetails fieldDetails = resources.theme().field();

    int thumbWidth = fieldDetails.slider().thumbWidth();
    int thumbHeight = fieldDetails.slider().thumbHeight();

    int fieldWidth = Math.max(fieldDetails.height(), fieldDetails.slider().thumbHeight());
    fieldWidth = Math.max(fieldWidth, fieldDetails.slider().trackHeight());

    int halfThumbWidth = thumbWidth / 2;
    int maxTrackLength = height - thumbWidth;

    int offset = (int) (fractionalValue * maxTrackLength) - halfThumbWidth;
    offset = Math.max(-halfThumbWidth, offset);
    offset = Math.min(maxTrackLength + halfThumbWidth, offset);

    SafeStylesBuilder sliderStyleBuilder = new SafeStylesBuilder();
    sliderStyleBuilder.appendTrustedString("height:" + height + "px;");
    sliderStyleBuilder.appendTrustedString("width:" + fieldWidth + "px;");

    SafeStylesBuilder trackStyleBuilder = new SafeStylesBuilder();
    trackStyleBuilder.appendTrustedString("height: " + height + "px;");
    trackStyleBuilder
            .appendTrustedString("left:" + ((fieldWidth - fieldDetails.slider().trackHeight()) / 2) + "px;");

    SafeStylesBuilder thumbStyleBuilder = new SafeStylesBuilder();
    thumbStyleBuilder.appendTrustedString("bottom:" + offset + "px;");
    // reversed width/height due to orientation
    int thumbLeft = ((fieldDetails.slider().trackHeight() - thumbHeight) / 2)
            - (fieldDetails.slider().trackBorder().top() + fieldDetails.slider().trackBorder().bottom());
    thumbStyleBuilder.appendTrustedString("left:" + thumbLeft + "px;");
    thumbStyleBuilder.appendTrustedString("margin-bottom:" + halfThumbWidth + "px;");

    SafeStylesBuilder thumbCenterStyleBuilder = new SafeStylesBuilder();
    updateThumbCenterStyle(thumbCenterStyleBuilder, "top", "height", thumbWidth,
            fieldDetails.slider().thumbBorder().left(), fieldDetails.slider().thumbBorder().right());
    updateThumbCenterStyle(thumbCenterStyleBuilder, "left", "width", thumbHeight,
            fieldDetails.slider().thumbBorder().top(), fieldDetails.slider().thumbBorder().bottom());

    sb.append(template.render(resources.style(), sliderStyleBuilder.toSafeStyles(),
            trackStyleBuilder.toSafeStyles(), thumbStyleBuilder.toSafeStyles(),
            thumbCenterStyleBuilder.toSafeStyles()));
}