Java Code Examples for com.google.gwt.dom.client.Node#ELEMENT_NODE

The following examples show how to use com.google.gwt.dom.client.Node#ELEMENT_NODE . 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: DOMMutationExtractor.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Handles DOM mutation events.
 * @param event
 * @param contentRange  last known selection
 */
public void handleDOMMutation(SignalEvent event, ContentRange contentRange) {
  // Early exit if non-safari or non-mac
  if (!(UserAgent.isSafari() && UserAgent.isMac())) {
    return;
  }

  // We don't care about DOMMutations that we generate while we are reverting.
  if (isReverting) {
    return;
  }

  previousContentRange = contentRange;

  Node n = event.getTarget();
  if (n.getNodeType() == Node.ELEMENT_NODE) {
    Element e = Element.as(event.getTarget());
    if (DOM_EVENTS_IGNORE.contains(event.getType())) {
      // ignore
      return;
    } else if (event.getType().equals("DOMNodeInserted") && handleDOMNodeInserted(e)) {
      return;
    } else if (event.getType().equals("DOMNodeRemoved") && handleDOMNodeRemoved(e)) {
      return;
    }
  }
  return;
}
 
Example 2
Source File: DOMMutationExtractor.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Handles DOM mutation events.
 * @param event
 * @param contentRange  last known selection
 */
public void handleDOMMutation(SignalEvent event, ContentRange contentRange) {
  // Early exit if non-safari or non-mac
  if (!(UserAgent.isSafari() && UserAgent.isMac())) {
    return;
  }

  // We don't care about DOMMutations that we generate while we are reverting.
  if (isReverting) {
    return;
  }

  previousContentRange = contentRange;

  Node n = event.getTarget();
  if (n.getNodeType() == Node.ELEMENT_NODE) {
    Element e = Element.as(event.getTarget());
    if (DOM_EVENTS_IGNORE.contains(event.getType())) {
      // ignore
      return;
    } else if (event.getType().equals("DOMNodeInserted") && handleDOMNodeInserted(e)) {
      return;
    } else if (event.getType().equals("DOMNodeRemoved") && handleDOMNodeRemoved(e)) {
      return;
    }
  }
  return;
}
 
Example 3
Source File: Header.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void highlight(String name)
{
    toggleSubnavigation(name);

    com.google.gwt.user.client.Element target = linksPane.getElementById("header-links-ref");
    if(target!=null) // TODO: i think this cannot happen, does it?
    {
        NodeList<Node> childNodes = target.getChildNodes();
        for(int i=0; i<childNodes.getLength(); i++)
        {
            Node n = childNodes.getItem(i);
            if(Node.ELEMENT_NODE == n.getNodeType())
            {
                Element element = (Element) n;
                if(element.getId().equals("header-"+name))
                {
                    element.addClassName("header-link-selected");
                    element.setAttribute("aria-selected", "true");
                }
                else {
                    element.removeClassName("header-link-selected");
                    element.setAttribute("aria-selected", "false");
                }
            }
        }
    }
}
 
Example 4
Source File: DomHelper.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * @return true if it is an element
 */
public static boolean isElement(Node n) {
  return n.getNodeType() == Node.ELEMENT_NODE;
}
 
Example 5
Source File: HtmlViewImpl.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Element asElement(Node node) {
  return node.getNodeType() == Node.ELEMENT_NODE ? node.<Element>cast() : null;
}
 
Example 6
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * @return true if it is an element
 */
public static boolean isElement(Node n) {
  return n.getNodeType() == Node.ELEMENT_NODE;
}
 
Example 7
Source File: HtmlViewImpl.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
public Element asElement(Node node) {
  return node.getNodeType() == Node.ELEMENT_NODE ? node.<Element>cast() : null;
}