Revision 270 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.serv/org.gvsig.tools.swing.serv.field/src/main/java/org/gvsig/tools/swing/serv/field/component/date/DateSpinner.java
DateSpinner.java | ||
---|---|---|
60 | 60 |
*/ |
61 | 61 |
public class DateSpinner extends JSpinner { |
62 | 62 |
|
63 |
private static final String DEFAULT_FORMAT = "dd/MM/yyyy hh:mm:ss Z"; |
|
64 |
|
|
65 |
// |
|
66 |
// public DateSpinner(Date date, String format){ |
|
67 |
// this(date,TYPE_SHOW_DATE_ONLY); |
|
68 |
// } |
|
63 |
private static final String DEFAULT_FORMAT = "dd/MM/yyyy hh:mm:ss Z"; |
|
69 | 64 |
|
70 |
// public DateSpinner(Date date, String format, int dateField){ |
|
71 |
// this(new DateElement(date), format, dateField); |
|
72 |
// } |
|
65 |
// |
|
66 |
// public DateSpinner(Date date, String format){ |
|
67 |
// this(date,TYPE_SHOW_DATE_ONLY); |
|
68 |
// } |
|
73 | 69 |
|
74 |
public DateSpinner(Date date, int dateType) { |
|
75 |
DateSpinnerModel model = new DateSpinnerModel(date, dateType, this.getLocale()); |
|
76 |
this.setModel(model); |
|
77 |
|
|
78 |
JSpinner.DateEditor de = new NullDateEditor(this,dateType); |
|
79 |
this.setEditor(de); |
|
80 |
|
|
81 |
this.initUI(); |
|
82 |
this.setValue(date); |
|
83 |
// refresh(); |
|
84 |
} |
|
70 |
// public DateSpinner(Date date, String format, int dateField){ |
|
71 |
// this(new DateElement(date), format, dateField); |
|
72 |
// } |
|
85 | 73 |
|
86 |
/** |
|
87 |
* @param date |
|
88 |
*/ |
|
89 |
public DateSpinner(int dateField) { |
|
90 |
this(null, dateField); |
|
91 |
} |
|
74 |
public DateSpinner(Date date, int dateType) { |
|
75 |
DateSpinnerModel model = |
|
76 |
new DateSpinnerModel(date, dateType, this.getLocale()); |
|
77 |
this.setModel(model); |
|
92 | 78 |
|
79 |
JSpinner.DateEditor de = new NullDateEditor(this, dateType); |
|
80 |
this.setEditor(de); |
|
93 | 81 |
|
94 |
private DateEditor getDateEditor(){ |
|
95 |
return (DateEditor) this.getEditor(); |
|
96 |
} |
|
97 |
/** |
|
82 |
this.initUI(); |
|
83 |
this.setValue(date); |
|
84 |
// refresh(); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* @param date |
|
89 |
*/ |
|
90 |
public DateSpinner(int dateField) { |
|
91 |
this(null, dateField); |
|
92 |
} |
|
93 |
|
|
94 |
private DateEditor getDateEditor() { |
|
95 |
return (DateEditor) this.getEditor(); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
98 | 99 |
* |
99 | 100 |
*/ |
100 |
private void initUI() {
|
|
101 |
this.setBackground(null);
|
|
102 |
this.setForeground(Color.BLUE);
|
|
103 |
}
|
|
101 |
private void initUI() {
|
|
102 |
this.setBackground(null);
|
|
103 |
this.setForeground(Color.BLUE);
|
|
104 |
}
|
|
104 | 105 |
|
105 |
private Border createCompoundBorder() { |
|
106 |
// Create a border for all calendars |
|
107 |
Border etchedBorder = |
|
108 |
BorderFactory.createEtchedBorder(); |
|
109 |
Border emptyBorder = |
|
110 |
BorderFactory.createEmptyBorder(10, 10, 10, 10); |
|
111 |
return BorderFactory.createCompoundBorder(etchedBorder, emptyBorder); |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
106 |
private Border createCompoundBorder() { |
|
107 |
// Create a border for all calendars |
|
108 |
Border etchedBorder = BorderFactory.createEtchedBorder(); |
|
109 |
Border emptyBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10); |
|
110 |
return BorderFactory.createCompoundBorder(etchedBorder, emptyBorder); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
115 | 114 |
* |
116 | 115 |
*/ |
117 |
private void refresh() {
|
|
118 |
this.setValue(this.getValue());
|
|
119 |
}
|
|
116 |
private void refresh() {
|
|
117 |
this.setValue(this.getValue());
|
|
118 |
}
|
|
120 | 119 |
|
121 |
/**
|
|
122 |
* @param time
|
|
123 |
*/
|
|
124 |
public void setDate(Date date) {
|
|
125 |
this.setValue(date);
|
|
126 |
}
|
|
127 |
|
|
128 |
public Date getCurDate(Date date){
|
|
129 |
return (Date) this.getValue();
|
|
130 |
}
|
|
131 |
|
|
132 |
/**
|
|
133 |
* @param b
|
|
134 |
*/
|
|
135 |
public void setEditable(boolean isEditable) {
|
|
136 |
this.setEnabled(this.isEnabled());
|
|
137 |
}
|
|
138 |
|
|
139 |
public void alignToField(ComponentService arg0) {
|
|
140 |
|
|
141 |
}
|
|
142 |
|
|
143 |
public void addDateChangeListener(ChangeListener listener){
|
|
144 |
this.getModel().addChangeListener(listener);
|
|
145 |
}
|
|
120 |
/**
|
|
121 |
* @param time
|
|
122 |
*/
|
|
123 |
public void setDate(Date date) {
|
|
124 |
this.setValue(date);
|
|
125 |
}
|
|
126 |
|
|
127 |
public Date getCurDate(Date date) {
|
|
128 |
return (Date) this.getValue();
|
|
129 |
}
|
|
130 |
|
|
131 |
/**
|
|
132 |
* @param b
|
|
133 |
*/
|
|
134 |
public void setEditable(boolean isEditable) {
|
|
135 |
this.setEnabled(this.isEnabled());
|
|
136 |
}
|
|
137 |
|
|
138 |
public void alignToField(ComponentService arg0) {
|
|
139 |
|
|
140 |
}
|
|
141 |
|
|
142 |
public void addDateChangeListener(ChangeListener listener) {
|
|
143 |
this.getModel().addChangeListener(listener);
|
|
144 |
}
|
|
146 | 145 |
} |
Also available in: Unified diff