01: package jimm.datavision.gui.parameter;
02:
03: import jimm.datavision.Parameter;
04: import java.util.Date;
05: import java.util.Calendar;
06: import javax.swing.*;
07: import com.toedter.calendar.JCalendar;
08:
09: /**
10: * A range date inquisitor knows how to display and control the widgets
11: * needed to ask a user for two date parameter values.
12: *
13: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
14: */
15: class RangeDateInq extends Inquisitor {
16:
17: protected JCalendar fromCal;
18: protected JCalendar toCal;
19:
20: RangeDateInq(Parameter param) {
21: super (param);
22:
23: // Build GUI
24: Box box = Box.createVerticalBox();
25: panel.add(box);
26:
27: box.add(fromCal = new JCalendar());
28: box.add(Box.createVerticalStrut(8));
29: box.add(toCal = new JCalendar());
30:
31: // Copy default values into "real" values
32: parameter.setValue(0, parameter.getDefaultValue(0));
33: parameter.setValue(1, parameter.getDefaultValue(1));
34: }
35:
36: void copyGUIIntoParam() {
37: parameter.setValue(0, fromCal.getCalendar().getTime());
38: parameter.setValue(1, toCal.getCalendar().getTime());
39: }
40:
41: void copyParamIntoGUI() {
42: Calendar calendar = Calendar.getInstance();
43: calendar.setTime((Date) parameter.getValue(0));
44: fromCal.setCalendar(calendar);
45:
46: calendar = Calendar.getInstance();
47: calendar.setTime((Date) parameter.getValue(1));
48: toCal.setCalendar(calendar);
49: }
50:
51: }
|