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

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

Introduction

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

Prototype

public static SafeHtml fromString(String s) 

Source Link

Document

Returns a SafeHtml containing the escaped string.

Usage

From source file:org.spiffyui.client.MessageUtil.java

License:Apache License

/**
  * <p>/*  w  w w.  j a  va 2 s .  c  o  m*/
  * Show aan error message.
  * </p>
  * 
  * <p> 
  * This message has a default style of black text with a red background.
  * </p>
  * 
  * <h3>CSS Style Ryles</h3>
  * 
  * <ul>
  * <li>.humanMsgErr</li>
  * </ul>
  * 
  * @param errorMsg the error message for the alert in HTML
  * @param logMsg   the message for the error log in HTML
  * @param isSafe if this field is true then this just calls showMessage, otherwise it
  *               runs the specified message through the GWT SaveHtmlUtils
  */
public static void showError(String errorMsg, String logMsg, boolean isSafe) {
    if (isSafe) {
        showError(errorMsg, logMsg);
    } else {
        showError(SafeHtmlUtils.fromString(errorMsg).asString(), SafeHtmlUtils.fromString(logMsg).asString());
    }
}

From source file:org.spiffyui.client.rest.RESTException.java

License:Apache License

/**
 * Creates a new RESTException// ww w  .  ja  v a  2 s  . c  o m
 * 
 * @param code    the exception code
 * @param subcode the optional exception subcode
 * @param reason  the optional exception reason
 * @param details the optional exception details
 * @param responseCode
 *                the HTTP response code
 * @param url     the URL for this exception
 */
public RESTException(String code, String subcode, String reason, Map<String, String> details, int responseCode,
        String url) {
    if (code == null) {
        throw new IllegalArgumentException("RESTException requires a code.");
    }

    m_code = semiUnescapeHtml(SafeHtmlUtils.fromString(code).asString());

    if (subcode != null) {
        m_subcode = semiUnescapeHtml(SafeHtmlUtils.fromString(subcode).asString());
    }

    if (reason != null) {
        m_reason = semiUnescapeHtml(SafeHtmlUtils.fromString(reason).asString());
    }

    m_details = details;
    m_responseCode = responseCode;
    m_url = url;
}

From source file:org.uberfire.client.views.pfly.modal.ErrorPopupView.java

License:Apache License

@Override
public void showMessage(final String msg, final Command afterShow, final Command afterClose) {

    final Bs3Modal modal = modalFactory.get();
    modal.setModalTitle("Error");
    modal.setContent(new HTML(SafeHtmlUtils.fromString(msg)));
    modal.show(afterShow, afterClose);//from w ww.j  av  a 2  s .  c  o m
}

From source file:org.wte4j.ui.client.templates.contextmenu.MyMenuItem.java

License:Apache License

@UiConstructor
public MyMenuItem(String text, ImageResource res) {
    super(SafeHtmlUtils.fromString(text));

    ImageResourceRenderer renderer = new ImageResourceRenderer();
    setHTML(renderer.render(res).asString() + "&nbsp;" + text);
}

From source file:org.xdi.oxd.license.admin.client.Admin.java

public static SafeHtml asHtml(String str) {
    String s = str != null ? str : "";
    if (s.length() > 40) {
        s = s.substring(0, 40) + "...";
    }/*w  ww .j a  v  a 2 s .  c  o m*/
    return SafeHtmlUtils.fromString(s);
}

From source file:org.zoxweb.client.widget.WidgetUtil.java

License:Apache License

/**
 * /*  w w w .  ja v a  2s. com*/
 * @param color
 * @param text
 * @return SafeHtml
 */
public static SafeHtml renderText(String color, String text) {
    SafeHtml safeValue = SafeHtmlUtils.fromString(color);
    // Use the template to create the Cell's html.
    SafeStyles styles = SafeStylesUtils.forTrustedColor(safeValue.asString());
    return STYLE_TEMPLATES.cell(styles, SafeHtmlUtils.fromString(text));
}

From source file:pl.itrack.client.local.view.widgets.modals.BaseDialog.java

License:Apache License

public void setTitle(String title) {
    header.getElement().setInnerSafeHtml(SafeHtmlUtils.fromString(title));
}

From source file:stroom.alert.client.event.CommonAlertEvent.java

License:Apache License

static SafeHtml fromString(final String string) {
    if (string == null) {
        return null;
    }/*from   w w  w.j av  a  2  s  . c o  m*/
    return SafeHtmlUtils.fromString(string);
}

From source file:stroom.cell.valuespinner.client.ValueSpinnerCell.java

License:Apache License

@Override
public void render(final Context context, final Number value, final SafeHtmlBuilder sb) {
    // If the value isn't editable then just output the value.
    if (value != null) {
        if (!(value instanceof Editable) || !((Editable) value).isEditable()) {
            sb.append(SafeHtmlUtils.fromString(String.valueOf(value)));

        } else {//from   w w w  . j  ava 2s  .  c  o m
            // Get the view data.
            final Object key = context.getKey();

            // Get the current view data if there is some.
            ViewData viewData = getViewData(key);

            // If the value held by the view data object is the same as the
            // passed value then we no longer need the view data object to
            // hold temporary state.
            if (viewData != null && viewData.getCurrentValue() != null) {
                try {
                    final Number currentValue = Long.valueOf(viewData.getCurrentValue());
                    if (currentValue != null && currentValue.equals(value)) {
                        clearViewData(key);
                        viewData = null;
                    }
                } catch (final NumberFormatException e) {
                    // Ignore.
                }
            }

            if (viewData != null) {
                sb.append(template.input(viewData.getCurrentValue(), arrowUpHtml, arrowDownHtml));
            } else {
                sb.append(template.input(String.valueOf(value), arrowUpHtml, arrowDownHtml));
            }
        }
    } else {
        sb.append(SafeHtmlUtils.fromSafeConstant("<br/>"));
    }
}

From source file:stroom.dashboard.client.table.TablePresenter.java

License:Apache License

private void addColumn(final Field field, final int pos) {
    final Column<Row, SafeHtml> column = new Column<Row, SafeHtml>(new SafeHtmlCell()) {
        @Override/*from   w  ww . j  av a  2 s.  c o  m*/
        public SafeHtml getValue(final Row row) {
            if (row == null) {
                return null;
            }

            final List<String> values = row.getValues();
            if (values != null) {
                final String value = values.get(pos);
                if (value != null) {
                    if (field.getGroup() != null && field.getGroup() >= row.getDepth()) {
                        final SafeHtmlBuilder sb = new SafeHtmlBuilder();
                        sb.appendHtmlConstant("<b>");
                        sb.appendEscaped(value);
                        sb.appendHtmlConstant("</b>");

                        return sb.toSafeHtml();
                    }
                    return SafeHtmlUtils.fromString(value);
                }
            }
            return null;
        }

        @Override
        public String getCellStyleNames(Cell.Context context, Row object) {
            if (field.getFormat() != null && field.getFormat().getWrap() != null
                    && field.getFormat().getWrap()) {
                return super.getCellStyleNames(context, object) + " "
                        + getView().getResources().dataGridStyle().dataGridCellWrapText();
            }

            return super.getCellStyleNames(context, object);
        }
    };

    final FieldHeader fieldHeader = new FieldHeader(fieldsManager, field);
    fieldHeader.setUpdater(value -> getView().redrawHeaders());

    getView().addResizableColumn(column, fieldHeader, field.getWidth());
    existingColumns.add(column);
}