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.text.fields;
17:
18: import javax.swing.event.DocumentEvent;
19: import javax.swing.event.DocumentListener;
20: import javax.swing.text.BadLocationException;
21: import javax.swing.text.PlainDocument;
22: import org.itsnat.comp.ItsNatComponentManager;
23: import org.itsnat.comp.html.ItsNatHTMLInputPassword;
24: import org.itsnat.core.ItsNatDocument;
25: import org.itsnat.feashow.FeatureTreeNode;
26: import org.w3c.dom.events.Event;
27: import org.w3c.dom.events.EventListener;
28:
29: public class InputPasswordTreeNode extends FeatureTreeNode implements
30: EventListener, DocumentListener {
31: protected ItsNatHTMLInputPassword inputComp;
32:
33: public InputPasswordTreeNode() {
34: }
35:
36: public void startExamplePanel() {
37: ItsNatDocument itsNatDoc = getItsNatDocument();
38: ItsNatComponentManager componentMgr = itsNatDoc
39: .getItsNatComponentManager();
40:
41: this .inputComp = (ItsNatHTMLInputPassword) componentMgr
42: .createItsNatComponentById("inputId");
43: inputComp.setText("Initial password");
44:
45: inputComp.addEventListener("change", this );
46: PlainDocument dataModel = (PlainDocument) inputComp
47: .getDocument();
48: dataModel.addDocumentListener(this );
49:
50: inputComp.focus();
51: inputComp.select();
52: }
53:
54: public void endExamplePanel() {
55: this .inputComp.dispose();
56: this .inputComp = null;
57: }
58:
59: public void handleEvent(Event evt) {
60: log(evt.getCurrentTarget() + " " + evt.getType());
61: }
62:
63: public void insertUpdate(DocumentEvent e) {
64: javax.swing.text.Document docModel = e.getDocument();
65: int offset = e.getOffset();
66: int len = e.getLength();
67:
68: try {
69: log(e.getClass() + " inserted, pos " + offset + "," + len
70: + " chars,\"" + docModel.getText(offset, len)
71: + "\"");
72: } catch (BadLocationException ex) {
73: throw new RuntimeException(ex);
74: }
75: }
76:
77: public void removeUpdate(DocumentEvent e) {
78: // javax.swing.text.Document docModel = e.getDocument();
79: int offset = e.getOffset();
80: int len = e.getLength();
81:
82: log(e.getClass() + " removed, pos " + offset + "," + len
83: + " chars");
84: }
85:
86: public void changedUpdate(DocumentEvent e) {
87: // A PlainDocument has no attributes
88: }
89: }
|