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.ContinueEvent;
20: import org.itsnat.core.event.CustomParamTransport;
21: import org.itsnat.core.event.ItsNatEvent;
22: import org.itsnat.core.event.ParamTransport;
23: import org.itsnat.feashow.FeatureTreeNode;
24: import org.w3c.dom.Document;
25: import org.w3c.dom.Element;
26: import org.w3c.dom.events.Event;
27: import org.w3c.dom.events.EventListener;
28: import org.w3c.dom.events.EventTarget;
29:
30: public class ContinueEventListenerTreeNode extends FeatureTreeNode
31: implements EventListener {
32: protected Element linkToStart;
33:
34: public ContinueEventListenerTreeNode() {
35: }
36:
37: public void startExamplePanel() {
38: ItsNatDocument itsNatDoc = getItsNatDocument();
39: Document doc = itsNatDoc.getDocument();
40:
41: this .linkToStart = doc.getElementById("linkToStartId");
42:
43: itsNatDoc.addEventListener((EventTarget) linkToStart, "click",
44: this , false);
45: }
46:
47: public void endExamplePanel() {
48: ItsNatDocument itsNatDoc = getItsNatDocument();
49: itsNatDoc.removeEventListener((EventTarget) linkToStart,
50: "click", this , false);
51:
52: this .linkToStart = null;
53: }
54:
55: public void handleEvent(Event evt) {
56: // EventTarget currTarget = evt.getCurrentTarget();
57:
58: log("Uh! I forgot the document tittle!");
59:
60: EventListener listener = new EventListener() {
61: public void handleEvent(Event evt) {
62: ContinueEvent contEvt = (ContinueEvent) evt;
63: String title = (String) contEvt.getExtraParam("title");
64: log("OK this is the title: " + title + " ");
65: }
66: };
67:
68: ItsNatDocument itsNatDoc = getItsNatDocument();
69: ItsNatEvent itsNatEvent = (ItsNatEvent) evt;
70: ParamTransport[] extraParams = new ParamTransport[] { new CustomParamTransport(
71: "title", "document.title") };
72: itsNatDoc.addContinueEventListener(null, listener, itsNatEvent
73: .getSyncMode(), extraParams, null, -1);
74: }
75:
76: }
|