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.NodeCompleteTransport;
20: import org.itsnat.feashow.FeatureTreeNode;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.Element;
23: import org.w3c.dom.Node;
24: import org.w3c.dom.Text;
25: import org.w3c.dom.events.Event;
26: import org.w3c.dom.events.EventListener;
27: import org.w3c.dom.events.EventTarget;
28:
29: public class AutoSyncNodeCompleteOnServerTreeNode extends
30: FeatureTreeNode implements EventListener {
31: protected Element clickable;
32:
33: public AutoSyncNodeCompleteOnServerTreeNode() {
34: }
35:
36: public void startExamplePanel() {
37: ItsNatDocument itsNatDoc = getItsNatDocument();
38: Document doc = itsNatDoc.getDocument();
39:
40: this .clickable = doc.getElementById("clickableId");
41:
42: itsNatDoc.addEventListener((EventTarget) clickable, "click",
43: this , false, new NodeCompleteTransport());
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:
57: Node newNode = currTarget.getLastChild();
58: Text text = (Text) newNode.getFirstChild();
59: log("New node : " + newNode + " " + text.getData());
60:
61: log("New style value: " + currTarget.getAttribute("style"));
62: }
63:
64: }
|