org.gwtwidgets.client.ui.cal
Class SimpleCalendar

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by org.gwtwidgets.client.ui.cal.SimpleCalendar
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.SourcesClickEvents

public class SimpleCalendar
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.user.client.ui.SourcesClickEvents

Renders a simple calendar with (or optionally) without) controls to change the month and year of the calendar displayed. Allows events to be added to the calender, and a ClickListener may be added in order to receve notification when a date cell is clicked.

SimpleCalendar ships with three sample CSS stylesheets that can be injected or linked in the HTML file. The following stylesheets are available.

<stylesheet src="style/gwl-simplecalendar-blue.css" />
<stylesheet src="style/gwl-simplecalendar-green.css" />
<stylesheet src="style/gwl-simplecalendar-orange.css" />

Style information

.gwl-simpleCalendar { the root container }
.gwl-calControls { the controls container }
.gwl-calNavControl { each of the 4 control links }
.gwl-calDateDisplay { displayed date }

See CalendarPanel for a list of styles that apply to the calendar grid.

NOTE: If you are using the supplied CSS files in conjunction with CalendarEvent objects that have CSS class names, you may encounder rending issues. For example, an event with the class name of "holiday" may not render as expected when you use the CSS selector, e.g. ".holiday". To work around this, include the parent class selector for the SimpleCalendar as well, e.g. ".gwl-simpleCalendar .holiday".

Author:
rhanson

Constructor Summary
SimpleCalendar()
          Render a SimpleCalendar for the current month.
SimpleCalendar(java.util.Date date, boolean showControls)
          Render a SimpleCalendar for the month specified Date.
SimpleCalendar(int month, int year, boolean showControls)
          Render a SimpleCalendar for the month specified month/year.
SimpleCalendar(int month, int year, boolean showControls, CalendarFactory factory)
          Render a SimpleCalendar for the month specified month/year.
 
Method Summary
 void addClickListener(com.google.gwt.user.client.ui.ClickListener listener)
          Add a ClickListener that will receive events when a user clicks on a day cell.
 CalendarEvent addEvent(java.util.Date date, boolean timeSignificant)
           
 CalendarEvent addEvent(java.util.Date start, java.util.Date end, boolean timeSignificant)
           
 int getCurrentMonth()
           
 java.lang.String getCurrentMonthName()
           
 java.lang.String getCurrentYear()
           
 CalendarDate getDateSelected()
          Returns the CalendarDate object for the last date cell that was clicked.
 java.util.List getEvents()
           
 void redraw()
           
 void removeClickListener(com.google.gwt.user.client.ui.ClickListener listener)
           
 void setCalendarMonth(java.util.Date date)
           
 void setCalendarMonth(int month, int year)
           
 void setMonthNames(java.lang.String[] inMonthNames)
           
 void setWeekDayNames(java.lang.String[] inWeekDayNames)
           
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
getElement, getWidget, initWidget, isAttached, onAttach, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, onBrowserEvent, onLoad, onUnload, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleCalendar

public SimpleCalendar()
Render a SimpleCalendar for the current month.


SimpleCalendar

public SimpleCalendar(java.util.Date date,
                      boolean showControls)
Render a SimpleCalendar for the month specified Date.

Parameters:
date -
showControls - pass false to hide next/prev controls

SimpleCalendar

public SimpleCalendar(int month,
                      int year,
                      boolean showControls)
Render a SimpleCalendar for the month specified month/year.

Parameters:
month - 0-11
year - e.g. 2008
showControls - pass false to hide next/prev controls

SimpleCalendar

public SimpleCalendar(int month,
                      int year,
                      boolean showControls,
                      CalendarFactory factory)
Render a SimpleCalendar for the month specified month/year.

Parameters:
month - 0-11
year - e.g. 2008
showControls - pass false to hide next/prev controls
factory - the CalendarFactory to use for tracking events
Method Detail

addClickListener

public void addClickListener(com.google.gwt.user.client.ui.ClickListener listener)
Add a ClickListener that will receive events when a user clicks on a day cell.

For example: the following code adds a listener that will popup a message with the date that was clicked.

 SimpleCalendar cal = new SimpleCalendar();
 cal.addClickListener(new ClickListener() {
    public void onClick (Widget sender) {
       CalendarDate date = ((SimpleCalendar) sender).getDateSelected();
       Window.alert(date.toString());
    }
 });
 

Specified by:
addClickListener in interface com.google.gwt.user.client.ui.SourcesClickEvents

removeClickListener

public void removeClickListener(com.google.gwt.user.client.ui.ClickListener listener)
Specified by:
removeClickListener in interface com.google.gwt.user.client.ui.SourcesClickEvents

getDateSelected

public CalendarDate getDateSelected()
Returns the CalendarDate object for the last date cell that was clicked.

Returns:
last CalendarDate clicked or null

addEvent

public CalendarEvent addEvent(java.util.Date date,
                              boolean timeSignificant)
Parameters:
date -
timeSignificant -
Returns:
See Also:
CalendarPanel.addEvent(java.util.Date, boolean)

addEvent

public CalendarEvent addEvent(java.util.Date start,
                              java.util.Date end,
                              boolean timeSignificant)
Parameters:
start -
end -
timeSignificant -
Returns:
See Also:
CalendarPanel.addEvent(java.util.Date, java.util.Date, boolean)

getCurrentMonth

public int getCurrentMonth()
Returns:
See Also:
CalendarPanel.getCurrentMonth()

getCurrentMonthName

public java.lang.String getCurrentMonthName()
Returns:
See Also:
CalendarPanel.getCurrentMonthName()

getCurrentYear

public java.lang.String getCurrentYear()
Returns:
See Also:
CalendarPanel.getCurrentYear()

setCalendarMonth

public void setCalendarMonth(java.util.Date date)
Parameters:
date -
See Also:
CalendarPanel.setCalendarMonth(java.util.Date)

setCalendarMonth

public void setCalendarMonth(int month,
                             int year)
Parameters:
month -
year -
See Also:
CalendarPanel.setCalendarMonth(int, int)

setMonthNames

public void setMonthNames(java.lang.String[] inMonthNames)
Parameters:
inMonthNames -
See Also:
CalendarPanel.setMonthNames(java.lang.String[])

setWeekDayNames

public void setWeekDayNames(java.lang.String[] inWeekDayNames)
Parameters:
inWeekDayNames -
See Also:
CalendarPanel.setWeekDayNames(java.lang.String[])

redraw

public void redraw()
See Also:
CalendarPanel.redraw()

getEvents

public java.util.List getEvents()
Returns:
See Also:
CalendarPanel.getEvents()


Copyright © 2009. All Rights Reserved.