1 Clazz.declarePackage ("javax.swing");
2 Clazz.load (["javax.swing.AbstractSpinnerModel"], "javax.swing.SpinnerDateModel", ["java.lang.IllegalArgumentException", "java.util.Calendar", "$.Date"], function () {
3 c$ = Clazz.decorateAsClass (function () {
7 this.calendarField = 0;
8 Clazz.instantialize (this, arguments);
9 }, javax.swing, "SpinnerDateModel", javax.swing.AbstractSpinnerModel);
10 Clazz.defineMethod (c$, "calendarFieldOK",
11 function (calendarField) {
12 switch (calendarField) {
33 Clazz.makeConstructor (c$,
34 function (value, start, end, calendarField) {
35 Clazz.superConstructor (this, javax.swing.SpinnerDateModel, []);
37 throw new IllegalArgumentException ("value is null");
38 }if (!this.calendarFieldOK (calendarField)) {
39 throw new IllegalArgumentException ("invalid calendarField");
40 }if (!(((start == null) || (start.compareTo (value) <= 0)) && ((end == null) || (end.compareTo (value) >= 0)))) {
41 throw new IllegalArgumentException ("(start <= value <= end) is false");
42 }this.value = java.util.Calendar.getInstance ();
45 this.calendarField = calendarField;
46 this.value.setTime (value);
47 }, "java.util.Date,Comparable,Comparable,~N");
48 Clazz.makeConstructor (c$,
50 this.construct ( new java.util.Date (), null, null, 5);
52 Clazz.defineMethod (c$, "setStart",
54 if ((start == null) ? (this.start != null) : !start.equals (this.start)) {
56 this.fireStateChanged ();
58 Clazz.defineMethod (c$, "getStart",
62 Clazz.defineMethod (c$, "setEnd",
64 if ((end == null) ? (this.end != null) : !end.equals (this.end)) {
66 this.fireStateChanged ();
68 Clazz.defineMethod (c$, "getEnd",
72 Clazz.defineMethod (c$, "setCalendarField",
73 function (calendarField) {
74 if (!this.calendarFieldOK (calendarField)) {
75 throw new IllegalArgumentException ("invalid calendarField");
76 }if (calendarField != this.calendarField) {
77 this.calendarField = calendarField;
78 this.fireStateChanged ();
80 Clazz.defineMethod (c$, "getCalendarField",
82 return this.calendarField;
84 Clazz.overrideMethod (c$, "getNextValue",
86 var cal = java.util.Calendar.getInstance ();
87 cal.setTime (this.value.getTime ());
88 cal.add (this.calendarField, 1);
89 var next = cal.getTime ();
90 return ((this.end == null) || (this.end.compareTo (next) >= 0)) ? next : null;
92 Clazz.overrideMethod (c$, "getPreviousValue",
94 var cal = java.util.Calendar.getInstance ();
95 cal.setTime (this.value.getTime ());
96 cal.add (this.calendarField, -1);
97 var prev = cal.getTime ();
98 return ((this.start == null) || (this.start.compareTo (prev) <= 0)) ? prev : null;
100 Clazz.defineMethod (c$, "getDate",
102 return this.value.getTime ();
104 Clazz.overrideMethod (c$, "getValue",
106 return this.value.getTime ();
108 Clazz.overrideMethod (c$, "setValue",
110 if ((value == null) || !(Clazz.instanceOf (value, java.util.Date))) {
111 throw new IllegalArgumentException ("illegal value");
112 }if (!value.equals (this.value.getTime ())) {
113 this.value.setTime (value);
114 this.fireStateChanged ();