Example usage for com.google.gwt.safehtml.shared SafeHtmlUtils fromTrustedString

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils fromTrustedString

Introduction

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

Prototype

public static SafeHtml fromTrustedString(String s) 

Source Link

Document

Returns a SafeHtml constructed from a trusted string, i.e., without escaping the string.

Usage

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");
    }/*  ww w . j ava  2  s  . c  o m*/

    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.grid.Css3GridAppearance.java

License:sencha.com license

@Override
public SafeHtml renderEmptyContent(String emptyText) {
    return SafeHtmlUtils.fromTrustedString(emptyText);
}

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.onevu.gwt.uibinder.client.impl.AbstractUiRenderer.java

License:Apache License

/**
 * Inserts an attribute into the first tag found in a {@code safeHtml}
 * template. This method assumes that the {@code safeHtml} template begins
 * with an open HTML tag. {@code SafeHtml} templates produced by UiBinder
 * always meet these conditions.//  w w  w. j a  v  a2s  . com
 * <p>
 * This method does not attempt to ensure {@code atributeName} and
 * {@code attributeValue} contain safe values.
 * 
 * @returns the {@code safeHtml} template with "{@code attributeName}=
 *          {@code attributeValue}" inserted as an attribute of the first tag
 *          found
 */
protected static SafeHtml stampUiRendererAttribute(SafeHtml safeHtml, String attributeName,
        String attributeValue) {
    String html = safeHtml.asString();
    int endOfFirstTag = html.indexOf(">");

    assert endOfFirstTag > 1 : "Safe html template does not start with an HTML open tag";

    if (html.charAt(endOfFirstTag - 1) == '/') {
        endOfFirstTag--;
    }

    html = html.substring(0, endOfFirstTag) + " " + attributeName + "=\"" + attributeValue + "\""
            + html.substring(endOfFirstTag);
    return SafeHtmlUtils.fromTrustedString(html);
}

From source file:gov.wa.wsdot.mobile.client.activities.borderwait.BorderWaitActivity.java

License:Open Source License

private static SafeHtml makeImage(ImageResource resource) {
    AbstractImagePrototype image = AbstractImagePrototype.create(resource);
    String html = image.getHTML();

    return SafeHtmlUtils.fromTrustedString(html);
}

From source file:gov.wa.wsdot.mobile.client.activities.ferries.schedules.departures.FerriesRouteDeparturesViewGwtImpl.java

License:Open Source License

public FerriesRouteDeparturesViewGwtImpl() {

    pullToRefresh = new PullPanel();
    pullArrowHeader = new PullArrowHeader();
    pullToRefresh.setHeader(pullArrowHeader);

    daysOfWeek = new MListBox();

    handleOnLoad();/*  w w w.  j  a va 2s  .  co  m*/

    cellList = new CellList<FerriesScheduleTimesItem>(
            new FerriesRouteDeparturesCell<FerriesScheduleTimesItem>() {

                @Override
                public String getDeparting(FerriesScheduleTimesItem model) {
                    Date departingTime = new Date(Long.parseLong(model.getDepartingTime()));

                    return dateFormat.format(departingTime, usPacific);
                }

                @Override
                public String getArriving(FerriesScheduleTimesItem model) {
                    if (!model.getArrivingTime().equals("N/A")) {
                        Date arrivingTime = new Date(Long.parseLong(model.getArrivingTime()));

                        return dateFormat.format(arrivingTime, usPacific);
                    } else {
                        return "";
                    }
                }

                @Override
                public SafeHtml getAnnotation(FerriesScheduleTimesItem model) {
                    if (model.getAnnotations() != null) {
                        return SafeHtmlUtils.fromTrustedString(model.getAnnotations());
                    } else {
                        return SafeHtmlUtils.fromString("");
                    }
                }

                @Override
                public boolean canBeSelected(FerriesScheduleTimesItem model) {
                    return false;
                }

                @Override
                public String getDriveUpSpaces(FerriesScheduleTimesItem model) {
                    return String.valueOf(model.getDriveUpSpaceCount());
                }

                @Override
                public String getMaxSpaceCount(FerriesScheduleTimesItem model) {
                    return String.valueOf(model.getMaxSpaceCount());
                }

                @Override
                public String getLastUpdated(FerriesScheduleTimesItem model) {
                    if (model.getLastUpdated() != null) {
                        return ParserUtils.relativeTime(model.getLastUpdated(), "MMMM d, yyyy h:mm a", false);
                    } else {
                        return "";
                    }
                }

            });

    cameraCellList = new CellList<CameraItem>(new CameraCell<CameraItem>() {

        @Override
        public String getUrl(CameraItem model) {
            return model.getImageUrl();
        }

        @Override
        public boolean canBeSelected(CameraItem model) {
            return true;
        }
    });

    initWidget(uiBinder.createAndBindUi(this));

    accessibilityPrepare();

    if (MGWT.getOsDetection().isAndroid()) {
        leftFlexSpacer.setVisible(false);
        cameraScrollPanel.setBounce(false);
    }
}

From source file:gov.wa.wsdot.mobile.client.activities.socialmedia.twitter.TwitterCell.java

License:Open Source License

@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) {
    SafeHtml content = TEMPLATE.content(AppBundle.INSTANCE.css().cameraImage(), AppBundle.INSTANCE.css().img(),
            SafeHtmlUtils.htmlEscape(getMediaUrl(model)), AppBundle.INSTANCE.css().cellImage(),
            getDisplayImage(model), AppBundle.INSTANCE.css().cellDetails(),
            SafeHtmlUtils.htmlEscape(getDisplayString(model)),
            SafeHtmlUtils.fromTrustedString(getDisplayDescription(model)),
            SafeHtmlUtils.htmlEscape(getDisplayLastUpdated(model)));

    SafeHtml contentNoCameraImage = TEMPLATE.content(AppBundle.INSTANCE.css().cameraImageHidden(),
            AppBundle.INSTANCE.css().img(), SafeHtmlUtils.htmlEscape(getMediaUrl(model)),
            AppBundle.INSTANCE.css().cellImage(), getDisplayImage(model),
            AppBundle.INSTANCE.css().cellDetails(), SafeHtmlUtils.htmlEscape(getDisplayString(model)),
            SafeHtmlUtils.fromTrustedString(getDisplayDescription(model)),
            SafeHtmlUtils.htmlEscape(getDisplayLastUpdated(model)));

    if (getMediaUrl(model) != "") {
        safeHtmlBuilder.append(content);
    } else {/*from w  ww  .  jav a  2 s  .c o  m*/
        safeHtmlBuilder.append(contentNoCameraImage);
    }
}

From source file:gov.wa.wsdot.mobile.client.widget.SimpleListItem.java

License:Open Source License

@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) {
    SafeHtml content = TEMPLATE.content(AppBundle.INSTANCE.css().cellDetails3(),
            SafeHtmlUtils.fromTrustedString(getDisplayDescription(model)),
            SafeHtmlUtils.htmlEscape(getDisplayLastUpdated(model)));

    safeHtmlBuilder.append(content);//from  www.  j av a2  s . c o m
}

From source file:gov.wa.wsdot.mobile.client.widget.TitleDescLastUpdatedCell.java

License:Open Source License

@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, final T model) {
    SafeHtml content = TEMPLATE.content(AppBundle.INSTANCE.css().cellDetails3(),
            SafeHtmlUtils.fromTrustedString(getDisplayTitle(model)),
            SafeHtmlUtils.fromTrustedString(getDisplayDescription(model)),
            SafeHtmlUtils.htmlEscape(getDisplayLastUpdated(model)));

    safeHtmlBuilder.append(content);// w ww.j av a2 s .co  m
}

From source file:gwt.material.design.client.base.helper.CodeHelper.java

License:Apache License

public static SafeHtml parseCode(String code) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
    String[] arr$ = splitted;/*  w ww . j a  v  a2 s.  com*/
    int len$ = splitted.length;

    for (int i$ = 0; i$ < len$; ++i$) {
        String s = arr$[i$];
        builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
        builder.appendHtmlConstant("<br>");
    }

    return builder.toSafeHtml();
}