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:com.gwtmodel.table.view.table.edit.CustomizedGwtSelectionCell.java

License:Apache License

protected void renderCustom(Context context, String value, SafeHtmlBuilder sb, String style, String cClass) {
    // Get the view data.
    Object key = context.getKey();
    String viewData = getViewData(key);
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);//  w  w  w .j av  a  2  s. co  m
        viewData = null;
    }

    int selectedIndex = getSelectedIndex(viewData == null ? value : viewData);
    // sb.appendHtmlConstant("<select tabindex=\"-1\">");
    sb.append(templateInput.input(style, cClass));
    int index = 0;
    for (String option : options) {
        if (index++ == selectedIndex) {
            sb.append(template.selected(option));
        } else {
            sb.append(template.deselected(option));
        }
    }
    sb.appendHtmlConstant("</select>");
}

From source file:com.gwtmodel.table.view.table.edit.PresentationEditCellFactory.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from  w  w  w . j  a  v  a  2  s  .c  o m*/
public void addActionColumn() {
    Column imColumn = constructControlColumn();

    Cell headercell = new ClickableTextCell() {
        @Override
        public void render(Cell.Context context, SafeHtml value, SafeHtmlBuilder sb) {
            SafeHtml html = createSafeForImage(PersistTypeEnum.ADDBEFORE);
            sb.append(html);
        }
    };

    final ElemContainer elemX = new ElemContainer();
    Header head = new Header(headercell) {
        @Override
        public Object getValue() {
            return null;
        }

        @Override
        public void onBrowserEvent(Cell.Context context, Element elem, NativeEvent event) {
            elemX.elem = elem;
            super.onBrowserEvent(context, elem, event);
        }
    };
    head.setUpdater(new ValueUpdater<String>() {
        @Override
        public void update(String value) {
            if (model.getRowEditAction() != null) {
                WSize w = new WSize(elemX.elem);
                model.getRowEditAction().action(w, 0, PersistTypeEnum.ADDBEFORE);
            }
        }
    });

    table.insertColumn(0, imColumn, head);
}

From source file:com.gwtmodel.table.view.table.edit.PresentationEditCellHelper.java

License:Apache License

protected void addInputSb(final SafeHtmlBuilder sb, MutableInteger i, final String value, VListHeaderDesc he) {
    addInputSbI(i, he, new InsertStyleAndClass() {

        @Override//from  w  w  w . j a  v  a  2 s .c  o  m
        public void set(String inputStyle, String inputClass) {
            sb.append(templateInput.input(getS(value), inputStyle, inputClass));
        }
    });
}

From source file:com.itgp.gwtviz.client.ui.cell.client.StringCellAsNumber.java

License:Open Source License

@Override
public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
    if (value != null) {
        double d = 0;
        try {//from   w  ww . j  a va  2s  .  com
            value = value.replaceAll("[^\\d.]", "");
            d = Double.parseDouble(value);
        } catch (NumberFormatException e) {
            return;
        }

        sb.append(renderer.render(format.format(d)));
    }
}

From source file:com.jettmarks.routes.client.ui.NavLinkCell.java

License:Apache License

@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, NavLink model) {
    if (model == null)
        return;/*from  w ww .j ava  2s.  c  o  m*/
    SafeHtml content = TEMPLATE.content(model.getDisplayName());
    safeHtmlBuilder.append(content);
}

From source file:com.jettmarks.routes.client.ui.RouteCell.java

License:Apache License

/**
 * @see com.googlecode.mgwt.ui.client.widget.celllist.Cell#render(com.google.gwt
 *      .safehtml.shared.SafeHtmlBuilder, java.lang.Object)
 *///from   w  w  w .j a v  a  2 s  . c o  m
@Override
public void render(SafeHtmlBuilder safeHtmlBuilder, BikeTrainRoute model) {
    if (model == null)
        return;
    SafeHtml content = TEMPLATE
            .content((model.getDisplayName() != null) ? model.getDisplayName() : model.getName());
    safeHtmlBuilder.append(content);
}

From source file:com.jitlogic.zico.client.views.traces.MethodDetailCell.java

License:Open Source License

@Override
public void render(Context context, TraceRecordInfo tr, SafeHtmlBuilder sb) {
    if (tr.getAttributes() != null) {
        sb.appendHtmlConstant("<table border=\"0\" cellspacing=\"2\"><tbody>");
        for (KeyValuePair e : tr.getAttributes()) {
            sb.appendHtmlConstant("<tr><td align=\"right\" class=\"" + methodAttributeKey + "\"><b>");
            sb.append(SafeHtmlUtils.fromString(e.getKey()));
            sb.appendHtmlConstant("</b></td><td><div class=\"" + methodAttributeVal + "\">");
            sb.append(SafeHtmlUtils.fromString(e.getValue() != null ? e.getValue().toString() : ""));
            sb.appendHtmlConstant("</div></td></tr>");
        }//from ww  w  .  j  a  va 2 s . c  o  m
        sb.appendHtmlConstant("</tbody></table>");
    }
    if (tr.getExceptionInfo() != null) {
        SymbolicExceptionInfo e = tr.getExceptionInfo();
        sb.appendHtmlConstant("<div class=\"" + methodErrorClassName + "\">");
        sb.append(SafeHtmlUtils.fromString("Caught: " + e.getExClass()));
        sb.appendHtmlConstant("</div>");
        sb.appendHtmlConstant("<div class=\"" + methodErrorMessage + "\">");
        sb.append(SafeHtmlUtils.fromString("" + e.getMessage()));
        sb.appendHtmlConstant("</b></div>");
        int i = 0;
        for (String s : e.getStackTrace()) {
            sb.appendHtmlConstant("<div class=\"" + methodErrorStack + "\">");
            sb.append(SafeHtmlUtils.fromString("" + s));
            sb.appendHtmlConstant("</div>");
            i++;
            if (i > 5) {
                sb.appendHtmlConstant("<div class=\"" + methodErrorMessage + "\">");
                sb.append(
                        SafeHtmlUtils.fromString("...  (double click on this method to see full stack trace)"));
                sb.appendHtmlConstant("</div>");
                break;
            }
        }
    }
}

From source file:com.jitlogic.zico.client.views.traces.TraceDetailCell.java

License:Open Source License

@Override
public void render(Context context, TraceInfo ti, SafeHtmlBuilder sb) {
    if (ti.getAttributes() != null) {
        sb.appendHtmlConstant("<table border=\"0\" cellspacing=\"2\"><tbody>");
        for (KeyValuePair e : ti.getAttributes()) {
            sb.appendHtmlConstant("<tr><td align=\"right\" style=\"color:blue; font-size: small;\"><b>");
            sb.append(SafeHtmlUtils.fromString(e.getKey()));
            sb.appendHtmlConstant(//from  w  w w .  j av  a 2  s  .  c  om
                    "</b></td><td><div style=\"text-wrap: unrestricted; white-space: pre; word-wrap: break-word; font-size: small;\">");
            sb.append(SafeHtmlUtils.fromString(e.getValue() != null ? e.getValue().toString() : ""));
            sb.appendHtmlConstant("</div></td></tr>");
        }
        sb.appendHtmlConstant("</tbody></table>");
    }
    if (ti.getExceptionInfo() != null) {
        SymbolicExceptionInfo e = ti.getExceptionInfo();
        sb.appendHtmlConstant("<div><span style=\"color: red;\">");
        sb.append(SafeHtmlUtils.fromString("Caught: " + e.getExClass()));
        sb.appendHtmlConstant("</span></div><div><b>");
        sb.append(SafeHtmlUtils.fromString("" + e.getMessage()));
        sb.appendHtmlConstant("</b></div>");
        int i = 0;
        for (String s : e.getStackTrace()) {
            sb.appendHtmlConstant("<div>");
            sb.append(SafeHtmlUtils.fromString("" + s));
            sb.appendHtmlConstant("</div>");
            i++;
            if (i > 5) {
                sb.appendHtmlConstant("<div>");
                sb.append(SafeHtmlUtils
                        .fromString("...      (open trace attributes window to see full stack trace)"));
                sb.appendHtmlConstant("</div>");
                break;
            }

        }
    }
}

From source file:com.jitlogic.zico.client.widgets.NanoTimeRenderingCell.java

License:Open Source License

@Override
public void render(Context context, Long time, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant("<span>");
    sb.append(SafeHtmlUtils.fromString(ClientUtil.formatDuration(time)));
    sb.appendHtmlConstant("</span>");
}

From source file:com.jitlogic.zico.widgets.client.SelectCell.java

License:Open Source License

@Override
public void render(Context context, V value, SafeHtmlBuilder sb) {
    Object key = context.getKey();
    V viewData = getViewData(key);//from www  . j  av  a  2  s .  c o  m
    if (viewData != null && viewData.equals(value)) {
        clearViewData(key);
        viewData = null;
    }

    V selected = viewData == null ? value : viewData;

    sb.appendHtmlConstant("<select tabindex=\"-1\">");

    for (int i = 0; i < options.size(); i++) {
        V val = values.get(i);
        T opt = options.get(i);
        if (selected != null && selected.equals(val)) {
            sb.append(template.selectedOption("" + val, "" + opt));
        } else {
            sb.append(template.option("" + val, "" + opt));
        }
    }

    sb.appendHtmlConstant("</select>");
}