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