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(); } }
/** * 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); }
public void handleEvent(final Event evt) { Runnable runnable = new Runnable() { public void run() { MutationEvent mevt = (MutationEvent) evt; Element targetElement = (Element) mevt.getTarget(); // Repaint the target node DefaultTreeModel model = (DefaultTreeModel) tree .getModel(); model.nodeChanged(findNode(tree, targetElement)); attributePanel.updateOnDocumentChange(mevt.getType(), targetElement); } }; refreshGUI(runnable); registerDocumentChange((MutationEvent) evt); }
public void handleEvent(final Event evt) { Runnable runnable = new Runnable() { public void run() { MutationEvent mevt = (MutationEvent) evt; Node targetNode = (Node) mevt.getTarget(); if (characterDataPanel.getNode() == targetNode) { characterDataPanel.getTextArea().setText( targetNode.getNodeValue()); attributePanel.updateOnDocumentChange(mevt .getType(), targetNode); } } }; refreshGUI(runnable); if (characterDataPanel.getNode() == evt.getTarget()) { registerDocumentChange((MutationEvent) evt); } }
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); } } }
/** * Handles the event. */ public void handleEvent(Event evt) { Node n = (Node) evt.getTarget(); while (n != null && !(n instanceof XBLOMDefinitionElement)) { n = n.getParentNode(); } DefinitionRecord defRec = (DefinitionRecord) definitions.get(n, importElement); if (defRec == null) { return; } rebind(defRec.namespaceURI, defRec.localName, document.getDocumentElement()); }
/** * 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 e) { MutationEvent mutation = (MutationEvent) e; Node related = mutation.getRelatedNode(); // XXX if it's got children ... check all kids too, they // will invalidate our saved index if (related.getNodeType() != Node.ELEMENT_NODE || related.getNodeName() != elementName || related.getNamespaceURI() != elementURI) { return; } if (current != null) current.detach(); current = null; }
public void handleEvent(Event evt) { if (!(evt instanceof AbstractEvent)) return; final AbstractEvent ae = (AbstractEvent)evt; List l = ae.getDefaultActions(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof AnchorDefaultActionable) return; // only one anchor in default list... } } SVGAElement elt = (SVGAElement)evt.getCurrentTarget(); ae.addDefaultAction(new AnchorDefaultActionable (elt, userAgent, holder)); }
public void handleEvent(Event evt) { if (!(evt instanceof AbstractEvent)) return; final AbstractEvent ae = (AbstractEvent)evt; List l = ae.getDefaultActions(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof MouseOverDefaultActionable) return; // only one anchor in default list... } } Element target = (Element)ae.getTarget(); SVGAElement elt = (SVGAElement)ae.getCurrentTarget(); ae.addDefaultAction(new MouseOverDefaultActionable (target, elt, userAgent, holder)); }
public void handleEvent(Event evt) { if (!(evt instanceof AbstractEvent)) return; final AbstractEvent ae = (AbstractEvent)evt; List l = ae.getDefaultActions(); if (l != null) { Iterator i = l.iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof MouseOutDefaultActionable) return; // only one anchor in default list... } } SVGAElement elt = (SVGAElement)evt.getCurrentTarget(); ae.addDefaultAction(new MouseOutDefaultActionable (elt, userAgent, holder)); }
public void handleEvent(final Event evt) { Runnable runnable = new Runnable() { public void run() { MutationEvent mevt = (MutationEvent) evt; Node targetNode = (Node) mevt.getTarget(); DefaultMutableTreeNode treeNode = findNode(tree, targetNode); DefaultTreeModel model = (DefaultTreeModel) tree .getModel(); if (treeNode != null) { model.removeNodeFromParent(treeNode); } attributePanel.updateOnDocumentChange(mevt.getType(), targetNode); } }; refreshGUI(runnable); registerDocumentChange((MutationEvent)evt); }
/** * Creates an DocumentEventSupport object suitable for use with * this implementation. */ public DocumentEventSupport createDocumentEventSupport() { DocumentEventSupport result = super.createDocumentEventSupport(); result.registerEventFactory("WheelEvent", new DocumentEventSupport.EventFactory() { public Event createEvent() { return new SVGOMWheelEvent(); } }); result.registerEventFactory("ShadowTreeEvent", new DocumentEventSupport.EventFactory() { public Event createEvent() { return new XBLOMShadowTreeEvent(); } }); return result; }
public void handleEvent(Event e) { DOMMouseEvent evt = (DOMMouseEvent) e; DOMMouseEvent newMouseEvent = (DOMMouseEvent) // DOM Level 2 6.5 cast from Document to DocumentEvent is ok ((DocumentEvent)imgElement.getOwnerDocument()).createEvent("MouseEvents"); newMouseEvent.initMouseEventNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, evt.getType(), evt.getBubbles(), evt.getCancelable(), evt.getView(), evt.getDetail(), evt.getScreenX(), evt.getScreenY(), evt.getClientX(), evt.getClientY(), evt.getButton(), (EventTarget)imgElement, evt.getModifiersString()); ((EventTarget)imgElement).dispatchEvent(newMouseEvent); }
/** * Creates an DocumentEventSupport object suitable for use with * this implementation. */ public DocumentEventSupport createDocumentEventSupport() { DocumentEventSupport result = new DocumentEventSupport(); result.registerEventFactory("SVGEvents", new DocumentEventSupport.EventFactory() { public Event createEvent() { return new SVGOMEvent(); } }); result.registerEventFactory("TimeEvent", new DocumentEventSupport.EventFactory() { public Event createEvent() { return new DOMTimeEvent(); } }); return result; }
public void documentLoadingCompleted(SVGDocumentLoaderEvent e) { NodeEventTarget root = (NodeEventTarget) e.getSVGDocument().getRootElement(); root.addEventListenerNS (XMLConstants.XML_EVENTS_NAMESPACE_URI, SVGConstants.SVG_SVGZOOM_EVENT_TYPE, new EventListener() { public void handleEvent(Event evt) { if (!(evt.getTarget() instanceof SVGSVGElement)) return; // assert(evt.getType() == // SVGConstants.SVG_SVGZOOM_EVENT_TYPE); SVGSVGElement svg = (SVGSVGElement) evt.getTarget(); scaleChange(svg.getCurrentScale()); } // handleEvent() }, false, null); }
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(); } }
@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(); }
public Event createEvent(String eventType) throws DOMException { if ("Event".equals(eventType)) { return new EventImpl(); } else { throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Not supported interface"); } }
public boolean beginElement() { DocumentEvent doc = (DocumentEvent) SmilParElementImpl.this.getOwnerDocument(); Event startEvent = doc.createEvent("Event"); startEvent.initEvent(SMIL_SLIDE_START_EVENT, false, false); dispatchEvent(startEvent); return true; }
public boolean endElement() { DocumentEvent doc = (DocumentEvent) SmilParElementImpl.this.getOwnerDocument(); Event endEvent = doc.createEvent("Event"); endEvent.initEvent(SMIL_SLIDE_END_EVENT, false, false); dispatchEvent(endEvent); return true; }
private Event createEvent(String eventType) { DocumentEvent doc = (DocumentEvent)SmilMediaElementImpl.this.getOwnerDocument(); Event event = doc.createEvent("Event"); event.initEvent(eventType, false, false); if (LOCAL_LOGV) { Log.v(TAG, "Dispatching 'begin' event to " + SmilMediaElementImpl.this.getTagName() + " " + SmilMediaElementImpl.this.getSrc() + " at " + System.currentTimeMillis()); } return event; }
private Event createEvent(String eventType, int seekTo) { DocumentEvent doc = (DocumentEvent)SmilMediaElementImpl.this.getOwnerDocument(); EventImpl event = (EventImpl) doc.createEvent("Event"); event.initEvent(eventType, false, false, seekTo); if (LOCAL_LOGV) { Log.v(TAG, "Dispatching 'begin' event to " + SmilMediaElementImpl.this.getTagName() + " " + SmilMediaElementImpl.this.getSrc() + " at " + System.currentTimeMillis()); } return event; }
/** * @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(); } }
@Override public void handleEvent(Event event) { HTMLAnchorElement anchorElement = (HTMLAnchorElement)event.getCurrentTarget(); String href = anchorElement.getHref(); if (isDesktopSupported()) { openLinkInSystemBrowser(href); } else { Log.warn(APPLICATION, "OS does not support desktop operations like browsing. Cannot open link '"+href+"'!"); } event.preventDefault(); }
/** * Invoked by a {@link TimingSpecifier} to indicate that an event occurred * that would create a new instance time for this timed element. These * will be processed at the beginning of the next tick. */ void eventOccurred(TimingSpecifier t, Event e) { Set ts = (HashSet) handledEvents.get(e); if (ts == null) { ts = new HashSet(); handledEvents.put(e, ts); } ts.add(t); root.currentIntervalWillUpdate(); }
public void handleEvent(Event evt) { EventTarget newTarget = evt.getTarget(); if (lastFocusEventTarget != null && lastFocusEventTarget != newTarget) { fireDOMFocusOutEvent(lastFocusEventTarget, newTarget); } lastFocusEventTarget = evt.getTarget(); }
/** * Runs an event handler. */ public void runEventHandler(String script, Event evt, String lang, String desc) { Interpreter interpreter = getInterpreter(lang); if (interpreter == null) return; try { checkCompatibleScriptURL(lang, docPURL); Object event; if (evt instanceof ScriptEventWrapper) { event = ((ScriptEventWrapper) evt).getEventObject(); } else { event = evt; } interpreter.bindObject(EVENT_NAME, event); interpreter.bindObject(ALTERNATE_EVENT_NAME, event); interpreter.evaluate(new StringReader(script), desc); } catch (IOException ioe) { // Do nothing, can't really happen with StringReader } catch (InterpreterException ie) { handleInterpreterException(ie); } catch (SecurityException se) { handleSecurityException(se); } }
public void handleEvent(Event evt) { Node n = (Node) evt.getTarget(); addScriptingListeners(n); gatherScriptElements(n); while (!toExecute.isEmpty()) { loadScript((AbstractElement) toExecute.removeFirst()); } }
/** * Runs the script. */ public void handleEvent(Event evt) { Element elt = (Element)evt.getCurrentTarget(); // Evaluate the script String script = elt.getAttributeNS(null, attribute); if (script.length() == 0) return; DocumentLoader dl = bridgeContext.getDocumentLoader(); SVGDocument d = (SVGDocument)elt.getOwnerDocument(); int line = dl.getLineNumber(elt); final String desc = Messages.formatMessage (EVENT_SCRIPT_DESCRIPTION, new Object [] {d.getURL(), attribute, new Integer(line)}); // Find the scripting language Element e = elt; while (e != null && (!SVGConstants.SVG_NAMESPACE_URI.equals (e.getNamespaceURI()) || !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName()))) { e = SVGUtilities.getParentElement(e); } if (e == null) return; String lang = e.getAttributeNS (null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE); runEventHandler(script, evt, lang, desc); }
public void handleEvent(Event evt) { Object event; if (evt instanceof ScriptEventWrapper) { event = ((ScriptEventWrapper) evt).getEventObject(); } else { event = evt; } interpreter.callHandler(function, event); }
public void handleEvent(Event evt) { if (evt instanceof ScriptEventWrapper) { array[0] = ((ScriptEventWrapper) evt).getEventObject(); } else { array[0] = evt; } ContextAction handleEventAction = new ContextAction() { public Object run(Context cx) { ScriptableObject.callMethod (scriptable, HANDLE_EVENT, array); return null; } }; interpreter.call(handleEventAction); }
/** * <b>DOM L2 (Events)</b> * Returns an instance of the specified type of event object. * Understands about DOM Mutation, HTML, and UI events. * * <p>If the name of the event type begins with "USER-", then an object * implementing the "Event" class will be returned; this provides a * limited facility for application-defined events to use the DOM event * infrastructure. Alternatively, use one of the standard DOM event * classes and initialize it using use such a "USER-" event type name; * or defin, instantiate, and initialize an application-specific subclass * of DomEvent and pass that to dispatchEvent(). * * @param eventType Identifies the particular DOM feature module * defining the type of event, such as "MutationEvents". * <em>The event "name" is a different kind of "type".</em> */ public Event createEvent(String eventType) { eventType = eventType.toLowerCase(); if ("mutationevents".equals(eventType)) { return new DomEvent.DomMutationEvent(null); } if ("htmlevents".equals(eventType) || "events".equals(eventType) || "user-events".equals(eventType)) { return new DomEvent(null); } if ("uievents".equals(eventType)) { return new DomEvent.DomUIEvent(null); } // mouse events throw new DomDOMException(DOMException.NOT_SUPPORTED_ERR, eventType, null, 0); }