Changeset 27

Show
Ignore:
Timestamp:
01/24/06 13:43:10
Author:
douglm
Message:

Set default timezone when creating events

Move fields from TimeDateComponents? to CalendarInfo?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3

    • Property svn:ignore set to dist
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/CalendarInfo.java

    r2 r27  
    6060  private int numberDaysInWeek; 
    6161 
     62  /** labels for the dates in a month */ 
     63  private String[] dayLabels; 
     64  /** internal values for the dates in a month */ 
     65  private String[] dayVals; 
     66 
    6267  /** Constructor 
    6368   * 
     
    119124      shortDayNamesAdjusted = shortDayNames; 
    120125    } 
     126 
     127    dayLabels = new String[getRangeSize(c, Calendar.DAY_OF_MONTH)]; 
     128    dayVals = new String[getRangeSize(c, Calendar.DAY_OF_MONTH)]; 
     129 
     130    int dom = c.getMinimum(Calendar.DAY_OF_MONTH); 
     131    for (int i = 0; i < dayLabels.length; i++) { 
     132      dayLabels[i] = String.valueOf(dom); 
     133      dayVals[i] = twoDigit(dom); 
     134      dom++; 
     135    } 
    121136  } 
    122137 
     
    193208    return lastDayOfWeek; 
    194209  } 
     210 
     211  /** 
     212   * @return labels 
     213   */ 
     214  public String[] getDayLabels() { 
     215    return dayLabels; 
     216  } 
     217 
     218  /** 
     219   * @return vals 
     220   */ 
     221  public String[] getDayVals() { 
     222    return dayVals; 
     223  } 
     224 
     225  /** Return the size of the range for a given unit of time 
     226   * 
     227   * @param unit      value defined in java.util.Calendar 
     228   * @return int      size of range 
     229   */ 
     230  private int getRangeSize(Calendar cal, int unit) { 
     231    return cal.getMaximum(unit) - cal.getMinimum(unit) + 1; 
     232  } 
     233 
     234  private static String twoDigit(int val) { 
     235    if (val > 9) { 
     236      return String.valueOf(val); 
     237    } 
     238 
     239    return "0" + String.valueOf(val); 
     240  } 
     241 
     242  private static String fourDigit(int val) { 
     243    if (val > 999) { 
     244      return String.valueOf(val); 
     245    } 
     246 
     247    String strVal = String.valueOf(val); 
     248 
     249    return "0000".substring(strVal.length()) + strVal; 
     250  } 
    195251} 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/DayView.java

    r2 r27  
    6666  /** Constructor: 
    6767   * 
     68   * @param  calInfo   Object providing calendaring information 
    6869   * @param  curDay    MyCalendarVO representing current day. 
    6970   * @param  cal       CalSvcI calendar service interface 
     
    7172   * @throws CalFacadeException 
    7273   */ 
    73   public DayView(MyCalendarVO curDay, 
     74  public DayView(CalendarInfo calInfo, 
     75                 MyCalendarVO curDay, 
    7476                 CalSvcI cal, 
    7577                 boolean debug) throws CalFacadeException { 
    76     super(curDay, "Day", cal, 
     78    super(calInfo, curDay, "Day", cal, 
    7779          curDay, 
    7880          curDay.getTomorrow(), 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java

    r2 r27  
    6363import org.apache.log4j.Logger; 
    6464 
    65 /** Object to provide formatting services for an EventVO
     65/** Object to provide formatting services for a BwEvent
    6666 * 
    6767 * @author Mike Douglass   douglm@rpi.edu 
     
    7272  private EventInfo eventInfo; 
    7373 
     74  private CalendarInfo calInfo; 
     75 
    7476  private CalTimezones ctz; 
    7577 
     
    9092   * 
    9193   * @param eventInfo 
     94   * @param calInfo 
    9295   * @param view 
    9396   * @param ctz 
    9497   */ 
    9598  public EventFormatter(EventInfo eventInfo, TimeView view, 
    96                         CalTimezones ctz) { 
     99                        CalendarInfo calInfo, CalTimezones ctz) { 
    97100    this.eventInfo = eventInfo; 
     101    this.calInfo = calInfo; 
    98102    this.ctz= ctz; 
    99103  } 
     
    108112  public EventInfo getEventInfo() { 
    109113    return eventInfo; 
     114  } 
     115 
     116  /** 
     117   * @return CalendarInfo 
     118   */ 
     119  public CalendarInfo getCalInfo() { 
     120    return calInfo; 
    110121  } 
    111122 
     
    132143  public MyCalendarVO getToday() { 
    133144    if (today == null) { 
     145      // XXX Locale? 
    134146      today = new MyCalendarVO(); 
    135147    } 
     
    146158    try { 
    147159      if (start == null) { 
    148         start = new DateTimeFormatter(getToday().getCalInfo(), 
     160        start = new DateTimeFormatter(getCalInfo(), 
    149161                                      getEvent().getDtstart(), ctz); 
    150162      } 
     
    169181    try { 
    170182      if (end == null) { 
    171         end = new DateTimeFormatter(getToday().getCalInfo(), 
     183        end = new DateTimeFormatter(getCalInfo(), 
    172184                                    getEvent().getDtend(), 
    173185                                    ctz); 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/FormattedEvents.java

    r2 r27  
    6868public class FormattedEvents extends AbstractCollection { 
    6969  private Collection events; 
     70  private CalendarInfo calInfo; 
    7071  private CalTimezones ctz; 
    7172 
     
    7374   * 
    7475   * @param events 
     76   * @param calInfo 
    7577   * @param ctz 
    7678   */ 
    7779  public FormattedEvents(Collection events, 
    78                          CalTimezones ctz) { 
     80                         CalendarInfo calInfo, CalTimezones ctz) { 
    7981    this.events = events; 
     82    this.calInfo = calInfo; 
    8083    this.ctz = ctz; 
    8184  } 
     
    103106      EventInfo ev = (EventInfo)it.next(); 
    104107 
    105       return new EventFormatter(ev, null, ctz); 
     108      return new EventFormatter(ev, null, calInfo, ctz); 
    106109    } 
    107110 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/MonthView.java

    r2 r27  
    6666  /** Constructor: 
    6767   * 
     68   * @param  calInfo   Object providing calendaring information 
    6869   * @param  curDay    MyCalendarVO representing current day. 
    6970   * @param  cal       CalSvcI calendar service interface 
     
    7172   * @throws CalFacadeException 
    7273   */ 
    73   public MonthView(MyCalendarVO curDay, 
     74  public MonthView(CalendarInfo calInfo, 
     75                   MyCalendarVO curDay, 
    7476                   CalSvcI cal, 
    7577                   boolean debug) throws CalFacadeException { 
    76     super(curDay, "Month", cal, 
     78    super(calInfo, curDay, "Month", cal, 
    7779          curDay.getFirstDayOfThisMonth(), 
    7880          curDay.getLastDayOfThisMonth(), 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeView.java

    r2 r27  
    8888public class TimeView implements Serializable { 
    8989  protected boolean debug; 
     90  protected CalendarInfo calInfo; 
    9091  protected MyCalendarVO curDay; 
    9192  protected CalSvcI cal; 
     
    107108  /** Constructor: 
    108109   * 
     110   * @param  calInfo   Object providing calendaring information 
    109111   * @param  curDay    MyCalendarVO representing current day. 
    110112   * @param  periodName Name of period, capitalized, e.g. Week 
     
    121123   * @throws CalFacadeException 
    122124   */ 
    123   public TimeView(MyCalendarVO curDay, 
     125  public TimeView(CalendarInfo calInfo, 
     126                  MyCalendarVO curDay, 
    124127                  String periodName, 
    125128                  CalSvcI cal, 
     
    130133                  boolean showData, 
    131134                  boolean debug) throws CalFacadeException { 
     135    this.calInfo = calInfo; 
    132136    this.curDay = curDay; 
    133137    this.periodName = periodName; 
     
    423427 
    424428      /* Our month entry */ 
    425       TimeViewDailyInfo monthTvdi = new TimeViewDailyInfo(); 
     429      TimeViewDailyInfo monthTvdi = new TimeViewDailyInfo(calInfo); 
    426430      initTvdi(monthTvdi, gtpi); 
    427431 
    428432      /* Create a year entry */ 
    429       TimeViewDailyInfo yearTvdi = new TimeViewDailyInfo(); 
     433      TimeViewDailyInfo yearTvdi = new TimeViewDailyInfo(calInfo); 
    430434      yearTvdi.setCal(gtpi.currentDay); 
    431435      yearTvdi.setYear(gtpi.year); 
     
    435439 
    436440      for (;;) { 
    437         TimeViewDailyInfo weekTvdi = new TimeViewDailyInfo(); 
     441        TimeViewDailyInfo weekTvdi = new TimeViewDailyInfo(calInfo); 
    438442 
    439443        initTvdi(weekTvdi, gtpi); 
     
    468472          initGtpiForMonth(gtpi); 
    469473 
    470           monthTvdi = new TimeViewDailyInfo(); 
     474          monthTvdi = new TimeViewDailyInfo(calInfo); 
    471475          initTvdi(monthTvdi, gtpi); 
    472476          weeks = new Vector(); 
     
    532536 
    533537    while (dayNum != dayOfWeek) { 
    534       tvdi = new TimeViewDailyInfo(); 
     538      tvdi = new TimeViewDailyInfo(calInfo); 
    535539      tvdi.setFiller(true); 
    536540 
     
    563567 
    564568      /* Create a day entry */ 
    565       tvdi = new TimeViewDailyInfo(); 
     569      tvdi = new TimeViewDailyInfo(calInfo); 
    566570 
    567571      initTvdi(tvdi, gtpi); 
     
    603607     */ 
    604608    while (days.size() < 7) { 
    605       tvdi = new TimeViewDailyInfo(); 
     609      tvdi = new TimeViewDailyInfo(calInfo); 
    606610      tvdi.setFiller(true); 
    607611 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/TimeViewDailyInfo.java

    r2 r27  
    7272 */ 
    7373public class TimeViewDailyInfo implements Serializable { 
     74  private CalendarInfo calInfo; 
     75 
    7476  /** The view that created this. 
    7577   */ 
     
    177179   */ 
    178180  private Collection eventFormatters; 
     181 
     182  /** Constructor: 
     183   * 
     184   * @param  calInfo   Object providing calendaring information 
     185   */ 
     186  public TimeViewDailyInfo(CalendarInfo calInfo) { 
     187    this.calInfo = calInfo; 
     188  } 
    179189 
    180190  /** The view that created this. 
     
    555565        while (it.hasNext()) { 
    556566          eventFormatters.add(new EventFormatter((EventInfo)it.next(), view, 
    557                               view.getTimezones())); 
     567                              calInfo, view.getTimezones())); 
    558568        } 
    559569      } 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/WeekView.java

    r2 r27  
    6666  /** Constructor: 
    6767   * 
     68   * @param  calInfo   Object providing calendaring information 
    6869   * @param  curDay    MyCalendarVO representing current day. 
    6970   * @param  cal       CalSvcI calendar service interface 
     
    7172   * @throws CalFacadeException 
    7273   */ 
    73   public WeekView(MyCalendarVO curDay, 
     74  public WeekView(CalendarInfo calInfo, 
     75                  MyCalendarVO curDay, 
    7476                  CalSvcI cal, 
    7577                  boolean debug) throws CalFacadeException { 
    76     super(curDay, "Week", cal, 
     78    super(calInfo, curDay, "Week", cal, 
    7779          curDay.getFirstDayOfThisWeek(), 
    7880          curDay.getLastDayOfThisWeek(), 
  • trunk/calendar3/appcommon/src/org/bedework/appcommon/YearView.java

    r2 r27  
    6666  /** Constructor: 
    6767   * 
     68   * @param  calInfo   Object providing calendaring information 
    6869   * @param  curDay    MyCalendarVO representing current day. 
    6970   * @param  cal       CalSvcI calendar service interface 
     
    7576   * @throws CalFacadeException 
    7677   */ 
    77   public YearView(MyCalendarVO curDay, 
     78  public YearView(CalendarInfo calInfo, 
     79                  MyCalendarVO curDay, 
    7880                  CalSvcI cal, 
    7981                  boolean showData, 
    8082                  boolean debug) throws CalFacadeException { 
    81     super(curDay, "Year", cal, 
     83    super(calInfo, curDay, "Year", cal, 
    8284          curDay.getFirstDayOfThisYear(), 
    8385          curDay.getLastDayOfThisYear(), 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/AccessUtil.java

    r2 r27  
    7171import org.apache.log4j.Logger; 
    7272 
     73import java.io.Serializable; 
    7374import java.util.Collection; 
    7475import java.util.HashMap; 
     
    9596  /* Information created and saved about access on a given path. 
    9697   */ 
    97   private class PathInfo
     98  private class PathInfo implements Serializable
    9899    String path;   // The key 
    99100    Acl pathAcl;   // Merged acl for the path. 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalTimezonesImpl.java

    r2 r27  
    9292  private boolean debug; 
    9393 
     94  private String defaultTimeZoneId; 
     95  private transient TimeZone defaultTimeZone; 
     96 
    9497  private static class TimezoneInfo { 
    9598    TimeZone tz; 
     
    161164 
    162165  public TimeZone getTimeZone(final String id) throws CalFacadeException { 
     166    if ((defaultTimeZone != null) && id.equals(defaultTimeZoneId)) { 
     167      return defaultTimeZone; 
     168    } 
     169 
    163170    stats.incTzFetches(); 
    164171    TimezoneInfo tzinfo = lookup(id); 
     
    181188    } 
    182189 
     190    if ((defaultTimeZone == null) && id.equals(defaultTimeZoneId)) { 
     191      defaultTimeZone = tzinfo.tz; 
     192    } 
     193 
    183194    return tzinfo.tz; 
     195  } 
     196 
     197  public TimeZone getDefaultTimeZone() throws CalFacadeException { 
     198    if ((defaultTimeZone == null) && (defaultTimeZoneId != null)) { 
     199      defaultTimeZone = getTimeZone(defaultTimeZoneId); 
     200    } 
     201 
     202    return defaultTimeZone; 
     203  } 
     204 
     205  public void setDefaultTimeZoneId(String id) throws CalFacadeException { 
     206    defaultTimeZone = null; 
     207    defaultTimeZoneId = id; 
     208  } 
     209 
     210  public String getDefaultTimeZoneId() throws CalFacadeException { 
     211    return defaultTimeZoneId; 
    184212  } 
    185213 
  • trunk/calendar3/calCore/src/org/bedework/calcore/hibernate/CalintfImpl.java

    r18 r27  
    348348 
    349349    timezones = new CalTimezonesImpl(this, getStats(), publicAdmin, debug); 
     350    timezones.setDefaultTimeZoneId(getSyspars().getTzid()); 
    350351 
    351352    return userCreated; 
     
    375376        throw new CalFacadeException("No system parameters with name " + name); 
    376377      } 
    377        
     378 
    378379      if (debug) { 
    379       trace("Read system parameters: " + syspars); 
     380        trace("Read system parameters: " + syspars); 
    380381      } 
    381382    } 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/CalFacadeUtil.java

    r18 r27  
    267267    } 
    268268 
    269     dtm.init(dateOnly, date, null, timezones); 
     269    dtm.init(dateOnly, date, timezones.getDefaultTimeZoneId(), timezones); 
    270270 
    271271    return dtm; 
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/ifs/CalTimezones.java

    r2 r27  
    100100 public TimeZone getTimeZone(final String id) throws CalFacadeException; 
    101101 
     102 /** Get the default timezone for this system. 
     103  * 
     104  * @return default TimeZone or null for none set. 
     105  * @throws CalFacadeException 
     106  */ 
     107 public TimeZone getDefaultTimeZone() throws CalFacadeException; 
     108 
     109 /** Set the default timezone id for this system. 
     110  * 
     111  * @param id 
     112  * @throws CalFacadeException 
     113  */ 
     114 public void setDefaultTimeZoneId(String id) throws CalFacadeException; 
     115 
     116 /** Get the default timezone id for this system. 
     117 * 
     118 * @return String id 
     119 * @throws CalFacadeException 
     120 */ 
     121 public String getDefaultTimeZoneId() throws CalFacadeException; 
     122 
    102123 /** Find a timezone object in the database given the id. 
    103124  * 
  • trunk/calendar3/tools/src/org/bedework/tools/dumprestore/restore/Restore.java

    r18 r27  
    133133                                          globals.getPublicUser(), 
    134134                                          globals.rintf); 
     135    globals.timezones.setDefaultTimeZoneId(globals.syspars.getTzid()); 
    135136 
    136137    if (globals.from2p3px) { 
  • trunk/calendar3/tools/src/org/bedework/tools/dumprestore/restore/TimezonesImpl.java

    r18 r27  
    9292  private BwUser user; 
    9393 
     94  private String defaultTimeZoneId; 
     95  private transient TimeZone defaultTimeZone; 
     96 
    9497  private RestoreIntf ri; 
    9598 
     
    212215 
    213216    return tzinfo.tz; 
     217  } 
     218 
     219  public TimeZone getDefaultTimeZone() throws CalFacadeException { 
     220    if ((defaultTimeZone == null) && (defaultTimeZoneId != null)) { 
     221      defaultTimeZone = getTimeZone(defaultTimeZoneId); 
     222    } 
     223 
     224    return defaultTimeZone; 
     225  } 
     226 
     227  public void setDefaultTimeZoneId(String id) throws CalFacadeException { 
     228    defaultTimeZone = null; 
     229    defaultTimeZoneId = id; 
     230  } 
     231 
     232  public String getDefaultTimeZoneId() throws CalFacadeException { 
     233    return defaultTimeZoneId; 
    214234  } 
    215235 
  • trunk/calendar3/webadmin/src/org/bedework/webadmin/event/PEGetFormattedEventsAction.java

    r2 r27  
    9797 
    9898    form.setFormattedEvents(new FormattedEvents(getEvents(false, form), 
     99                                                form.getCalInfo(), 
    99100                                                form.getCalSvcI().getTimezones())); 
    100101 
  • trunk/calendar3/webclient/src/org/bedework/webclient/BwEventAction.java

    r2 r27  
    8888    EventFormatter ef = new EventFormatter(ev, 
    8989                                           form.getCurTimeView(), 
     90                                           form.getCalInfo(), 
    9091                                           form.getCalSvcI().getTimezones()); 
    9192 
  • trunk/calendar3/webclient/war/docs/footer.jsp

    r2 r27  
    99 
    1010  <bean:define id="forLabels" name="calForm" property="forLabels" /> 
     11  <bean:define id="calInfo" name="calForm" property="today.calInfo" /> 
    1112 
     13   <%-- 
    1214  <daylabels> 
    1315    <logic:iterate id="dayLabels" name="calForm" property="forLabels.dayLabels"> 
     
    2123    <start><bean:write name="calForm" property="viewStartDate.day"/></start> 
    2224  </dayvalues> 
     25  --%> 
     26  <daylabels> 
     27    <logic:iterate id="dayLabel" name="calInfo" property="dayLabels"> 
     28      <val><bean:write name="dayLabel"/></val> 
     29    </logic:iterate> 
     30  </daylabels> 
     31  <dayvalues> 
     32    <logic:iterate id="dayVal" name="calInfo" property="dayVals"> 
     33      <val><bean:write name="dayVal"/></val> 
     34    </logic:iterate> 
     35    <start><bean:write name="calForm" property="viewStartDate.day"/></start> 
     36  </dayvalues> 
    2337  <daynames> 
    24     <logic:iterate id="dayName" name="calForm" property="today.calInfo.dayNamesAdjusted"> 
     38    <logic:iterate id="dayName" name="calInfo" property="dayNamesAdjusted"> 
    2539      <val><bean:write name="dayName"/></val> 
    2640    </logic:iterate> 
    2741  </daynames> 
    2842  <shortdaynames> 
    29     <logic:iterate id="shortDayName" name="calForm" property="today.calInfo.shortDayNamesAdjusted"> 
     43    <logic:iterate id="shortDayName" name="calInfo" property="shortDayNamesAdjusted"> 
    3044      <val><bean:write name="shortDayName"/></val> 
    3145    </logic:iterate> 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/BwActionFormBase.java

    r17 r27  
    5656 
    5757import org.bedework.appcommon.BedeworkDefs; 
     58import org.bedework.appcommon.CalendarInfo; 
    5859import org.bedework.appcommon.DayView; 
    5960import org.bedework.appcommon.MonthView; 
     
    767768  public MyCalendarVO getToday() { 
    768769    if (today == null) { 
     770      // XXX locale 
    769771      today = new MyCalendarVO(); 
    770772    } 
    771773    return today; 
     774  } 
     775 
     776  /** 
     777   * @return calendar info 
     778   */ 
     779  public CalendarInfo getCalInfo() { 
     780    return getToday().getCalInfo(); 
    772781  } 
    773782 
     
    10981107      switch (curViewPeriod) { 
    10991108      case BedeworkDefs.dayView: 
    1100         setCurTimeView(new DayView(viewMcDate, getCalSvcI(), debug)); 
     1109        setCurTimeView(new DayView(getCalInfo(), viewMcDate, getCalSvcI(), debug)); 
    11011110        break; 
    11021111      case BedeworkDefs.weekView: 
    1103         setCurTimeView(new WeekView(viewMcDate, getCalSvcI(), debug)); 
     1112        setCurTimeView(new WeekView(getCalInfo(), viewMcDate, getCalSvcI(), debug)); 
    11041113        break; 
    11051114      case BedeworkDefs.monthView: 
    1106         setCurTimeView(new MonthView(viewMcDate, getCalSvcI(), debug)); 
     1115        setCurTimeView(new MonthView(getCalInfo(), viewMcDate, getCalSvcI(), debug)); 
    11071116        break; 
    11081117      case BedeworkDefs.yearView: 
    1109         setCurTimeView(new YearView(viewMcDate, getCalSvcI(), 
     1118        setCurTimeView(new YearView(getCalInfo(), viewMcDate, getCalSvcI(), 
    11101119                       getShowYearData(), debug)); 
    11111120        break; 
     
    17821791  public EventDates getEventDates() { 
    17831792    if (eventDates == null) { 
    1784       eventDates = new EventDates(getCalSvcI(), hour24, minIncrement, err, debug); 
     1793      eventDates = new EventDates(getCalSvcI(), getCalInfo(), 
     1794                                  hour24, minIncrement, err, debug); 
    17851795    } 
    17861796 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/EntityDates.java

    r2 r27  
    5555package org.bedework.webcommon; 
    5656 
     57import org.bedework.appcommon.CalendarInfo; 
    5758import org.bedework.calsvci.CalSvcI; 
    5859 
     
    6970 
    7071  protected CalSvcI svci; 
     72  private CalendarInfo calInfo; 
    7173 
    7274  protected boolean hour24; 
     
    8385   * 
    8486   * @param svci 
     87   * @param calInfo 
    8588   * @param hour24 
    8689   * @param minIncrement 
     
    8891   * @param debug 
    8992   */ 
    90   public EntityDates(CalSvcI svci, boolean hour24, int minIncrement, 
     93  public EntityDates(CalSvcI svci, CalendarInfo calInfo, 
     94                     boolean hour24, int minIncrement, 
    9195                     MessageEmit err, boolean debug) { 
    9296    this.svci = svci; 
     97    this.calInfo = calInfo; 
    9398    this.hour24 = hour24; 
    9499    this.minIncrement = minIncrement; 
     
    114119  public TimeDateComponents getNowTimeComponents() { 
    115120    try { 
    116       TimeDateComponents tc = new TimeDateComponents(svci, minIncrement, 
     121      TimeDateComponents tc = new TimeDateComponents(svci, calInfo, minIncrement, 
    117122                                                     hour24, 
    118123                                                     debug); 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/EventDates.java

    r2 r27  
    5555package org.bedework.webcommon; 
    5656 
     57import org.bedework.appcommon.CalendarInfo; 
    5758import org.bedework.calfacade.BwDateTime; 
    5859import org.bedework.calfacade.BwEvent; 
     
    8586  /** 
    8687   * @param svci 
     88   * @param calInfo 
    8789   * @param hour24 
    8890   * @param minIncrement 
     
    9092   * @param debug 
    9193   */ 
    92   public EventDates(CalSvcI svci, boolean hour24, int minIncrement, 
     94  public EventDates(CalSvcI svci, CalendarInfo calInfo, 
     95                    boolean hour24, int minIncrement, 
    9396                    MessageEmit err, boolean debug) { 
    94     super(svci, hour24, minIncrement, err, debug); 
     97    super(svci, calInfo, hour24, minIncrement, err, debug); 
    9598  } 
    9699 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/TimeDateComponents.java

    r2 r27  
    5555package org.bedework.webcommon; 
    5656 
     57import org.bedework.appcommon.CalendarInfo; 
    5758import org.bedework.calfacade.BwDateTime; 
    5859import org.bedework.calfacade.CalFacadeException; 
     
    9798  private static final String[] DEFAULT_AMPM_LABELS = {"am", "pm"}; 
    9899 
    99   /** default labels for the dates in a month */ 
    100   private static String[] defaultDayLabels = 
    101       new String[maximumValues(Calendar.DAY_OF_MONTH)]; 
    102   /** default internal values for the dates in a month */ 
    103   private static String[] defaultDayVals = 
    104       new String[maximumValues(Calendar.DAY_OF_MONTH)]; 
     100  /* * default labels for the dates in a month */ 
     101  //private static String[] defaultDayLabels = 
     102  //    new String[maximumValues(Calendar.DAY_OF_MONTH)]; 
     103  //** default internal values for the dates in a month */ 
     104  //private static String[] defaultDayVals = 
     105  //    new String[maximumValues(Calendar.DAY_OF_MONTH)]; 
    105106 
    106107  /** default labels for the months of the year */ 
     
    150151    Calendar cal = Calendar.getInstance(/* XXX locale?????*/); 
    151152 
     153    /* 
    152154    for (int i = 0, dateOfMonth = cal.getMinimum(Calendar.DAY_OF_MONTH); 
    153155         i < defaultDayLabels.length; i++, dateOfMonth++) { 
     
    157159      defaultDayVals[i] = twoDigit(dateOfMonth); 
    158160    } 
     161    */ 
    159162 
    160163    cal.set(Calendar.MONTH, cal.getMinimum(Calendar.MONTH)); 
     
    211214 
    212215  private CalSvcI svci; 
     216  private CalendarInfo calInfo; 
    213217 
    214218  /** Holds time and date information */ 
    215219  private Calendar cal; 
    216220 
    217   private String[] dayLabels; 
    218   private String[] dayVals; 
     221  //private String[] dayLabels; 
     222  //private String[] dayVals; 
    219223  private String[] monthLabels; 
    220224  private String[] monthVals; 
     
    256260   * 
    257261   * @param svci 
     262   * @param calInfo 
    258263   * @param minuteIncrement  increment for minutes: &le; 1 is all, 
    259264   *                        5 is every 5 minutes, etc 
     
    263268   *                        arrays 
    264269   */ 
    265   public TimeDateComponents(CalSvcI svci, int minuteIncrement, 
     270  public TimeDateComponents(CalSvcI svci, 
     271                            CalendarInfo calInfo, 
     272                            int minuteIncrement, 
    266273                            boolean hour24, 
    267274                            boolean debug) throws TimeDateException { 
     
    270277    } 
    271278    this.svci = svci; 
    272  
    273     init(defaultDayLabels, 
    274          defaultDayVals, 
    275          defaultMonthLabels, 
    276          defaultMonthVals, 
    277          hour24 ? defaultHour24Labels : defaultHourLabels, 
    278          hour24 ? defaultHour24Vals : defaultHourVals, 
    279          defaultMinuteLabels, 
    280          defaultMinuteVals, 
    281          minuteIncrement, 
    282          DEFAULT_AMPM_LABELS, 
    283          hour24, 
    284          debug); 
    285   } 
    286  
    287   /* See XXX note below before getter/setter methods if you want to 
    288      make this constructor non-private. 
    289    * / 
    290   / * * Set up instance of this class. 
    291    * 
    292    * @param dayLabels     external array of labels used for timedate 
    293    * @param dayVals       internal array of values used for timedate 
    294    * @param monthLabels   external array of labels used for timedate 
    295    * @param monthVals     internal array of values used for timedate 
    296    * @param hourLabels    external array of labels used for timedate 
    297    * @param hourVals      internal array of values used for timedate 
    298    * @param minuteLabels  external array of labels used for timedate 
    299    * @param minuteVals    internal array of values used for timedate 
    300    * @param minuteIncrement  increment for minutes, 0, 1 is all, 
    301    *                      5 is every 5  inutes etc. 
    302    * @param ampmLabels    internal array of values used for timedate 
    303    * @param hour24        true if we ignore am/pm and use 24hr clock 
    304    * @exception TimeDateException if there is a problem with one of the 
    305    *    minutes arrays 
    306    * / 
    307   private TimeDateComponents(String[] dayLabels, 
    308                              String[] dayVals, 
    309                              String[] monthLabels, 
    310                              String[] monthVals, 
    311                              String[] hourLabels, 
    312                              String[] hourVals, 
    313                              String[] minuteLabels, 
    314                              String[] minuteVals, 
    315                              int minuteIncrement, 
    316                              String[] ampmLabels, 
    317                              boolean hour24, 
    318                              boolean debug) throws TimeDateException { 
    319     init(dayLabels, 
    320          dayVals, 
    321          monthLabels, 
    322          monthVals, 
    323          hourLabels, 
    324          hourVals, 
    325          minuteLabels, 
    326          minuteVals, 
    327          minuteIncrement, 
    328          ampmLabels, 
    329          hour24, 
    330          debug); 
    331   } */ 
    332  
    333   /** Set up instance of this class 
    334    * 
    335    * @param dayLabels     external array of labels used for timedate 
    336    * @param dayVals       internal array of values used for timedate 
    337    * @param monthLabels   external array of labels used for timedate 
    338    * @param monthVals     internal array of values used for timedate 
    339    * @param hourLabels    external array of labels used for timedate 
    340    * @param hourVals      internal array of values used for timedate 
    341    * @param minuteLabels  external array of labels used for timedate 
    342    * @param minuteVals    internal array of values used for timedate 
    343    * @param minuteIncrement  increment for minutes, &le; 1 is all, 
    344    *                      5 is every 5 minutes etc. 
    345    * @param ampmLabels    internal array of values used for timedate 
    346    * @param hour24        true if we ignore am/pm and use 24hr clock 
    347    * @exception TimeDateException if there is a problem with one of the 
    348    *    minutes arrays 
    349    */ 
    350   private void init(String[] dayLabels, 
    351                     String[] dayVals, 
    352                     String[] monthLabels, 
    353                     String[] monthVals, 
    354                     String[] hourLabels, 
    355                     String[] hourVals, 
    356                     String[] minuteLabels, 
    357                     String[] minuteVals, 
    358                     int minuteIncrement, 
    359                     String[] ampmLabels, 
    360                     boolean hour24, 
    361                     boolean debug) throws TimeDateException { 
    362     this.dayLabels = dayLabels; 
    363     this.dayVals = dayVals; 
    364     this.monthLabels = monthLabels; 
    365     this.monthVals = monthVals; 
    366     this.hourLabels = hourLabels; 
    367     this.hourVals = hourVals; 
    368  
    369     setMinutes(minuteLabels, minuteVals, minuteIncrement); 
    370  
    371     this.ampmLabels = ampmLabels; 
     279    this.calInfo = calInfo; 
    372280    this.hour24 = hour24; 
    373281    //this.debug = debug; 
     282 
     283    //dayLabels = defaultDayLabels; 
     284    //dayVals = defaultDayVals; 
     285    monthLabels = defaultMonthLabels; 
     286    monthVals = defaultMonthVals; 
     287    if (hour24) { 
     288      hourLabels = defaultHour24Labels; 
     289      hourVals = defaultHour24Vals; 
     290    } else { 
     291      hourLabels = defaultHourLabels; 
     292      hourVals = defaultHourVals; 
     293    } 
     294 
     295    setMinutes(defaultMinuteLabels, defaultMinuteVals, minuteIncrement); 
     296 
     297    this.ampmLabels = DEFAULT_AMPM_LABELS; 
    374298  } 
    375299 
     
    414338 
    415339  /** 
     340   * @return CalendarInfo 
     341   */ 
     342  public CalendarInfo getCalInfo() { 
     343    return calInfo; 
     344  } 
     345 
     346  /** 
    416347   * 
    417348   */ 
     
    431362   */ 
    432363  public String[] getDayLabels() { 
    433     return this.dayLabels
     364    return getCalInfo().getDayLabels()
    434365  } 
    435366 
     
    438369   */ 
    439370  public String[] getDayVals() { 
    440     return this.dayVals
     371    return getCalInfo().getDayVals()
    441372  } 
    442373 
     
    626557  public String getDay() { 
    627558    // Calendar.DAY_OF_MONTH returns 1-31 
    628     return dayVals[getCal().get(Calendar.DAY_OF_MONTH) - 1]; 
     559    return getDayVals()[getCal().get(Calendar.DAY_OF_MONTH) - 1]; 
    629560  } 
    630561