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.buttons.normal;
17:
18: import java.awt.event.ActionEvent;
19: import java.awt.event.ActionListener;
20: import javax.swing.ButtonModel;
21: import javax.swing.event.ChangeEvent;
22: import javax.swing.event.ChangeListener;
23: import org.itsnat.comp.ItsNatComponentManager;
24: import org.itsnat.comp.html.ItsNatHTMLInputSubmit;
25: import org.itsnat.core.ItsNatDocument;
26: import org.itsnat.feashow.FeatureTreeNode;
27: import org.w3c.dom.events.Event;
28: import org.w3c.dom.events.EventListener;
29: import org.w3c.dom.events.EventTarget;
30:
31: public class InputSubmitTreeNode extends FeatureTreeNode implements
32: EventListener, ActionListener, ChangeListener {
33: protected ItsNatHTMLInputSubmit inputComp;
34:
35: public InputSubmitTreeNode() {
36: }
37:
38: public void startExamplePanel() {
39: ItsNatDocument itsNatDoc = getItsNatDocument();
40: ItsNatComponentManager componentMgr = itsNatDoc
41: .getItsNatComponentManager();
42:
43: this .inputComp = (ItsNatHTMLInputSubmit) componentMgr
44: .createItsNatComponentById("inputId");
45: inputComp.addEventListener("click", this );
46:
47: ButtonModel dataModel = inputComp.getButtonModel();
48: dataModel.addActionListener(this );
49: dataModel.addChangeListener(this );
50: }
51:
52: public void endExamplePanel() {
53: this .inputComp.dispose();
54: this .inputComp = null;
55: }
56:
57: public void handleEvent(Event evt) {
58: log(evt.getCurrentTarget() + " " + evt.getType());
59: }
60:
61: public void actionPerformed(ActionEvent e) {
62: log(e.getClass().toString());
63: }
64:
65: public void stateChanged(ChangeEvent e) {
66: ButtonModel model = (ButtonModel) e.getSource();
67:
68: String fact = "";
69: if (model.isArmed())
70: fact += "armed ";
71: if (model.isPressed())
72: fact += "pressed ";
73: if (model.isRollover())
74: fact += "rollover ";
75: if (model.isSelected())
76: fact += "selected ";
77:
78: if (!fact.equals("")) {
79: log(e.getClass() + " " + fact + " ");
80: }
81: }
82:
83: }
|