01: package org.itsnat.feashow.features.components.text.fields;
02:
03: import java.beans.PropertyChangeEvent;
04: import java.beans.PropertyChangeListener;
05: import java.beans.PropertyVetoException;
06: import java.beans.VetoableChangeListener;
07: import java.util.Date;
08: import org.itsnat.comp.ItsNatComponentManager;
09: import org.itsnat.comp.html.ItsNatHTMLInputTextFormatted;
10: import org.itsnat.core.ItsNatDocument;
11: import org.itsnat.feashow.FeatureTreeNode;
12:
13: public class InputTextFormattedTreeNode extends FeatureTreeNode
14: implements PropertyChangeListener, VetoableChangeListener {
15: protected ItsNatHTMLInputTextFormatted inputComp;
16:
17: public InputTextFormattedTreeNode() {
18: }
19:
20: public void startExamplePanel() {
21: ItsNatDocument itsNatDoc = getItsNatDocument();
22: ItsNatComponentManager componentMgr = itsNatDoc
23: .getItsNatComponentManager();
24:
25: this .inputComp = (ItsNatHTMLInputTextFormatted) componentMgr
26: .createItsNatComponentById("inputId",
27: "formattedTextField", null);
28: try {
29: inputComp.setValue(new Date());
30: } catch (PropertyVetoException ex) {
31: throw new RuntimeException(ex);
32: }
33:
34: inputComp.addPropertyChangeListener("value", this );
35:
36: inputComp.addVetoableChangeListener(this );
37: }
38:
39: public void endExamplePanel() {
40: this .inputComp.dispose();
41: this .inputComp = null;
42: }
43:
44: public void propertyChange(PropertyChangeEvent evt) {
45: Date value = (Date) evt.getNewValue();
46:
47: log("Value changed to: " + value + " ");
48: }
49:
50: public void vetoableChange(PropertyChangeEvent evt)
51: throws PropertyVetoException {
52: Date newDate = (Date) evt.getNewValue();
53: if (newDate.compareTo(new Date()) > 0)
54: throw new PropertyVetoException(
55: "Future date is not allowed", evt);
56: }
57: }
|