org.w3c.dom.events.Event Java Examples

The following examples show how to use org.w3c.dom.events.Event. 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: SvgElementMapper.java    From jetpad-projectional-open-source with Apache License 2.0 6 votes vote down vote up
private void addMouseHandler(final SvgEventSpec spec, final String eventType) {
  final EventListener listener = new EventListener() {
    @Override
    public void handleEvent(Event evt) {
      evt.stopPropagation();
      getSource().dispatch(spec, new MouseEvent(((DOMMouseEvent) evt).getClientX(), ((DOMMouseEvent) evt).getClientY()));
    }
  };
  getTarget().addEventListener(eventType, listener, false);
  myHandlerRegs.put(spec, new Registration() {
    @Override
    protected void doRemove() {
      getTarget().removeEventListener(eventType, listener, false);
    }
  });
}
 
Example #2
Source File: DocumentImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #3
Source File: DomSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void handleEvent(final Event evt) {
    try {
        getLock().write(new Runnable() {
            public void run() {
                Document d = (Document)evt.getCurrentTarget();
                Document old = (Document)getValueNonBlocking();
                assert old == null || old == d;
                logger.log(Level.FINEST, "DomSupport got DOM event {0} on {1}, inIsolatingChange={2}", new Object[] {evt, ph, inIsolatingChange ? Boolean.TRUE : Boolean.FALSE});
                if (!inIsolatingChange) {
                    try {
                        setDocument(d);
                    } catch (IOException e) {
                        assert false : e;
                    }
                } else {
                    madeIsolatedChanges = true;
                }
            }
        });
    } catch (RuntimeException e) {
        // Xerces ignores them.
        e.printStackTrace();
    }
}
 
Example #4
Source File: DocumentImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #5
Source File: DocumentImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #6
Source File: DocumentImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #7
Source File: WebBrowserBoxController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
protected void clickLink() {
        EventListener listener = new EventListener() {
            public void handleEvent(Event ev) {
//                    ev.;
            }
        };
        Document doc = webEngine.getDocument();
        Element el = doc.getElementById("exit-app");
        ((EventTarget) el).addEventListener("click", listener, false);

        NodeList links = doc.getElementsByTagName("a");
        for (int i = 0; i < links.getLength(); ++i) {
//            Node node = links.item(i);
//            String link = links.item(i).toString();
//
//            EventListener listener = new EventListener() {
//                public void handleEvent(Event ev) {
////                    ev.;
//                }
//            };

        }
    }
 
Example #8
Source File: DocumentImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #9
Source File: DocumentImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #10
Source File: DocumentImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #11
Source File: DocumentImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #12
Source File: DocumentImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #13
Source File: DocumentImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #14
Source File: DocumentImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dispatches event to the target node's descendents recursively
 *
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
    if (n==null)
            return;

    // ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
Example #15
Source File: HyperlinkRedirectListener.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    boolean done = false;
    try {
        if(Desktop.isDesktopSupported()) {
            openLinkInSystemBrowser(href);
            done = true;
        } else {
            LOGGER.warn("OS does not support desktop operations like browsing. Cannot open link '{}'.", href);
        }
    } catch(URISyntaxException | IOException e) {
        LOGGER.warn("OS does not support desktop operations like browsing. Failed open link '{}'.", href, e);
    }
    if(done) {
        event.preventDefault();
    }
}
 
Example #16
Source File: LocationAnnotator.java    From metafacture-core with Apache License 2.0 6 votes vote down vote up
public LocationAnnotator(final XMLReader xmlReader, final Document document) {
    super(xmlReader);

    final EventListener listener = new EventListener() {

        @Override
        public void handleEvent(final Event event) {
            final Node node = (Node) event.getTarget();
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                domNodes.push(node);
            }
        }

    };

    ((EventTarget) document).addEventListener(DOM_NODE_INSERTED, listener, true);
}
 
Example #17
Source File: XPathResultImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #18
Source File: XPathResultImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #19
Source File: HyperlinkRedirectListener.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    if (Desktop.isDesktopSupported()) {
        openLinkInSystemBrowser(href);
    } else {
        LOGGER.warning("OS does not support desktop operations like browsing. Cannot open link '{" + href + "}'.");
    }

    event.preventDefault();
}
 
Example #20
Source File: ElementLook.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void handleEvent(Event evt) {
    // XXX for some reason, sometimes if refactoring is done while an XML phadhail is
    // expanded, some infinite loop occurs and this method is called repeatedly
    try {
        Element parent = (Element)evt.getCurrentTarget();
        if (logger.isLoggable(Level.FINER)) {
            logger.log(Level.FINER, "ElementLook: event on {0}: {1}; co={2}", new Object[] {parent.getTagName(), evt, getChildObjects(parent, null)});
        }
        fireChange(parent, Look.GET_CHILD_OBJECTS | Look.GET_DISPLAY_NAME);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
}
 
Example #21
Source File: XPathResultImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #22
Source File: XPathResultImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #23
Source File: XPathResultImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #24
Source File: XPathResultImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #25
Source File: XmlLocationAnnotator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XmlLocationAnnotator(XMLReader xmlReader, Document dom) {
    super(xmlReader);

    // Add listener to DOM, so we know which node was added.
    EventListener modListener = new EventListener() {
        @Override
        public void handleEvent(Event e) {
            EventTarget target = ((MutationEvent) e).getTarget();
            elementStack.push((Element) target);
        }
    };
    ((EventTarget) dom).addEventListener("DOMNodeInserted", modListener, true);
}
 
Example #26
Source File: XPathResultImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}
 
Example #27
Source File: XmlLocationAnnotator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XmlLocationAnnotator(XMLReader xmlReader, Document dom) {
    super(xmlReader);

    // Add listener to DOM, so we know which node was added.
    EventListener modListener = new EventListener() {
        @Override
        public void handleEvent(Event e) {
            EventTarget target = ((MutationEvent) e).getTarget();
            elementStack.push((Element) target);
        }
    };
    ((EventTarget) dom).addEventListener("DOMNodeInserted", modListener, true);
}
 
Example #28
Source File: XmlLocationAnnotator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XmlLocationAnnotator(XMLReader xmlReader, Document dom) {
    super(xmlReader);

    // Add listener to DOM, so we know which node was added.
    EventListener modListener = new EventListener() {
        @Override
        public void handleEvent(Event e) {
            EventTarget target = ((MutationEvent) e).getTarget();
            elementStack.push((Element) target);
        }
    };
    ((EventTarget) dom).addEventListener("DOMNodeInserted", modListener, true);
}
 
Example #29
Source File: XmlLocationAnnotator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XmlLocationAnnotator(XMLReader xmlReader, Document dom) {
    super(xmlReader);

    // Add listener to DOM, so we know which node was added.
    EventListener modListener = new EventListener() {
        @Override
        public void handleEvent(Event e) {
            EventTarget target = ((MutationEvent) e).getTarget();
            elementStack.push((Element) target);
        }
    };
    ((EventTarget) dom).addEventListener("DOMNodeInserted", modListener, true);
}
 
Example #30
Source File: XPathResultImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see org.w3c.dom.events.EventListener#handleEvent(Event)
 */
public void handleEvent(Event event) {

        if (event.getType().equals("DOMSubtreeModified")) {
                // invalidate the iterator
                m_isInvalidIteratorState = true;

                // deregister as a listener to reduce computational load
                removeEventListener();
        }
}