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.ItsNatHTMLButton;
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:
30: public class ButtonTreeNode extends FeatureTreeNode implements
31: EventListener, ActionListener, ChangeListener {
32: protected ItsNatHTMLButton buttonComp;
33:
34: public ButtonTreeNode() {
35: }
36:
37: public void startExamplePanel() {
38: ItsNatDocument itsNatDoc = getItsNatDocument();
39: ItsNatComponentManager componentMgr = itsNatDoc
40: .getItsNatComponentManager();
41:
42: this .buttonComp = (ItsNatHTMLButton) componentMgr
43: .createItsNatComponentById("buttonId");
44: buttonComp.addEventListener("click", this );
45:
46: ButtonModel dataModel = buttonComp.getButtonModel();
47: dataModel.addActionListener(this );
48: dataModel.addChangeListener(this );
49: }
50:
51: public void endExamplePanel() {
52: this .buttonComp.dispose();
53: this .buttonComp = null;
54: }
55:
56: public void handleEvent(Event evt) {
57: log(evt.getCurrentTarget() + " " + evt.getType());
58: }
59:
60: public void actionPerformed(ActionEvent e) {
61: log(e.getClass().toString());
62: }
63:
64: public void stateChanged(ChangeEvent e) {
65: ButtonModel model = (ButtonModel) e.getSource();
66:
67: String fact = "";
68: if (model.isArmed())
69: fact += "armed ";
70: if (model.isPressed())
71: fact += "pressed ";
72: if (model.isRollover())
73: fact += "rollover ";
74: if (model.isSelected())
75: fact += "selected ";
76:
77: if (!fact.equals("")) {
78: log(e.getClass() + " " + fact + " ");
79: }
80: }
81:
82: }
|