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:cc.alcina.framework.gwt.client.cell.PropertySelectorCell.java

License:Apache License

@Override
public void render(Context context, Set<T> value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    Set<T> viewData = getViewData(key);
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);// ww w  . j  a  va2 s  .  c om
        viewData = null;
    }
    String s = null;
    if (viewData != null) {
        s = toStringMapper.apply(viewData);
    } else if (value != null) {
        s = toStringMapper.apply(value);
    }
    if (s != null) {
        if (s.isEmpty()) {
            s = "\u00A0";
        }
        sb.append(renderer.render(s));
    }
}

From source file:cc.alcina.framework.gwt.client.cell.PropertyTextCell.java

License:Apache License

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    ViewData viewData = getViewData(key);
    if (viewData != null && !viewData.isEditing() && value != null && value.equals(viewData.getText())) {
        clearViewData(key);/*w  w  w  . j av a2s .c o  m*/
        viewData = null;
    }
    String toRender = value;
    if (viewData != null) {
        String text = viewData.getText();
        if (text == null) {
            text = "";
        }
        if (viewData.isEditing()) {
            /*
             * Do not use the renderer in edit mode because the value of a
             * text input element is always treated as text. SafeHtml isn't
             * valid in the context of the value attribute.
             */
            sb.append(template.input(text));
            return;
        } else {
            // The user pressed enter, but view data still exists.
            toRender = text;
        }
    }
    sb.appendHtmlConstant("<span class='property-text-cell'>");
    if (toRender != null && toRender.trim().length() > 0) {
        sb.append(renderer.render(toRender));
    } else {
        /*
         * Render a blank space to force the rendered element to have a
         * height. Otherwise it is not clickable.
         */
        sb.appendHtmlConstant("\u00A0");
    }
    sb.appendHtmlConstant("</span>");
}

From source file:cc.alcina.framework.gwt.client.cell.UnsafeHtmlCell.java

License:Apache License

@Override
public void render(Context context, FunctionalTuple value, SafeHtmlBuilder sb) {
    String prelude = "<div>";
    if (Ax.notBlank(value.title)) {
        prelude = Ax.format("<div title='%s'>", SafeHtmlUtils.htmlEscape(value.title));
    }// w  w w. j  a  v a2s  .c o m
    sb.append(SafeHtmlUtils.fromTrustedString(prelude));
    sb.append(SafeHtmlUtils.fromTrustedString(Ax.blankToEmpty(value.text)));
    sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
}

From source file:ch.cern.atlas.apvs.client.widget.EditTextCell.java

License:Apache License

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    ViewData viewData = getViewData(key);
    if (viewData != null && !viewData.isEditing() && value != null && value.equals(viewData.getText())) {
        clearViewData(key);//from w w w.j av a  2  s  . c o m
        viewData = null;
    }

    String toRender = value;
    if (viewData != null) {
        String text = viewData.getText();
        if (viewData.isEditing()) {
            /*
             * Do not use the renderer in edit mode because the value of a text
             * input element is always treated as text. SafeHtml isn't valid in the
             * context of the value attribute.
             */
            sb.append(template.input(text));
            return;
        } else {
            // The user pressed enter, but view data still exists.
            toRender = text;
        }
    }

    if (toRender != null && toRender.trim().length() > 0) {
        sb.append(renderer.render(toRender));
    } else {
        /*
         * Render a blank space to force the rendered element to have a height.
         * Otherwise it is not clickable.
         */
        sb.appendHtmlConstant("\u00A0");
    }
}

From source file:cimav.client.view.nomina.NomCantidadInputCell.java

@Override
public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    TextInputCell.ViewData viewData = this.getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);/*  w ww  . j a  v  a 2  s  .c  o m*/
        viewData = null;
    }

    // boolean isEditing = this.isEditing(context, null, value);
    String s = (viewData != null) ? viewData.getCurrentValue() : value;
    if (s == null) // || isEditing)
    {
        sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\"></input>");
    } else {
        // this is where we set value, size, style
        sb.append(template.input(s,
                "width: 100%; text-align: inherit; margin: 0px; height: 22px !important; font-size:11px;"));
    }
}

From source file:cimav.client.view.nomina.NomDateInputCell.java

@Override
public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    TextInputCell.ViewData viewData = this.getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);/*from www. j a va2s .c o  m*/
        viewData = null;
    }

    // boolean isEditing = this.isEditing(context, null, value);
    String v = (viewData != null) ? viewData.getCurrentValue() : value;
    if (v == null) // || isEditing)
    {
        sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\"></input>");
    } else {
        // this is where we set value, size, style
        sb.append(template.input(v, "1980-01-01",
                "width: 100%; text-align: inherit; margin: 0px; height: 22px !important; font-size:11px;"));
    }
}

From source file:cimav.client.view.nomina.NomIconInputCell.java

@Override
public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    TextInputCell.ViewData viewData = this.getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);//from  w  w w  .java2  s .  com
        viewData = null;
    }

    // boolean isEditing = this.isEditing(context, null, value);
    String v = (viewData != null) ? viewData.getCurrentValue() : value;
    if (v == null) // || isEditing)
    {
        sb.appendHtmlConstant("<input type='text' tabindex='-1'></input>");
    } else {
        if (SALDO == tipo) {
            sb.append(templateSaldo.input(v));
        } else if (FALTA == tipo) {
            sb.append(templateFalta.input(v));
        } else if (HORA_EXTRA == tipo) {
            sb.append(templateHoraExtra.input(v));
        }
    }
}

From source file:cimav.client.view.nomina.NomIntegerInputCell.java

@Override
public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    TextInputCell.ViewData viewData = this.getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);/*from   w w  w .j  a v a2  s  .  c om*/
        viewData = null;
    }

    // boolean isEditing = this.isEditing(context, null, value);
    String s = (viewData != null) ? viewData.getCurrentValue() : value;
    if (s == null) // || isEditing)
    {
        sb.appendHtmlConstant("<input type=\"text\" tabindex=\"-1\"></input>");
    } else {
        // this is where we set value, size, style
        sb.append(template.input(s, this.max));
    }
}

From source file:cimav.client.view.nomina.NomTextInputCell.java

@Override
public void render(Cell.Context context, String value, SafeHtmlBuilder sb) {
    // Get the view data.
    Object key = context.getKey();
    TextInputCell.ViewData viewData = this.getViewData(key);
    if (viewData != null && viewData.getCurrentValue().equals(value)) {
        clearViewData(key);/*from  w  w w  .  ja  va2  s . c om*/
        viewData = null;
    }

    // boolean isEditing = this.isEditing(context, null, value);
    String v = (viewData != null) ? viewData.getCurrentValue() : value;
    if (v == null) // || isEditing)
    {
        sb.appendHtmlConstant("<input type'text' tabindex='-1'></input>");
    } else {
        // this is where we set value, size, style
        sb.append(template.input(v,
                "width: 130px; text-align: inherit; margin: 0px; height: 22px !important; font-size:11px;"));
    }
}

From source file:com.akanoo.client.widgets.UserCell.java

License:Apache License

@Override
public void render(com.google.gwt.cell.client.Cell.Context context, UserInfo value, SafeHtmlBuilder sb) {
    Style style = resources.userCellStyle();
    SafeUri thumbUrl = null;//  w  ww.  j ava 2  s. c  om
    if (value.thumbUrl != null)
        try {
            thumbUrl = UriUtils.fromString(value.thumbUrl);
        } catch (Exception ex) {
        }

    if (thumbUrl != null)
        sb.append(template.cell(style.cell(), style.thumb(), thumbUrl, style.name(), value.name));
    else
        sb.append(template.cellSimple(style.cell(), style.name(), value.name));
}