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 /uitest/src/com | |
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 'uitest/src/com')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java index a1bcca2e4e..b56f92962a 100644 --- a/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java +++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarTest.java @@ -108,6 +108,7 @@ public class CalendarTest extends UI { private CheckBox hideWeekendsButton; private CheckBox readOnlyButton; + private ComboBox customFirstDayOfWeekSelect; private TextField captionField; @@ -221,10 +222,12 @@ public class CalendarTest extends UI { setLocale(Locale.getDefault()); } - // Initialize locale, timezone and timeformat selects. + // Initialize locale, timezone, timeformat and custom first day of week + // selects. localeSelect = createLocaleSelect(); timeZoneSelect = createTimeZoneSelect(); formatSelect = createCalendarFormatSelect(); + customFirstDayOfWeekSelect = createCustomFirstDayOfWeekSelect(); initCalendar(); initLayoutContent(); @@ -359,6 +362,7 @@ public class CalendarTest extends UI { controlPanel.addComponent(localeSelect); controlPanel.addComponent(timeZoneSelect); controlPanel.addComponent(formatSelect); + controlPanel.addComponent(customFirstDayOfWeekSelect); controlPanel.addComponent(hideWeekendsButton); controlPanel.addComponent(readOnlyButton); controlPanel.addComponent(disabledButton); @@ -770,6 +774,39 @@ public class CalendarTest extends UI { return s; } + private ComboBox createCustomFirstDayOfWeekSelect() { + ComboBox comboBox = new ComboBox("First day of week"); + + comboBox.addContainerProperty("caption", String.class, ""); + comboBox.setItemCaptionPropertyId("caption"); + + comboBox.setImmediate(true); + + Item defaultItem = comboBox.addItem(DEFAULT_ITEMID); + defaultItem.getItemProperty("caption").setValue("Default by locale"); + + Item sunday = comboBox.addItem(java.util.Calendar.SUNDAY); + sunday.getItemProperty("caption").setValue("Sunday"); + + Item monday = comboBox.addItem(java.util.Calendar.MONDAY); + monday.getItemProperty("caption").setValue("Monday"); + + comboBox.select(DEFAULT_ITEMID); + comboBox.setNullSelectionAllowed(false); + + comboBox.addValueChangeListener(new ValueChangeListener() { + + private static final long serialVersionUID = 1L; + + @Override + public void valueChange(ValueChangeEvent event) { + updateCalendarFirstDayOfWeek(event.getProperty().getValue()); + } + }); + + return comboBox; + } + private ComboBox createLocaleSelect() { ComboBox s = new ComboBox("Locale"); s.addContainerProperty("caption", String.class, ""); @@ -831,6 +868,20 @@ public class CalendarTest extends UI { calendarComponent.setTimeFormat(calFormat); } + private void updateCalendarFirstDayOfWeek(Object firstDayOfWeek) { + Integer firstDayOfWeekValue = null; + if (firstDayOfWeek instanceof Integer) { + firstDayOfWeekValue = (Integer) firstDayOfWeek; + calendarComponent.setFirstDayOfWeek(firstDayOfWeekValue); + } else { + // it means 'Default by locale has been selected' + calendarComponent.setFirstDayOfWeek(null); + } + + // if we need we may update also field of this test 'calendar' which + // also keeps first day of week + } + private String getLocaleItemCaption(Locale l) { String country = l.getDisplayCountry(getLocale()); String language = l.getDisplayLanguage(getLocale()); |