diff options
9 files changed, 744 insertions, 47 deletions
diff --git a/WebContent/VAADIN/themes/base/common/common.scss b/WebContent/VAADIN/themes/base/common/common.scss index 40bea2c9d6..7cd1f2dd1c 100644 --- a/WebContent/VAADIN/themes/base/common/common.scss +++ b/WebContent/VAADIN/themes/base/common/common.scss @@ -252,4 +252,7 @@ div.v-app-loading { overflow: auto; } +/* Enable kinetic scrolling on Mobile Safari 6 */ +.v-ios.v-sa6 .v-scrollable { + -webkit-overflow-scrolling: touch; }
\ No newline at end of file diff --git a/client-compiler/src/com/vaadin/tools/WidgetsetCompiler.java b/client-compiler/src/com/vaadin/tools/WidgetsetCompiler.java index 51d5ec8187..854efe54d6 100755 --- a/client-compiler/src/com/vaadin/tools/WidgetsetCompiler.java +++ b/client-compiler/src/com/vaadin/tools/WidgetsetCompiler.java @@ -80,6 +80,8 @@ public class WidgetsetCompiler { System.out.println("Starting GWT compiler"); System.setProperty("gwt.nowarn.legacy.tools", "true"); + System.setProperty("gwt.forceVersionCheckURL", + "http://tools.vaadin.com/version/currentversion.xml"); Class<?> compilerClass = Class .forName("com.google.gwt.dev.GWTCompiler"); Method method = compilerClass.getDeclaredMethod("main", diff --git a/client/src/com/vaadin/client/BrowserInfo.java b/client/src/com/vaadin/client/BrowserInfo.java index f7c8d2f331..e32e9b65f0 100644 --- a/client/src/com/vaadin/client/BrowserInfo.java +++ b/client/src/com/vaadin/client/BrowserInfo.java @@ -360,13 +360,15 @@ public class BrowserInfo { if (!isTouchDevice()) { return false; } + // TODO Should test other Android browsers, especially Chrome if (isAndroid() && isWebkit() && getWebkitVersion() >= 534) { return false; } - // Cannot enable native touch scrolling on iOS 5 until #8792 is resolved - // if (isIOS() && isWebkit() && getWebkitVersion() >= 534) { - // return false; - // } + // iOS 6 Safari supports native scrolling; iOS 5 suffers from #8792 + // TODO Should test other iOS browsers + if (isIOS() && isSafari() && getBrowserMajorVersion() >= 6) { + return false; + } return true; } diff --git a/client/src/com/vaadin/client/ui/datefield/VCalendarPanel.java b/client/src/com/vaadin/client/ui/datefield/VCalendarPanel.java index dc40675e0a..9d519e3179 100644 --- a/client/src/com/vaadin/client/ui/datefield/VCalendarPanel.java +++ b/client/src/com/vaadin/client/ui/datefield/VCalendarPanel.java @@ -135,8 +135,16 @@ public class VCalendarPanel extends FocusableFlexTable implements */ @Override public void onClick(ClickEvent event) { - Day day = (Day) event.getSource(); - focusDay(day.getDate()); + Date newDate = ((Day) event.getSource()).getDate(); + if (newDate.getMonth() != displayedMonth.getMonth() + || newDate.getYear() != displayedMonth.getYear()) { + // If an off-month date was clicked, we must change the + // displayed month and re-render the calendar (#8931) + displayedMonth.setMonth(newDate.getMonth()); + displayedMonth.setYear(newDate.getYear()); + renderCalendar(); + } + focusDay(newDate); selectFocused(); onSubmit(); } @@ -403,8 +411,8 @@ public class VCalendarPanel extends FocusableFlexTable implements } final String monthName = needsMonth ? getDateTimeService().getMonth( - focusedDate.getMonth()) : ""; - final int year = focusedDate.getYear() + 1900; + displayedMonth.getMonth()) : ""; + final int year = displayedMonth.getYear() + 1900; getFlexCellFormatter().setStyleName(0, 2, VDateField.CLASSNAME + "-calendarpanel-month"); setHTML(0, 2, "<span class=\"" + VDateField.CLASSNAME @@ -605,14 +613,17 @@ public class VCalendarPanel extends FocusableFlexTable implements */ private void focusNextDay(int days) { int oldMonth = focusedDate.getMonth(); + int oldYear = focusedDate.getYear(); focusedDate.setDate(focusedDate.getDate() + days); - if (focusedDate.getMonth() == oldMonth) { + if (focusedDate.getMonth() == oldMonth + && focusedDate.getYear() == oldYear) { // Month did not change, only move the selection focusDay(focusedDate); } else { // If the month changed we need to re-render the calendar displayedMonth.setMonth(focusedDate.getMonth()); + displayedMonth.setYear(focusedDate.getYear()); renderCalendar(); } } diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index f673babc26..442fa095d4 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -282,43 +282,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements */ @Override public void discard() throws Buffered.SourceException { - if (dataSource != null) { - - // Gets the correct value from datasource - T newFieldValue; - try { - - // Discards buffer by overwriting from datasource - newFieldValue = convertFromDataSource(getDataSourceValue()); - - // If successful, remove set the buffering state to be ok - if (getCurrentBufferedSourceException() != null) { - setCurrentBufferedSourceException(null); - } - } catch (final Throwable e) { - // FIXME: What should really be done here if conversion fails? - - // Sets the buffering state - currentBufferedSourceException = new Buffered.SourceException( - this, e); - markAsDirty(); - - // Throws the source exception - throw currentBufferedSourceException; - } - - final boolean wasModified = isModified(); - setModified(false); - - // If the new value differs from the previous one - if (!equals(newFieldValue, getInternalValue())) { - setInternalValue(newFieldValue); - fireValueChange(false); - } else if (wasModified) { - // If the value did not change, but the modification status did - markAsDirty(); - } - } + updateValueFromDataSource(); } /** @@ -1323,7 +1287,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements addPropertyListeners(); if (!isModified() && !isBuffered()) { // Update value from data source - discard(); + updateValueFromDataSource(); } } } @@ -1540,6 +1504,46 @@ public abstract class AbstractField<T> extends AbstractComponent implements } } + private void updateValueFromDataSource() { + if (dataSource != null) { + + // Gets the correct value from datasource + T newFieldValue; + try { + + // Discards buffer by overwriting from datasource + newFieldValue = convertFromDataSource(getDataSourceValue()); + + // If successful, remove set the buffering state to be ok + if (getCurrentBufferedSourceException() != null) { + setCurrentBufferedSourceException(null); + } + } catch (final Throwable e) { + // FIXME: What should really be done here if conversion fails? + + // Sets the buffering state + currentBufferedSourceException = new Buffered.SourceException( + this, e); + markAsDirty(); + + // Throws the source exception + throw currentBufferedSourceException; + } + + final boolean wasModified = isModified(); + setModified(false); + + // If the new value differs from the previous one + if (!equals(newFieldValue, getInternalValue())) { + setInternalValue(newFieldValue); + fireValueChange(false); + } else if (wasModified) { + // If the value did not change, but the modification status did + markAsDirty(); + } + } + } + /** * Gets the converter used to convert the property data source value to the * field value. diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html new file mode 100644 index 0000000000..aa6c536af3 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.html @@ -0,0 +1,382 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>DateFieldExtendedRange</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">DateFieldExtendedRange</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/DateFieldExtendedRange?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>8,16</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>2011-01-01</td> +</tr> +<tr> + <td>assertText</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>27</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day37</td> + <td>6</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>11,11</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>10,12</td> +</tr> +<tr> + <td>assertText</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>26</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day36</td> + <td>5</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>15,20</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#popupButton</td> + <td>11,8</td> +</tr> +<tr> + <td>assertText</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>27</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]#day37</td> + <td>6</td> +</tr> +<tr> + <td>assertText</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>27</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#day37</td> + <td>6</td> +</tr> +<tr> + <td>assertText</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[4]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>26</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day36</td> + <td>5</td> +</tr> +<tr> + <td>assertText</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[6]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>27</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#day37</td> + <td>6</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>11,9</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>12,9</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#field</td> + <td>27.12.2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>10,15</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>14,7</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#field</td> + <td>12/26/10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#popupButton</td> + <td>15,10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>6,11</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#field</td> + <td>27.12.2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>11,7</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>joulukuu 2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[4]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>13,4</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>December 2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//div[@id='runDateFieldExtendedRange-312092003']/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div/div[6]/div[2]/div/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>11,8</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>joulukuu 2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#day27</td> + <td>13,13</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>tammikuu 2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day26</td> + <td>12,7</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>January 2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#day27</td> + <td>14,12</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>tammikuu 2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>14,17</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>enter</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#field</td> + <td>3.1.2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>9,12</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>enter</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#field</td> + <td>1/2/11</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#popupButton</td> + <td>15,15</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>down</td> +</tr> +<tr> + <td>pressSpecialKey</td> + <td>vaadin=runDateFieldExtendedRange::Root/VOverlay[0]/VCalendarPanel[0]</td> + <td>enter</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#field</td> + <td>3.1.2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>10,15</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>12,8</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#field</td> + <td>27.12.2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#popupButton</td> + <td>12,15</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>14,9</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VPopupCalendar[0]#field</td> + <td>12/26/10</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#popupButton</td> + <td>15,15</td> +</tr> +<tr> + <td>mouseClick</td> + <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/span</td> + <td>8,12</td> +</tr> +<tr> + <td>assertValue</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[4]/VPopupCalendar[0]#field</td> + <td>27.12.2010</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#day37</td> + <td>18,10</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>helmikuu 2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#day36</td> + <td>15,11</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>February 2011</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#day37</td> + <td>19,13</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[5]/VDateFieldCalendar[0]/VCalendarPanel[0]#header</td> + <td>helmikuu 2011</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runDateFieldExtendedRange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VPopupCalendar[0]#popupButton</td> + <td>10,13</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>2010-02-16</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.java new file mode 100644 index 0000000000..e420278148 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldExtendedRange.java @@ -0,0 +1,79 @@ +package com.vaadin.tests.components.datefield; + +import java.util.Calendar; +import java.util.Locale; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.DateField; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.InlineDateField; +import com.vaadin.ui.PopupDateField; + +@SuppressWarnings("serial") +public class DateFieldExtendedRange extends TestBase { + + private Calendar date = Calendar.getInstance(); + + @Override + protected void setup() { + date.set(2011, 0, 1); + + GridLayout layout = new GridLayout(2, 3); + layout.setWidth("600px"); + layout.setSpacing(true); + + final DateField[] fields = new DateField[6]; + + Locale fi = new Locale("fi", "FI"); + Locale us = new Locale("en", "US"); + + fields[0] = makeDateField(true, fi, "Finnish locale"); + fields[1] = makeDateField(false, fi, "Finnish locale"); + + fields[2] = makeDateField(true, us, "US English locale"); + fields[3] = makeDateField(false, us, "US English locale"); + + fields[4] = makeDateField(true, fi, "Finnish locale with week numbers"); + fields[4].setShowISOWeekNumbers(true); + fields[5] = makeDateField(false, fi, "Finnish locale with week numbers"); + fields[5].setShowISOWeekNumbers(true); + + for (DateField f : fields) { + layout.addComponent(f); + } + + addComponent(layout); + + addComponent(new Button("Change date", new ClickListener() { + public void buttonClick(ClickEvent event) { + date.set(2010, 1, 16); + for (DateField f : fields) { + f.setValue(date.getTime()); + } + } + })); + } + + @Override + protected String getDescription() { + return "Show a few days of the preceding and following months in the datefield popup"; + } + + @Override + protected Integer getTicketNumber() { + return 6718; + } + + private DateField makeDateField(boolean isPopup, Locale locale, + String caption) { + DateField df = isPopup ? new PopupDateField() : new InlineDateField(); + df.setResolution(DateField.RESOLUTION_DAY); + df.setValue(date.getTime()); + df.setLocale(locale); + df.setCaption(caption); + return df; + } +} diff --git a/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.html b/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.html new file mode 100644 index 0000000000..9bd0149bdb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.html @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="" /> +<title>TableReduceContainerSize</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TableReduceContainerSize</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/TableReduceContainerSize?restartApplication</td> + <td></td> +</tr> +<tr> + <td>scroll</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>19700</td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td> + <td>Index: *</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>scroll</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> + <td>19700</td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableReduceContainerSize::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VLabel[0]</td> + <td>Index: *</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.java b/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.java new file mode 100644 index 0000000000..bc729ef042 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableReduceContainerSize.java @@ -0,0 +1,147 @@ +package com.vaadin.tests.components.table; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.vaadin.data.Container.Filter; +import com.vaadin.data.Item; +import com.vaadin.data.util.BeanItemContainer; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Table; + +/** + * Test for #8291 and #7666: NegativeArraySizeException when Table scrolled to + * the end and its size reduced. + */ +public class TableReduceContainerSize extends TestBase { + + @Override + protected void setup() { + addComponent(new TestView()); + } + + private static class DecimateFilter implements Filter { + public boolean passesFilter(Object itemId, Item item) + throws UnsupportedOperationException { + return ((((TestObject) itemId).property3 % 10) == 0); + } + + public boolean appliesToProperty(Object propertyId) { + return true; + } + } + + private static class TestView extends HorizontalLayout { + + private Filter filter = null; + + private boolean reduceData; + + private TestView() { + final Table table = new Table(); + List<TestObject> data = createData(1000); + final BeanItemContainer<TestObject> container = new BeanItemContainer<TestObject>( + TestObject.class, data) { + + @Override + public int size() { + if (reduceData) { + return 100; + } else { + return super.size(); + } + } + }; + table.setContainerDataSource(container); + addComponent(table); + final Label label = new Label(); + addComponent(label); + Button button = new Button("Click"); + button.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + try { + reduceData = !reduceData; + table.refreshRowCache(); + label.setValue("Index: " + + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue("Exception: " + + e.getClass().getSimpleName()); + } + } + }); + addComponent(button); + Button button2 = new Button("Filter"); + button2.addListener(new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + try { + if (filter != null) { + container.removeAllContainerFilters(); + filter = null; + } else { + filter = new DecimateFilter(); + container.addContainerFilter(filter); + } + table.refreshRowCache(); + label.setValue("Index: " + + table.getCurrentPageFirstItemIndex()); + } catch (Exception e) { + label.setValue("Exception: " + + e.getClass().getSimpleName()); + } + } + }); + addComponent(button2); + } + } + + private static List<TestObject> createData(int count) { + ArrayList<TestObject> data = new ArrayList<TestObject>(count); + for (int i = 0; i < count; i++) { + data.add(new TestObject("string-" + i, new Date(), i)); + } + return data; + } + + public static class TestObject { + + private String property1; + private Date property2; + private Integer property3; + + public TestObject(String property1, Date property2, Integer property3) { + this.property1 = property1; + this.property2 = property2; + this.property3 = property3; + } + + public String getProperty1() { + return property1; + } + + public Date getProperty2() { + return property2; + } + + public Integer getProperty3() { + return property3; + } + + } + + @Override + protected String getDescription() { + return "Table throws NegativeArraySizeException if container size is reduced to less than current scroll position"; + } + + @Override + protected Integer getTicketNumber() { + return 8291; + } + +} |