cc.gammasoft.date
Class CalendarController

java.lang.Object
  |
  +--cc.gammasoft.date.CalendarController

public class CalendarController
extends java.lang.Object
implements java.awt.event.ActionListener


Field Summary
protected  java.text.SimpleDateFormat dateFormat
           
protected  javax.swing.event.EventListenerList listenerList
           
protected  java.text.DateFormatSymbols symbols
           
protected static java.util.Calendar today
           
 
Constructor Summary
CalendarController(java.text.SimpleDateFormat dateFormat)
           
 
Method Summary
 void actionMonth(int month, java.awt.event.ActionEvent e)
          This method sets current date month
 void actionNextMonth(java.awt.event.ActionEvent e)
          button next month performed
 void actionNextYear(java.awt.event.ActionEvent e)
          button next year performed
 void actionPerformed(java.awt.event.ActionEvent e)
          action performed method
 void actionPreviousMonth(java.awt.event.ActionEvent e)
          button previous month performed
 void actionPreviousYear(java.awt.event.ActionEvent e)
          button previous year performed
 void actionYear(java.lang.String year, java.awt.event.ActionEvent e)
          This method sets current date year
 void addCalendarControllerListener(CalendarControllerListener l)
          This method adds event listeners
 void fireDayChangedEvent(java.awt.event.ActionEvent e)
          This method fires month Changed event
 void fireMonthChangedEvent(java.awt.event.ActionEvent e)
          This method fires month Changed event
 void fireYearChangedEvent(java.awt.event.ActionEvent e)
          This method fires year Changed event
 java.lang.String formatCalendar(java.util.Calendar calendar)
          This method returns formatted String version of calendar object.
 java.lang.String formatCurrentDate()
          This method returns formatted version of controller's current date
static java.util.Calendar formatSQLDate(java.lang.String YMD)
          This method formats sqlDate
 java.lang.String formatToday()
          This method returns formatted version of today's date
 java.util.Calendar getCurrentDate()
          returns controller's current date
 java.text.SimpleDateFormat getDateFormat()
          This method returns Date formatter
 java.text.DateFormatSymbols getDateFormatSymbols()
          returns DateFormatSymbols
 java.lang.String getSQLDate()
          Formats a date in JDBC date escape format.
static java.lang.String getSQLDate(java.util.Calendar calendar)
          Formats a date in JDBC date escape format.
 java.lang.String getSQLTime()
          Formats a date in JDBC time escape format.
static java.lang.String getSQLTime(java.util.Calendar calendar)
          Formats a date in JDBC time escape format.
 java.lang.String getSQLTimestamp()
          Formats a date in JDBC timestamp escape format.
static java.lang.String getSQLTimestamp(java.util.Calendar calendar)
          Formats a date in JDBC timesttamp escape format.
 java.util.Calendar getToday()
          This method returns formatted version of today's date
protected  void notifyListenersControllerChanged(CalendarControllerEvent viewerEvent)
          This method notifies listeners
 void removeCalendarControllerListener(CalendarControllerListener l)
          This method adds event listeners
 void setCurrentDate(java.util.Calendar currentDate)
          This method sets currentDate
 void setCurrentDate(java.lang.String YMD)
          This method sets currentDate from SQL Date
 void setDateFormat(java.text.SimpleDateFormat dateFormat)
          This method returns Date formatter
 java.lang.String toString()
          Formats a date in JDBC date escape format.
 void viewChanged(java.util.Calendar calendar)
          This is get called inside the view when date changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList

today

protected static final java.util.Calendar today

dateFormat

protected java.text.SimpleDateFormat dateFormat

symbols

protected java.text.DateFormatSymbols symbols
Constructor Detail

CalendarController

public CalendarController(java.text.SimpleDateFormat dateFormat)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
action performed method
Specified by:
actionPerformed in interface java.awt.event.ActionListener

actionYear

public void actionYear(java.lang.String year,
                       java.awt.event.ActionEvent e)
This method sets current date year
Parameters:
String - year

actionMonth

public void actionMonth(int month,
                        java.awt.event.ActionEvent e)
This method sets current date month
Parameters:
int - month

actionPreviousYear

public void actionPreviousYear(java.awt.event.ActionEvent e)
button previous year performed

actionNextYear

public void actionNextYear(java.awt.event.ActionEvent e)
button next year performed

actionNextMonth

public void actionNextMonth(java.awt.event.ActionEvent e)
button next month performed

actionPreviousMonth

public void actionPreviousMonth(java.awt.event.ActionEvent e)
button previous month performed

fireYearChangedEvent

public void fireYearChangedEvent(java.awt.event.ActionEvent e)
This method fires year Changed event

fireMonthChangedEvent

public void fireMonthChangedEvent(java.awt.event.ActionEvent e)
This method fires month Changed event

fireDayChangedEvent

public void fireDayChangedEvent(java.awt.event.ActionEvent e)
This method fires month Changed event

notifyListenersControllerChanged

protected void notifyListenersControllerChanged(CalendarControllerEvent viewerEvent)
This method notifies listeners

addCalendarControllerListener

public void addCalendarControllerListener(CalendarControllerListener l)
This method adds event listeners
Parameters:
CalendarViewerListener -  

removeCalendarControllerListener

public void removeCalendarControllerListener(CalendarControllerListener l)
This method adds event listeners
Parameters:
CalendarViewerListener -  

formatCalendar

public java.lang.String formatCalendar(java.util.Calendar calendar)
This method returns formatted String version of calendar object.
Returns:
String format

getDateFormat

public java.text.SimpleDateFormat getDateFormat()
This method returns Date formatter
Returns:
DateFormat formatter

setDateFormat

public void setDateFormat(java.text.SimpleDateFormat dateFormat)
This method returns Date formatter
Returns:
DateFormat formatter

formatToday

public java.lang.String formatToday()
This method returns formatted version of today's date
Returns:
String today's date

formatCurrentDate

public java.lang.String formatCurrentDate()
This method returns formatted version of controller's current date
Returns:
String currentDate

getToday

public java.util.Calendar getToday()
This method returns formatted version of today's date
Returns:
String today's date

getCurrentDate

public java.util.Calendar getCurrentDate()
returns controller's current date
Returns:
Calendar currentDate

setCurrentDate

public void setCurrentDate(java.util.Calendar currentDate)
This method sets currentDate

setCurrentDate

public void setCurrentDate(java.lang.String YMD)
This method sets currentDate from SQL Date

formatSQLDate

public static java.util.Calendar formatSQLDate(java.lang.String YMD)
This method formats sqlDate
Returns:
Calendar calendar

viewChanged

public void viewChanged(java.util.Calendar calendar)
This is get called inside the view when date changed. In MonthView view, when the user clicks on a grid cell. In Tab view when the user clicks on tab component. and so on. Each view should call this method when date changed event occurs.

getSQLDate

public java.lang.String getSQLDate()
Formats a date in JDBC date escape format.
Returns:
a String in yyyy-mm-dd format

getSQLDate

public static java.lang.String getSQLDate(java.util.Calendar calendar)
Formats a date in JDBC date escape format.
Parameters:
Calendar - calendar
Returns:
a String in yyyy-mm-dd format

getSQLTime

public java.lang.String getSQLTime()
Formats a date in JDBC time escape format.
Returns:
a String in time format

getSQLTime

public static java.lang.String getSQLTime(java.util.Calendar calendar)
Formats a date in JDBC time escape format.
Parameters:
Calendar - calendar
Returns:
a String in Time format

getSQLTimestamp

public java.lang.String getSQLTimestamp()
Formats a date in JDBC timestamp escape format.
Returns:
a String in timestamp format

getSQLTimestamp

public static java.lang.String getSQLTimestamp(java.util.Calendar calendar)
Formats a date in JDBC timesttamp escape format.
Parameters:
Calendar - calendar
Returns:
a String in Timestamp format

getDateFormatSymbols

public java.text.DateFormatSymbols getDateFormatSymbols()
returns DateFormatSymbols
Returns:
DateFormatSymbols symbols

toString

public java.lang.String toString()
Formats a date in JDBC date escape format.
Returns:
a String in yyyy-mm-dd format
Overrides:
toString in class java.lang.Object