@Override public void handleEvent(Event e) { if (!(e instanceof MutationEvent)) { return; } MutationEvent mutEvt = (MutationEvent)e; EventTarget et = mutEvt.getTarget(); if (!(et instanceof Element)) { return; } handleElement((Element)et); }
public void handleEvent(Event evt) { MutationEvent mevt = (MutationEvent) evt; handleAttrModified((Element) evt.getTarget(), (Attr) mevt.getRelatedNode(), mevt.getAttrChange(), mevt.getPrevValue(), mevt.getNewValue()); } }
org.w3c.dom.events.EventListener myModificationListener = new org.w3c.dom.events.EventListener() { @Override public void handleEvent(Event e) { if (e instanceof MutationEvent) { MutationEvent me = (MutationEvent) e; System.out.println("type: " + me.getType() + ", dest: " + me.getTarget()); } } }; Node someDomNode = ... // here the unusual casting magic happens ((EventTarget) node).addEventListener( "DOMSubtreeModified", // constant myModificationListener, true); // modify the node here by appending a child // -> listener gets invoked
public void handleEvent (Event evt) { MutationEvent me = (MutationEvent)evt; if (me.getAttrChange() != MutationEvent.MODIFICATION) updateScriptingListeners((Element)me.getTarget(), me.getAttrName()); } }
/** * Adds the "DOMAttrModified" Mutation event, of the * MutationEvent.MODIFICATION type to current history browser's * interface compound command * * @param mevt * The Mutation Event */ protected void registerAttributeModified(MutationEvent mevt) { Element targetElement = (Element) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createAttributeModifiedCommand (targetElement, mevt.getAttrName(), mevt.getPrevValue(), mevt.getNewValue(), null)); }
/** * Adds the "DOMCharDataModified" Mutation event to current history * browser's interface compound command * * @param mevt * The Mutation Event */ protected void registerCharDataModified(MutationEvent mevt) { Node targetNode = (Node) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createCharDataModifiedCommand (targetNode, mevt.getPrevValue(), mevt.getNewValue())); }
/** * Adds the "DOMAttrModified" Mutation event, of the * MutationEvent.ADDITION type to current history browser's * interface compound command * * @param mevt * The Mutation Event */ protected void registerAttributeAdded(MutationEvent mevt) { Element targetElement = (Element) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createAttributeAddedCommand (targetElement, mevt.getAttrName(), mevt.getNewValue(), null)); }
/** * Adds the "DOMAttrModified" Mutation event, of the * MutationEvent.REMOVAL type to current history browser's * interface compound command * * @param mevt * The Mutation Event */ protected void registerAttributeRemoved(MutationEvent mevt) { Element targetElement = (Element) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createAttributeRemovedCommand (targetElement, mevt.getAttrName(), mevt.getPrevValue(), null)); }
private void fireDocumentReplaced(Document document) { Trace.trace("insync.markup", "MU.fireDomListeners " + document); DocumentEvent doc = (DocumentEvent)document; MutationEvent me = (MutationEvent)doc.createEvent("MutationEvents"); me.initMutationEvent(DOM_DOCUMENT_REPLACED, false, false, document, null, null, null, MutationEvent.REMOVAL); EventTarget target = (EventTarget)document; target.dispatchEvent(me); }
/** * Adds the "DOMNodeRemoved" Mutation event to current history browser's * interface compound command * * @param mevt * The Mutation Event */ protected void registerNodeRemoved(MutationEvent mevt) { Node targetNode = (Node) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createNodeRemovedCommand (mevt.getRelatedNode(), targetNode.getNextSibling(), targetNode)); }
/** * Handles the event. */ public void handleEvent(Event evt) { EventTarget target = evt.getTarget(); if (target != evt.getCurrentTarget()) { return; } MutationEvent mevt = (MutationEvent) evt; if (mevt.getAttrName().equals(XBL_REF_ATTRIBUTE)) { Element defRef = (Element) target; removeDefinitionRef(defRef); if (mevt.getNewValue().length() == 0) { XBLOMDefinitionElement def = (XBLOMDefinitionElement) defRef; String ns = def.getElementNamespaceURI(); String ln = def.getElementLocalName(); addDefinition(ns, ln, (XBLOMDefinitionElement) defRef, null); } else { addDefinitionRef(defRef); } } } }
public void handleEvent(Event evt) { MutationEvent me = (MutationEvent) evt; Attr a = (Attr) me.getRelatedNode(); Element e = (Element) evt.getTarget(); if (e instanceof XBLOMContentElement) { String ans = a.getNamespaceURI(); String aln = a.getLocalName(); if (aln == null) { aln = a.getNodeName(); } if (ans == null && XBLConstants.XBL_INCLUDES_ATTRIBUTE.equals(aln) || "http://xml.apache.org/batik/ext".equals(ans) && "selectorLanguage".equals(aln)) { selectors.remove(e); update(false); } } } }
if (mutationEvent.getAttrChange() == 0)
/** * Handles the event. */ public void handleEvent(Event evt) { EventTarget target = evt.getTarget(); if (target != evt.getCurrentTarget()) { return; } MutationEvent mevt = (MutationEvent) evt; if (mevt.getAttrName().equals(XBL_BINDINGS_ATTRIBUTE)) { Element imp = (Element) target; removeImport(imp); addImport(imp); } } }
/** * Puts the document change in the current history browser's interface * compound command if the document change occured outside of the * DOMViewer. * * @param mevt * The info on the event. Use to describe the document change * to the history browser */ protected void registerDocumentChange(MutationEvent mevt) { if (shouldRegisterDocumentChange()) { String type = mevt.getType(); if (type.equals(NODE_INSERTED)) { registerNodeInserted(mevt); } else if (type.equals(NODE_REMOVED)) { registerNodeRemoved(mevt); } else if (type.equals(ATTRIBUTE_MODIFIED)) { registerAttributeChanged(mevt); } else if (type.equals(CHAR_DATA_MODIFIED)) { registerCharDataModified(mevt); } } }
public void handleEvent(Event evt) { MutationEvent mevt = (MutationEvent) evt; handleAttrModified((Element) evt.getTarget(), (Attr) mevt.getRelatedNode(), mevt.getAttrChange(), mevt.getPrevValue(), mevt.getNewValue()); } }
public void handleEvent (Event evt) { MutationEvent me = (MutationEvent)evt; if (me.getAttrChange() != MutationEvent.MODIFICATION) updateScriptingListeners((Element)me.getTarget(), me.getAttrName()); } }
/** * Adds the "DOMAttrModified" Mutation event, of the * MutationEvent.MODIFICATION type to current history browser's * interface compound command * * @param mevt * The Mutation Event */ protected void registerAttributeModified(MutationEvent mevt) { Element targetElement = (Element) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createAttributeModifiedCommand (targetElement, mevt.getAttrName(), mevt.getPrevValue(), mevt.getNewValue(), null)); }
/** * Adds the "DOMCharDataModified" Mutation event to current history * browser's interface compound command * * @param mevt * The Mutation Event */ protected void registerCharDataModified(MutationEvent mevt) { Node targetNode = (Node) mevt.getTarget(); historyBrowserInterface.addToCurrentCompoundCommand (historyBrowserInterface.createCharDataModifiedCommand (targetNode, mevt.getPrevValue(), mevt.getNewValue())); }