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:com.extjs.gxt.ui.client.widget.grid.RowEditor.java

License:sencha.com license

protected SafeHtml getErrorText() {
    StringBuffer sb = new StringBuffer();
    sb.append("<ul>");
    for (int i = 0; i < getItemCount(); i++) {

        Field<?> f = (Field<?>) getItem(i);
        if (!f.isValid(true)) {
            sb.append("<li><b>");
            sb.append(grid.getColumnModel().getColumn(i).getHeaderHtml().asString());
            sb.append("</b>: ");
            sb.append(SafeHtmlUtils.htmlEscape(f.getErrorMessage()));
            sb.append("</li>");
        }/*from  w w w.jav a2  s. c om*/
    }
    sb.append("</ul>");
    return SafeHtmlUtils.fromTrustedString(sb.toString());
}

From source file:com.extjs.gxt.ui.client.widget.grid.RowNumberer.java

License:sencha.com license

public RowNumberer() {
    setHeaderHtml(SafeHtmlUtils.EMPTY_SAFE_HTML);
    setWidth(23);//from ww  w . j  a  v  a 2 s. c  o  m
    setSortable(false);
    setResizable(false);
    setFixed(true);
    setMenuDisabled(true);
    setDataIndex("");
    setId("numberer");

    setRenderer(new GridCellRenderer<ModelData>() {

        public SafeHtml render(ModelData model, String property, ColumnData d, int rowIndex, int colIndex,
                ListStore<ModelData> store, Grid<ModelData> grid) {
            d.cellAttr = "rowspan='2'";
            return SafeHtmlUtils.fromTrustedString(String.valueOf(rowIndex + 1));
        }
    });
}

From source file:com.extjs.gxt.ui.client.widget.Slider.java

License:sencha.com license

protected void updateTip() {
    if (useTip) {
        if (!tip.isRendered()) {
            tip.showAt(-100, -100);/*w  ww. j  a  v a2 s  .  c o  m*/
        }
        tip.getBody().update(SafeHtmlUtils.fromTrustedString(Integer.toString(value)));
        Point p = tip.el().getAlignToXY(thumb.el().dom, vertical ? "r-l?" : "b-t?",
                vertical ? new int[] { -5, 0 } : new int[] { 0, -5 });
        tip.showAt(p.x, p.y);
    }
}

From source file:com.extjs.gxt.ui.client.widget.treegrid.TreeGridView.java

License:sencha.com license

public SafeHtml getTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon,
        boolean checkable, Joint joint, int level) {

    StringBuilder sb = new StringBuilder();
    sb.append("<div role=\"presentation\" unselectable=\"on\" id=\"");
    sb.append(id);//from w  ww.  jav a2s.co  m
    sb.append("\" class=\"x-tree3-node\">");

    String cls = "x-tree3-el";
    if (GXT.isHighContrastMode) {
        switch (joint) {
        case COLLAPSED:
            cls += " x-tree3-node-joint-collapse";
            break;
        case EXPANDED:
            cls += " x-tree3-node-joint-expand";
            break;
        }
    }

    sb.append("<div role=\"presentation\" unselectable=\"on\" class=\"" + cls + "\">");

    Element jointElement = null;
    switch (joint) {
    case COLLAPSED:
        jointElement = (Element) tree.getStyle().getJointCollapsedIcon().createElement().cast();
        break;
    case EXPANDED:
        jointElement = (Element) tree.getStyle().getJointExpandedIcon().createElement().cast();
        break;
    }
    if (jointElement != null) {
        El.fly(jointElement).addStyleName("x-tree3-node-joint");
    }

    sb.append("<img src=\"");
    sb.append(GXT.BLANK_IMAGE_URL);
    sb.append("\" style=\"height:18px;width:");
    sb.append(level * getIndenting(findNode(m)));
    sb.append("px;\" />");
    sb.append(jointElement == null
            ? "<img src=\"" + GXT.BLANK_IMAGE_URL + "\" style=\"width: 16px\" class=\"x-tree3-node-joint\" />"
            : DOM.toString(jointElement));
    if (checkable) {
        Element e = (Element) GXT.IMAGES.unchecked().createElement().cast();
        El.fly(e).addStyleName("x-tree3-node-check");
        sb.append(DOM.toString(e));
    } else {
        sb.append("<span class=\"x-tree3-node-check\"></span>");
    }
    if (icon != null) {
        Element e = icon.createElement().cast();
        El.fly(e).addStyleName("x-tree3-node-icon");
        sb.append(DOM.toString(e));
    } else {
        sb.append("<span class=\"x-tree3-node-icon\"></span>");
    }
    sb.append("<span unselectable=\"on\" class=\"x-tree3-node-text\">");
    sb.append(text.asString());
    sb.append("</span>");

    sb.append("</div>");
    sb.append("</div>");

    return SafeHtmlUtils.fromTrustedString(sb.toString());
}

From source file:com.extjs.gxt.ui.client.widget.treegrid.TreeGridView.java

License:sencha.com license

public SafeHtml getWidgetTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon,
        boolean checkable, Joint joint, int level) {

    StringBuffer sb = new StringBuffer();
    sb.append("<div unselectable=\"on\" id=\"");
    sb.append(id);/*from  ww w .j  a  v  a 2 s. com*/
    sb.append("\" class=\"x-tree3-node\">");
    // jumping content when inserting in column with cell widget the column
    // extra width fixes
    sb.append(
            "<div role=\"presentation\" unselectable=\"on\" class=\"x-tree3-el\" style=\"width: 1000px;height: auto;\">");

    sb.append(
            "<table cellpadding=0 cellspacing=0 role=presentation><tr role=presentation><td role=presentation>");

    Element jointElement = null;
    switch (joint) {
    case COLLAPSED:
        jointElement = (Element) tree.getStyle().getJointCollapsedIcon().createElement().cast();
        break;
    case EXPANDED:
        jointElement = (Element) tree.getStyle().getJointExpandedIcon().createElement().cast();
        break;
    }
    if (jointElement != null) {
        El.fly(jointElement).addStyleName("x-tree3-node-joint");
    }

    sb.append("</td><td><img src=\"");
    sb.append(GXT.BLANK_IMAGE_URL);
    sb.append("\" style=\"height:18px;width:");
    sb.append(level * getIndenting(findNode(m)));
    sb.append("px;\" /></td><td  class='x-tree3-el-jnt'>");

    sb.append(jointElement == null
            ? "<img src=\"" + GXT.BLANK_IMAGE_URL + "\" style=\"width: 16px\" class=\"x-tree3-node-joint\" />"
            : DOM.toString(jointElement));

    if (checkable) {
        Element e = (Element) GXT.IMAGES.unchecked().createElement().cast();
        El.fly(e).addStyleName("x-tree3-node-check");
        sb.append(DOM.toString(e));
    } else {
        sb.append("<span class=\"x-tree3-node-check\"></span>");
    }

    sb.append("</td><td>");

    if (icon != null) {
        Element e = icon.createElement().cast();
        El.fly(e).addStyleName("x-tree3-node-icon");
        sb.append(DOM.toString(e));
    } else {
        sb.append("<span class=\"x-tree3-node-icon\"></span>");
    }

    sb.append("</td><td>");
    sb.append("<span unselectable=\"on\" class=\"x-tree3-node-text\">");
    sb.append(text.asString());
    sb.append("</span>");
    sb.append("</td></tr></table>");

    sb.append("</div>");
    sb.append("</div>");

    return SafeHtmlUtils.fromTrustedString(sb.toString());
}

From source file:com.gafactory.core.client.ui.grids.BaseListGrid.java

License:Open Source License

protected Column<T, SafeHtml> addTrustedHtmlColumn(final ValueProvider<T, String> valueProvider, String header,
        int width, boolean sortable) {
    return addColumn(new Column<T, SafeHtml>(new SafeHtmlCell()) {
        @Override//from w w w.  j av  a  2  s .  com
        public SafeHtml getValue(T object) {
            return object != null ? SafeHtmlUtils.fromTrustedString(valueProvider.getValue(object))
                    : SafeHtmlUtils.EMPTY_SAFE_HTML;
        }
    }, header, width, sortable, valueProvider.getPath());
}

From source file:com.goodow.wave.client.wavepanel.blip.TreeTestViewModel.java

License:Apache License

TreeTestViewModel() {
    List<String> title = titles.getList();
    title.add("a");
    title.add("b");
    title.add("c");
    title.add("d");

    List<HasCell<Integer, ?>> hasCell = new ArrayList<HasCell<Integer, ?>>();
    hasCell.add(new HasCell<Integer, Integer>() {

        private AbstractCell<Integer> cell = new AbstractCell<Integer>() {

            @Override//from w  w  w .  j a  v  a 2s  .  com
            public void render(final com.google.gwt.cell.client.Cell.Context context, final Integer value,
                    final SafeHtmlBuilder sb) {
                sb.append(SafeHtmlUtils.fromTrustedString("<div style='float:left;'>"));
                sb.append(value.intValue());
                sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
            }
        };

        @Override
        public Cell<Integer> getCell() {
            return cell;
        }

        @Override
        public FieldUpdater<Integer, Integer> getFieldUpdater() {
            return null;
        }

        @Override
        public Integer getValue(final Integer object) {
            return object;
        }
    });

    hasCell.add(new HasCell<Integer, Integer>() {

        private TrangleButtonCell<Integer> tbc = new TrangleButtonCell<Integer>();

        @Override
        public Cell<Integer> getCell() {
            return tbc;
        }

        @Override
        public FieldUpdater<Integer, Integer> getFieldUpdater() {
            return null;
        }

        @Override
        public Integer getValue(final Integer object) {
            return object;
        }
    });

    composite = new CompositeCell<Integer>(hasCell) {

        @Override
        public void render(final Context context, final Integer value, final SafeHtmlBuilder sb) {
            sb.append(SafeHtmlUtils.fromTrustedString("<div>"));
            super.render(context, value, sb);
            sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
        }

        @Override
        protected Element getContainerElement(final Element parent) {
            return parent.getFirstChildElement();
        }

        @Override
        protected <X> void render(final Context context, final Integer value, final SafeHtmlBuilder sb,
                final HasCell<Integer, X> hasCell) {
            Cell<X> cell = hasCell.getCell();
            // sb.append(SafeHtmlUtils.fromTrustedString("<div>"));
            cell.render(context, hasCell.getValue(value), sb);
            // sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
        }
    };

}

From source file:com.google.gwt.sample.expenses.client.Approval.java

License:Apache License

private Approval(String text, String color, ImageResource res) {
    this.text = text;
    this.color = color;
    this.iconHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(res).getHTML());
}

From source file:com.google.gwt.sample.expenses.client.SortableHeader.java

License:Apache License

private static SafeHtml makeImage(ImageResource resource) {
    AbstractImagePrototype proto = AbstractImagePrototype.create(resource);
    String html = proto.getHTML().replace("style='", "style='position:absolute;right:0px;top:0px;");
    return SafeHtmlUtils.fromTrustedString(html);
}

From source file:com.google.gwt.sample.showcase.client.content.lists.CwStackLayoutPanel.java

License:Apache License

/**
 * Add a {@link TreeItem} to a root item.
 * //from  w  w w .  j a va  2  s  . c o  m
 * @param root the root {@link TreeItem}
 * @param image the icon for the new child item
 * @param label the label for the child icon
 */
@ShowcaseSource
private void addItem(TreeItem root, ImageResource image, String label) {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.append(SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(image).getHTML()));
    sb.appendEscaped(" ").appendEscaped(label);
    root.addItem(sb.toSafeHtml());
}