diff options
author | Leonid Rozenblyum <lrozenblyum@gmail.com> | 2015-11-04 12:18:46 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-11-11 10:09:45 +0000 |
commit | 91dcac26f683314d176a7763f53dad158c36e3df (patch) | |
tree | 7c95e3458ae0db6150b3af53bd8fd320f020a4e2 /server/src/com/vaadin | |
parent | d18d2fb7edd7901bab603bbce02d561808300ab3 (diff) | |
download | vaadin-framework-91dcac26f683314d176a7763f53dad158c36e3df.tar.gz vaadin-framework-91dcac26f683314d176a7763f53dad158c36e3df.zip |
Specify custom first day of week for Calendar #19227
Added possibility to provide first day of week independent of Locale.
(the Calendar code has been reformatted according to Eclipse 'Save
action'). Unit-tests added. UI test extended.
Change-Id: I3e3531228c139ce2014a1227e47c12e7896a6f87
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/ui/Calendar.java | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/server/src/com/vaadin/ui/Calendar.java b/server/src/com/vaadin/ui/Calendar.java index acddbe308b..0fb6925ae2 100644 --- a/server/src/com/vaadin/ui/Calendar.java +++ b/server/src/com/vaadin/ui/Calendar.java @@ -220,6 +220,8 @@ public class Calendar extends AbstractComponent implements */ private CalendarServerRpcImpl rpc = new CalendarServerRpcImpl(); + private Integer customFirstDayOfWeek; + /** * Returns the logger for the calendar */ @@ -427,6 +429,10 @@ public class Calendar extends AbstractComponent implements } else { currentCalendar = java.util.Calendar.getInstance(getLocale()); } + + if (customFirstDayOfWeek != null) { + currentCalendar.setFirstDayOfWeek(customFirstDayOfWeek); + } } private void setupCalendarEvents() { @@ -1281,9 +1287,8 @@ public class Calendar extends AbstractComponent implements /* * (non-Javadoc) * - * @see - * com.vaadin.addon.calendar.ui.CalendarEvents.EventChangeListener#eventChange - * (com.vaadin.addon.calendar.ui.CalendarEvents.EventChange) + * @see com.vaadin.addon.calendar.ui.CalendarEvents.EventChangeListener# + * eventChange (com.vaadin.addon.calendar.ui.CalendarEvents.EventChange) */ @Override public void eventSetChange(EventSetChangeEvent changeEvent) { @@ -1440,9 +1445,8 @@ public class Calendar extends AbstractComponent implements /* * (non-Javadoc) * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.CalendarEventNotifier - * #getHandler(java.lang.String) + * @see com.vaadin.addon.calendar.ui.CalendarComponentEvents. + * CalendarEventNotifier #getHandler(java.lang.String) */ @Override public EventListener getHandler(String eventId) { @@ -1992,4 +1996,25 @@ public class Calendar extends AbstractComponent implements customAttributes.add("end-date"); return customAttributes; } + + /** + * Allow setting first day of week depending on Locale. Set to null if you + * want first day of week depend on locale + * + * @since + * @param dayOfWeek + */ + public void setFirstDayOfWeek(Integer dayOfWeek) { + int minimalSupported = java.util.Calendar.SUNDAY; + int maximalSupported = java.util.Calendar.SATURDAY; + if (dayOfWeek != null + && (dayOfWeek < minimalSupported || dayOfWeek > maximalSupported)) { + throw new IllegalArgumentException( + String.format( + "Day of week must be between %s and %s. Actually received: %s", + minimalSupported, maximalSupported, dayOfWeek)); + } + customFirstDayOfWeek = dayOfWeek; + markAsDirty(); + } } |