Example usage for com.google.gwt.dom.client TableElement as

List of usage examples for com.google.gwt.dom.client TableElement as

Introduction

In this page you can find the example usage for com.google.gwt.dom.client TableElement as.

Prototype

public static TableElement as(Element elem) 

Source Link

Document

Assert that the given Element is compatible with this class and automatically typecast it.

Usage

From source file:com.anzsoft.client.ui.ChatWindow.java

License:Open Source License

private DivElement createMessage(final String user, final String message, boolean local) {
    Element element = DOM.createDiv();
    DivElement messageDiv = DivElement.as(element);
    lastMsgID = DOM.createUniqueId();/*from   ww  w  . j a  v  a2s. c o m*/
    messageDiv.setId(lastMsgID);
    messageDiv.setClassName("selected-article");

    //create the avatar table
    element = DOM.createTable();
    TableElement avatarTable = TableElement.as(element);
    messageDiv.appendChild(avatarTable);
    avatarTable.setAttribute("hspace", "4");
    avatarTable.setAttribute("cellspacing", "0");
    avatarTable.setAttribute("vspace", "2");
    avatarTable.setAttribute("border", "0");
    avatarTable.setAttribute("align", "left");

    Element tbodyElement = DOM.createTBody();
    avatarTable.appendChild(tbodyElement);

    Element trElement = DOM.createTR();
    tbodyElement.appendChild(trElement);

    Element tdElement = DOM.createTD();
    trElement.appendChild(tdElement);
    tdElement.setAttribute("height", "45");
    tdElement.setAttribute("width", "45");
    tdElement.setAttribute("align", "middle");
    Style style = tdElement.getStyle();
    style.setProperty("border", "1px solid black");
    style.setProperty("background-color", "white");

    Element imgElement = DOM.createImg();
    ImageElement imageElement = ImageElement.as(imgElement);
    tdElement.appendChild(imageElement);
    imageElement.setAttribute("height", "45");
    imageElement.setAttribute("widht", "45");
    XmppVCard vc = null;
    if (local)
        vc = JabberApp.instance().getSelfVCard();
    else
        vc = vcard;
    if (!GXT.isIE && vc != null && !vc.photo().isEmpty())
        imageElement.setSrc("data:image;base64," + vc.photo());
    else
        imageElement.setSrc(JabberApp.instance().getAvatarUrl(jid));

    tdElement = DOM.createTD();
    tdElement.setInnerHTML("&nbsp&nbsp");
    trElement.appendChild(tdElement);

    //create the div for timestamp and nick
    element = DOM.createDiv();
    DivElement tnDiv = DivElement.as(element);
    tnDiv.setClassName("msg_header");
    messageDiv.appendChild(tnDiv);
    //style = tnDiv.getStyle();
    //style.setProperty("border-bottom", "1px solid black");

    element = DOM.createTable();
    TableElement tnTableElement = TableElement.as(element);
    tnDiv.appendChild(tnTableElement);
    tnTableElement.setAttribute("cellspacing", "0");
    tnTableElement.setAttribute("cellpadding", "0");
    tnTableElement.setAttribute("width", "80%");
    tnTableElement.setAttribute("border", "0");

    tbodyElement = DOM.createTBody();
    tnTableElement.appendChild(tbodyElement);

    trElement = DOM.createTR();
    tbodyElement.appendChild(trElement);

    Element nickElement = DOM.createTD();
    trElement.appendChild(nickElement);
    nickElement.setClassName("msg-nick");
    nickElement.setAttribute("valign", "bottom");
    nickElement.setAttribute("align", "left");
    nickElement.setInnerHTML("<b>" + user + "</b>");

    Element timeElement = DOM.createTD();
    trElement.appendChild(timeElement);
    timeElement.setClassName("msg-nick");
    timeElement.setAttribute("valign", "bottom");
    timeElement.setAttribute("align", "right");
    DateTimeFormat timeFormat = DateTimeFormat.getMediumTimeFormat();
    String datetime = timeFormat.format(new java.util.Date());
    timeElement.setInnerHTML("<small>" + datetime + "</small>");

    Element messageElement = DOM.createSpan();
    messageElement.setInnerHTML(ChatTextFormatter.format(message == null ? "" : message).getHTML());

    messageDiv.appendChild(messageElement);
    return messageDiv;
}

From source file:com.dom_distiller.client.FilteringDomVisitor.java

License:Open Source License

@Override
public boolean visit(Node n) {
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        Element e = Element.as(n);

        // Skip invisible or uninteresting elements.
        boolean visible = DomUtil.isVisible(e);
        logVisibilityInfo(e, visible);/*from w  w w . j  av a2s  .c om*/
        if (!visible) {
            hiddenElements.add(e);
            return false;
        }

        // Skip data tables, keep track of them to be extracted by RelevantElementsFinder later.
        if (e.hasTagName("TABLE")) {
            TableClassifier.Type type = TableClassifier.table(TableElement.as(e));
            logTableInfo(e, type);
            if (type == TableClassifier.Type.DATA) {
                dataTables.add(e);
                return false;
            }
        }

        // Some components are revisited later in context as they break text-flow of a document.
        // e.g. <video> can contain text if format is unsupported.
        if (sTagsProcessedAsABlock.contains(e.getTagName())) {
            if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
                LogUtil.logToConsole(
                        "SKIP " + e.getTagName() + " from processing. " + "It may be restored later.");
            }
            return false;
        }
    }
    return domVisitor.visit(n);
}

From source file:com.sencha.gxt.theme.base.client.grid.GridBaseAppearance.java

License:sencha.com license

@Override
public NodeList<Element> getRows(XElement parent) {
    return TableElement.as(parent.getFirstChildElement()).getTBodies().getItem(1).getRows().cast();
}

From source file:com.sencha.gxt.theme.base.client.grid.GridBaseAppearance.java

License:sencha.com license

@Override
public Element getRowBody(Element row) {
    return TableElement.as(row.getFirstChildElement().getFirstChildElement().getFirstChildElement())
            .getTBodies().getItem(1).getRows().getItem(1).getCells().getItem(0).getFirstChildElement();
}

From source file:com.vaadin.client.widget.grid.AutoScroller.java

License:Apache License

private TableElement getTableElement() {
    final Element root = grid.getElement();
    final Element tablewrapper = Element.as(root.getChild(2));
    if (tablewrapper != null) {
        return TableElement.as(tablewrapper.getFirstChildElement());
    } else {/*ww w  .j  a va  2  s  . c om*/
        return null;
    }
}

From source file:org.chromium.distiller.webdocument.DomConverter.java

License:Open Source License

private boolean visitElement(Element e) {
    // Skip invisible or uninteresting elements.
    boolean visible = DomUtil.isVisible(e);
    logVisibilityInfo(e, visible);//  w  w w . ja va2  s  . com
    if (!visible) {
        hiddenElements.add(e);
        return false;
    }

    // Node-type specific extractors check for elements they are interested in here. Everything
    // else will be filtered through the switch below.

    // Check for embedded elements that might be extracted.
    if (embedTagNames.contains(e.getTagName())) {
        // If the tag is marked as interesting, check the extractors.
        for (EmbedExtractor extractor : extractors) {
            WebElement embed = extractor.extract(e);
            if (embed != null) {
                builder.embed(embed);
                return false;
            }
        }
    }

    // Create a placeholder for the elements we want to preserve.
    if (WebTag.canBeNested(e.getTagName())) {
        builder.tag(new WebTag(e.getTagName(), WebTag.TagType.START));
    }

    switch (e.getTagName()) {
    case "BR":
        builder.lineBreak(e);
        return false;
    // Skip data tables, keep track of them to be extracted by RelevantElementsFinder
    // later.
    case "TABLE":
        TableClassifier.Type type = TableClassifier.table(TableElement.as(e));
        logTableInfo(e, type);
        if (type == TableClassifier.Type.DATA) {
            builder.dataTable(e);
            return false;
        }
        break;

    // Some components are revisited later in context as they break text-flow of a
    // document.  e.g. <video> can contain text if format is unsupported.
    case "VIDEO":
        builder.embed(new WebVideo(e, e.getClientHeight(), e.getClientHeight()));
        return false;

    // These element types are all skipped (but may affect document construction).
    case "OPTION":
    case "OBJECT":
    case "EMBED":
    case "APPLET":
        skip(e);
        return false;

    // These types are skipped and don't affect document construction.
    case "HEAD":
    case "STYLE":
    case "SCRIPT":
    case "LINK":
    case "NOSCRIPT":
        return false;
    }
    builder.startElement(e);
    return true;
}