org.gwtwidgets.client.ui.cal
Class CalendarFactory

java.lang.Object
  extended by org.gwtwidgets.client.ui.cal.CalendarFactory

public class CalendarFactory
extends java.lang.Object

A calendar engine. Allows for creation of CalendarMonth beans, provides access to events, performs caching of data, manages listeners, fires events, and provides utilities. The class is not a widget, and has no interface. If you require two calendars with seperate event lists, you should use two factory instances.

Author:
rhanson

Constructor Summary
CalendarFactory()
           
 
Method Summary
 void addCalendarListener(CalendarListener listener)
          Add a listener for calendar events.
 CalendarEvent createEvent(java.util.Date date, boolean timeSignificant)
          Creates a new event and registers it with the factory.
 CalendarEvent createEvent(java.util.Date start, java.util.Date end, boolean timeSignificant)
          Creates a new event for a specified range and registers it with the factory.
 void fireDateClick(CalendarDate date)
          Inform registered listeners that a date was clicked.
 void fireEventDateClick(CalendarDate date)
          Inform registered listeners that a event date was clicked.
 void fireMonthChange(CalendarMonth month)
          Inform registered listeners that the month was changed.
 CalendarMonth getCalendar(java.util.Date date)
          Gets, caches, and returns a CalendarMonth object for the requested month.
 CalendarMonth getCalendar(int month, int year)
          Gets, caches, and returns a CalendarMonth object for the requested month.
 java.util.List getCalendars(java.util.Date start, java.util.Date end)
          Gets, caches, and returns a list of CalendarMonth objects for the requested date range.
 CalendarMonth getCurrentCalendar()
          Gets, caches, and returns a CalendarMonth object for the current month.
 CalendarMonth getNextMonth(CalendarMonth cal)
          Get the calendar object for the following month.
 CalendarMonth getNextYear(CalendarMonth cal)
          Get the calendar object for the following year (current plus 12 months).
static int getNumberOfDays(int month, int year)
          Utility method to return the number of days in the specified month.
 CalendarMonth getPrevMonth(CalendarMonth cal)
          Get the calendar object for the previous month.
 CalendarMonth getPrevYear(CalendarMonth cal)
          Get the calendar object for the previous year (current minus 12 months).
 void removeCalendarListener(CalendarListener listener)
          Remove a calendar listener.
 void removeEvent(CalendarEvent event)
          Removes an event from the factory and all cached months.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarFactory

public CalendarFactory()
Method Detail

getCalendar

public CalendarMonth getCalendar(int month,
                                 int year)
Gets, caches, and returns a CalendarMonth object for the requested month.

Parameters:
month - 0 - 11
year - 4 digit year (e.g. 2006)
Returns:
month object

getCalendar

public CalendarMonth getCalendar(java.util.Date date)
Gets, caches, and returns a CalendarMonth object for the requested month.

Parameters:
date - date
Returns:
month object

getCurrentCalendar

public CalendarMonth getCurrentCalendar()
Gets, caches, and returns a CalendarMonth object for the current month.

Returns:
month object

getCalendars

public java.util.List getCalendars(java.util.Date start,
                                   java.util.Date end)
Gets, caches, and returns a list of CalendarMonth objects for the requested date range.

Parameters:
start - first month
end - last month
Returns:
list of month objects

getNumberOfDays

public static int getNumberOfDays(int month,
                                  int year)
Utility method to return the number of days in the specified month.

Parameters:
month - 0-11
year - 4 digit year
Returns:
number of days

getNextMonth

public CalendarMonth getNextMonth(CalendarMonth cal)
Get the calendar object for the following month.

Parameters:
cal - current month object
Returns:
calendar object for the following month

getNextYear

public CalendarMonth getNextYear(CalendarMonth cal)
Get the calendar object for the following year (current plus 12 months).

Parameters:
cal - current month object
Returns:
calendar object for the following year

getPrevMonth

public CalendarMonth getPrevMonth(CalendarMonth cal)
Get the calendar object for the previous month.

Parameters:
cal - current month object
Returns:
calendar object for the previous month

getPrevYear

public CalendarMonth getPrevYear(CalendarMonth cal)
Get the calendar object for the previous year (current minus 12 months).

Parameters:
cal - current month object
Returns:
calendar object for the previous year

createEvent

public CalendarEvent createEvent(java.util.Date date,
                                 boolean timeSignificant)
Creates a new event and registers it with the factory.

Parameters:
date - date/time of the event
timeSignificant - false for "all day" events (e.g. holiday)
Returns:
the event registered

createEvent

public CalendarEvent createEvent(java.util.Date start,
                                 java.util.Date end,
                                 boolean timeSignificant)
Creates a new event for a specified range and registers it with the factory.

Parameters:
start - start date/time of the event
end - end date/time of the event
timeSignificant - false for "all day" events (e.g. holiday)
Returns:
the event registered

removeEvent

public void removeEvent(CalendarEvent event)
Removes an event from the factory and all cached months.

Parameters:
event - event object

addCalendarListener

public void addCalendarListener(CalendarListener listener)
Add a listener for calendar events. Events are NOT triggered automatically. You must call the appropriate fire method to inform listeners.

Parameters:
listener - calendar listener

removeCalendarListener

public void removeCalendarListener(CalendarListener listener)
Remove a calendar listener.

Parameters:
listener - calendar listener

fireDateClick

public void fireDateClick(CalendarDate date)
Inform registered listeners that a date was clicked.

Parameters:
date - date object to pass to listeners

fireEventDateClick

public void fireEventDateClick(CalendarDate date)
Inform registered listeners that a event date was clicked.

Parameters:
date - date object to pass to listeners

fireMonthChange

public void fireMonthChange(CalendarMonth month)
Inform registered listeners that the month was changed.

Parameters:
month - month object to pass to listeners


Copyright © 2009. All Rights Reserved.