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.components;
17:
18: import org.itsnat.comp.ItsNatComponentManager;
19: import org.itsnat.comp.free.ItsNatFreeInclude;
20: import org.itsnat.comp.html.ItsNatHTMLInput;
21: import org.itsnat.core.ItsNatDocument;
22: import org.itsnat.feashow.FeatureTreeNode;
23: import org.w3c.dom.events.Event;
24: import org.w3c.dom.events.EventListener;
25:
26: public class FreeIncludeTreeNode extends FeatureTreeNode implements
27: EventListener {
28: protected ItsNatFreeInclude includeComp;
29: protected ItsNatHTMLInput buttonComp;
30:
31: public FreeIncludeTreeNode() {
32: }
33:
34: public void startExamplePanel() {
35: ItsNatDocument itsNatDoc = getItsNatDocument();
36: ItsNatComponentManager componentMgr = itsNatDoc
37: .getItsNatComponentManager();
38:
39: this .includeComp = (ItsNatFreeInclude) componentMgr
40: .createItsNatComponentById("includeId", "freeInclude",
41: null);
42:
43: this .buttonComp = (ItsNatHTMLInput) componentMgr
44: .createItsNatComponentById("buttonId");
45: buttonComp.addEventListener("click", this );
46:
47: include();
48: }
49:
50: public void endExamplePanel() {
51: this .includeComp.dispose();
52: this .includeComp = null;
53:
54: this .buttonComp.dispose();
55: this .buttonComp = null;
56: }
57:
58: public void handleEvent(Event evt) {
59: if (includeComp.isIncluded())
60: uninclude();
61: else
62: include();
63: }
64:
65: public void include() {
66: includeComp.includeFragment("feashow.fragmentExample", true);
67: buttonComp.getHTMLInputElement().setValue("Remove");
68: }
69:
70: public void uninclude() {
71: includeComp.removeFragment();
72: buttonComp.getHTMLInputElement().setValue("Include");
73: }
74: }
|