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;
17:
18: import org.itsnat.core.ItsNatDocument;
19: import org.itsnat.feashow.FeatureTreeNode;
20: import org.w3c.dom.Document;
21: import org.w3c.dom.Element;
22: import org.w3c.dom.events.Event;
23: import org.w3c.dom.events.EventListener;
24: import org.w3c.dom.events.EventTarget;
25:
26: public class EventMonitorTreeNode extends FeatureTreeNode implements
27: EventListener {
28: protected Element linkElem;
29:
30: public EventMonitorTreeNode() {
31: }
32:
33: public void startExamplePanel() {
34: ItsNatDocument itsNatDoc = getItsNatDocument();
35: Document doc = itsNatDoc.getDocument();
36:
37: this .linkElem = (Element) doc.getElementById("linkId");
38: itsNatDoc.addEventListener((EventTarget) linkElem, "click",
39: this , false);
40:
41: String code = "";
42: code += "document.monitor = new EventMonitor(); \n";
43: code += "document.getItsNatDoc().addEventMonitor(document.monitor); \n";
44: itsNatDoc.addCodeToSend(code);
45: }
46:
47: public void endExamplePanel() {
48: ItsNatDocument itsNatDoc = getItsNatDocument();
49:
50: String code = "";
51: code += "document.getItsNatDoc().removeEventMonitor(document.monitor); \n";
52: itsNatDoc.addCodeToSend(code);
53:
54: itsNatDoc.removeEventListener((EventTarget) linkElem, "click",
55: this , false);
56: this .linkElem = null;
57: }
58:
59: public void handleEvent(Event evt) {
60: try {
61: Thread.sleep(2000);
62: } catch (InterruptedException ex) {
63: }
64: }
65: }
|