Java Code Examples for com.google.gwt.dom.client.Element#getTagName()

The following examples show how to use com.google.gwt.dom.client.Element#getTagName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DomLogger.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Outputs debug-string representing a DOM element
 *
 * @param e
 * @return XML rendering of element
 */
@SuppressWarnings("unused")
private static String toXml(Element e) {
  String out = "";
  if (DomHelper.isTextNode(e)) {
    out = "'" + shortString(e.getNodeValue()) + "'";
  } else {
    String tagName = e.getTagName();
    out = "<" + tagName;
    if (tagName.equals("INPUT")) {
      out += attr(e, "type");
      out += attr(e, "value");
    }
    out += attr(e, "class");
    if (tagName.equals("A")) {
      out += ">" + e.getInnerText() + "</A>";
    } else {
      out += "/>";
    }
  }
  return out;
}
 
Example 2
Source File: DomHelper.java    From swellrt with Apache License 2.0 6 votes vote down vote up
public static ElementEditability getElementEditability(Element elem) {
  // NOTE(danilatos): This is not necessarily accurate in 100% of situations, with weird
  // combinations of editability/enabled etc attributes and tagnames...

  String tagName = null;
  try {
    tagName = elem.getTagName();
  } catch (Exception exception) {
    // Couldn't get access to the tag name for some reason (see b/2314641).
  }

  if (tagName != null) {
    tagName = tagName.toLowerCase();
    if (tagName.equals("input") || tagName.equals("textarea")) {
      return ElementEditability.EDITABLE;
    }
  }

  return getContentEditability(elem);
}
 
Example 3
Source File: NavSpy.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void collectHeadings(Element element, List<Element> headings) {
	for (int i = 0; i < element.getChildCount(); i++) {
		Node node = element.getChild(i);
		if (node instanceof Element) {
			Element child = (Element) node;
			String tagName = child.getTagName();
			if (tagName != null && Heading.HEADING_TAGS.contains(tagName.toLowerCase())) {
				if (this.spyName != null && this.spyName.equals(child.getAttribute(Heading.ATTRIBUTE_DATA_SUMMARY))) {
					headings.add(child);
				}
			} else {
				this.collectHeadings(child, headings);
			}
		}
	}
}
 
Example 4
Source File: DomLogger.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Outputs debug-string representing a DOM element
 *
 * @param e
 * @return XML rendering of element
 */
@SuppressWarnings("unused")
private static String toXml(Element e) {
  String out = "";
  if (DomHelper.isTextNode(e)) {
    out = "'" + shortString(e.getNodeValue()) + "'";
  } else {
    String tagName = e.getTagName();
    out = "<" + tagName;
    if (tagName.equals("INPUT")) {
      out += attr(e, "type");
      out += attr(e, "value");
    }
    out += attr(e, "class");
    if (tagName.equals("A")) {
      out += ">" + e.getInnerText() + "</A>";
    } else {
      out += "/>";
    }
  }
  return out;
}
 
Example 5
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
public static ElementEditability getElementEditability(Element elem) {
  // NOTE(danilatos): This is not necessarily accurate in 100% of situations, with weird
  // combinations of editability/enabled etc attributes and tagnames...

  String tagName = null;
  try {
    tagName = elem.getTagName();
  } catch (Exception exception) {
    // Couldn't get access to the tag name for some reason (see b/2314641).
  }

  if (tagName != null) {
    tagName = tagName.toLowerCase();
    if (tagName.equals("input") || tagName.equals("textarea")) {
      return ElementEditability.EDITABLE;
    }
  }

  return getContentEditability(elem);
}
 
Example 6
Source File: ClientUtils.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Dumps Element content and traverse its children.
 * <p/><b>WARNING:</b> it is com.google.gwt.dom.client.Element not com.google.gwt.xml.client.Element!!!
 * 
 * @param elm an element to dump
 * @param indent row indentation for current level
 * @param indentIncrement increment for next level
 * @param sb dumped content
 * @return dumped content
 */
public static StringBuilder dump(Element elm, String indent, String indentIncrement, StringBuilder sb) {
    int childCount = elm.getChildCount();
    String innerText = elm.getInnerText();
    String lang = elm.getLang();
    String nodeName = elm.getNodeName();
    short nodeType = elm.getNodeType();
    String getString = elm.getString();
    String tagNameWithNS = elm.getTagName();
    String xmlLang = elm.getAttribute("xml:lang");

    sb.append(ClientUtils.format("%sElement {nodeName: %s, nodeType: %s, tagNameWithNS: %s, lang: %s,"
            + " childCount: %s, getString: %s, xmlLang: %s}\n",
            indent, nodeName, nodeType, tagNameWithNS, lang, childCount, getString, xmlLang));
    NodeList<Node> childNodes = elm.getChildNodes();
    indent += indentIncrement;
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node child = childNodes.getItem(i);
        if (Element.is(child)) {
            dump(Element.as(child), indent, indentIncrement, sb);
        } else {
            sb.append(ClientUtils.format("%sNode: nodeType: %s, nodeName: %s, childCount: %s, nodeValue: %s\n",
                    indent, child.getNodeType(), child.getNodeName(), child.getChildCount(), child.getNodeValue()));
        }
    }
    return sb;
}
 
Example 7
Source File: HtmlViewImpl.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public String getTagName(Element element) {
  return element.getTagName();
}
 
Example 8
Source File: HtmlViewImpl.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public String getTagName(Element element) {
  return element.getTagName();
}