org.w3c.dom.events.EventTarget Java Examples

The following examples show how to use org.w3c.dom.events.EventTarget. 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: 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 #2
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 #3
Source File: HyperlinkRedirectListener.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
    if (State.SUCCEEDED.equals(newValue)) {
        Document document = webView.getEngine().getDocument();
        NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
        for (int i = 0; i < anchors.getLength(); i++) {
            Node node = anchors.item(i);
            EventTarget eventTarget = (EventTarget) node;
            eventTarget.addEventListener(CLICK_EVENT, this, false);
        }
    }
}
 
Example #4
Source File: MdSlideManager.java    From opencards with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static void redirectLinksToBrowser(WebEngine webEngine) {
    webEngine.getLoadWorker().stateProperty().addListener(
            (ov, oldState, newState) -> {
                // adjust link handling
                if (webEngine.getDocument() == null)
                    return;

                NodeList nodeList = webEngine.getDocument().getElementsByTagName("a");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    EventTarget eventTarget = (EventTarget) node;

                    eventTarget.addEventListener("click", evt -> {
                        EventTarget target = evt.getCurrentTarget();
                        HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
                        String href = anchorElement.getHref();

                        //handle opening URL outside JavaFX WebView
                        try {
                            Desktop.getDesktop().browse(new URI(href));
                        } catch (IOException | URISyntaxException e) {
                            e.printStackTrace();
                        }
                        evt.preventDefault();
                    }, false);
                }
            });
}
 
Example #5
Source File: HyperlinkRedirectListener.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue) {
    if(State.SUCCEEDED.equals(newValue)) {
        Document document = webView.getEngine().getDocument();
        NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
        for(int i = 0; i < anchors.getLength(); i++) {
            Node node = anchors.item(i);
            EventTarget eventTarget = (EventTarget) node;
            eventTarget.addEventListener(CLICK_EVENT, this, false);
        }
    }
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
Source File: EventImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #11
Source File: ElementLook.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void detachFrom(Element e) {
    EventTarget et = (EventTarget) e;
    et.removeEventListener("DOMSubtreeModified", this, false);
}
 
Example #12
Source File: XPathResultImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
* Add m_contextNode to Event Listner to listen for Mutations Events
*
*/
 private void addEventListener(){
       if(m_contextNode instanceof EventTarget)
               ((EventTarget)m_contextNode).addEventListener("DOMSubtreeModified",this,true);

 }
 
Example #13
Source File: XPathResultImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Remove m_contextNode to Event Listner to listen for Mutations Events
 *
 */
private void removeEventListener(){
        if(m_contextNode instanceof EventTarget)
                ((EventTarget)m_contextNode).removeEventListener("DOMSubtreeModified",this,true);
}
 
Example #14
Source File: EventImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}
 
Example #15
Source File: EventImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #16
Source File: EventImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}
 
Example #17
Source File: EventImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #18
Source File: EventImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}
 
Example #19
Source File: EventImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #20
Source File: XPathResultImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
* Add m_contextNode to Event Listner to listen for Mutations Events
*
*/
 private void addEventListener(){
       if(m_contextNode instanceof EventTarget)
               ((EventTarget)m_contextNode).addEventListener("DOMSubtreeModified",this,true);

 }
 
Example #21
Source File: XPathResultImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Remove m_contextNode to Event Listner to listen for Mutations Events
 *
 */
private void removeEventListener(){
        if(m_contextNode instanceof EventTarget)
                ((EventTarget)m_contextNode).removeEventListener("DOMSubtreeModified",this,true);
}
 
Example #22
Source File: EventImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}
 
Example #23
Source File: EventImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #24
Source File: XPathResultImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
* Add m_contextNode to Event Listner to listen for Mutations Events
*
*/
 private void addEventListener(){
       if(m_contextNode instanceof EventTarget)
               ((EventTarget)m_contextNode).addEventListener("DOMSubtreeModified",this,true);

 }
 
Example #25
Source File: XPathResultImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Remove m_contextNode to Event Listner to listen for Mutations Events
 *
 */
private void removeEventListener(){
        if(m_contextNode instanceof EventTarget)
                ((EventTarget)m_contextNode).removeEventListener("DOMSubtreeModified",this,true);
}
 
Example #26
Source File: EventImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}
 
Example #27
Source File: EventImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
Example #28
Source File: XPathResultImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
* Add m_contextNode to Event Listner to listen for Mutations Events
*
*/
 private void addEventListener(){
       if(m_contextNode instanceof EventTarget)
               ((EventTarget)m_contextNode).addEventListener("DOMSubtreeModified",this,true);

 }
 
Example #29
Source File: XPathResultImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Remove m_contextNode to Event Listner to listen for Mutations Events
 *
 */
private void removeEventListener(){
        if(m_contextNode instanceof EventTarget)
                ((EventTarget)m_contextNode).removeEventListener("DOMSubtreeModified",this,true);
}
 
Example #30
Source File: EventImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/** @return the Node (EventTarget) whose EventListeners are currently
    being processed. During capture and bubble phases, this may not be
    the target node. */
public EventTarget getCurrentTarget()
{
    return currentTarget;
}