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:org.obiba.opal.web.gwt.app.client.ui.celltable.LabelValueColumn.java

License:Open Source License

public LabelValueColumn() {
    super(new TextCell(new SafeHtmlRenderer<String>() {

        @Override/*w w  w  .j a  v a2 s .c  o m*/
        public SafeHtml render(String object) {
            return object == null ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromTrustedString(object);
        }

        @Override
        public void render(String object, SafeHtmlBuilder appendable) {
            appendable.append(SafeHtmlUtils.fromTrustedString(object));
        }
    }));
}

From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LinkCell.java

License:Open Source License

@Override
public void render(Context context, C value, SafeHtmlBuilder sb) {
    String link = getLink(value);
    if (isEnabled() && !Strings.isNullOrEmpty(link)) {
        sb.append(SafeHtmlUtils.fromSafeConstant("<a href=\"" + link + "\">"))
                .appendHtmlConstant(getText(value)).append(SafeHtmlUtils.fromSafeConstant("</a>"));
    } else {/*from   w  w  w . j  a  v  a  2  s  . c  o  m*/
        sb.append(SafeHtmlUtils.fromSafeConstant(getText(value)));
    }
}

From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LocaleTextColumn.java

License:Open Source License

public LocaleTextColumn() {
    super(new TextCell(new SafeHtmlRenderer<String>() {

        @Override/*w ww. j a v a  2  s  .  c o  m*/
        public SafeHtml render(String object) {
            return object == null ? SafeHtmlUtils.EMPTY_SAFE_HTML : SafeHtmlUtils.fromTrustedString(object);
        }

        @Override
        public void render(String object, SafeHtmlBuilder appendable) {
            appendable.append(SafeHtmlUtils.fromTrustedString(object));
        }
    }));
}

From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.LocalisedSafeHtmlRenderer.java

License:Open Source License

@Override
public void render(String object, SafeHtmlBuilder builder) {
    builder.append(localisedHtml(object));
}

From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.StatusImageCell.java

License:Open Source License

/**
 * The value is expected to be encoded as TITLE:[STATUS|PROGRESS].
 * @param context/*from ww  w .  ja va2  s  . com*/
 * @param value
 * @param sb
 */
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    if (value != null) {
        String[] values = value.split(":");
        // The template will sanitize the URI.
        if (value.endsWith("%")) {
            sb.append(template.progress(values[0], values[1]));
        } else {
            sb.append(template.img(values[0], values[1]));
        }
    }
}

From source file:org.obiba.opal.web.gwt.app.client.ui.celltable.UserStatusIconActionCell.java

License:Open Source License

@Override
public void render(Context context, SubjectCredentialsDto value, SafeHtmlBuilder sb) {
    String cssClass = "icon";
    if (!value.getEnabled())
        cssClass += " disabled";
    sb.append(SafeHtmlUtils.fromSafeConstant("<a class=\"" + cssClass + "\">")) //
            .appendHtmlConstant(new Icon(value.getEnabled() ? iconType : IconType.REMOVE).toString()) //
            .append(message) //
            .append(SafeHtmlUtils.fromSafeConstant("</a>"));
}

From source file:org.obiba.opal.web.gwt.app.client.ui.CriterionDropdown.java

License:Open Source License

protected RadioButton getRadioButton(final String label, Integer count) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder().appendEscaped(label);

    if (count != null) {
        builder.appendHtmlConstant("<span style=\"font-size:x-small\"> (").append(count).appendEscaped(")")
                .appendHtmlConstant("</span>");
    }//from  w ww . j  a v a2  s  . c o m

    RadioButton radio = new RadioButton(fieldName + "-radio-" + this.groupId, builder.toSafeHtml());

    radio.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            updateCriterionFilter(label);
        }
    });

    return radio;
}

From source file:org.opencms.gwt.client.ui.history.CmsButtonCell.java

License:Open Source License

/**
 * @see com.google.gwt.cell.client.ActionCell#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
 *///from w  ww  .j  a v  a 2s. c  o m
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, T value, SafeHtmlBuilder sb) {

    if (m_checkActive.apply(value)) {
        sb.append(CmsResourceHistoryTable.templates.button(m_title, m_cssClass));
    }
}

From source file:org.opencms.gwt.client.ui.history.CmsVersionCell.java

License:Open Source License

/**
 * @see com.google.gwt.cell.client.AbstractCell#render(com.google.gwt.cell.client.Cell.Context, java.lang.Object, com.google.gwt.safehtml.shared.SafeHtmlBuilder)
 *///from  w  ww  . j  a  va  2  s  .  c o m
@Override
public void render(com.google.gwt.cell.client.Cell.Context context, CmsHistoryResourceBean value,
        SafeHtmlBuilder sb) {

    CmsHistoryVersion version = value.getVersion();
    Integer versionNumber = version.getVersionNumber();

    String versionText = "";
    String versionTitle = "";

    if (versionNumber != null) {
        versionText = "" + versionNumber + (version.isOnline() ? "*" : "");
    } else if (version.isOffline()) {
        versionText = "--";
    } else if (version.isOnline()) {
        versionText = "*";
    }

    if (version.isOffline()) {
        versionTitle = CmsHistoryMessages.offline();
    } else if (version.isOnline()) {
        versionTitle = CmsHistoryMessages.online();
    }
    sb.append(CmsResourceHistoryTable.templates.textSpanWithTitle(versionText, versionTitle));
}

From source file:org.opendatakit.aggregate.client.popups.AuditCSVPopup.java

License:Apache License

public AuditCSVPopup(String keyString) {
    super();//from   ww  w .  jav a  2  s  . c  om
    String[] parts = keyString.split("\\?");
    if (parts.length != 2)
        throw new RuntimeException("blobKey missing in keyString");
    String blobKey = parts[1].split("=")[1];

    setTitle("Audit CSV");
    int width = Window.getClientWidth() / 2;
    int height = Window.getClientHeight() / 2;

    final HTMLPanel panel = new HTMLPanel("");
    panel.add(new SimplePanel(new ClosePopupButton(this)));
    panel.add(new HTML("<h2>Audit CSV contents</h2>"));
    panel.setStylePrimaryName(UIConsts.VERTICAL_FLOW_PANEL_STYLENAME);
    panel.getElement().getStyle().setProperty("overflow", "scroll");
    panel.setPixelSize(width + 6, height + 30);
    setWidget(panel);

    AsyncCallback<String> callback = new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            AggregateUI.getUI().reportError(caught);
        }

        public void onSuccess(String csvContents) {
            String[] allLines = csvContents.split("\n");

            SafeHtmlBuilder builder = new SafeHtmlBuilder();
            builder.appendHtmlConstant("<table class=\"dataTable\">")
                    .appendHtmlConstant("<tr class=\"titleBar\">")
                    .appendHtmlConstant("<td>Event</td><td>Node</td><td>Start</td><td>End</td>")
                    .appendHtmlConstant("</tr>");

            for (int i = 1, max = allLines.length; i < max; i++) {
                builder.append(Row.from(allLines[i]).asTr());
            }
            builder.appendHtmlConstant("</table>");

            AggregateUI.getUI().clearError();
            panel.add(new HTML(builder.toSafeHtml()));
            AggregateUI.resize();
        }
    };

    SecureGWT.getSubmissionService().getSubmissionAuditCSV(blobKey, callback);
}