01: /*
02: * This file is not part of the ItsNat framework.
03: *
04: * Original source code use and closed source derivatives are authorized
05: * to third parties with no restriction or fee.
06: * The original source code is owned by the author.
07: *
08: * This program is distributed AS IS in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * Author: Jose Maria Arranz Santamaria
13: * (C) Innowhere Software Services S.L., Spanish company, year 2007
14: */
15:
16: package org.itsnat.feashow.features.core.listeners;
17:
18: import org.itsnat.core.ItsNatDocument;
19: import org.itsnat.core.event.NodeAttributeTransport;
20: import org.itsnat.feashow.FeatureTreeNode;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.Element;
23: import org.w3c.dom.events.Event;
24: import org.w3c.dom.events.EventListener;
25: import org.w3c.dom.events.EventTarget;
26:
27: public class AutoSyncAttributesOnServerTreeNode extends FeatureTreeNode
28: implements EventListener {
29: protected Element clickable;
30:
31: public AutoSyncAttributesOnServerTreeNode() {
32: }
33:
34: public void startExamplePanel() {
35: ItsNatDocument itsNatDoc = getItsNatDocument();
36: Document doc = itsNatDoc.getDocument();
37:
38: this .clickable = doc.getElementById("clickableId");
39:
40: itsNatDoc.addEventListener((EventTarget) clickable, "click",
41: this , false, new NodeAttributeTransport("style"));
42: // Alternative
43: // itsNatDoc.addEventListener((EventTarget)clickable,"click",this,false,new NodeAllAttribTransport());
44: }
45:
46: public void endExamplePanel() {
47: ItsNatDocument itsNatDoc = getItsNatDocument();
48: itsNatDoc.removeEventListener((EventTarget) clickable, "click",
49: this , false);
50:
51: this .clickable = null;
52: }
53:
54: public void handleEvent(Event evt) {
55: Element currTarget = (Element) evt.getCurrentTarget();
56: log("New style value: " + currTarget.getAttribute("style"));
57: }
58:
59: }
|