Index: trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java (revision 27)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java (revision 31)
@@ -30,4 +30,6 @@
import java.io.Serializable;
+import java.text.DateFormat;
+import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -65,4 +67,23 @@
private String[] dayVals;
+ /** labels for the months of the year */
+ private String[] monthLabels;
+ /** internal values for the months of the year */
+ private String[] monthVals;
+
+ /** labels for the hours of the day */
+ private String[] hourLabels;
+ /** internal values for the hours of the day */
+ private String[] hourVals;
+ /** labels for the hours of the day (24-hour clock) */
+ private String[] hour24Labels;
+ /** internal values for the hours of the day (24-hour clock) */
+ private String[] hour24Vals;
+
+ /** labels for the minutes of the hour */
+ private String[] minuteLabels;
+ /** internal values for the minutes of the hour */
+ private String[] minuteVals;
+
/** Constructor
*
@@ -82,10 +103,11 @@
ArrayList sdow = new ArrayList();
+ /* ********************* Day of Week ************************* */
+
firstDayOfWeek = c.getFirstDayOfWeek();
/** Get the number of days in a week. Is this ever anything other than 7?
*/
- numberDaysInWeek = c.getMaximum(Calendar.DAY_OF_WEEK) -
- c.getMinimum(Calendar.DAY_OF_WEEK) + 1;
+ numberDaysInWeek = getRangeSize(c, Calendar.DAY_OF_WEEK);
lastDayOfWeek = firstDayOfWeek - 1;
@@ -125,4 +147,6 @@
}
+ /* ****************** Day of Month ***************************** */
+
dayLabels = new String[getRangeSize(c, Calendar.DAY_OF_MONTH)];
dayVals = new String[getRangeSize(c, Calendar.DAY_OF_MONTH)];
@@ -134,4 +158,63 @@
dom++;
}
+
+ /* *********************** Months ***************************** */
+
+ monthLabels = new String[getRangeSize(c, Calendar.MONTH)];
+ monthVals = new String[getRangeSize(c, Calendar.MONTH)];
+
+ c.set(Calendar.MONTH, c.getMinimum(Calendar.MONTH));
+ c.getTime(); // force recompute
+
+ for (int i = 0; i < monthLabels.length; i++) {
+ // this gives abbreviated form of month name
+ monthLabels[i] = String.valueOf(getComponent(c, DateFormat.MONTH_FIELD,
+ DateFormat.MEDIUM));
+ /* Calendar class month numbers start at 0 */
+ monthVals[i] = twoDigit(c.get(Calendar.MONTH) + 1);
+ c.add(Calendar.MONTH, 1);
+ }
+
+ /* *********************** Hours ***************************** */
+
+ hourLabels = new String[getRangeSize(c, Calendar.HOUR)];
+ hourVals = new String[getRangeSize(c, Calendar.HOUR)];
+
+ /* Calendar.HOUR is 0 for 12 o'clock. Skip 0, then add it to the end
+ labeled as 12, but with value 0 */
+ hourLabels[hourLabels.length - 1] = String.valueOf(hourLabels.length - 1);
+ hourVals[hourLabels.length - 1] = twoDigit(0);
+
+ int hour = c.getMinimum(Calendar.HOUR) + 1;
+
+ for (int i = 1; i < hourLabels.length - 1; i++) {
+ hourLabels[i] = String.valueOf(hour);
+ hourVals[i] = twoDigit(hour);
+ hour++;
+ }
+
+ hour24Labels = new String[getRangeSize(c, Calendar.HOUR_OF_DAY)];
+ hour24Vals = new String[getRangeSize(c, Calendar.HOUR_OF_DAY)];
+
+ int hourOfDay = c.getMinimum(Calendar.HOUR_OF_DAY);
+
+ for (int i = 0; i < hour24Labels.length; i++) {
+ hour24Labels[i] = twoDigit(hourOfDay);
+ hour24Vals[i] = twoDigit(hourOfDay);
+ hourOfDay++;
+ }
+
+ /* *********************** Minutes ***************************** */
+
+ minuteLabels = new String[getRangeSize(c, Calendar.MINUTE)];
+ minuteVals = new String[getRangeSize(c, Calendar.MINUTE)];
+
+ int minute = c.getMinimum(Calendar.MINUTE);
+
+ for (int i=0; i < minuteLabels.length; i++) {
+ minuteLabels[i] = twoDigit(minute);
+ minuteVals[i] = twoDigit(minute);
+ minute++;
+ }
}
@@ -221,4 +304,84 @@
public String[] getDayVals() {
return dayVals;
+ }
+
+ /**
+ * @return labels
+ */
+ public String[] getMonthLabels() {
+ return monthLabels;
+ }
+
+ /**
+ * @return vals
+ */
+ public String[] getMonthVals() {
+ return monthVals;
+ }
+
+ /**
+ * @return labels
+ */
+ public String[] getHourLabels() {
+ return this.hourLabels;
+ }
+
+ /**
+ * @return vals
+ */
+ public String[] getHourVals() {
+ return this.hourVals;
+ }
+
+ /**
+ * @return labels
+ */
+ public String[] getHour24Labels() {
+ return this.hour24Labels;
+ }
+
+ /**
+ * @return vals
+ */
+ public String[] getHour24Vals() {
+ return this.hour24Vals;
+ }
+
+ /**
+ * @return labels
+ */
+ public String[] getMinuteLabels() {
+ return this.minuteLabels;
+ }
+
+ /**
+ * @return vals
+ */
+ public String[] getMinuteVals() {
+ return this.minuteVals;
+ }
+
+ /* ====================================================================
+ * Private methods
+ * ==================================================================== */
+
+ /** Get a String representation of a particular time field of the object.
+ *
+ * @param field The field to be returned,
+ * e.g., MONTH_FIELD. For possible values, see
+ * the constants in java.text.DateFormat
+ * @param dateFormat The style of DateFormat to use,
+ * e.g., SHORT. For possible values, see
+ * the constants in java.text.DateFormat.
+ * @return A String representation of a particular time
+ * field of the object.
+ */
+ private String getComponent(Calendar cal, int field, int dateFormat) {
+ FieldPosition f = new FieldPosition(field);
+ StringBuffer s = DateFormat.
+ getDateTimeInstance(dateFormat, dateFormat, getLocale()).
+ format(cal.getTime(), new StringBuffer(), f);
+
+ return s.substring(f.getBeginIndex(), f.getEndIndex());
}
@@ -239,13 +402,3 @@
return "0" + String.valueOf(val);
}
-
- private static String fourDigit(int val) {
- if (val > 999) {
- return String.valueOf(val);
- }
-
- String strVal = String.valueOf(val);
-
- return "0000".substring(strVal.length()) + strVal;
- }
}
Index: trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java (revision 27)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java (revision 31)
@@ -325,5 +325,5 @@
*/
public String[] getDayNamesAdjusted() {
- return curDay.getCalInfo().getDayNamesAdjusted();
+ return calInfo.getDayNamesAdjusted();
}
@@ -334,5 +334,5 @@
*/
public String[] getShortDayNamesAdjusted() {
- return curDay.getCalInfo().getShortDayNamesAdjusted();
+ return calInfo.getShortDayNamesAdjusted();
}
@@ -342,5 +342,5 @@
*/
public int getFirstDayOfWeek() {
- return curDay.getCalInfo().getFirstDayOfWeek();
+ return calInfo.getFirstDayOfWeek();
}
@@ -413,5 +413,5 @@
gtpi.multi = !gtpi.last.isSameDate(gtpi.first);
gtpi.currentDay = new MyCalendarVO(gtpi.first.getTime(),
- gtpi.first.getCalInfo().getLocale());
+ calInfo.getLocale());
gtpi.year = String.valueOf(gtpi.currentDay.getYear());
@@ -421,5 +421,5 @@
debugMsg("getFirstDayOfWeek() = " + getFirstDayOfWeek());
debugMsg("gtpi.first.getFirstDayOfWeek() = " +
- gtpi.first.getCalInfo().getFirstDayOfWeek());
+ calInfo.getFirstDayOfWeek());
}
@@ -580,10 +580,10 @@
/** Is this correct? The days of the week are rotated to adjust for
* first day differences. */
- tvdi.setDayName(gtpi.currentDay.getCalInfo().getDayName(dayOfWeek));
+ tvdi.setDayName(calInfo.getDayName(dayOfWeek));
tvdi.setFirstDayOfMonth(gtpi.newMonth);
gtpi.newMonth = false;
tvdi.setFirstDayOfWeek(getFirstDayOfWeek() == dayOfWeek);
- tvdi.setLastDayOfWeek(gtpi.currentDay.getCalInfo().getLastDayOfWeek() == dayOfWeek);
+ tvdi.setLastDayOfWeek(calInfo.getLastDayOfWeek() == dayOfWeek);
days.addElement(tvdi);
Index: trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java
===================================================================
--- trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (revision 18)
+++ trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/Events.java (revision 31)
@@ -1031,7 +1031,7 @@
sb.append(".dtstart.dtval");
- if (debug) {
- debugMsg("recurrences query is " + sb);
- }
+ //if (debug) {
+ // debugMsg("recurrences query is " + sb);
+ //}
sess.createQuery(sb.toString());
@@ -1081,7 +1081,7 @@
}
- if (debug) {
- debugMsg("recurrences after postexec " + evs.size());
- }
+ //if (debug) {
+ // debugMsg("recurrences after postexec " + evs.size());
+ //}
/** Run the events we got through the filters
Index: trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java
===================================================================
--- trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (revision 18)
+++ trunk/calendar3/calsvc/src/org/bedework/calsvc/CalSvc.java (revision 31)
@@ -131,5 +131,5 @@
*/
private BwUser publicUser;
-
+
// Set up by call to getCal()
private String publicUserAccount;
@@ -1747,5 +1747,5 @@
}
- trace("ev: " + ev);
+ //trace("ev: " + ev);
/* If the event is an event reference (an alias) implant it in an event
@@ -1813,5 +1813,5 @@
// Prepare for call below.
publicUserAccount = cali.getSyspars().getPublicUser();
-
+
BwUser auth;
if (isPublicAdmin() || isGuest()) {
Index: trunk/calendar3/webclient/war/docs/footer.jsp
===================================================================
--- trunk/calendar3/webclient/war/docs/footer.jsp (revision 27)
+++ trunk/calendar3/webclient/war/docs/footer.jsp (revision 31)
@@ -11,17 +11,4 @@
- <%--
-
-
-
-
-
-
-
-
-
-
-
- --%>
@@ -46,11 +33,11 @@
-
-
+
+
-
-
+
+
@@ -63,11 +50,11 @@
-
-
+
+
-
-
+
+
Index: trunk/calendar3/webcommon/src/org/bedework/webcommon/TimeDateComponents.java
===================================================================
--- trunk/calendar3/webcommon/src/org/bedework/webcommon/TimeDateComponents.java (revision 27)
+++ trunk/calendar3/webcommon/src/org/bedework/webcommon/TimeDateComponents.java (revision 31)
@@ -62,6 +62,4 @@
import java.io.Serializable;
-import java.text.DateFormat;
-import java.text.FieldPosition;
import java.util.Calendar;
import java.util.Date;
@@ -87,9 +85,4 @@
*/
public class TimeDateComponents implements Serializable {
- /** Label that indicates no time is specified */
- private static final String NO_TIME_LABEL = "None";
- /** Internal value to show no time is specified */
- private static final String NO_TIME_VALUE = "-1";
-
// arrays of values and labels for dropdown menus for various units of time
@@ -98,115 +91,4 @@
private static final String[] DEFAULT_AMPM_LABELS = {"am", "pm"};
- /* * default labels for the dates in a month */
- //private static String[] defaultDayLabels =
- // new String[maximumValues(Calendar.DAY_OF_MONTH)];
- //** default internal values for the dates in a month */
- //private static String[] defaultDayVals =
- // new String[maximumValues(Calendar.DAY_OF_MONTH)];
-
- /** default labels for the months of the year */
- private static String[] defaultMonthLabels =
- new String[maximumValues(Calendar.MONTH)];
- /** default internal values for the months of the year */
- private static String[] defaultMonthVals =
- new String[maximumValues(Calendar.MONTH)];
-
- // The hour arrays have an extra member to indicate no specified time
- /** default labels for the hours of the day */
- private static String[] defaultHourLabels =
- new String[maximumValues(Calendar.HOUR) + 1];
- /** default internal values for the hours of the day */
- private static String[] defaultHourVals =
- new String[maximumValues(Calendar.HOUR) + 1];
- /** default labels for the hours of the day (24-hour clock) */
- private static String[] defaultHour24Labels =
- new String[maximumValues(Calendar.HOUR_OF_DAY) + 1];
- /** default internal values for the hours of the day (24-hour clock) */
- private static String[] defaultHour24Vals =
- new String[maximumValues(Calendar.HOUR_OF_DAY) + 1];
-
- /** default labels for the minutes of the hour */
- private static String[] defaultMinuteLabels =
- new String[maximumValues(Calendar.MINUTE)];
- /** default internal values for the minutes of the hour */
- private static String[] defaultMinuteVals =
- new String[maximumValues(Calendar.MINUTE)];
-
- /**
- Get the maximum number of distinct values for an appropriate unit of time
- @param unit The unit of time. Should be one of the constants in
- java.util.Calendar, such as DAY_OF_MONTH
- @return the maximum number of distinct values for that unit. E.g., for
- DAY_OF_MONTH and a Gregorian calendar, 31
- */
- private static int maximumValues(int unit) {
- Calendar cal = Calendar.getInstance();
- return cal.getMaximum(unit) - cal.getMinimum(unit) + 1;
- }
-
- /** Initialize the arrays of time labels and values */
- static {
- /** For convenience, Get localized version of a calendar */
- //XXX some of this needs to be localized still
- Calendar cal = Calendar.getInstance(/* XXX locale?????*/);
-
- /*
- for (int i = 0, dateOfMonth = cal.getMinimum(Calendar.DAY_OF_MONTH);
- i < defaultDayLabels.length; i++, dateOfMonth++) {
- defaultDayLabels[i] = String.valueOf(dateOfMonth);
-
- //XXX assuming max number of days in months is two-digits
- defaultDayVals[i] = twoDigit(dateOfMonth);
- }
- */
-
- cal.set(Calendar.MONTH, cal.getMinimum(Calendar.MONTH));
- cal.getTime(); // force recompute
-
- for (int i = 0; i < defaultMonthLabels.length; i++) {
- // this gives abbreviated form of month name
- defaultMonthLabels[i] = String.valueOf(getComponent(cal, DateFormat.MONTH_FIELD,
- DateFormat.MEDIUM));
- //XXX assuming max number of months is two-digits
- /** Calendar class month numbers start at 0
- */
- defaultMonthVals[i] = twoDigit(cal.get(Calendar.MONTH) + 1);
- cal.add(Calendar.MONTH, 1);
- }
-
- defaultHourLabels[0] = NO_TIME_LABEL;
- defaultHourVals[0] = NO_TIME_VALUE;
-
- /* Calendar.HOUR is 0 for 12 o'clock. Skip 0, then add it to the end
- labeled as 12, but with value 0 */
- defaultHourLabels[defaultHourLabels.length - 1] =
- (defaultHourLabels.length-1) + "";
- defaultHourVals[defaultHourLabels.length - 1] = twoDigit(0);
-
- for (int i = 1, hour = cal.getMinimum(Calendar.HOUR) + 1;
- i < defaultHourLabels.length - 1; i++, hour++) {
- defaultHourLabels[i] = String.valueOf(hour);
- //XXX assuming max hour is two digits
- defaultHourVals[i] = twoDigit(hour);
- }
-
- defaultHour24Labels[0] = NO_TIME_LABEL;
- defaultHour24Vals[0] = NO_TIME_VALUE;
-
- for (int i=1, hourOfDay = cal.getMinimum(Calendar.HOUR_OF_DAY);
- i < defaultHour24Labels.length; i++, hourOfDay++) {
- defaultHour24Labels[i] = twoDigit(hourOfDay);
- //XXX assuming max hour of day is two digits
- defaultHour24Vals[i] = twoDigit(hourOfDay);
- }
-
- for (int i=0, minute = cal.getMinimum(Calendar.MINUTE);
- i < defaultMinuteLabels.length; i++, minute++) {
- defaultMinuteLabels[i] = twoDigit(minute);
- //XXX assuming max number of days in months is two-digits
- defaultMinuteVals[i] = twoDigit(minute);
- }
- }
-
//private boolean debug;
@@ -218,12 +100,4 @@
/** Holds time and date information */
private Calendar cal;
-
- //private String[] dayLabels;
- //private String[] dayVals;
- private String[] monthLabels;
- private String[] monthVals;
-
- private String[] hourLabels;
- private String[] hourVals;
/* We populate minuteLabels and minuteVals with the appropriate increments. */
@@ -283,6 +157,7 @@
//dayLabels = defaultDayLabels;
//dayVals = defaultDayVals;
- monthLabels = defaultMonthLabels;
- monthVals = defaultMonthVals;
+ //monthLabels = defaultMonthLabels;
+ //monthVals = defaultMonthVals;
+ /*
if (hour24) {
hourLabels = defaultHour24Labels;
@@ -292,47 +167,9 @@
hourVals = defaultHourVals;
}
-
- setMinutes(defaultMinuteLabels, defaultMinuteVals, minuteIncrement);
+ */
+
+ setMinutes(minuteIncrement);
this.ampmLabels = DEFAULT_AMPM_LABELS;
- }
-
- /**
- Set the minutes arrays to a subset of the values in two given arrays
- @param minuteLabels Array from which to draw the labels
- @param minuteVals Array from which to draw the values
- @param minuteIncrement Choose the 0th entry in each array, and every
- minuteIncrement'th one after that
- @exception TimeDateException If either of the arrays given is not
- the proper length
- */
- public void setMinutes(String[] minuteLabels,
- String[] minuteVals,
- int minuteIncrement) throws TimeDateException {
- this.minuteIncrement = (minuteIncrement <= 1) ? 1: minuteIncrement;
-
- if ((minuteLabels.length != defaultMinuteLabels.length) ||
- (minuteVals.length != defaultMinuteLabels.length)) {
- throw new TimeDateException("minute values/labels must have " +
- defaultMinuteLabels.length + " entries");
- }
-
- if (this.minuteIncrement == 1) {
- this.minuteLabels = minuteLabels;
- this.minuteVals = minuteVals;
- } else {
- int sz = defaultMinuteLabels.length / this.minuteIncrement;
-
- this.minuteLabels = new String[sz];
- this.minuteVals = new String[sz];
-
- for (int i=0, j=0;
- j < minuteLabels.length;
- i++, j += this.minuteIncrement)
- {
- this.minuteLabels[i] = minuteLabels[j];
- this.minuteVals[i] = minuteVals[j];
- }
- }
}
@@ -376,5 +213,5 @@
*/
public String[] getMonthLabels() {
- return this.monthLabels;
+ return getCalInfo().getMonthLabels();
}
@@ -383,5 +220,5 @@
*/
public String[] getMonthVals() {
- return this.monthVals;
+ return getCalInfo().getMonthVals();
}
@@ -390,5 +227,8 @@
*/
public String[] getHourLabels() {
- return this.hourLabels;
+ if (hour24) {
+ return getCalInfo().getHour24Labels();
+ }
+ return getCalInfo().getHourLabels();
}
@@ -397,5 +237,8 @@
*/
public String[] getHourVals() {
- return this.hourVals;
+ if (hour24) {
+ return getCalInfo().getHour24Vals();
+ }
+ return getCalInfo().getHourVals();
}
@@ -404,5 +247,5 @@
*/
public String[] getMinuteLabels() {
- return this.minuteLabels;
+ return minuteLabels;
}
@@ -411,5 +254,5 @@
*/
public String[] getMinuteVals() {
- return this.minuteVals;
+ return minuteVals;
}
@@ -536,5 +379,5 @@
public String getMonth() {
// Calendar.MONTH returns 0-11
- return monthVals[getCal().get(Calendar.MONTH)];
+ return getCalInfo().getMonthVals()[getCal().get(Calendar.MONTH)];
}
@@ -603,13 +446,18 @@
*/
public String getHour() {
- /* Calendar.HOUR_OF_DAY returns 0-23; must be adjusted up due NO_TIME_VAL
- Calendar.HOUR returns 0-11; must adjust due to funny 12/0 problem */
- if (this.hour24) {
- return this.hourVals[getCal().get(Calendar.HOUR_OF_DAY) + 1];
- } else if (getCal().get(Calendar.HOUR) == 0) {
- return this.hourVals[this.hourVals.length - 1];
- } else {
- return this.hourVals[getCal().get(Calendar.HOUR)];
- }
+ String[] vals = getHourVals();
+
+ if (hour24) {
+ return vals[getCal().get(Calendar.HOUR_OF_DAY)];
+ }
+
+ /* Calendar.HOUR returns 0-11; must adjust due to funny 12/0 problem */
+ int hr = getCal().get(Calendar.HOUR);
+
+ if (hr == 0) {
+ return vals[vals.length - 1];
+ }
+
+ return vals[hr];
}
@@ -657,5 +505,5 @@
private Calendar getCal() {
if (cal == null) {
- cal = Calendar.getInstance(/* XXX locale?????*/);
+ cal = Calendar.getInstance(getCalInfo().getLocale());
}
@@ -666,27 +514,19 @@
int imin;
- if ((val == null) || (val.equals(NO_TIME_VALUE))) {
+ if (val == null) {
return 0;
- } else {
- try {
- imin = Integer.parseInt(val);
- } catch (NumberFormatException e) {
- imin = 0;
- }
+ }
+
+ try {
+ imin = Integer.parseInt(val);
+ } catch (NumberFormatException e) {
+ imin = 0;
}
if (this.minuteIncrement > 1) {
return ((imin + 1) / this.minuteIncrement) * this.minuteIncrement;
- } else {
- return imin;
- }
- }
-
- private static String twoDigit(int val) {
- if (val > 9) {
- return String.valueOf(val);
- }
-
- return "0" + String.valueOf(val);
+ }
+
+ return imin;
}
@@ -701,22 +541,34 @@
}
- /** Get a String representation of a particular time
- * field of the object.
- *
- * @param field The field to be returned,
- * e.g., MONTH_FIELD. For possible values, see
- * the constants in java.text.DateFormat
- * @param dateFormat The style of DateFormat to use,
- * e.g., SHORT. For possible values, see
- * the constants in java.text.DateFormat.
- * @return A String representation of a particular time
- * field of the object.
- */
- private static String getComponent(Calendar cal, int field, int dateFormat) {
- FieldPosition f = new FieldPosition(field);
- StringBuffer s = DateFormat.
- getDateTimeInstance(dateFormat, dateFormat/* XXX ,cal.getLocale() */).
- format(cal.getTime(), new StringBuffer(), f);
- return s.substring(f.getBeginIndex(), f.getEndIndex());
+ /*
+ Set the minutes arrays to a subset of the values in two given arrays
+ @param increment Choose the 0th entry in each array, and every
+ minuteIncrement'th one after that
+ @exception TimeDateException If either of the arrays given is not
+ the proper length
+ */
+ private void setMinutes(int increment) throws TimeDateException {
+ minuteIncrement = (increment <= 1) ? 1: increment;
+
+ String[] labels = getCalInfo().getMinuteLabels();
+ String[] vals = getCalInfo().getMinuteVals();
+
+ if (minuteIncrement == 1) {
+ minuteLabels = labels;
+ minuteVals = vals;
+ return;
+ }
+
+ int sz = labels.length / minuteIncrement;
+
+ minuteLabels = new String[sz];
+ minuteVals = new String[sz];
+
+ int i = 0;
+ for (int j=0; j < labels.length; j += minuteIncrement) {
+ minuteLabels[i] = labels[j];
+ minuteVals[i] = vals[j];
+ i++;
+ }
}