org.gwtwidgets.client.ui.cal
Class CalendarPanel

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.Panel
              extended by com.google.gwt.user.client.ui.HTMLTable
                  extended by com.google.gwt.user.client.ui.Grid
                      extended by org.gwtwidgets.client.temp.TGrid
                          extended by org.gwtwidgets.client.ui.cal.CalendarPanel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesTableEvents

public class CalendarPanel
extends TGrid

A simple plain calendar panel without controls.

Styles, one or more may apply to a given cell:

.calendar-panel { calendar grid }
.calendar-cell { each calendar cell }
.calendar-dateCell { cells with dates }
.calendar-today { the current date }
.calendar-eventCell { calls with events }
.calendar-headingCell { cells with weekday names }
.calendar-cellSunday { cells for Sunday }
.calendar-cellMonday { cells for Monday }
.calendar-cellTuesday { cells for Tuesday }
.calendar-cellWednesday { cells for Wednesday }
.calendar-cellThurday { cells for Thursday }
.calendar-cellFriday { cells for Friday}
.calendar-cellSatuday { cells for Saturday }

In addition, any calendar cell that has events will also include the class names attached to thise events. For example, the following adds an event to the calendar and adds the class name "holiday" to the event.

 CalendarPanel panel = new CalendarPanel();
 CalendarEvent evtObj = panel.addEvent(evtDate, false);
 evtObj.setStyleClass("holiday");
 

Author:
rhanson

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.HTMLTable
com.google.gwt.user.client.ui.HTMLTable.CellFormatter, com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter, com.google.gwt.user.client.ui.HTMLTable.RowFormatter
 
Field Summary
 int OFFSET_FRIDAY
           
 int OFFSET_MONDAY
           
 int OFFSET_SATURDAY
           
 int OFFSET_SUNDAY
           
 int OFFSET_THURSDAY
           
 int OFFSET_TUESDAY
           
 int OFFSET_WEDNESDAY
           
 
Fields inherited from class com.google.gwt.user.client.ui.Grid
numColumns, numRows
 
Constructor Summary
CalendarPanel()
          Create a new CalendarPanel for the current date.
CalendarPanel(java.util.Date date)
          Create a CalendarPanel for the specified Date.
CalendarPanel(int month, int year)
          Create a CalendarPanel for the specified month/year.
CalendarPanel(int month, int year, CalendarFactory factory)
          Create a CalendarPanel for the specified month/year, using the specified CalendarFactory.
 
Method Summary
 void addCalendarListener(CalendarListener listener)
          Add listener for calendar events.
 CalendarEvent addEvent(java.util.Date date, boolean timeSignificant)
          Add a new event to the calendar and returns an event object.
 CalendarEvent addEvent(java.util.Date start, java.util.Date end, boolean timeSignificant)
          Add a new event to the calendar that spans multiple days, and returns an event object.
 void addNextMonthActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
          Adds appropriate event handling for a next month button/link.
 void addNextYearActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
          Adds appropriate event handling for a next year button/link.
 void addPrevMonthActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
          Adds appropriate event handling for a previous month button/link.
 void addPrevYearActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
          Adds appropriate event handling for a previous year button/link.
 int getCurrentMonth()
          Get the current month number 0-11.
 java.lang.String getCurrentMonthName()
          Get the name of the current month.
 java.lang.String getCurrentYear()
          Get the current year.
 java.util.List getEvents()
           
 int getFirstDayOffset()
          Get the number of days that the calendar columns have been shifted.
protected  void onAttach()
           
 void redraw()
          Redraws the calendar.
 void removeCalendarListener(CalendarListener listener)
          Remove a listener for calendar events.
 void removeEvent(CalendarEvent event)
          Removes an event from the calendar.
 void setCalendarMonth(java.util.Date date)
          Change the calendar to a specific date
 void setCalendarMonth(int month, int year)
          Change the calendar to a specific month and year
 void setFirstDayOffset(int firstDayOffset)
          Set the number of columns to shift calendar days.
 void setMonthNames(java.lang.String[] inMonthNames)
          Set the month names to be used.
 void setWeekDayNames(java.lang.String[] inWeekDayNames)
          Set the weekday names to be used.
 
Methods inherited from class org.gwtwidgets.client.temp.TGrid
clearCell
 
Methods inherited from class com.google.gwt.user.client.ui.Grid
createCell, getCellCount, getColumnCount, getRowCount, prepareCell, prepareColumn, prepareRow, resize, resizeColumns, resizeRows
 
Methods inherited from class com.google.gwt.user.client.ui.HTMLTable
addTableListener, checkCellBounds, checkRowBounds, clear, getBodyElement, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getDOMCellCount, getDOMCellCount, getDOMRowCount, getDOMRowCount, getEventTargetCell, getHTML, getRowFormatter, getText, getWidget, insertCell, insertCells, insertRow, internalClearCell, isCellPresent, iterator, onBrowserEvent, remove, removeCell, removeRow, removeTableListener, setBorderWidth, setCellFormatter, setCellPadding, setCellSpacing, setColumnFormatter, setHTML, setRowFormatter, setText, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, adopt, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onDetach, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, 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
 

Field Detail

OFFSET_SUNDAY

public final int OFFSET_SUNDAY
See Also:
Constant Field Values

OFFSET_MONDAY

public final int OFFSET_MONDAY
See Also:
Constant Field Values

OFFSET_TUESDAY

public final int OFFSET_TUESDAY
See Also:
Constant Field Values

OFFSET_WEDNESDAY

public final int OFFSET_WEDNESDAY
See Also:
Constant Field Values

OFFSET_THURSDAY

public final int OFFSET_THURSDAY
See Also:
Constant Field Values

OFFSET_FRIDAY

public final int OFFSET_FRIDAY
See Also:
Constant Field Values

OFFSET_SATURDAY

public final int OFFSET_SATURDAY
See Also:
Constant Field Values
Constructor Detail

CalendarPanel

public CalendarPanel()
Create a new CalendarPanel for the current date.


CalendarPanel

public CalendarPanel(java.util.Date date)
Create a CalendarPanel for the specified Date.


CalendarPanel

public CalendarPanel(int month,
                     int year)
Create a CalendarPanel for the specified month/year.

Parameters:
month - 0 - 11
year - 4 digit year (e.g. 2008)

CalendarPanel

public CalendarPanel(int month,
                     int year,
                     CalendarFactory factory)
Create a CalendarPanel for the specified month/year, using the specified CalendarFactory. A shared CalendarFactory can be used to share event information across multiple CalendarPanels.

Parameters:
month - 0 - 11
year - 4 digit year (e.g. 2008)
Method Detail

setCalendarMonth

public void setCalendarMonth(int month,
                             int year)
Change the calendar to a specific month and year

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

setCalendarMonth

public void setCalendarMonth(java.util.Date date)
Change the calendar to a specific date

Parameters:
date - date object

addPrevYearActivator

public void addPrevYearActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
Adds appropriate event handling for a previous year button/link.

Parameters:
source - button or other widget that handles click events

addNextYearActivator

public void addNextYearActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
Adds appropriate event handling for a next year button/link.

Parameters:
source - button or other widget that handles click events

addPrevMonthActivator

public void addPrevMonthActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
Adds appropriate event handling for a previous month button/link.

Parameters:
source - button or other widget that handles click events

addNextMonthActivator

public void addNextMonthActivator(com.google.gwt.user.client.ui.SourcesClickEvents source)
Adds appropriate event handling for a next month button/link.

Parameters:
source - button or other widget that handles click events

redraw

public void redraw()
Redraws the calendar. In most cases this is not required, but may be required after adding events.


addEvent

public CalendarEvent addEvent(java.util.Date date,
                              boolean timeSignificant)
Add a new event to the calendar and returns an event object.

Parameters:
date - date/time of the event
timeSignificant - false for "all day" events, like a holiday
Returns:
the event created

addEvent

public CalendarEvent addEvent(java.util.Date start,
                              java.util.Date end,
                              boolean timeSignificant)
Add a new event to the calendar that spans multiple days, and returns an event object.

Parameters:
start - start date/time of the event
end - end date/time of the event
timeSignificant - false for "all day" events, like a holiday
Returns:
the event created

removeEvent

public void removeEvent(CalendarEvent event)
Removes an event from the calendar.

Parameters:
event - event to be removed

addCalendarListener

public void addCalendarListener(CalendarListener listener)
Add listener for calendar events.

Parameters:
listener -

removeCalendarListener

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

Parameters:
listener -

getCurrentMonth

public int getCurrentMonth()
Get the current month number 0-11.

Returns:
month number 0-11

getCurrentMonthName

public java.lang.String getCurrentMonthName()
Get the name of the current month. A default set of names uses full English names (January, February, etc.). The list of available names may be changed using the setMonthNames(String[]) method.

Returns:
month name

getCurrentYear

public java.lang.String getCurrentYear()
Get the current year.

Returns:
current year

setMonthNames

public void setMonthNames(java.lang.String[] inMonthNames)
Set the month names to be used. You must pass an array of 12 names or a RuntimeException will be thrown.

Parameters:
inMonthNames - array of 12 month names

setWeekDayNames

public void setWeekDayNames(java.lang.String[] inWeekDayNames)
Set the weekday names to be used. These names appear in the first row of the calendar. The default values are S, M, T, W, T, F, S. You must pass an array of 7 names, otherwise a RuntimeException will be thrown.

Parameters:
inWeekDayNames - array of names

getFirstDayOffset

public int getFirstDayOffset()
Get the number of days that the calendar columns have been shifted. A result of 0 means that Sunday is the first column, 1 for Monday, 2 for Tuesday, etc. You may also use the constants for these offsets for comparison.

Returns:
offset

setFirstDayOffset

public void setFirstDayOffset(int firstDayOffset)
Set the number of columns to shift calendar days. Use this to change what the first day of the week is. Valid values are 0-6. Values outside of this range will throw a RuntimeException. The following will make Monday the first day of the week, causing the calendar headings to read M, T, W, T, F, S, S. cal.setFirstDayOffset(CalendarPanel.OFFSET_MONDAY);

Parameters:
firstDayOffset - offset in days

onAttach

protected void onAttach()
Overrides:
onAttach in class com.google.gwt.user.client.ui.Widget

getEvents

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


Copyright © 2009. All Rights Reserved.