本文整理汇总了Java中org.w3c.dom.events.MutationEvent类的典型用法代码示例。如果您正苦于以下问题:Java MutationEvent类的具体用法?Java MutationEvent怎么用?Java MutationEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutationEvent类属于org.w3c.dom.events包,在下文中一共展示了MutationEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifiedCharacterData
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* A method to be called when a character data node has been modified
*/
void modifiedCharacterData(NodeImpl node, String oldvalue, String value, boolean replace) {
if (mutationEvents) {
if (!replace) {
// MUTATION POST-EVENTS:
LCount lc =
LCount.lookup(MutationEventImpl.DOM_CHARACTER_DATA_MODIFIED);
if (lc.total > 0) {
MutationEvent me = new MutationEventImpl();
me.initMutationEvent(
MutationEventImpl.DOM_CHARACTER_DATA_MODIFIED,
true, false, null,
oldvalue, value, null, (short) 0);
dispatchEvent(node, me);
}
// Subroutine: Transmit DOMAttrModified and DOMSubtreeModified,
// if required. (Common to most kinds of mutation)
dispatchAggregateEvents(node, savedEnclosingAttr);
} // End mutation postprocessing
}
}
示例2: removedAttrNode
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* A method to be called when an attribute node has been removed
*/
void removedAttrNode(AttrImpl attr, NodeImpl oldOwner, String name) {
// We can't use the standard dispatchAggregate, since it assumes
// that the Attr is still attached to an owner. This code is
// similar but dispatches to the previous owner, "element".
if (mutationEvents) {
// If we have to send DOMAttrModified (determined earlier),
// do so.
LCount lc = LCount.lookup(MutationEventImpl.DOM_ATTR_MODIFIED);
if (lc.total > 0) {
MutationEventImpl me= new MutationEventImpl();
me.initMutationEvent(MutationEventImpl.DOM_ATTR_MODIFIED,
true, false, attr,
attr.getNodeValue(), null, name,
MutationEvent.REMOVAL);
dispatchEvent(oldOwner, me);
}
// We can hand off to process DOMSubtreeModified, though.
// Note that only the Element needs to be informed; the
// Attr's subtree has not been changed by this operation.
dispatchAggregateEvents(oldOwner, null, null, (short) 0);
}
}
示例3: handleEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
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);
}
}
}
示例4: handleEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* 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);
}
}
}
示例5: handleDOMNodeInsertedEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Invoked when an MutationEvent of type 'DOMNodeInserted' is fired.
*/
public void handleDOMNodeInsertedEvent(MutationEvent evt) {
Node childNode = (Node)evt.getTarget();
//check the type of the node inserted before discard the layout
//in the case of <title> or <desc> or <metadata>, the layout
//is unchanged
switch(childNode.getNodeType()) {
case Node.TEXT_NODE: // fall-through is intended
case Node.CDATA_SECTION_NODE:
laidoutText = null;
break;
case Node.ELEMENT_NODE: {
Element childElement = (Element)childNode;
if (isTextChild(childElement)) {
addContextToChild(ctx, childElement);
laidoutText = null;
}
break;
}
}
if (laidoutText == null) {
computeLaidoutText(ctx, e, getTextNode());
}
}
示例6: setNamedItem
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Adds a node to the map.
*/
public Node setNamedItem( String ns, String name, Node arg )
throws DOMException {
if ( ns != null && ns.length() == 0 ) {
ns = null;
}
( (AbstractAttr)arg ).setOwnerElement( AbstractElement.this );
AbstractAttr result = (AbstractAttr)put( ns, name, arg );
if ( result != null ) {
result.setOwnerElement( null );
fireDOMAttrModifiedEvent( name,
result,
result.getNodeValue(),
"",
MutationEvent.REMOVAL );
}
fireDOMAttrModifiedEvent( name,
(Attr)arg,
"",
arg.getNodeValue(),
MutationEvent.ADDITION );
return result;
}
示例7: fireDOMNodeInsertedIntoDocumentEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Recursively fires a DOMNodeInsertedIntoDocument event.
*/
public void fireDOMNodeInsertedIntoDocumentEvent() {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev =
(DOMMutationEvent)doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMNodeInsertedIntoDocument",
true, // canBubbleArg
false, // cancelableArg
null, // relatedNodeArg
null, // prevValueArg
null, // newValueArg
null, // attrNameArg
MutationEvent.ADDITION);
dispatchEvent(ev);
}
}
示例8: fireDOMNodeRemovedFromDocumentEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Recursively fires a DOMNodeRemovedFromDocument event.
*/
public void fireDOMNodeRemovedFromDocumentEvent() {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev
= (DOMMutationEvent) doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMNodeRemovedFromDocument",
true, // canBubbleArg
false, // cancelableArg
null, // relatedNodeArg
null, // prevValueArg
null, // newValueArg
null, // attrNameArg
MutationEvent.REMOVAL);
dispatchEvent(ev);
}
}
示例9: fireDOMCharacterDataModifiedEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Fires a DOMCharacterDataModified event.
*/
protected void fireDOMCharacterDataModifiedEvent(String oldv,
String newv) {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev
= (DOMMutationEvent) doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMCharacterDataModified",
true, // canBubbleArg
false, // cancelableArg
null, // relatedNodeArg
oldv, // prevValueArg
newv, // newValueArg
null, // attrNameArg
MutationEvent.MODIFICATION);
dispatchEvent(ev);
}
}
示例10: fireDOMSubtreeModifiedEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Fires a DOMSubtreeModified event.
*/
protected void fireDOMSubtreeModifiedEvent() {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev
= (DOMMutationEvent) doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMSubtreeModified",
true, // canBubbleArg
false, // cancelableArg
null, // relatedNodeArg
null, // prevValueArg
null, // newValueArg
null, // attrNameArg
MutationEvent.MODIFICATION);
dispatchEvent(ev);
}
}
示例11: fireDOMNodeInsertedEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Fires a DOMNodeInserted event.
*/
protected void fireDOMNodeInsertedEvent(Node node) {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev
= (DOMMutationEvent) doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMNodeInserted",
true, // canBubbleArg
false, // cancelableArg
this, // relatedNodeArg
null, // prevValueArg
null, // newValueArg
null, // attrNameArg
MutationEvent.ADDITION);
AbstractNode n = (AbstractNode)node;
n.dispatchEvent(ev);
n.fireDOMNodeInsertedIntoDocumentEvent();
}
}
示例12: fireDOMNodeRemovedEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Fires a DOMNodeRemoved event.
*/
protected void fireDOMNodeRemovedEvent(Node node) {
AbstractDocument doc = getCurrentDocument();
if (doc.getEventsEnabled()) {
DOMMutationEvent ev
= (DOMMutationEvent) doc.createEvent("MutationEvents");
ev.initMutationEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
"DOMNodeRemoved",
true, // canBubbleArg
false, // cancelableArg
this, // relatedNodeArg
null, // prevValueArg
null, // newValueArg
null, // attrNameArg
MutationEvent.REMOVAL);
AbstractNode n = (AbstractNode)node;
n.dispatchEvent(ev);
n.fireDOMNodeRemovedFromDocumentEvent();
}
}
示例13: handleEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
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);
}
示例14: registerAttributeChanged
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
/**
* Checks what type of the "DOMAttrModified" mutation event occured, and
* invokes the appropriate method to register the change.
*
* @param mevt
* The Mutation Event
*/
protected void registerAttributeChanged(MutationEvent mevt) {
switch (mevt.getAttrChange()) {
case MutationEvent.ADDITION:
registerAttributeAdded(mevt);
break;
case MutationEvent.REMOVAL:
registerAttributeRemoved(mevt);
break;
case MutationEvent.MODIFICATION:
registerAttributeModified(mevt);
break;
default:
registerAttributeModified(mevt);
break;
}
}
示例15: handleEvent
import org.w3c.dom.events.MutationEvent; //导入依赖的package包/类
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;
}