Package com.vaadin.v7.client.ui
Class VCalendar
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Composite
-
- com.vaadin.v7.client.ui.VCalendar
-
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.IsRenderable,com.google.gwt.user.client.ui.IsWidget,VHasDropHandler
public class VCalendar extends com.google.gwt.user.client.ui.Composite implements VHasDropHandler
Client side implementation for Calendar.- Since:
- 7.1
- Author:
- Vaadin Ltd.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceVCalendar.BackwardListenerListener interface for listening to backward events.static interfaceVCalendar.DateClickListenerListener interface for listening to event click events.static interfaceVCalendar.EventClickListenerListener interface for listening to click events.static interfaceVCalendar.EventMovedListenerListener interface for listening to event moved events.static interfaceVCalendar.EventResizeListenerListener interface for when an event gets resized (its start or end date changes).static interfaceVCalendar.ForwardListenerListener interface for listening to forward events.static interfaceVCalendar.MouseEventListenerListener interface for listening to mouse events.static interfaceVCalendar.RangeSelectListenerListener interface for listening to selection events.static interfaceVCalendar.ScrollListenerListener interface for listening to scroll events.static interfaceVCalendar.WeekClickListenerListener interface for listening to week number click events.
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_FIRSTDAYOFWEEKstatic StringATTR_FIRSTHOUROFDAYstatic StringATTR_LASTDAYOFWEEKstatic StringATTR_LASTHOUROFDAYprotected com.google.gwt.i18n.client.DateTimeFormatdateformat_dateprotected com.google.gwt.i18n.client.DateTimeFormatdateformat_datetimeprotected com.google.gwt.i18n.client.DateTimeFormattime12format_dateprotected com.google.gwt.i18n.client.DateTimeFormattime24format_date
-
Constructor Summary
Constructors Constructor Description VCalendar()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleanareDatesEqualToSecond(Date date1, Date date2)Are the dates equal (uses second resolution).static int[]distributeSize(int totalSize, int numberOfCells, int sizeModifier)Calculates correct size for all cells (size / amount of cells ) and distributes any overflow over all the cells.VCalendar.BackwardListenergetBackwardListener()Set the listener which listens to backward events from the calendar.VCalendar.DateClickListenergetDateClickListener()Gets the listener for listening to event clicks.com.google.gwt.i18n.client.DateTimeFormatgetDateFormat()Get the date format used to format dates only (excludes time).com.google.gwt.i18n.client.DateTimeFormatgetDateTimeFormat()Get the date and time format to format the dates (includes both date and time).String[]getDayNames()Get the names of the week days.CalendarDropHandlergetDropHandler()VCalendar.EventClickListenergetEventClickListener()Get the listener that listens to the user clicking on the events.static Comparator<CalendarEvent>getEventComparator()Deprecated.this returns just one default comparator, but there are number of comparators that are used to sort events depending on order.VCalendar.EventMovedListenergetEventMovedListener()Get the listener that listens to when event is dragged to a new location.VCalendar.EventResizeListenergetEventResizeListener()Get the listener that listens to when an events time limits are being adjusted.intgetFirstDayNumber()Get the number when a week starts.intgetFirstHourOfTheDay()Get the first hour of the day.VCalendar.ForwardListenergetForwardListener()Get the listener which listens to forward events from the calendar.intgetLastDayNumber()Get the number when a week ends.intgetLastHourOfTheDay()Get the last hour of the day.MonthGridgetMonthGrid()Get the month grid component.String[]getMonthNames()Get the month names.VCalendar.MouseEventListenergetMouseEventListener()Get the listener that listen to mouse events.VCalendar.RangeSelectListenergetRangeSelectListener()Get the listener that listens to the user highlighting a region in the calendar.VCalendar.ScrollListenergetScrollListener()Get the listener that listens to when the calendar widget is scrolled.CalendarState.EventSortOrdergetSortOrder()Return currently active sort order.com.google.gwt.i18n.client.DateTimeFormatgetTimeFormat()Get the time format used to format time only (excludes date).VCalendar.WeekClickListenergetWeekClickListener()Get the listener that listens to user clicking on the week numbers.WeekGridgetWeekGrid()Get he week grid component.booleanis24HFormat()Is the 24h time format used.booleanisBackwardNavigationEnabled()booleanisDisabled()Is the component disabled.booleanisDisabledOrReadOnly()Is the calendar either disabled or readonly.booleanisEventCaptionAsHtml()Checks whether event captions are rendered as HTMLbooleanisEventMoveAllowed()Is moving an event allowed.booleanisEventResizeAllowed()Is resizing an event allowed.booleanisForwardNavigationEnabled()static booleanisMidnight(Date date)Is the date at midnight.booleanisRangeMoveAllowed()Is moving a range allowed.booleanisRangeSelectAllowed()Is selecting a range allowed?booleanisReadOnly()Is the component read-only.static booleanisZeroLengthMidnightEvent(CalendarEvent event)Is the calendar event zero seconds long and is occurring at midnight.protected voidrecalculateHeights()Recalculates the heights of the sub-components in the calendar.protected voidrecalculateWidths()Recalculates the widths of the sub-components in the calendar.voidremoveMonthEvent(CalendarEvent target, boolean repaintImmediately)Remove a month event from the view.voidset24HFormat(boolean format)Should the 24h time format be used.voidsetBackwardNavigationEnabled(boolean enabled)voidsetDayNames(String[] names)Set the names of the week days.voidsetDisabled(boolean disabled)Is the component disabled.voidsetDropHandler(CalendarDropHandler dropHandler)Set the drop handler.voidsetEventCaptionAsHtml(boolean eventCaptionAsHtml)Sets whether the event captions are rendered as HTML.voidsetEventMoveAllowed(boolean eventMoveAllowed)Is moving an event allowed.voidsetEventResizeAllowed(boolean eventResizeAllowed)Is resizing an event allowed.voidsetFirstDayNumber(int dayNumber)Set the number when a week starts.voidsetFirstHourOfTheDay(int hour)Set the first hour of the day.voidsetForwardNavigationEnabled(boolean enabled)voidsetLastDayNumber(int dayNumber)Set the number when a week ends.voidsetLastHourOfTheDay(int hour)Set the last hour of the day.voidsetListener(VCalendar.BackwardListener listener)Set the listener which listens to backward events from the calendar.voidsetListener(VCalendar.DateClickListener listener)Sets the listener for listening to event clicks.voidsetListener(VCalendar.EventClickListener listener)Set the listener that listens to the user clicking on the events.voidsetListener(VCalendar.EventMovedListener eventMovedListener)Set the listener that listens to when event is dragged to a new location.voidsetListener(VCalendar.EventResizeListener eventResizeListener)Set the listener that listens to when an events time limits are being adjusted.voidsetListener(VCalendar.ForwardListener listener)Set the listener which listens to forward events from the calendar.voidsetListener(VCalendar.MouseEventListener mouseEventListener)Set the listener that listen to mouse events.voidsetListener(VCalendar.RangeSelectListener listener)Set the listener that listens to the user highlighting a region in the calendar.voidsetListener(VCalendar.ScrollListener scrollListener)Set the listener that listens to when the calendar widget is scrolled.voidsetListener(VCalendar.WeekClickListener listener)Set the listener that listens to user clicking on the week numbers.voidsetMonthNames(String[] names)Set the names of the months.voidsetRangeMoveAllowed(boolean rangeMoveAllowed)Is moving a range allowed.voidsetRangeSelectAllowed(boolean rangeSelectAllowed)Set selecting a range allowed.voidsetReadOnly(boolean readOnly)Is the component read-only.voidsetSizeForChildren(int newWidth, int newHeight)voidsetSortOrder(CalendarState.EventSortOrder order)Set sort strategy for events.CalendarEvent[]sortEvents(Collection<CalendarEvent> events)Sort the events by current sort order.CalendarEvent[]sortEventsByDuration(Collection<CalendarEvent> events)Deprecated.usesortEvents(Collection)method which shorts events by current sort order.voidupdateEventsToMonthGrid(Collection<CalendarEvent> events, boolean drawImmediately)Adds events to the month grid.voidupdateEventToMonthGrid(CalendarEvent changedEvent)Updates an event in the month grid.voidupdateMonthGrid(int daysCount, List<CalendarDay> days, Date today)Updates the events in the Month view.voidupdateMonthView(int firstDayOfWeek, Date today, int daysInMonth, Collection<CalendarEvent> events, List<CalendarDay> days)Re-renders the whole month view.voidupdateWeekGrid(int daysCount, List<CalendarDay> days, Date today, String[] realDayNames)Re-render the week grid.voidupdateWeekView(int scroll, Date today, int daysInMonth, int firstDayOfWeek, Collection<CalendarEvent> events, List<CalendarDay> days)Re-renders the whole week view.-
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
-
-
-
-
Field Detail
-
ATTR_FIRSTDAYOFWEEK
public static final String ATTR_FIRSTDAYOFWEEK
- See Also:
- Constant Field Values
-
ATTR_LASTDAYOFWEEK
public static final String ATTR_LASTDAYOFWEEK
- See Also:
- Constant Field Values
-
ATTR_FIRSTHOUROFDAY
public static final String ATTR_FIRSTHOUROFDAY
- See Also:
- Constant Field Values
-
ATTR_LASTHOUROFDAY
public static final String ATTR_LASTHOUROFDAY
- See Also:
- Constant Field Values
-
dateformat_datetime
protected final com.google.gwt.i18n.client.DateTimeFormat dateformat_datetime
-
dateformat_date
protected final com.google.gwt.i18n.client.DateTimeFormat dateformat_date
-
time12format_date
protected final com.google.gwt.i18n.client.DateTimeFormat time12format_date
-
time24format_date
protected final com.google.gwt.i18n.client.DateTimeFormat time24format_date
-
-
Method Detail
-
updateEventsToMonthGrid
public void updateEventsToMonthGrid(Collection<CalendarEvent> events, boolean drawImmediately)
Adds events to the month grid.- Parameters:
events- The events to adddrawImmediately- Should the grid be rendered immediately. (currently not in use)
-
removeMonthEvent
public void removeMonthEvent(CalendarEvent target, boolean repaintImmediately)
Remove a month event from the view.- Parameters:
target- The event to removerepaintImmediately- Should we repaint after the event was removed?
-
updateEventToMonthGrid
public void updateEventToMonthGrid(CalendarEvent changedEvent)
Updates an event in the month grid.- Parameters:
changedEvent- The event that has changed
-
sortEvents
public CalendarEvent[] sortEvents(Collection<CalendarEvent> events)
Sort the events by current sort order.- Parameters:
events- The events to sort- Returns:
- An array where the events has been sorted
-
sortEventsByDuration
@Deprecated public CalendarEvent[] sortEventsByDuration(Collection<CalendarEvent> events)
Deprecated.usesortEvents(Collection)method which shorts events by current sort order.Sort the event by how long they are.- Parameters:
events- The events to sort- Returns:
- An array where the events has been sorted
-
updateWeekGrid
public void updateWeekGrid(int daysCount, List<CalendarDay> days, Date today, String[] realDayNames)Re-render the week grid.- Parameters:
daysCount- The amount of days to include in the weekdays- The daystoday- Todays daterealDayNames- The names of the dates
-
updateMonthGrid
public void updateMonthGrid(int daysCount, List<CalendarDay> days, Date today)Updates the events in the Month view.- Parameters:
daysCount- How many days there aredaysUidl-today- Todays date
-
setSizeForChildren
public void setSizeForChildren(int newWidth, int newHeight)
-
recalculateHeights
protected void recalculateHeights()
Recalculates the heights of the sub-components in the calendar.
-
recalculateWidths
protected void recalculateWidths()
Recalculates the widths of the sub-components in the calendar.
-
getDateFormat
public com.google.gwt.i18n.client.DateTimeFormat getDateFormat()
Get the date format used to format dates only (excludes time).- Returns:
-
getTimeFormat
public com.google.gwt.i18n.client.DateTimeFormat getTimeFormat()
Get the time format used to format time only (excludes date).- Returns:
-
getDateTimeFormat
public com.google.gwt.i18n.client.DateTimeFormat getDateTimeFormat()
Get the date and time format to format the dates (includes both date and time).- Returns:
-
isDisabledOrReadOnly
public boolean isDisabledOrReadOnly()
Is the calendar either disabled or readonly.- Returns:
-
isDisabled
public boolean isDisabled()
Is the component disabled.
-
setDisabled
public void setDisabled(boolean disabled)
Is the component disabled.- Parameters:
disabled- True if disabled
-
isReadOnly
public boolean isReadOnly()
Is the component read-only.
-
setReadOnly
public void setReadOnly(boolean readOnly)
Is the component read-only.- Parameters:
readOnly- True if component is readonly
-
getMonthGrid
public MonthGrid getMonthGrid()
Get the month grid component.- Returns:
-
getWeekGrid
public WeekGrid getWeekGrid()
Get he week grid component.- Returns:
-
distributeSize
public static int[] distributeSize(int totalSize, int numberOfCells, int sizeModifier)Calculates correct size for all cells (size / amount of cells ) and distributes any overflow over all the cells.- Parameters:
totalSize- the total amount of size reserved for all cellsnumberOfCells- the number of cellssizeModifier- a modifier which is applied to all cells before distributing the overflow- Returns:
- an integer array that contains the correct size for each cell
-
getEventComparator
@Deprecated public static Comparator<CalendarEvent> getEventComparator()
Deprecated.this returns just one default comparator, but there are number of comparators that are used to sort events depending on order.Returns the default comparator which can compare calendar events by duration.- Returns:
-
isMidnight
public static boolean isMidnight(Date date)
Is the date at midnight.- Parameters:
date- The date to check- Returns:
-
areDatesEqualToSecond
public static boolean areDatesEqualToSecond(Date date1, Date date2)
Are the dates equal (uses second resolution).- Parameters:
date1- The first the to comparedate2- The second date to compare- Returns:
-
isZeroLengthMidnightEvent
public static boolean isZeroLengthMidnightEvent(CalendarEvent event)
Is the calendar event zero seconds long and is occurring at midnight.- Parameters:
event- The event to check- Returns:
-
set24HFormat
public void set24HFormat(boolean format)
Should the 24h time format be used.- Parameters:
format- True if the 24h format should be used else the 12h format is used
-
is24HFormat
public boolean is24HFormat()
Is the 24h time format used.
-
setDayNames
public void setDayNames(String[] names)
Set the names of the week days.- Parameters:
names- The names of the days (Monday, Thursday,...)
-
getDayNames
public String[] getDayNames()
Get the names of the week days.
-
setMonthNames
public void setMonthNames(String[] names)
Set the names of the months.- Parameters:
names- The names of the months (January, February,...)
-
getMonthNames
public String[] getMonthNames()
Get the month names.
-
setFirstDayNumber
public void setFirstDayNumber(int dayNumber)
Set the number when a week starts.- Parameters:
dayNumber- The number of the day
-
getFirstDayNumber
public int getFirstDayNumber()
Get the number when a week starts.
-
setLastDayNumber
public void setLastDayNumber(int dayNumber)
Set the number when a week ends.- Parameters:
dayNumber- The number of the day
-
getLastDayNumber
public int getLastDayNumber()
Get the number when a week ends.
-
setFirstHourOfTheDay
public void setFirstHourOfTheDay(int hour)
Set the first hour of the day.- Parameters:
hour- The first hour of the day
-
getFirstHourOfTheDay
public int getFirstHourOfTheDay()
Get the first hour of the day.- Returns:
- The first hour of the day
-
setLastHourOfTheDay
public void setLastHourOfTheDay(int hour)
Set the last hour of the day.- Parameters:
hour- The last hour of the day
-
getLastHourOfTheDay
public int getLastHourOfTheDay()
Get the last hour of the day.- Returns:
- The last hour of the day
-
updateWeekView
public void updateWeekView(int scroll, Date today, int daysInMonth, int firstDayOfWeek, Collection<CalendarEvent> events, List<CalendarDay> days)Re-renders the whole week view.- Parameters:
scroll- The amount of pixels to scroll the week viewtoday- Todays datedaysInMonth- How many days are there in the monthfirstDayOfWeek- The first day of the weekevents- The events to render
-
updateMonthView
public void updateMonthView(int firstDayOfWeek, Date today, int daysInMonth, Collection<CalendarEvent> events, List<CalendarDay> days)Re-renders the whole month view.- Parameters:
firstDayOfWeek- The first day of the weektoday- Todays datedaysInMonth- Amount of days in the monthevents- The events to renderdays- The day information
-
setListener
public void setListener(VCalendar.DateClickListener listener)
Sets the listener for listening to event clicks.- Parameters:
listener- The listener to use
-
getDateClickListener
public VCalendar.DateClickListener getDateClickListener()
Gets the listener for listening to event clicks.- Returns:
-
setListener
public void setListener(VCalendar.ForwardListener listener)
Set the listener which listens to forward events from the calendar.- Parameters:
listener- The listener to use
-
getForwardListener
public VCalendar.ForwardListener getForwardListener()
Get the listener which listens to forward events from the calendar.- Returns:
-
setListener
public void setListener(VCalendar.BackwardListener listener)
Set the listener which listens to backward events from the calendar.- Parameters:
listener- The listener to use
-
getBackwardListener
public VCalendar.BackwardListener getBackwardListener()
Set the listener which listens to backward events from the calendar.- Returns:
-
setListener
public void setListener(VCalendar.WeekClickListener listener)
Set the listener that listens to user clicking on the week numbers.- Parameters:
listener- The listener to use
-
getWeekClickListener
public VCalendar.WeekClickListener getWeekClickListener()
Get the listener that listens to user clicking on the week numbers.- Returns:
-
setListener
public void setListener(VCalendar.RangeSelectListener listener)
Set the listener that listens to the user highlighting a region in the calendar.- Parameters:
listener- The listener to use
-
getRangeSelectListener
public VCalendar.RangeSelectListener getRangeSelectListener()
Get the listener that listens to the user highlighting a region in the calendar.- Returns:
-
getEventClickListener
public VCalendar.EventClickListener getEventClickListener()
Get the listener that listens to the user clicking on the events.
-
setListener
public void setListener(VCalendar.EventClickListener listener)
Set the listener that listens to the user clicking on the events.- Parameters:
listener- The listener to use
-
getEventMovedListener
public VCalendar.EventMovedListener getEventMovedListener()
Get the listener that listens to when event is dragged to a new location.- Returns:
-
setListener
public void setListener(VCalendar.EventMovedListener eventMovedListener)
Set the listener that listens to when event is dragged to a new location.- Parameters:
eventMovedListener- The listener to use
-
getScrollListener
public VCalendar.ScrollListener getScrollListener()
Get the listener that listens to when the calendar widget is scrolled.- Returns:
-
setListener
public void setListener(VCalendar.ScrollListener scrollListener)
Set the listener that listens to when the calendar widget is scrolled.- Parameters:
scrollListener- The listener to use
-
getEventResizeListener
public VCalendar.EventResizeListener getEventResizeListener()
Get the listener that listens to when an events time limits are being adjusted.- Returns:
-
setListener
public void setListener(VCalendar.EventResizeListener eventResizeListener)
Set the listener that listens to when an events time limits are being adjusted.- Parameters:
eventResizeListener- The listener to use
-
getMouseEventListener
public VCalendar.MouseEventListener getMouseEventListener()
Get the listener that listen to mouse events.- Returns:
-
setListener
public void setListener(VCalendar.MouseEventListener mouseEventListener)
Set the listener that listen to mouse events.- Parameters:
mouseEventListener- The listener to use
-
isRangeSelectAllowed
public boolean isRangeSelectAllowed()
Is selecting a range allowed?
-
setRangeSelectAllowed
public void setRangeSelectAllowed(boolean rangeSelectAllowed)
Set selecting a range allowed.- Parameters:
rangeSelectAllowed- Should selecting a range be allowed
-
isRangeMoveAllowed
public boolean isRangeMoveAllowed()
Is moving a range allowed.- Returns:
-
setRangeMoveAllowed
public void setRangeMoveAllowed(boolean rangeMoveAllowed)
Is moving a range allowed.- Parameters:
rangeMoveAllowed- Is it allowed
-
isEventResizeAllowed
public boolean isEventResizeAllowed()
Is resizing an event allowed.
-
setEventResizeAllowed
public void setEventResizeAllowed(boolean eventResizeAllowed)
Is resizing an event allowed.- Parameters:
eventResizeAllowed- True if allowed false if not
-
isEventMoveAllowed
public boolean isEventMoveAllowed()
Is moving an event allowed.
-
setEventMoveAllowed
public void setEventMoveAllowed(boolean eventMoveAllowed)
Is moving an event allowed.- Parameters:
eventMoveAllowed- True if moving is allowed, false if not
-
isBackwardNavigationEnabled
public boolean isBackwardNavigationEnabled()
-
setBackwardNavigationEnabled
public void setBackwardNavigationEnabled(boolean enabled)
-
isForwardNavigationEnabled
public boolean isForwardNavigationEnabled()
-
setForwardNavigationEnabled
public void setForwardNavigationEnabled(boolean enabled)
-
getDropHandler
public CalendarDropHandler getDropHandler()
- Specified by:
getDropHandlerin interfaceVHasDropHandler
-
setDropHandler
public void setDropHandler(CalendarDropHandler dropHandler)
Set the drop handler.- Parameters:
dropHandler- The drophandler to use
-
setEventCaptionAsHtml
public void setEventCaptionAsHtml(boolean eventCaptionAsHtml)
Sets whether the event captions are rendered as HTML.If set to true, the captions are rendered in the browser as HTML and the developer is responsible for ensuring no harmful HTML is used. If set to false, the caption is rendered in the browser as plain text.
The default is false, i.e. to render that caption as plain text.
- Parameters:
eventCaptionAsHtml-trueif the captions are rendered as HTML,falseif rendered as plain text
-
isEventCaptionAsHtml
public boolean isEventCaptionAsHtml()
Checks whether event captions are rendered as HTMLThe default is false, i.e. to render that caption as plain text.
- Returns:
- true if the captions are rendered as HTML, false if rendered as plain text
-
setSortOrder
public void setSortOrder(CalendarState.EventSortOrder order)
Set sort strategy for events.- Parameters:
order- sort order
-
getSortOrder
public CalendarState.EventSortOrder getSortOrder()
Return currently active sort order.- Returns:
- current sort order
-
-