类org.w3c.dom.events.EventTarget源码实例Demo

下面列出了怎么用org.w3c.dom.events.EventTarget的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MyBox   文件: WebBrowserBoxController.java
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.;
//                }
//            };

        }
    }
 
源代码2 项目: metafacture-core   文件: LocationAnnotator.java
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);
}
 
源代码3 项目: org.hl7.fhir.core   文件: XmlLocationAnnotator.java
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);
}
 
源代码4 项目: org.hl7.fhir.core   文件: XmlLocationAnnotator.java
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);
}
 
源代码5 项目: org.hl7.fhir.core   文件: XmlLocationAnnotator.java
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);
}
 
源代码6 项目: org.hl7.fhir.core   文件: XmlLocationAnnotator.java
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);
}
 
源代码7 项目: marathonv5   文件: HyperlinkRedirectListener.java
@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);
        }
    }
}
 
@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);
        }
    }
}
 
源代码9 项目: opencards   文件: MdSlideManager.java
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);
                }
            });
}
 
源代码10 项目: constellation   文件: TutorialViewPane.java
public TutorialViewPane() {
    tutorialViewPane = new BorderPane();
    ConstellationSecurityManager.startSecurityLaterFX(() -> {
        Platform.setImplicitExit(false);

        final SplitPane splitPane = new SplitPane();
        splitPane.setOrientation(Orientation.HORIZONTAL);
        tutorialViewPane.setCenter(splitPane);

        //Create left VBox to handle "help" images of menu and mouse
        VBox leftVBox = new VBox(10);
        splitPane.getItems().add(leftVBox);
        leftVBox.setPadding(new Insets(10, 10, 10, 10));
        leftVBox.setAlignment(Pos.TOP_CENTER);

        //Create images for Left VBox
        ImageView menuImage = new ImageView(new Image(TutorialTopComponent.class.getResourceAsStream(MENU_IMAGE)));
        menuImage.setFitWidth(300);
        menuImage.setPreserveRatio(true);
        leftVBox.getChildren().add(menuImage);
        ImageView mouseImage = new ImageView(new Image(TutorialTopComponent.class.getResourceAsStream(MOUSE_IMAGE)));
        mouseImage.setFitWidth(300);
        mouseImage.setPreserveRatio(true);
        leftVBox.getChildren().add(mouseImage);

        //Create Right VBox to handle Browser and controls,
        //or error messages
        VBox rightVBox = new VBox();
        splitPane.getItems().add(rightVBox);

        splitPane.getDividers().get(0).setPosition(SPLIT_POS);

        final WebView whatsNewView = new WebView();
        VBox.setVgrow(whatsNewView, Priority.ALWAYS);
        whatsNewView.getEngine().getLoadWorker().stateProperty().addListener((final ObservableValue<? extends Worker.State> observable, final Worker.State oldValue, final Worker.State newValue) -> {
            if (newValue == Worker.State.SUCCEEDED) {
                // Add a click listener for <a> tags.
                // If there's a valid href attribute, open the default browser at that URL.
                // If there's a valid helpId attribute, open NetBeans help using the helpId.
                // An <a> without an href doesn't get underlined, so use href="" in addition to helpId="...".
                final EventListener listener = (final Event event) -> {
                    final String eventType = event.getType();
                    if (eventType.equals("click")) {
                        event.preventDefault();

                        final String href = ((Element) event.getTarget()).getAttribute("href");
                        if (href != null && !href.isEmpty()) {
                            PluginExecution.withPlugin(CorePluginRegistry.OPEN_IN_BROWSER)
                                    .withParameter(OpenInBrowserPlugin.APPLICATION_PARAMETER_ID, "Open Tutorial Link")
                                    .withParameter(OpenInBrowserPlugin.URL_PARAMETER_ID, href)
                                    .executeLater(null);
                        } else {
                            final String helpId = ((Element) event.getTarget()).getAttribute("helpId");
                            if (helpId != null && !helpId.isEmpty()) {
                                new HelpCtx(helpId).display();
                            }
                        }
                    }
                };

                final Document doc = whatsNewView.getEngine().getDocument();
                final NodeList nodeList = doc.getElementsByTagName("a");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    ((EventTarget) nodeList.item(i)).addEventListener("click", listener, true);
                }
            }
        });
        whatsNewView.getEngine().setUserStyleSheetLocation(TutorialTopComponent.class.getResource("resources/whatsnew.css").toExternalForm());
        whatsNewView.getStyleClass().add("web-view");
        try {
            whatsNewView.getEngine().loadContent(getWhatsNew());
        } catch (ParseException ex) {
            Exceptions.printStackTrace(ex);
        }
        rightVBox.getChildren().add(whatsNewView);

        //Finally, insert the tutorialViewPane object into the BorderPane
        this.setCenter(tutorialViewPane);
    });
}
 
源代码11 项目: jdk1.8-source-analysis   文件: EventImpl.java
/** @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;
}
 
源代码12 项目: jdk1.8-source-analysis   文件: EventImpl.java
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
源代码13 项目: jdk1.8-source-analysis   文件: XPathResultImpl.java
/**
* 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);

 }
 
源代码14 项目: jdk1.8-source-analysis   文件: XPathResultImpl.java
/**
 * 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);
}
 
源代码15 项目: TencentKona-8   文件: EventImpl.java
/** @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;
}
 
源代码16 项目: TencentKona-8   文件: EventImpl.java
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
源代码17 项目: TencentKona-8   文件: XPathResultImpl.java
/**
* 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);

 }
 
源代码18 项目: TencentKona-8   文件: XPathResultImpl.java
/**
 * 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);
}
 
源代码19 项目: jdk8u60   文件: EventImpl.java
/** @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;
}
 
源代码20 项目: jdk8u60   文件: EventImpl.java
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
源代码21 项目: jdk8u60   文件: XPathResultImpl.java
/**
* 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);

 }
 
源代码22 项目: jdk8u60   文件: XPathResultImpl.java
/**
 * 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);
}
 
源代码23 项目: JDKSourceCode1.8   文件: EventImpl.java
/** @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;
}
 
源代码24 项目: JDKSourceCode1.8   文件: EventImpl.java
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
源代码25 项目: JDKSourceCode1.8   文件: XPathResultImpl.java
/**
* 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);

 }
 
源代码26 项目: JDKSourceCode1.8   文件: XPathResultImpl.java
/**
 * 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);
}
 
源代码27 项目: openjdk-jdk8u   文件: EventImpl.java
/** @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;
}
 
源代码28 项目: openjdk-jdk8u   文件: EventImpl.java
/** @return the EventTarget (Node) to which the event was originally
    dispatched.
    */
public EventTarget getTarget()
{
    return target;
}
 
源代码29 项目: openjdk-jdk8u   文件: XPathResultImpl.java
/**
* 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);

 }
 
源代码30 项目: openjdk-jdk8u   文件: XPathResultImpl.java
/**
 * 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);
}
 
 类所在包
 同包方法