Example usage for com.google.gwt.user.client DOM toString

List of usage examples for com.google.gwt.user.client DOM toString

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM toString.

Prototype

@Deprecated
public static String toString(Element elem) 

Source Link

Document

Returns a stringized version of the element.

Usage

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.InvalidableWithCodeRenderer.java

License:Apache License

public static String render(IInvalidationProvider entity, String code) {
    final Element anchor = DOM.createAnchor();
    anchor.setInnerText(code);//from  w w w  .jav a  2 s  . c o m
    DOM.setElementProperty(anchor, "href", "#");
    String link = DOM.toString(anchor);
    boolean isValid = entity.getInvalidation() == null;
    if (isValid) {
        return link;
    }
    Element div = DOM.createDiv();
    div.setAttribute("class", "invalid");
    div.setInnerHTML(link);
    return DOM.toString(div);
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.LinkRenderer.java

License:Apache License

/** renders a div witch looks like an anchor (hand cursor is on div - block) */
public static String renderAsLink(final String message) {
    final Element div = DOM.createDiv();
    div.setInnerHTML(message);/*  w  ww.j a  va 2s. co m*/
    div.setClassName("link-style");
    return DOM.toString(div);
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.LinkRenderer.java

License:Apache License

/** renders a div with an inline anchor inside (hand cursor is on anchor - inline) */
public static String renderAsLinkWithAnchor(final String text, final String href,
        final boolean openInNewWindow) {
    final Element anchor = DOM.createAnchor();
    DOM.setInnerText(anchor, text);/*  w  ww. j  a v  a2s.c o  m*/

    DOM.setElementProperty(anchor, "href", href);
    if (openInNewWindow) {
        DOM.setElementProperty(anchor, "target", "blank");
    }
    return DOM.toString(anchor);
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.PersonRenderer.java

License:Apache License

/**
 * Creates an <i>HTML</i> A element for given <var>person</var> with a specified name.
 *///from   w  w  w .  ja  v a 2s  . c om
public final static String createPersonAnchor(final Person person, String personName) {
    assert person != null : "Unspecified person.";
    final String email = person.getEmail();
    if (StringUtils.isBlank(email) == false) {
        final Element anchor = DOMUtils.createAnchorElement(null, "mailto:" + email, email);
        DOM.setInnerText(anchor, personName);
        return DOM.toString(anchor);
    } else {
        return personName;
    }
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.MultilineHTML.java

License:Apache License

public static String wrapUpInDivWithTooltip(String text, String tooltip) {
    final Element div = DOM.createDiv();
    div.setInnerHTML(text);//from   www .java 2 s .com
    div.setTitle(tooltip);
    return DOM.toString(div);
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.util.DOMUtils.java

License:Apache License

/**
 * Creates a &lt;del&gt; <i>HTML</i> element.
 *///from   w  w w  . ja  va  2 s. c  om
public final static String createDelElement(final String innerText) {
    final Element element = DOM.createElement("del");
    DOM.setInnerText(element, innerText);
    return DOM.toString(element);
}

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  ww  w. j ava  2  s .  c  o  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);/*  w  ww  . j  a v  a2 s  .c o  m*/
    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.extjs.gxt.ui.client.widget.treepanel.TreePanelView.java

License:sencha.com license

public String getTemplate(ModelData m, String id, SafeHtml text, AbstractImagePrototype icon, boolean checkable,
        boolean checked, Joint joint, int level, TreeViewRenderMode renderMode) {
    if (renderMode == TreeViewRenderMode.CONTAINER) {
        if (GXT.isIE6 || GXT.isIE7) {
            return "<div unselectable=on class=\"x-tree3-node-ct\" style=\"position:relative;\" role=\"group\"></div>";
        } else {//from   w ww.ja  va2  s .com
            return "<div unselectable=on class=\"x-tree3-node-ct\" style=\"position:relative;\" role=\"group\"><table cellpadding=0 cellspacing=0 width=100%><tr><td></td></tr></table></div>";
        }
    }
    StringBuilder sb = new StringBuilder();
    if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.MAIN) {
        sb.append("<div unselectable=on id=\"");
        sb.append(id);
        sb.append("\"");

        sb.append(" class=\"x-tree3-node\"  role=\"presentation\">");

        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 unselectable=on class=\"" + cls + "\" id=\"" + tree.getId() + "__" + id
                + "\" role=\"treeitem\" ");
        sb.append(" aria-level=\"" + (level + 1) + "\">");
    }
    if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.BODY) {
        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) 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) (checked ? GXT.IMAGES.checked().createElement().cast()
                    : 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>");
    }

    if (renderMode == TreeViewRenderMode.ALL || renderMode == TreeViewRenderMode.MAIN) {
        sb.append("</div>");
        sb.append("</div>");
    }
    return sb.toString();
}

From source file:gwt.material.design.client.base.MaterialButtonCell.java

License:Apache License

@SuppressWarnings("deprecation")
@Override//from w  w  w  .j  a  v  a 2s  .co m
public void render(Context context, MaterialButton value, SafeHtmlBuilder sb) {
    sb.appendHtmlConstant(DOM.toString(value.getElement()));
}