diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-08-24 12:23:04 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-08-24 12:23:04 +0000 |
commit | b886cf2165451fe0443a253be37cfca50122d80e (patch) | |
tree | 4bddd55b16dedb01fd6306e2788ff604b387d87f | |
parent | 0cb9b8bc806f30ae2eb91c8ab1215a8b61871229 (diff) | |
download | vaadin-framework-b886cf2165451fe0443a253be37cfca50122d80e.tar.gz vaadin-framework-b886cf2165451fe0443a253be37cfca50122d80e.zip |
Fix for #5475 - DateField text field includes extra single quote in some cases
Extended test case to cover #5475
svn changeset:14579/svn branch:6.4
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/DateTimeService.java | 29 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/components/datefield/CustomDateFormats.html | 87 |
2 files changed, 113 insertions, 3 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/DateTimeService.java b/src/com/vaadin/terminal/gwt/client/DateTimeService.java index b307eaf737..dffe2a9a53 100644 --- a/src/com/vaadin/terminal/gwt/client/DateTimeService.java +++ b/src/com/vaadin/terminal/gwt/client/DateTimeService.java @@ -313,6 +313,16 @@ public class DateTimeService { String monthName = getMonth(date.getMonth());
if (monthName != null) {
+ /*
+ * Replace 4 or more M:s with the quoted month name. Also
+ * concatenate generated string with any other string prepending
+ * or following the MMMM pattern, i.e. 'MMMM'ta ' becomes
+ * 'MONTHta ' and not 'MONTH''ta ', 'ab'MMMM becomes 'abMONTH',
+ * 'x'MMMM'y' becomes 'xMONTHy'.
+ */
+ formatStr = formatStr.replaceAll("'([M]{4,})'", monthName);
+ formatStr = formatStr.replaceAll("([M]{4,})'", "'" + monthName);
+ formatStr = formatStr.replaceAll("'([M]{4,})", monthName + "'");
formatStr = formatStr.replaceAll("[M]{4,}", "'" + monthName
+ "'");
}
@@ -324,6 +334,16 @@ public class DateTimeService { String monthName = getShortMonth(date.getMonth());
if (monthName != null) {
+ /*
+ * Replace 3 or more M:s with the quoted month name. Also
+ * concatenate generated string with any other string prepending
+ * or following the MMM pattern, i.e. 'MMM'ta ' becomes 'MONTHta
+ * ' and not 'MONTH''ta ', 'ab'MMM becomes 'abMONTH', 'x'MMM'y'
+ * becomes 'xMONTHy'.
+ */
+ formatStr = formatStr.replaceAll("'([M]{3,})'", monthName);
+ formatStr = formatStr.replaceAll("([M]{3,})'", "'" + monthName);
+ formatStr = formatStr.replaceAll("'([M]{3,})", monthName + "'");
formatStr = formatStr.replaceAll("[M]{3,}", "'" + monthName
+ "'");
}
@@ -333,12 +353,15 @@ public class DateTimeService { }
/**
- * Replaces month names in the entered date Parses the month name from the
- * entered dat
+ * Replaces month names in the entered date with the name in the current
+ * browser locale.
*
* @param enteredDate
+ * Date string e.g. "5 May 2010"
* @param formatString
- * @return
+ * Format string e.g. "d M yyyy"
+ * @return The date string where the month names have been replaced by the
+ * browser locale version
*/
private String parseMonthName(String enteredDate, String formatString) {
LocaleInfo browserLocale = LocaleInfo.getCurrentLocale();
diff --git a/tests/src/com/vaadin/tests/components/datefield/CustomDateFormats.html b/tests/src/com/vaadin/tests/components/datefield/CustomDateFormats.html index b8d64acdc2..2a1a9ea186 100644 --- a/tests/src/com/vaadin/tests/components/datefield/CustomDateFormats.html +++ b/tests/src/com/vaadin/tests/components/datefield/CustomDateFormats.html @@ -82,6 +82,7 @@ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[37]/VPopupCalendar[0]/domChild[0]</td>
<td>01/02/10</td>
</tr>
+<!--Test parsing-->
<tr>
<td>mouseClick</td>
<td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[0]</td>
@@ -132,6 +133,92 @@ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[0]</td>
<td>26 septembre 2010</td>
</tr>
+<!--Parsing for fi_FI-->
+<tr>
+ <td>select</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VNativeSelect[0]/domChild[0]</td>
+ <td>label=fi_FI</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[0]</td>
+ <td>109,12</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[0]</td>
+ <td>10 maalis 1999</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[0]</td>
+ <td>15,8</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[0]</td>
+ <td>26 syyskuu 1980</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[1]</td>
+ <td>10,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[1]</td>
+ <td>10,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[1]</td>
+ <td>9,12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[1]</td>
+ <td>9,12</td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[7]/VPopupCalendar[0]/domChild[0]</td>
+ <td>10 maalis 1999</td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[10]/VPopupCalendar[0]/domChild[0]</td>
+ <td>26 syyskuu 1980</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[31]/VPopupCalendar[0]/domChild[0]</td>
+ <td>124,13</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[31]/VPopupCalendar[0]/domChild[0]</td>
+ <td>10. tammikuuta 2011</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[31]/VPopupCalendar[0]/domChild[1]</td>
+ <td>5,10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::Root/VOverlay[0]/VCalendarPanel[0]/domChild[1]/domChild[0]/domChild[2]/domChild[0]</td>
+ <td>tammikuu 2011</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[31]/VPopupCalendar[0]/domChild[1]</td>
+ <td>5,10</td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldCustomDateFormats::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[31]/VPopupCalendar[0]/domChild[0]</td>
+ <td>10. tammikuuta 2011</td>
+</tr>
<!--zh-->
<tr>
<td>select</td>
|