소스 검색

Rename PopupDateField to DateField #297.

DateField becomes abstract AbstractDateField, PopupDateField becomes
DateField

Change-Id: I3ac1e02d8754f0770b6a30222cb0fb2a1b9db07b
tags/8.0.0.alpha3
Denis Anisimov 7 년 전
부모
커밋
d078a5d7db
100개의 변경된 파일1565개의 추가작업 그리고 1556개의 파일을 삭제
  1. 2
    2
      client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java
  2. 2
    2
      client/src/main/java/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java
  3. 877
    0
      server/src/main/java/com/vaadin/ui/AbstractDateField.java
  4. 59
    784
      server/src/main/java/com/vaadin/ui/DateField.java
  5. 2
    2
      server/src/main/java/com/vaadin/ui/InlineDateField.java
  6. 0
    151
      server/src/main/java/com/vaadin/ui/PopupDateField.java
  7. 5
    5
      server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java
  8. 22
    70
      server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java
  9. 7
    3
      server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java
  10. 2
    2
      server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java
  11. 0
    62
      server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java
  12. 3
    2
      server/src/test/java/com/vaadin/ui/DateFieldTestCase.java
  13. 7
    0
      uitest-common/src/main/java/com/vaadin/testbench/customelements/AbstractDateFieldElement.java
  14. 2
    2
      uitest/src/main/java/com/vaadin/tests/FocusingComponents.java
  15. 2
    2
      uitest/src/main/java/com/vaadin/tests/PerformanceTestBasicComponentRendering.java
  16. 7
    6
      uitest/src/main/java/com/vaadin/tests/RandomLayoutStress.java
  17. 4
    3
      uitest/src/main/java/com/vaadin/tests/TestCaptionWrapper.java
  18. 11
    7
      uitest/src/main/java/com/vaadin/tests/TestDateField.java
  19. 4
    3
      uitest/src/main/java/com/vaadin/tests/TestForAlignments.java
  20. 3
    2
      uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java
  21. 2
    2
      uitest/src/main/java/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java
  22. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java
  23. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java
  24. 57
    0
      uitest/src/main/java/com/vaadin/tests/components/TestDateField.java
  25. 146
    0
      uitest/src/main/java/com/vaadin/tests/components/datefield/AbstractDateFieldTest.java
  26. 5
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/AriaDisabled.java
  27. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormat.java
  28. 4
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormatEEE.java
  29. 5
    4
      uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormats.java
  30. 3
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldChangeResolution.java
  31. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldClose.java
  32. 5
    4
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldDayResolutionOffset.java
  33. 4
    4
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldElementUI.java
  34. 7
    7
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldExtendedRange.java
  35. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldIsValid.java
  36. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldKeyboardInput.java
  37. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldLocale.java
  38. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMinResolution.java
  39. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
  40. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java
  41. 5
    4
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java
  42. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
  43. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.java
  44. 16
    15
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldRanges.java
  45. 4
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java
  46. 26
    119
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTest.java
  47. 3
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTextEnabled.java
  48. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTimezone.java
  49. 5
    5
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java
  50. 5
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldValueChangeEvents.java
  51. 12
    11
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParent.java
  52. 11
    11
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateFields.java
  53. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java
  54. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java
  55. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java
  56. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java
  57. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledInlineDateField.java
  58. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
  59. 4
    4
      uitest/src/main/java/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java
  60. 1
    1
      uitest/src/main/java/com/vaadin/tests/components/datefield/InlineDateFieldTest.java
  61. 6
    5
      uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java
  62. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/LocaleChange.java
  63. 3
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/LowResolution.java
  64. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java
  65. 6
    5
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java
  66. 6
    6
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java
  67. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldInputPrompt.java
  68. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldLocaleTest.java
  69. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldPopup.java
  70. 3
    3
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldStates.java
  71. 0
    52
      uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java
  72. 4
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/TestDatefieldYear.java
  73. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java
  74. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java
  75. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/gridlayout/LayoutAfterHidingError.java
  76. 3
    2
      uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java
  77. 3
    3
      uitest/src/main/java/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java
  78. 4
    3
      uitest/src/main/java/com/vaadin/tests/components/uitest/components/DatesCssTest.java
  79. 3
    3
      uitest/src/main/java/com/vaadin/tests/declarative/PotusForm.java
  80. 2
    3
      uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java
  81. 2
    2
      uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java
  82. 5
    4
      uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java
  83. 2
    2
      uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
  84. 2
    2
      uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseRegError.java
  85. 2
    2
      uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java
  86. 28
    28
      uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java
  87. 4
    3
      uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java
  88. 3
    2
      uitest/src/main/java/com/vaadin/tests/themes/valo/Tables.java
  89. 1
    1
      uitest/src/test/java/com/vaadin/tests/components/datefield/AbstractDateFieldTestTest.java
  90. 2
    2
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldDayResolutionOffsetTest.java
  91. 26
    0
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java
  92. 2
    2
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java
  93. 2
    1
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetachTest.java
  94. 2
    1
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
  95. 2
    2
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java
  96. 3
    3
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldValueChangeEventsTest.java
  97. 9
    12
      uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java
  98. 0
    21
      uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java
  99. 4
    5
      uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldInputPromptTest.java
  100. 0
    0
      uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java

+ 2
- 2
client/src/main/java/com/vaadin/client/ui/datefield/DateFieldConnector.java 파일 보기

@@ -31,9 +31,9 @@ import com.vaadin.client.ui.VPopupCalendar;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.datefield.PopupDateFieldState;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;

@Connect(DateField.class)
@Connect(AbstractDateField.class)
public class DateFieldConnector extends TextualDateConnector {

/*

+ 2
- 2
client/src/main/java/com/vaadin/client/ui/datefield/PopupDateFieldConnector.java 파일 보기

@@ -17,9 +17,9 @@
package com.vaadin.client.ui.datefield;

import com.vaadin.shared.ui.Connect;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@Connect(PopupDateField.class)
@Connect(DateField.class)
public class PopupDateFieldConnector extends DateFieldConnector {

}

+ 877
- 0
server/src/main/java/com/vaadin/ui/AbstractDateField.java 파일 보기

@@ -0,0 +1,877 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.ui;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.logging.Logger;

import org.jsoup.nodes.Element;

import com.vaadin.data.Result;
import com.vaadin.data.validator.DateRangeValidator;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.shared.ui.datefield.TextualDateFieldState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;

/**
* A date editor component with <code>java.util.Date</code> as an input value.
*
* @author Vaadin Ltd
*
* @since 8.0
*
*/
public abstract class AbstractDateField extends AbstractField<Date>
implements LegacyComponent {

/**
* Value of the field.
*/
private Date value;

/**
* Specified smallest modifiable unit for the date field.
*/
private Resolution resolution = Resolution.DAY;

/**
* The internal calendar to be used in java.utl.Date conversions.
*/
private transient Calendar calendar;

/**
* Overridden format string
*/
private String dateFormat;

private boolean lenient = false;

private String dateString = null;

private String currentParseErrorMessage;

/**
* Was the last entered string parsable? If this flag is false, datefields
* internal validator does not pass.
*/
private boolean uiHasValidDateString = true;

/**
* Determines if week numbers are shown in the date selector.
*/
private boolean showISOWeekNumbers = false;

private String defaultParseErrorMessage = "Date format not recognized";

private TimeZone timeZone = null;

private static Map<Resolution, String> variableNameForResolution = new HashMap<>();

private String dateOutOfRangeMessage = "Date is out of allowed range";

/**
* Determines whether the ValueChangeEvent should be fired. Used to prevent
* firing the event when UI has invalid string until uiHasValidDateString
* flag is set
*/
private boolean preventValueChangeEvent;

static {
variableNameForResolution.put(Resolution.SECOND, "sec");
variableNameForResolution.put(Resolution.MINUTE, "min");
variableNameForResolution.put(Resolution.HOUR, "hour");
variableNameForResolution.put(Resolution.DAY, "day");
variableNameForResolution.put(Resolution.MONTH, "month");
variableNameForResolution.put(Resolution.YEAR, "year");
}

/* Constructors */

/**
* Constructs an empty <code>DateField</code> with no caption.
*/
public AbstractDateField() {
}

/**
* Constructs an empty <code>DateField</code> with caption.
*
* @param caption
* the caption of the datefield.
*/
public AbstractDateField(String caption) {
setCaption(caption);
}

/**
* Constructs a new <code>DateField</code> with the given caption and
* initial text contents.
*
* @param caption
* the caption <code>String</code> for the editor.
* @param value
* the Date value.
*/
public AbstractDateField(String caption, Date value) {
setValue(value);
setCaption(caption);
}

/* Component basic features */

/*
* Paints this component. Don't add a JavaDoc comment here, we use the
* default documentation from implemented interface.
*/
@Override
public void paintContent(PaintTarget target) throws PaintException {

// Adds the locale as attribute
final Locale l = getLocale();
if (l != null) {
target.addAttribute("locale", l.toString());
}

if (getDateFormat() != null) {
target.addAttribute("format", dateFormat);
}

if (!isLenient()) {
target.addAttribute("strict", true);
}

target.addAttribute(DateFieldConstants.ATTR_WEEK_NUMBERS,
isShowISOWeekNumbers());
target.addAttribute("parsable", uiHasValidDateString);
/*
* TODO communicate back the invalid date string? E.g. returning back to
* app or refresh.
*/

// Gets the calendar
final Calendar calendar = getCalendar();
final Date currentDate = getValue();

// Only paint variables for the resolution and up, e.g. Resolution DAY
// paints DAY,MONTH,YEAR
for (Resolution res : Resolution
.getResolutionsHigherOrEqualTo(resolution)) {
int value = -1;
if (currentDate != null) {
value = calendar.get(res.getCalendarField());
if (res == Resolution.MONTH) {
// Calendar month is zero based
value++;
}
}
target.addVariable(this, variableNameForResolution.get(res), value);
}
}

/*
* Invoked when a variable of the component changes. Don't add a JavaDoc
* comment here, we use the default documentation from implemented
* interface.
*/
@Override
public void changeVariables(Object source, Map<String, Object> variables) {

if (!isReadOnly() && (variables.containsKey("year")
|| variables.containsKey("month")
|| variables.containsKey("day") || variables.containsKey("hour")
|| variables.containsKey("min") || variables.containsKey("sec")
|| variables.containsKey("msec")
|| variables.containsKey("dateString"))) {

// Old and new dates
final Date oldDate = getValue();
Date newDate = null;

// this enables analyzing invalid input on the server
final String newDateString = (String) variables.get("dateString");
dateString = newDateString;

// Gets the new date in parts
boolean hasChanges = false;
Map<Resolution, Integer> calendarFieldChanges = new HashMap<>();

for (Resolution r : Resolution
.getResolutionsHigherOrEqualTo(resolution)) {
// Only handle what the client is allowed to send. The same
// resolutions that are painted
String variableName = variableNameForResolution.get(r);

if (variables.containsKey(variableName)) {
Integer value = (Integer) variables.get(variableName);
if (r == Resolution.MONTH) {
// Calendar MONTH is zero based
value--;
}
if (value >= 0) {
hasChanges = true;
calendarFieldChanges.put(r, value);
}
}
}

// If no new variable values were received, use the previous value
if (!hasChanges) {
newDate = null;
} else {
// Clone the calendar for date operation
final Calendar cal = getCalendar();

// Update the value based on the received info
// Must set in this order to avoid invalid dates (or wrong
// dates if lenient is true) in calendar
for (int r = Resolution.YEAR.ordinal(); r >= 0; r--) {
Resolution res = Resolution.values()[r];
if (calendarFieldChanges.containsKey(res)) {

// Field resolution should be included. Others are
// skipped so that client can not make unexpected
// changes (e.g. day change even though resolution is
// year).
Integer newValue = calendarFieldChanges.get(res);
cal.set(res.getCalendarField(), newValue);
}
}
newDate = cal.getTime();
}

if (newDate == null && dateString != null
&& !dateString.isEmpty()) {
Result<Date> parsedDate = handleUnparsableDateString(
dateString);
if (parsedDate.isError()) {

/*
* Saves the localized message of parse error. This can be
* overridden in handleUnparsableDateString. The message
* will later be used to show a validation error.
*/
currentParseErrorMessage = parsedDate.getMessage().get();

/*
* The value of the DateField should be null if an invalid
* value has been given. Not using setValue() since we do
* not want to cause the client side value to change.
*/
uiHasValidDateString = false;

/*
* Datefield now contains some text that could't be parsed
* into date. ValueChangeEvent is fired after the value is
* changed and the flags are set
*/
if (oldDate != null) {
/*
* Set the logic value to null without firing the
* ValueChangeEvent
*/
preventValueChangeEvent = true;
try {
setValue(null);
} finally {
preventValueChangeEvent = false;
}

/*
* Reset the dateString (overridden to null by setValue)
*/
dateString = newDateString;
}

/*
* If value was changed fire the ValueChangeEvent
*/
if (oldDate != null) {
fireEvent(createValueChange(true));
}

markAsDirty();
} else {
parsedDate.ifOk(value -> setValue(value, true));

/*
* Ensure the value is sent to the client if the value is
* set to the same as the previous (#4304). Does not repaint
* if handleUnparsableDateString throws an exception. In
* this case the invalid text remains in the DateField.
*/
markAsDirty();
}

} else if (newDate != oldDate
&& (newDate == null || !newDate.equals(oldDate))) {
setValue(newDate, true); // Don't require a repaint, client
// updates itself
} else if (!uiHasValidDateString) { // oldDate ==
// newDate == null
// Empty value set, previously contained unparsable date string,
// clear related internal fields
setValue(null);
}
}

if (variables.containsKey(FocusEvent.EVENT_ID)) {
fireEvent(new FocusEvent(this));
}

if (variables.containsKey(BlurEvent.EVENT_ID)) {
fireEvent(new BlurEvent(this));
}
}

/**
* Sets the start range for this component. If the value is set before this
* date (taking the resolution into account), the component will not
* validate. If <code>startDate</code> is set to <code>null</code>, any
* value before <code>endDate</code> will be accepted by the range
*
* @param startDate
* - the allowed range's start date
*/
public void setRangeStart(Date startDate) {
if (startDate != null && getState().rangeEnd != null
&& startDate.after(getState().rangeEnd)) {
throw new IllegalStateException(
"startDate cannot be later than endDate");
}

// Create a defensive copy against issues when using java.sql.Date (and
// also against mutable Date).
getState().rangeStart = startDate != null
? new Date(startDate.getTime()) : null;
}

/**
* Sets the current error message if the range validation fails.
*
* @param dateOutOfRangeMessage
* - Localizable message which is shown when value (the date) is
* set outside allowed range
*/
public void setDateOutOfRangeMessage(String dateOutOfRangeMessage) {
this.dateOutOfRangeMessage = dateOutOfRangeMessage;
}

/**
* Returns current date-out-of-range error message.
*
* @see #setDateOutOfRangeMessage(String)
* @return Current error message for dates out of range.
*/
public String getDateOutOfRangeMessage() {
return dateOutOfRangeMessage;
}

/**
* Gets the resolution.
*
* @return int
*/
public Resolution getResolution() {
return resolution;
}

/**
* Sets the resolution of the DateField.
*
* The default resolution is {@link Resolution#DAY} since Vaadin 7.0.
*
* @param resolution
* the resolution to set.
*/
public void setResolution(Resolution resolution) {
this.resolution = resolution;
markAsDirty();
}

/**
* Sets the end range for this component. If the value is set after this
* date (taking the resolution into account), the component will not
* validate. If <code>endDate</code> is set to <code>null</code>, any value
* after <code>startDate</code> will be accepted by the range.
*
* @param endDate
* - the allowed range's end date (inclusive, based on the
* current resolution)
*/
public void setRangeEnd(Date endDate) {
if (endDate != null && getState().rangeStart != null
&& getState().rangeStart.after(endDate)) {
throw new IllegalStateException(
"endDate cannot be earlier than startDate");
}

// Create a defensive copy against issues when using java.sql.Date (and
// also against mutable Date).
getState().rangeEnd = endDate != null ? new Date(endDate.getTime())
: null;
}

/**
* Returns the precise rangeStart used.
*
* @return the precise rangeStart used
*/
public Date getRangeStart() {
return getState(false).rangeStart;
}

/**
* Returns the precise rangeEnd used.
*
* @return the precise rangeEnd used
*/
public Date getRangeEnd() {
return getState(false).rangeEnd;
}

/**
* Sets formatting used by some component implementations. See
* {@link SimpleDateFormat} for format details.
*
* By default it is encouraged to used default formatting defined by Locale,
* but due some JVM bugs it is sometimes necessary to use this method to
* override formatting. See Vaadin issue #2200.
*
* @param dateFormat
* the dateFormat to set
*
* @see com.vaadin.ui.AbstractComponent#setLocale(Locale))
*/
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
markAsDirty();
}

/**
* Returns a format string used to format date value on client side or null
* if default formatting from {@link Component#getLocale()} is used.
*
* @return the dateFormat
*/
public String getDateFormat() {
return dateFormat;
}

/**
* Specifies whether or not date/time interpretation in component is to be
* lenient.
*
* @see Calendar#setLenient(boolean)
* @see #isLenient()
*
* @param lenient
* true if the lenient mode is to be turned on; false if it is to
* be turned off.
*/
public void setLenient(boolean lenient) {
this.lenient = lenient;
markAsDirty();
}

/**
* Returns whether date/time interpretation is to be lenient.
*
* @see #setLenient(boolean)
*
* @return true if the interpretation mode of this calendar is lenient;
* false otherwise.
*/
public boolean isLenient() {
return lenient;
}

@Override
public Date getValue() {
return value;
}

@Override
public void setValue(Date value) {
/*
* First handle special case when the client side component have a date
* string but value is null (e.g. unparsable date string typed in by the
* user). No value changes should happen, but we need to do some
* internal housekeeping.
*/
if (value == null && !uiHasValidDateString) {
/*
* Side-effects of doSetValue clears possible previous strings and
* flags about invalid input.
*/
doSetValue(null);

markAsDirty();
return;
}
super.setValue(value);
}

/**
* Checks whether ISO 8601 week numbers are shown in the date selector.
*
* @return true if week numbers are shown, false otherwise.
*/
public boolean isShowISOWeekNumbers() {
return showISOWeekNumbers;
}

/**
* Sets the visibility of ISO 8601 week numbers in the date selector. ISO
* 8601 defines that a week always starts with a Monday so the week numbers
* are only shown if this is the case.
*
* @param showWeekNumbers
* true if week numbers should be shown, false otherwise.
*/
public void setShowISOWeekNumbers(boolean showWeekNumbers) {
showISOWeekNumbers = showWeekNumbers;
markAsDirty();
}

/**
* Returns new instance calendar used in Date conversions.
*
* Returns new clone of the calendar object initialized using the the
* current date (if available)
*
* If this is no calendar is assigned the <code>Calendar.getInstance</code>
* is used.
*
* @return the Calendar.
* @see #setCalendar(Calendar)
*/
private Calendar getCalendar() {

// Makes sure we have an calendar instance
if (calendar == null) {
calendar = Calendar.getInstance();
// Start by a zeroed calendar to avoid having values for lower
// resolution variables e.g. time when resolution is day
int min, field;
for (Resolution r : Resolution
.getResolutionsLowerThan(resolution)) {
field = r.getCalendarField();
min = calendar.getActualMinimum(field);
calendar.set(field, min);
}
calendar.set(Calendar.MILLISECOND, 0);
}

// Clone the instance
final Calendar newCal = (Calendar) calendar.clone();

final TimeZone currentTimeZone = getTimeZone();
if (currentTimeZone != null) {
newCal.setTimeZone(currentTimeZone);
}

final Date currentDate = getValue();
if (currentDate != null) {
newCal.setTime(currentDate);
}
return newCal;
}

/**
* Gets the time zone used by this field. The time zone is used to convert
* the absolute time in a Date object to a logical time displayed in the
* selector and to convert the select time back to a Date object.
*
* If {@code null} is returned, the current default time zone returned by
* {@code TimeZone.getDefault()} is used.
*
* @return the current time zone
*/
public TimeZone getTimeZone() {
return timeZone;
}

/**
* Return the error message that is shown if the user inputted value can't
* be parsed into a Date object. If
* {@link #handleUnparsableDateString(String)} is overridden and it throws a
* custom exception, the message returned by
* {@link Exception#getLocalizedMessage()} will be used instead of the value
* returned by this method.
*
* @see #setParseErrorMessage(String)
*
* @return the error message that the DateField uses when it can't parse the
* textual input from user to a Date object
*/
public String getParseErrorMessage() {
return defaultParseErrorMessage;
}

/**
* Sets the default error message used if the DateField cannot parse the
* text input by user to a Date field. Note that if the
* {@link #handleUnparsableDateString(String)} method is overridden, the
* localized message from its exception is used.
*
* @see #getParseErrorMessage()
* @see #handleUnparsableDateString(String)
* @param parsingErrorMessage
*/
public void setParseErrorMessage(String parsingErrorMessage) {
defaultParseErrorMessage = parsingErrorMessage;
}

/**
* Sets the time zone used by this date field. The time zone is used to
* convert the absolute time in a Date object to a logical time displayed in
* the selector and to convert the select time back to a Date object.
*
* If no time zone has been set, the current default time zone returned by
* {@code TimeZone.getDefault()} is used.
*
* @see #getTimeZone()
* @param timeZone
* the time zone to use for time calculations.
*/
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
markAsDirty();
}

/**
* Adds a <code>FocusListener</code> to the Component which gets fired when
* a <code>LegacyField</code> receives keyboard focus.
*
* @param listener
* @see FocusListener
*/
public void addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
}

/**
* Removes a <code>FocusListener</code> from the Component.
*
* @param listener
* @see FocusListener
*/
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}

/**
* Adds a <code>BlurListener</code> to the Component which gets fired when a
* <code>LegacyField</code> loses keyboard focus.
*
* @param listener
* @see BlurListener
*/
public void addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
}

/**
* Removes a <code>BlurListener</code> from the Component.
*
* @param listener
* @see BlurListener
*/
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}

@Override
public void readDesign(Element design, DesignContext designContext) {
super.readDesign(design, designContext);
if (design.hasAttr("value") && !design.attr("value").isEmpty()) {
Date date = DesignAttributeHandler.getFormatter()
.parse(design.attr("value"), Date.class);
// formatting will return null if it cannot parse the string
if (date == null) {
Logger.getLogger(AbstractDateField.class.getName()).info(
"cannot parse " + design.attr("value") + " as date");
}
setValue(date);
}
}

@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
if (getValue() != null) {
design.attr("value",
DesignAttributeHandler.getFormatter().format(getValue()));
}
}

@Override
protected void fireEvent(EventObject event) {
if (event instanceof ValueChange) {
if (!preventValueChangeEvent) {
super.fireEvent(event);
}
} else {
super.fireEvent(event);
}
}

/**
* This method is called to handle a non-empty date string from the client
* if the client could not parse it as a Date.
*
* By default, an error result is returned whose error message is
* {@link #getParseErrorMessage()}.
*
* This can be overridden to handle conversions, to return a result with
* {@code null} value (equivalent to empty input) or to return a custom
* error.
*
* @param dateString
* date string to handle
* @return result that contains parsed Date as a value or an error
*/
protected Result<Date> handleUnparsableDateString(String dateString) {
return Result.error(getParseErrorMessage());
}

@Override
protected TextualDateFieldState getState() {
return (TextualDateFieldState) super.getState();
}

@Override
protected TextualDateFieldState getState(boolean markAsDirty) {
return (TextualDateFieldState) super.getState(markAsDirty);
}

@Override
protected void doSetValue(Date value) {
// Also set the internal dateString
if (value != null) {
dateString = value.toString();
} else {
dateString = null;
}

this.value = value;
setComponentError(null);
if (!uiHasValidDateString) {
// clear component error and parsing flag
uiHasValidDateString = true;
setComponentError(new UserError(currentParseErrorMessage));
} else {
DateRangeValidator validator = new DateRangeValidator(
getDateOutOfRangeMessage(), getRangeStart(getResolution()),
getRangeEnd(getResolution()), getResolution());
Result<Date> result = validator.apply(value);
if (result.isError()) {
setComponentError(new UserError(getDateOutOfRangeMessage()));
}
}
}

/**
* Gets the start range for a certain resolution. The range is inclusive, so
* if <code>rangeStart</code> is set to one millisecond before year n and
* resolution is set to YEAR, any date in year n - 1 will be accepted.
* Lowest supported resolution is DAY.
*
* @param forResolution
* - the range conforms to the resolution
* @return
*/
private Date getRangeStart(Resolution forResolution) {
if (getState(false).rangeStart == null) {
return null;
}
Calendar startCal = Calendar.getInstance();
startCal.setTime(getState(false).rangeStart);

if (forResolution == Resolution.YEAR) {
startCal.set(startCal.get(Calendar.YEAR), 0, 1, 0, 0, 0);
} else if (forResolution == Resolution.MONTH) {
startCal.set(startCal.get(Calendar.YEAR),
startCal.get(Calendar.MONTH), 1, 0, 0, 0);
} else {
startCal.set(startCal.get(Calendar.YEAR),
startCal.get(Calendar.MONTH), startCal.get(Calendar.DATE),
0, 0, 0);
}

startCal.set(Calendar.MILLISECOND, 0);
return startCal.getTime();
}

/**
* Gets the end range for a certain resolution. The range is inclusive, so
* if rangeEnd is set to zero milliseconds past year n and resolution is set
* to YEAR, any date in year n will be accepted. Resolutions lower than DAY
* will be interpreted on a DAY level. That is, everything below DATE is
* cleared
*
* @param forResolution
* - the range conforms to the resolution
* @return
*/
private Date getRangeEnd(Resolution forResolution) {
// We need to set the correct resolution for the dates,
// otherwise the range validator will complain

Date rangeEnd = getState(false).rangeEnd;
if (rangeEnd == null) {
return null;
}

Calendar endCal = Calendar.getInstance();
endCal.setTime(rangeEnd);

if (forResolution == Resolution.YEAR) {
// Adding one year (minresolution) and clearing the rest.
endCal.set(endCal.get(Calendar.YEAR) + 1, 0, 1, 0, 0, 0);
} else if (forResolution == Resolution.MONTH) {
// Adding one month (minresolution) and clearing the rest.
endCal.set(endCal.get(Calendar.YEAR),
endCal.get(Calendar.MONTH) + 1, 1, 0, 0, 0);
} else {
endCal.set(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH),
endCal.get(Calendar.DATE) + 1, 0, 0, 0);
}
// removing one millisecond will now get the endDate to return to
// current resolution's set time span (year or month)
endCal.set(Calendar.MILLISECOND, -1);
return endCal.getTime();
}

}

+ 59
- 784
server/src/main/java/com/vaadin/ui/DateField.java 파일 보기

@@ -15,124 +15,33 @@
*/
package com.vaadin.ui;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
import java.util.logging.Logger;

import org.jsoup.nodes.Element;

import com.vaadin.data.Result;
import com.vaadin.data.validator.DateRangeValidator;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.datefield.DateFieldConstants;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.shared.ui.datefield.TextualDateFieldState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.shared.ui.datefield.PopupDateFieldState;

/**
* A date editor component with <code>java.util.Date</code> as an input value.
*
* @author Vaadin Ltd
* A date entry component, which displays the actual date selector as a popup.
*
* @see AbstractDateField
* @see InlineDateField
* @author Vaadin Ltd.
* @since 8.0
*
*/
public class DateField extends AbstractField<Date> implements LegacyComponent {

/**
* Value of the field.
*/
private Date value;

/**
* Specified smallest modifiable unit for the date field.
*/
private Resolution resolution = Resolution.DAY;
public class DateField extends AbstractDateField {

/**
* The internal calendar to be used in java.utl.Date conversions.
*/
private transient Calendar calendar;
private String inputPrompt = null;

/**
* Overridden format string
*/
private String dateFormat;

private boolean lenient = false;

private String dateString = null;

private String currentParseErrorMessage;

/**
* Was the last entered string parsable? If this flag is false, datefields
* internal validator does not pass.
*/
private boolean uiHasValidDateString = true;

/**
* Determines if week numbers are shown in the date selector.
*/
private boolean showISOWeekNumbers = false;

private String defaultParseErrorMessage = "Date format not recognized";

private TimeZone timeZone = null;

private static Map<Resolution, String> variableNameForResolution = new HashMap<>();

private String dateOutOfRangeMessage = "Date is out of allowed range";

/**
* Determines whether the ValueChangeEvent should be fired. Used to prevent
* firing the event when UI has invalid string until uiHasValidDateString
* flag is set
*/
private boolean preventValueChangeEvent;

static {
variableNameForResolution.put(Resolution.SECOND, "sec");
variableNameForResolution.put(Resolution.MINUTE, "min");
variableNameForResolution.put(Resolution.HOUR, "hour");
variableNameForResolution.put(Resolution.DAY, "day");
variableNameForResolution.put(Resolution.MONTH, "month");
variableNameForResolution.put(Resolution.YEAR, "year");
}

/* Constructors */

/**
* Constructs an empty <code>DateField</code> with no caption.
* Constructs an empty <code>PopupDateField</code> with no caption.
*/
public DateField() {
super();
}

/**
* Constructs an empty <code>DateField</code> with caption.
*
* @param caption
* the caption of the datefield.
*/
public DateField(String caption) {
setCaption(caption);
}

/**
* Constructs a new <code>DateField</code> with the given caption and
* Constructs a new <code>PopupDateField</code> with the given caption and
* initial text contents.
*
* @param caption
@@ -141,736 +50,102 @@ public class DateField extends AbstractField<Date> implements LegacyComponent {
* the Date value.
*/
public DateField(String caption, Date value) {
setValue(value);
setCaption(caption);
}

/* Component basic features */

/*
* Paints this component. Don't add a JavaDoc comment here, we use the
* default documentation from implemented interface.
*/
@Override
public void paintContent(PaintTarget target) throws PaintException {

// Adds the locale as attribute
final Locale l = getLocale();
if (l != null) {
target.addAttribute("locale", l.toString());
}

if (getDateFormat() != null) {
target.addAttribute("format", dateFormat);
}

if (!isLenient()) {
target.addAttribute("strict", true);
}

target.addAttribute(DateFieldConstants.ATTR_WEEK_NUMBERS,
isShowISOWeekNumbers());
target.addAttribute("parsable", uiHasValidDateString);
/*
* TODO communicate back the invalid date string? E.g. returning back to
* app or refresh.
*/

// Gets the calendar
final Calendar calendar = getCalendar();
final Date currentDate = getValue();

// Only paint variables for the resolution and up, e.g. Resolution DAY
// paints DAY,MONTH,YEAR
for (Resolution res : Resolution
.getResolutionsHigherOrEqualTo(resolution)) {
int value = -1;
if (currentDate != null) {
value = calendar.get(res.getCalendarField());
if (res == Resolution.MONTH) {
// Calendar month is zero based
value++;
}
}
target.addVariable(this, variableNameForResolution.get(res), value);
}
}

/*
* Invoked when a variable of the component changes. Don't add a JavaDoc
* comment here, we use the default documentation from implemented
* interface.
*/
@Override
public void changeVariables(Object source, Map<String, Object> variables) {

if (!isReadOnly() && (variables.containsKey("year")
|| variables.containsKey("month")
|| variables.containsKey("day") || variables.containsKey("hour")
|| variables.containsKey("min") || variables.containsKey("sec")
|| variables.containsKey("msec")
|| variables.containsKey("dateString"))) {

// Old and new dates
final Date oldDate = getValue();
Date newDate = null;

// this enables analyzing invalid input on the server
final String newDateString = (String) variables.get("dateString");
dateString = newDateString;

// Gets the new date in parts
boolean hasChanges = false;
Map<Resolution, Integer> calendarFieldChanges = new HashMap<>();

for (Resolution r : Resolution
.getResolutionsHigherOrEqualTo(resolution)) {
// Only handle what the client is allowed to send. The same
// resolutions that are painted
String variableName = variableNameForResolution.get(r);

if (variables.containsKey(variableName)) {
Integer value = (Integer) variables.get(variableName);
if (r == Resolution.MONTH) {
// Calendar MONTH is zero based
value--;
}
if (value >= 0) {
hasChanges = true;
calendarFieldChanges.put(r, value);
}
}
}

// If no new variable values were received, use the previous value
if (!hasChanges) {
newDate = null;
} else {
// Clone the calendar for date operation
final Calendar cal = getCalendar();

// Update the value based on the received info
// Must set in this order to avoid invalid dates (or wrong
// dates if lenient is true) in calendar
for (int r = Resolution.YEAR.ordinal(); r >= 0; r--) {
Resolution res = Resolution.values()[r];
if (calendarFieldChanges.containsKey(res)) {

// Field resolution should be included. Others are
// skipped so that client can not make unexpected
// changes (e.g. day change even though resolution is
// year).
Integer newValue = calendarFieldChanges.get(res);
cal.set(res.getCalendarField(), newValue);
}
}
newDate = cal.getTime();
}

if (newDate == null && dateString != null
&& !dateString.isEmpty()) {
Result<Date> parsedDate = handleUnparsableDateString(
dateString);
if (parsedDate.isError()) {

/*
* Saves the localized message of parse error. This can be
* overridden in handleUnparsableDateString. The message
* will later be used to show a validation error.
*/
currentParseErrorMessage = parsedDate.getMessage().get();

/*
* The value of the DateField should be null if an invalid
* value has been given. Not using setValue() since we do
* not want to cause the client side value to change.
*/
uiHasValidDateString = false;

/*
* Datefield now contains some text that could't be parsed
* into date. ValueChangeEvent is fired after the value is
* changed and the flags are set
*/
if (oldDate != null) {
/*
* Set the logic value to null without firing the
* ValueChangeEvent
*/
preventValueChangeEvent = true;
try {
setValue(null);
} finally {
preventValueChangeEvent = false;
}

/*
* Reset the dateString (overridden to null by setValue)
*/
dateString = newDateString;
}

/*
* If value was changed fire the ValueChangeEvent
*/
if (oldDate != null) {
fireEvent(createValueChange(true));
}

markAsDirty();
} else {
parsedDate.ifOk(value -> setValue(value, true));

/*
* Ensure the value is sent to the client if the value is
* set to the same as the previous (#4304). Does not repaint
* if handleUnparsableDateString throws an exception. In
* this case the invalid text remains in the DateField.
*/
markAsDirty();
}

} else if (newDate != oldDate
&& (newDate == null || !newDate.equals(oldDate))) {
setValue(newDate, true); // Don't require a repaint, client
// updates itself
} else if (!uiHasValidDateString) { // oldDate ==
// newDate == null
// Empty value set, previously contained unparsable date string,
// clear related internal fields
setValue(null);
}
}

if (variables.containsKey(FocusEvent.EVENT_ID)) {
fireEvent(new FocusEvent(this));
}

if (variables.containsKey(BlurEvent.EVENT_ID)) {
fireEvent(new BlurEvent(this));
}
}

/**
* Sets the start range for this component. If the value is set before this
* date (taking the resolution into account), the component will not
* validate. If <code>startDate</code> is set to <code>null</code>, any
* value before <code>endDate</code> will be accepted by the range
*
* @param startDate
* - the allowed range's start date
*/
public void setRangeStart(Date startDate) {
if (startDate != null && getState().rangeEnd != null
&& startDate.after(getState().rangeEnd)) {
throw new IllegalStateException(
"startDate cannot be later than endDate");
}

// Create a defensive copy against issues when using java.sql.Date (and
// also against mutable Date).
getState().rangeStart = startDate != null
? new Date(startDate.getTime()) : null;
super(caption, value);
}

/**
* Sets the current error message if the range validation fails.
* Constructs an empty <code>PopupDateField</code> with caption.
*
* @param dateOutOfRangeMessage
* - Localizable message which is shown when value (the date) is
* set outside allowed range
*/
public void setDateOutOfRangeMessage(String dateOutOfRangeMessage) {
this.dateOutOfRangeMessage = dateOutOfRangeMessage;
}

/**
* Returns current date-out-of-range error message.
*
* @see #setDateOutOfRangeMessage(String)
* @return Current error message for dates out of range.
*/
public String getDateOutOfRangeMessage() {
return dateOutOfRangeMessage;
}

/**
* Gets the resolution.
*
* @return int
* @param caption
* the caption of the datefield.
*/
public Resolution getResolution() {
return resolution;
public DateField(String caption) {
super(caption);
}

/**
* Sets the resolution of the DateField.
*
* The default resolution is {@link Resolution#DAY} since Vaadin 7.0.
*
* @param resolution
* the resolution to set.
*/
public void setResolution(Resolution resolution) {
this.resolution = resolution;
markAsDirty();
}
@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);

/**
* Sets the end range for this component. If the value is set after this
* date (taking the resolution into account), the component will not
* validate. If <code>endDate</code> is set to <code>null</code>, any value
* after <code>startDate</code> will be accepted by the range.
*
* @param endDate
* - the allowed range's end date (inclusive, based on the
* current resolution)
*/
public void setRangeEnd(Date endDate) {
if (endDate != null && getState().rangeStart != null
&& getState().rangeStart.after(endDate)) {
throw new IllegalStateException(
"endDate cannot be earlier than startDate");
if (inputPrompt != null) {
target.addAttribute("prompt", inputPrompt);
}

// Create a defensive copy against issues when using java.sql.Date (and
// also against mutable Date).
getState().rangeEnd = endDate != null ? new Date(endDate.getTime())
: null;
}

/**
* Returns the precise rangeStart used.
* Gets the current input prompt.
*
* @return the precise rangeStart used
* @see #setInputPrompt(String)
* @return the current input prompt, or null if not enabled
*/
public Date getRangeStart() {
return getState(false).rangeStart;
public String getInputPrompt() {
return inputPrompt;
}

/**
* Returns the precise rangeEnd used.
* Sets the input prompt - a textual prompt that is displayed when the field
* would otherwise be empty, to prompt the user for input.
*
* @return the precise rangeEnd used
* @param inputPrompt
*/
public Date getRangeEnd() {
return getState(false).rangeEnd;
}

/**
* Sets formatting used by some component implementations. See
* {@link SimpleDateFormat} for format details.
*
* By default it is encouraged to used default formatting defined by Locale,
* but due some JVM bugs it is sometimes necessary to use this method to
* override formatting. See Vaadin issue #2200.
*
* @param dateFormat
* the dateFormat to set
*
* @see com.vaadin.ui.AbstractComponent#setLocale(Locale))
*/
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
public void setInputPrompt(String inputPrompt) {
this.inputPrompt = inputPrompt;
markAsDirty();
}

/**
* Returns a format string used to format date value on client side or null
* if default formatting from {@link Component#getLocale()} is used.
*
* @return the dateFormat
*/
public String getDateFormat() {
return dateFormat;
}

/**
* Specifies whether or not date/time interpretation in component is to be
* lenient.
*
* @see Calendar#setLenient(boolean)
* @see #isLenient()
*
* @param lenient
* true if the lenient mode is to be turned on; false if it is to
* be turned off.
*/
public void setLenient(boolean lenient) {
this.lenient = lenient;
markAsDirty();
}

/**
* Returns whether date/time interpretation is to be lenient.
*
* @see #setLenient(boolean)
*
* @return true if the interpretation mode of this calendar is lenient;
* false otherwise.
*/
public boolean isLenient() {
return lenient;
}

@Override
public Date getValue() {
return value;
protected PopupDateFieldState getState() {
return (PopupDateFieldState) super.getState();
}

@Override
public void setValue(Date value) {
/*
* First handle special case when the client side component have a date
* string but value is null (e.g. unparsable date string typed in by the
* user). No value changes should happen, but we need to do some
* internal housekeeping.
*/
if (value == null && !uiHasValidDateString) {
/*
* Side-effects of doSetValue clears possible previous strings and
* flags about invalid input.
*/
doSetValue(null);

markAsDirty();
return;
}
super.setValue(value);
}

/**
* Checks whether ISO 8601 week numbers are shown in the date selector.
*
* @return true if week numbers are shown, false otherwise.
*/
public boolean isShowISOWeekNumbers() {
return showISOWeekNumbers;
}

/**
* Sets the visibility of ISO 8601 week numbers in the date selector. ISO
* 8601 defines that a week always starts with a Monday so the week numbers
* are only shown if this is the case.
*
* @param showWeekNumbers
* true if week numbers should be shown, false otherwise.
*/
public void setShowISOWeekNumbers(boolean showWeekNumbers) {
showISOWeekNumbers = showWeekNumbers;
markAsDirty();
}

/**
* Returns new instance calendar used in Date conversions.
*
* Returns new clone of the calendar object initialized using the the
* current date (if available)
*
* If this is no calendar is assigned the <code>Calendar.getInstance</code>
* is used.
*
* @return the Calendar.
* @see #setCalendar(Calendar)
*/
private Calendar getCalendar() {

// Makes sure we have an calendar instance
if (calendar == null) {
calendar = Calendar.getInstance();
// Start by a zeroed calendar to avoid having values for lower
// resolution variables e.g. time when resolution is day
int min, field;
for (Resolution r : Resolution
.getResolutionsLowerThan(resolution)) {
field = r.getCalendarField();
min = calendar.getActualMinimum(field);
calendar.set(field, min);
}
calendar.set(Calendar.MILLISECOND, 0);
}

// Clone the instance
final Calendar newCal = (Calendar) calendar.clone();

final TimeZone currentTimeZone = getTimeZone();
if (currentTimeZone != null) {
newCal.setTimeZone(currentTimeZone);
}

final Date currentDate = getValue();
if (currentDate != null) {
newCal.setTime(currentDate);
}
return newCal;
}

/**
* Gets the time zone used by this field. The time zone is used to convert
* the absolute time in a Date object to a logical time displayed in the
* selector and to convert the select time back to a Date object.
*
* If {@code null} is returned, the current default time zone returned by
* {@code TimeZone.getDefault()} is used.
*
* @return the current time zone
*/
public TimeZone getTimeZone() {
return timeZone;
}

/**
* Return the error message that is shown if the user inputted value can't
* be parsed into a Date object. If
* {@link #handleUnparsableDateString(String)} is overridden and it throws a
* custom exception, the message returned by
* {@link Exception#getLocalizedMessage()} will be used instead of the value
* returned by this method.
*
* @see #setParseErrorMessage(String)
*
* @return the error message that the DateField uses when it can't parse the
* textual input from user to a Date object
*/
public String getParseErrorMessage() {
return defaultParseErrorMessage;
}

/**
* Sets the default error message used if the DateField cannot parse the
* text input by user to a Date field. Note that if the
* {@link #handleUnparsableDateString(String)} method is overridden, the
* localized message from its exception is used.
*
* @see #getParseErrorMessage()
* @see #handleUnparsableDateString(String)
* @param parsingErrorMessage
*/
public void setParseErrorMessage(String parsingErrorMessage) {
defaultParseErrorMessage = parsingErrorMessage;
}

/**
* Sets the time zone used by this date field. The time zone is used to
* convert the absolute time in a Date object to a logical time displayed in
* the selector and to convert the select time back to a Date object.
*
* If no time zone has been set, the current default time zone returned by
* {@code TimeZone.getDefault()} is used.
*
* @see #getTimeZone()
* @param timeZone
* the time zone to use for time calculations.
*/
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
markAsDirty();
}

/**
* Adds a <code>FocusListener</code> to the Component which gets fired when
* a <code>LegacyField</code> receives keyboard focus.
*
* @param listener
* @see FocusListener
*/
public void addFocusListener(FocusListener listener) {
addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
FocusListener.focusMethod);
protected PopupDateFieldState getState(boolean markAsDirty) {
return (PopupDateFieldState) super.getState(markAsDirty);
}

/**
* Removes a <code>FocusListener</code> from the Component.
* Checks whether the text field is enabled (default) or not.
*
* @param listener
* @see FocusListener
*/
public void removeFocusListener(FocusListener listener) {
removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
}

/**
* Adds a <code>BlurListener</code> to the Component which gets fired when a
* <code>LegacyField</code> loses keyboard focus.
* @see PopupDateField#setTextFieldEnabled(boolean);
*
* @param listener
* @see BlurListener
* @return <b>true</b> if the text field is enabled, <b>false</b> otherwise.
*/
public void addBlurListener(BlurListener listener) {
addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
BlurListener.blurMethod);
}

/**
* Removes a <code>BlurListener</code> from the Component.
*
* @param listener
* @see BlurListener
*/
public void removeBlurListener(BlurListener listener) {
removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
}

@Override
public void readDesign(Element design, DesignContext designContext) {
super.readDesign(design, designContext);
if (design.hasAttr("value") && !design.attr("value").isEmpty()) {
Date date = DesignAttributeHandler.getFormatter()
.parse(design.attr("value"), Date.class);
// formatting will return null if it cannot parse the string
if (date == null) {
Logger.getLogger(DateField.class.getName()).info(
"cannot parse " + design.attr("value") + " as date");
}
setValue(date);
}
}

@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
if (getValue() != null) {
design.attr("value",
DesignAttributeHandler.getFormatter().format(getValue()));
}
}

@Override
protected void fireEvent(EventObject event) {
if (event instanceof ValueChange) {
if (!preventValueChangeEvent) {
super.fireEvent(event);
}
} else {
super.fireEvent(event);
}
public boolean isTextFieldEnabled() {
return getState(false).textFieldEnabled;
}

/**
* This method is called to handle a non-empty date string from the client
* if the client could not parse it as a Date.
*
* By default, an error result is returned whose error message is
* {@link #getParseErrorMessage()}.
* Enables or disables the text field. By default the text field is enabled.
* Disabling it causes only the button for date selection to be active, thus
* preventing the user from entering invalid dates.
*
* This can be overridden to handle conversions, to return a result with
* {@code null} value (equivalent to empty input) or to return a custom
* error.
* See {@link http://dev.vaadin.com/ticket/6790}.
*
* @param dateString
* date string to handle
* @return result that contains parsed Date as a value or an error
* @param state
* <b>true</b> to enable text field, <b>false</b> to disable it.
*/
protected Result<Date> handleUnparsableDateString(String dateString) {
return Result.error(getParseErrorMessage());
}

@Override
protected TextualDateFieldState getState() {
return (TextualDateFieldState) super.getState();
}

@Override
protected TextualDateFieldState getState(boolean markAsDirty) {
return (TextualDateFieldState) super.getState(markAsDirty);
}

@Override
protected void doSetValue(Date value) {
// Also set the internal dateString
if (value != null) {
dateString = value.toString();
} else {
dateString = null;
}

this.value = value;
setComponentError(null);
if (!uiHasValidDateString) {
// clear component error and parsing flag
uiHasValidDateString = true;
setComponentError(new UserError(currentParseErrorMessage));
} else {
DateRangeValidator validator = new DateRangeValidator(
getDateOutOfRangeMessage(), getRangeStart(getResolution()),
getRangeEnd(getResolution()), getResolution());
Result<Date> result = validator.apply(value);
if (result.isError()) {
setComponentError(new UserError(getDateOutOfRangeMessage()));
}
}
public void setTextFieldEnabled(boolean state) {
getState().textFieldEnabled = state;
}

/**
* Gets the start range for a certain resolution. The range is inclusive, so
* if <code>rangeStart</code> is set to one millisecond before year n and
* resolution is set to YEAR, any date in year n - 1 will be accepted.
* Lowest supported resolution is DAY.
* Set a description that explains the usage of the Widget for users of
* assistive devices.
*
* @param forResolution
* - the range conforms to the resolution
* @return
* @param description
* String with the description
*/
private Date getRangeStart(Resolution forResolution) {
if (getState(false).rangeStart == null) {
return null;
}
Calendar startCal = Calendar.getInstance();
startCal.setTime(getState(false).rangeStart);

if (forResolution == Resolution.YEAR) {
startCal.set(startCal.get(Calendar.YEAR), 0, 1, 0, 0, 0);
} else if (forResolution == Resolution.MONTH) {
startCal.set(startCal.get(Calendar.YEAR),
startCal.get(Calendar.MONTH), 1, 0, 0, 0);
} else {
startCal.set(startCal.get(Calendar.YEAR),
startCal.get(Calendar.MONTH), startCal.get(Calendar.DATE),
0, 0, 0);
}

startCal.set(Calendar.MILLISECOND, 0);
return startCal.getTime();
public void setAssistiveText(String description) {
getState().descriptionForAssistiveDevices = description;
}

/**
* Gets the end range for a certain resolution. The range is inclusive, so
* if rangeEnd is set to zero milliseconds past year n and resolution is set
* to YEAR, any date in year n will be accepted. Resolutions lower than DAY
* will be interpreted on a DAY level. That is, everything below DATE is
* cleared
* Get the description that explains the usage of the Widget for users of
* assistive devices.
*
* @param forResolution
* - the range conforms to the resolution
* @return
* @return String with the description
*/
private Date getRangeEnd(Resolution forResolution) {
// We need to set the correct resolution for the dates,
// otherwise the range validator will complain

Date rangeEnd = getState(false).rangeEnd;
if (rangeEnd == null) {
return null;
}

Calendar endCal = Calendar.getInstance();
endCal.setTime(rangeEnd);

if (forResolution == Resolution.YEAR) {
// Adding one year (minresolution) and clearing the rest.
endCal.set(endCal.get(Calendar.YEAR) + 1, 0, 1, 0, 0, 0);
} else if (forResolution == Resolution.MONTH) {
// Adding one month (minresolution) and clearing the rest.
endCal.set(endCal.get(Calendar.YEAR),
endCal.get(Calendar.MONTH) + 1, 1, 0, 0, 0);
} else {
endCal.set(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH),
endCal.get(Calendar.DATE) + 1, 0, 0, 0);
}
// removing one millisecond will now get the endDate to return to
// current resolution's set time span (year or month)
endCal.set(Calendar.MILLISECOND, -1);
return endCal.getTime();
public String getAssistiveText() {
return getState(false).descriptionForAssistiveDevices;
}

}

+ 2
- 2
server/src/main/java/com/vaadin/ui/InlineDateField.java 파일 보기

@@ -20,12 +20,12 @@ import java.util.Date;
/**
* A date entry component, which displays the actual date selector inline.
*
* @see AbstractDateField
* @see DateField
* @see PopupDateField
* @author Vaadin Ltd.
* @since 8.0
*/
public class InlineDateField extends DateField {
public class InlineDateField extends AbstractDateField {

/**
* Constructs an empty <code>DateField</code> with no caption.

+ 0
- 151
server/src/main/java/com/vaadin/ui/PopupDateField.java 파일 보기

@@ -1,151 +0,0 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.ui;

import java.util.Date;

import com.vaadin.server.PaintException;
import com.vaadin.server.PaintTarget;
import com.vaadin.shared.ui.datefield.PopupDateFieldState;

/**
* A date entry component, which displays the actual date selector as a popup.
*
* @see DateField
* @see InlineDateField
* @author Vaadin Ltd.
* @since 8.0
*/
public class PopupDateField extends DateField {

private String inputPrompt = null;

/**
* Constructs an empty <code>PopupDateField</code> with no caption.
*/
public PopupDateField() {
super();
}

/**
* Constructs a new <code>PopupDateField</code> with the given caption and
* initial text contents.
*
* @param caption
* the caption <code>String</code> for the editor.
* @param value
* the Date value.
*/
public PopupDateField(String caption, Date value) {
super(caption, value);
}

/**
* Constructs an empty <code>PopupDateField</code> with caption.
*
* @param caption
* the caption of the datefield.
*/
public PopupDateField(String caption) {
super(caption);
}

@Override
public void paintContent(PaintTarget target) throws PaintException {
super.paintContent(target);

if (inputPrompt != null) {
target.addAttribute("prompt", inputPrompt);
}
}

/**
* Gets the current input prompt.
*
* @see #setInputPrompt(String)
* @return the current input prompt, or null if not enabled
*/
public String getInputPrompt() {
return inputPrompt;
}

/**
* Sets the input prompt - a textual prompt that is displayed when the field
* would otherwise be empty, to prompt the user for input.
*
* @param inputPrompt
*/
public void setInputPrompt(String inputPrompt) {
this.inputPrompt = inputPrompt;
markAsDirty();
}

@Override
protected PopupDateFieldState getState() {
return (PopupDateFieldState) super.getState();
}

@Override
protected PopupDateFieldState getState(boolean markAsDirty) {
return (PopupDateFieldState) super.getState(markAsDirty);
}

/**
* Checks whether the text field is enabled (default) or not.
*
* @see PopupDateField#setTextFieldEnabled(boolean);
*
* @return <b>true</b> if the text field is enabled, <b>false</b> otherwise.
*/
public boolean isTextFieldEnabled() {
return getState(false).textFieldEnabled;
}

/**
* Enables or disables the text field. By default the text field is enabled.
* Disabling it causes only the button for date selection to be active, thus
* preventing the user from entering invalid dates.
*
* See {@link http://dev.vaadin.com/ticket/6790}.
*
* @param state
* <b>true</b> to enable text field, <b>false</b> to disable it.
*/
public void setTextFieldEnabled(boolean state) {
getState().textFieldEnabled = state;
}

/**
* Set a description that explains the usage of the Widget for users of
* assistive devices.
*
* @param description
* String with the description
*/
public void setAssistiveText(String description) {
getState().descriptionForAssistiveDevices = description;
}

/**
* Get the description that explains the usage of the Widget for users of
* assistive devices.
*
* @return String with the description
*/
public String getAssistiveText() {
return getState(false).descriptionForAssistiveDevices;
}
}

+ 5
- 5
server/src/test/java/com/vaadin/data/BinderBookOfVaadinTest.java 파일 보기

@@ -35,7 +35,7 @@ import com.vaadin.server.AbstractErrorMessage;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Slider;
import com.vaadin.ui.TextField;

@@ -301,8 +301,8 @@ public class BinderBookOfVaadinTest {
@Test
public void crossFieldValidation_validateUsingBinder() {
Binder<Trip> binder = new Binder<>();
PopupDateField departing = new PopupDateField("Departing");
PopupDateField returning = new PopupDateField("Returning");
DateField departing = new DateField("Departing");
DateField returning = new DateField("Returning");

Binding<Trip, Date, Date> returnBinding = binder.forField(returning)
.withValidator(
@@ -356,8 +356,8 @@ public class BinderBookOfVaadinTest {
@Test
public void crossFieldValidation_validateUsingBinding() {
Binder<Trip> binder = new Binder<>();
PopupDateField departing = new PopupDateField("Departing");
PopupDateField returning = new PopupDateField("Returning");
DateField departing = new DateField("Departing");
DateField returning = new DateField("Returning");

Binding<Trip, Date, Date> returnBinding = binder.forField(returning)
.withValidator(

+ 22
- 70
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java 파일 보기

@@ -15,97 +15,49 @@
*/
package com.vaadin.tests.server.component.datefield;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.junit.Test;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.DateField;

/**
* Tests the declarative support for implementations of {@link DateField}.
* Tests the declarative support for implementations of
* {@link AbstractDateField}.
*
* @author Vaadin Ltd
* @since 7.4
* @author Vaadin Ltd
*/
public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> {
public class DateFieldDeclarativeTest
extends DeclarativeTestBase<DateField> {

private String getYearResolutionDesign() {
return "<vaadin-date-field resolution='year' value='2020'/>";
private String getBasicDesign() {
return "<vaadin-date-field assistive-text='at' text-field-enabled='false' show-iso-week-numbers resolution=\"MINUTE\" range-end=\"2019-01-15\" input-prompt=\"Pick a day\" value=\"2003-02-27 07:15\"></vaadin-date-field>";
}

private DateField getYearResolutionExpected() {
DateField df = new DateField();
df.setResolution(Resolution.YEAR);
df.setValue(new Date(2020 - 1900, 1 - 1, 1));
return df;
}

private String getTimezoneDesign() {
String timeZone = new SimpleDateFormat("Z").format(new Date());
return String.format(
"<vaadin-date-field range-start=\"2014-05-05 00:00:00%1$s\" range-end=\"2014-06-05 00:00:00%1$s\" date-out-of-range-message=\"Please select a sensible date\" date-format=\"yyyy-MM-dd\" lenient show-iso-week-numbers parse-error-message=\"You are doing it wrong\" time-zone=\"GMT+05:00\" value=\"2014-05-15 00:00:00%1$s\"/>",
timeZone);
}

private DateField getTimezoneExpected() {
DateField df = new DateField();

df.setRangeStart(new Date(2014 - 1900, 5 - 1, 5));
df.setRangeEnd(new Date(2014 - 1900, 6 - 1, 5));
df.setDateOutOfRangeMessage("Please select a sensible date");
df.setResolution(Resolution.DAY);
df.setDateFormat("yyyy-MM-dd");
df.setLenient(true);
df.setShowISOWeekNumbers(true);
df.setParseErrorMessage("You are doing it wrong");
df.setTimeZone(TimeZone.getTimeZone("GMT+5"));
df.setValue(new Date(2014 - 1900, 5 - 1, 15));

return df;
private DateField getBasicExpected() {
DateField pdf = new DateField();
pdf.setShowISOWeekNumbers(true);
pdf.setResolution(Resolution.MINUTE);
pdf.setRangeEnd(new Date(2019 - 1900, 1 - 1, 15));
pdf.setInputPrompt("Pick a day");
pdf.setValue(new Date(2003 - 1900, 2 - 1, 27, 7, 15));
pdf.setTextFieldEnabled(false);
pdf.setAssistiveText("at");
return pdf;
}

@Test
public void readTimezone() {
testRead(getTimezoneDesign(), getTimezoneExpected());
public void readBasic() throws Exception {
testRead(getBasicDesign(), getBasicExpected());
}

@Test
public void writeTimezone() {
testWrite(getTimezoneDesign(), getTimezoneExpected());
public void writeBasic() throws Exception {
testRead(getBasicDesign(), getBasicExpected());
}

@Test
public void readYearResolution() {
testRead(getYearResolutionDesign(), getYearResolutionExpected());
}

@Test
public void writeYearResolution() {
// Writing is always done in full resolution..
String timeZone = new SimpleDateFormat("Z")
.format(new Date(2020 - 1900, 1 - 1, 1));
testWrite(
getYearResolutionDesign().replace("2020",
"2020-01-01 00:00:00" + timeZone),
getYearResolutionExpected());
}

@Test
public void testReadOnlyValue() {
Date date = new Date(2020 - 1900, 1 - 1, 1);
String timeZone = new SimpleDateFormat("Z").format(date);
String design = "<vaadin-date-field readonly resolution='year' value='2020-01-01 00:00:00"
+ timeZone + "'/>";
DateField df = new DateField();
df.setResolution(Resolution.YEAR);
df.setValue(date);
df.setReadOnly(true);

testRead(design, df);
testWrite(design, df);
}
}

+ 7
- 3
server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java 파일 보기

@@ -7,19 +7,23 @@ import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;

public class DateFieldListenersTest extends AbstractListenerMethodsTestBase {

public static class TestDateField extends AbstractDateField {

}

@Test
public void testFocusListenerAddGetRemove() throws Exception {
testListenerAddGetRemove(DateField.class, FocusEvent.class,
testListenerAddGetRemove(TestDateField.class, FocusEvent.class,
FocusListener.class);
}

@Test
public void testBlurListenerAddGetRemove() throws Exception {
testListenerAddGetRemove(DateField.class, BlurEvent.class,
testListenerAddGetRemove(TestDateField.class, BlurEvent.class,
BlurListener.class);
}
}

+ 2
- 2
server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java 파일 보기

@@ -23,12 +23,12 @@ import org.junit.Test;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.declarative.Design;

/**
* Tests the declarative support for implementations of {@link DateField}.
* Tests the declarative support for implementations of {@link AbstractDateField}.
*
* @since 7.4
* @author Vaadin Ltd

+ 0
- 62
server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java 파일 보기

@@ -1,62 +0,0 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.server.component.datefield;

import java.util.Date;

import org.junit.Test;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.DateField;
import com.vaadin.ui.PopupDateField;

/**
* Tests the declarative support for implementations of {@link DateField}.
*
* @since 7.4
* @author Vaadin Ltd
*/
public class PopupDateFieldDeclarativeTest
extends DeclarativeTestBase<PopupDateField> {

private String getBasicDesign() {
return "<vaadin-popup-date-field assistive-text='at' text-field-enabled='false' show-iso-week-numbers resolution=\"MINUTE\" range-end=\"2019-01-15\" input-prompt=\"Pick a day\" value=\"2003-02-27 07:15\"></vaadin-popup-date-field>";
}

private PopupDateField getBasicExpected() {
PopupDateField pdf = new PopupDateField();
pdf.setShowISOWeekNumbers(true);
pdf.setResolution(Resolution.MINUTE);
pdf.setRangeEnd(new Date(2019 - 1900, 1 - 1, 15));
pdf.setInputPrompt("Pick a day");
pdf.setValue(new Date(2003 - 1900, 2 - 1, 27, 7, 15));
pdf.setTextFieldEnabled(false);
pdf.setAssistiveText("at");
return pdf;
}

@Test
public void readBasic() throws Exception {
testRead(getBasicDesign(), getBasicExpected());
}

@Test
public void writeBasic() throws Exception {
testRead(getBasicDesign(), getBasicExpected());
}

}

+ 3
- 2
server/src/test/java/com/vaadin/ui/DateFieldTestCase.java 파일 보기

@@ -11,12 +11,13 @@ import org.junit.Test;

public class DateFieldTestCase {

private DateField dateField;
private AbstractDateField dateField;
private Date date;

@Before
public void setup() {
dateField = new DateField();
dateField = new AbstractDateField() {
};
date = new Date();
}


+ 7
- 0
uitest-common/src/main/java/com/vaadin/testbench/customelements/AbstractDateFieldElement.java 파일 보기

@@ -0,0 +1,7 @@
package com.vaadin.testbench.customelements;

import com.vaadin.testbench.elementsbase.ServerClass;

@ServerClass("com.vaadin.ui.AbstractDateField")
public class AbstractDateFieldElement extends DateFieldElement {
}

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/FocusingComponents.java 파일 보기

@@ -1,9 +1,9 @@
package com.vaadin.tests;

import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.v7.ui.AbstractSelect;
import com.vaadin.v7.ui.ComboBox;
@@ -31,7 +31,7 @@ public class FocusingComponents extends CustomComponent {
addFocusableTest(f);
addFocusableTest(new ComboBox());
addFocusableTest(new TextField());
addFocusableTest(new DateField());
addFocusableTest(new TestDateField());
addFocusableTest(new NativeSelect());
addFocusableTest(new ListSelect());
addFocusableTest(new OptionGroup());

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/PerformanceTestBasicComponentRendering.java 파일 보기

@@ -21,9 +21,9 @@ import java.util.Map;

import com.vaadin.server.UserError;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
@@ -85,7 +85,7 @@ public class PerformanceTestBasicComponentRendering extends CustomComponent {
tf.setComponentError(new UserError("dsfjklsdf"));
testContainer.addComponent(tf);

testContainer.addComponent(new DateField("DateField" + i));
testContainer.addComponent(new TestDateField("DateField" + i));

testContainer.addComponent(new Button("Button" + i));


+ 7
- 6
uitest/src/main/java/com/vaadin/tests/RandomLayoutStress.java 파일 보기

@@ -19,10 +19,11 @@ package com.vaadin.tests;
import java.util.Random;

import com.vaadin.server.ExternalResource;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
@@ -181,15 +182,15 @@ public class RandomLayoutStress extends com.vaadin.server.LegacyApplication {
break;
case 6:
// Datefield
result = new DateField();
((DateField) result).setStyleName("calendar");
((DateField) result).setValue(new java.util.Date());
result = new TestDateField();
((AbstractDateField) result).setStyleName("calendar");
((AbstractDateField) result).setValue(new java.util.Date());
result.setCaption("Calendar component " + caption);
break;
case 7:
// Datefield
result = new DateField();
((DateField) result).setValue(new java.util.Date());
result = new TestDateField();
((AbstractDateField) result).setValue(new java.util.Date());
result.setCaption("Calendar component " + caption);
break;
}

+ 4
- 3
uitest/src/main/java/com/vaadin/tests/TestCaptionWrapper.java 파일 보기

@@ -21,18 +21,20 @@ import com.vaadin.server.ErrorMessage;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component.Listener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Upload;
@@ -41,7 +43,6 @@ import com.vaadin.ui.Window;
import com.vaadin.v7.ui.NativeSelect;
import com.vaadin.v7.ui.OptionGroup;
import com.vaadin.v7.ui.ProgressIndicator;
import com.vaadin.ui.RichTextArea;
import com.vaadin.v7.ui.Select;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.TextField;
@@ -119,7 +120,7 @@ public class TestCaptionWrapper extends CustomComponent implements Listener {
test(layout, button);
button.addListener(this);

final DateField df = new DateField("DateField " + count++);
final AbstractDateField df = new TestDateField("DateField " + count++);
test(layout, df);

final CheckBox cb = new CheckBox("Checkbox " + count++);

+ 11
- 7
uitest/src/main/java/com/vaadin/tests/TestDateField.java 파일 보기

@@ -21,8 +21,8 @@ import java.util.Locale;
import com.vaadin.server.ClassResource;
import com.vaadin.server.ErrorMessage;
import com.vaadin.server.UserError;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

@@ -34,7 +34,7 @@ public class TestDateField extends CustomComponent {

VerticalLayout main = new VerticalLayout();

DateField df;
AbstractDateField df;

public TestDateField() {
setCompositionRoot(main);
@@ -45,7 +45,7 @@ public class TestDateField extends CustomComponent {
main.removeAllComponents();
main.addComponent(new Label("DateField"));

df = new DateField();
df = new com.vaadin.tests.components.TestDateField();
main.addComponent(df);

final ErrorMessage errorMsg = new UserError("User error " + df);
@@ -58,19 +58,23 @@ public class TestDateField extends CustomComponent {
df.addStyleName("thisShouldBeHarmless");

// Another test: locale
final DateField df1 = new DateField("US locale");
final AbstractDateField df1 = new com.vaadin.tests.components.TestDateField(
"US locale");
main.addComponent(df1);
df1.setLocale(new Locale("en", "US"));

final DateField df2 = new DateField("DE locale");
final AbstractDateField df2 = new com.vaadin.tests.components.TestDateField(
"DE locale");
main.addComponent(df2);
df2.setLocale(new Locale("de", "DE"));

final DateField df3 = new DateField("RU locale");
final AbstractDateField df3 = new com.vaadin.tests.components.TestDateField(
"RU locale");
main.addComponent(df3);
df3.setLocale(new Locale("ru", "RU"));

final DateField df4 = new DateField("FI locale");
final AbstractDateField df4 = new com.vaadin.tests.components.TestDateField(
"FI locale");
main.addComponent(df4);
df4.setLocale(new Locale("fi", "FI"));
}

+ 4
- 3
uitest/src/main/java/com/vaadin/tests/TestForAlignments.java 파일 보기

@@ -16,10 +16,11 @@

package com.vaadin.tests;

import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.TextField;
@@ -36,8 +37,8 @@ public class TestForAlignments extends CustomComponent {
final Button b4 = new Button("Top");
final TextField t1 = new TextField("Right aligned");
final TextField t2 = new TextField("Bottom aligned");
final DateField d1 = new DateField("Center aligned");
final DateField d2 = new DateField("Center aligned");
final AbstractDateField d1 = new TestDateField("Center aligned");
final AbstractDateField d2 = new TestDateField("Center aligned");

final VerticalLayout vert = new VerticalLayout();
vert.addComponent(b1);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/TestForBasicApplicationLayout.java 파일 보기

@@ -20,11 +20,12 @@ import java.util.Locale;

import com.vaadin.server.Sizeable;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
@@ -81,7 +82,7 @@ public class TestForBasicApplicationLayout extends CustomComponent {
controls.addComponent(click);
controls.addComponent(click2);
reportLayout.addComponent(controls);
final DateField cal = new DateField();
final AbstractDateField cal = new TestDateField();
cal.setResolution(Resolution.DAY);
cal.setLocale(new Locale("en", "US"));
reportLayout.addComponent(cal);

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/TestSelectAndDatefieldInDeepLayouts.java 파일 보기

@@ -19,11 +19,11 @@ package com.vaadin.tests;
import java.util.Collection;
import java.util.Vector;

import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.Select;
@@ -99,7 +99,7 @@ public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent {
}

Component getDateField() {
return new DateField(getCaption("datefield"));
return new TestDateField(getCaption("datefield"));
}

private Collection<String> getSelectOptions() {

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/AbstractComponentContainerTest.java 파일 보기

@@ -14,7 +14,7 @@ import com.vaadin.ui.HasComponents.ComponentDetachListener;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalSplitPanel;
import com.vaadin.ui.RichTextArea;
@@ -85,7 +85,7 @@ public abstract class AbstractComponentContainerTest<T extends AbstractComponent
private Command<T, ComponentSize> addPopupDateFieldCommand = new Command<T, ComponentSize>() {
@Override
public void execute(T c, ComponentSize size, Object data) {
PopupDateField tf = new PopupDateField();
DateField tf = new DateField();
c.addComponent(tf);
size.apply(tf);
}

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/FocusAndBlurListeners.java 파일 보기

@@ -6,12 +6,12 @@ import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.NativeButton;
@@ -49,7 +49,7 @@ public class FocusAndBlurListeners extends TestBase {
TextField tf = new TextField("TextField");
l.addComponent(tf);

DateField df = new DateField("DateField");
AbstractDateField df = new TestDateField("DateField");
l.addComponent(df);

ComboBox cb = new ComboBox("ComboBox");

+ 57
- 0
uitest/src/main/java/com/vaadin/tests/components/TestDateField.java 파일 보기

@@ -0,0 +1,57 @@
/*
* Copyright 2000-2016 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.components;

import java.util.Date;

import com.vaadin.ui.AbstractDateField;

/**
* @author Vaadin Ltd
*
*/
public class TestDateField extends AbstractDateField {

/**
* Constructs an empty <code>DateField</code> with no caption.
*/
public TestDateField() {
}

/**
* Constructs an empty <code>DateField</code> with caption.
*
* @param caption
* the caption of the datefield.
*/
public TestDateField(String caption) {
setCaption(caption);
}

/**
* Constructs a new <code>DateField</code> with the given caption and
* initial text contents.
*
* @param caption
* the caption <code>String</code> for the editor.
* @param value
* the Date value.
*/
public TestDateField(String caption, Date value) {
setValue(value);
setCaption(caption);
}
}

+ 146
- 0
uitest/src/main/java/com/vaadin/tests/components/datefield/AbstractDateFieldTest.java 파일 보기

@@ -0,0 +1,146 @@
package com.vaadin.tests.components.datefield;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.AbstractDateField;

public class AbstractDateFieldTest<T extends AbstractDateField>
extends AbstractFieldTest<T, Date> {

@SuppressWarnings("unchecked")
@Override
protected Class<T> getTestClass() {
return (Class<T>) TestDateField.class;
}

private Command<T, Date> setValue = new Command<T, Date>() {

@Override
public void execute(T c, Date value, Object data) {
c.setValue(value);
}
};

@Override
protected void createActions() {
super.createActions();
createResolutionSelectAction(CATEGORY_FEATURES);
createBooleanAction("Lenient", CATEGORY_FEATURES, false,
lenientCommand);
createBooleanAction("Show week numbers", CATEGORY_FEATURES, false,
weekNumberCommand);
createDateFormatSelectAction(CATEGORY_FEATURES);
createSetValueAction(CATEGORY_FEATURES);

}

private void createSetValueAction(String category) {
LinkedHashMap<String, Date> options = new LinkedHashMap<>();
options.put("(null)", null);
options.put("(current time)", new Date());
Calendar c = Calendar.getInstance(new Locale("fi", "FI"));
c.clear();
c.set(2010, 12 - 1, 12, 12, 0, 0);
c.set(Calendar.MILLISECOND, 0);
options.put("2010-12-12 12:00:00.000", c.getTime());
c.clear();
c.set(2000, 1 - 1, 2, 3, 4, 5);
c.set(Calendar.MILLISECOND, 6);
options.put("2000-01-02 03:04:05.006", c.getTime());
createMultiClickAction("Set value", category, options, setValue, null);
}

private void createDateFormatSelectAction(String category) {
LinkedHashMap<String, String> options = new LinkedHashMap<>();

options.put("-", null);
options.put("d M yyyy", "d M yyyy");
options.put("d MM yyyy", "d MM yyyy");
options.put("d MMM yyyy", "d MMM yyyy");
options.put("d MMMM yyyy", "d MMMM yyyy");
options.put("dd M yyyy", "dd M yyyy");
options.put("ddd M yyyy", "ddd M yyyy");
options.put("d M y", "d M y");
options.put("d M yy", "d M yy");
options.put("d M yyy", "d M yyy");
options.put("d M yyyy", "d M yyyy");
options.put("d M 'custom text' yyyy", "d M 'custom text' yyyy");
options.put("'day:'d', month:'M', year: 'yyyy",
"'day:'d', month:'M', year: 'yyyy");
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.LONG),
getDatePattern(new Locale("fi", "FI"), DateFormat.LONG));
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM),
getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM));
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT),
getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT));

createSelectAction("Date format", category, options, "-",
dateFormatCommand);

}

private String getDatePattern(Locale locale, int dateStyle) {
DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);

if (dateFormat instanceof SimpleDateFormat) {
String pattern = ((SimpleDateFormat) dateFormat).toPattern();
return pattern;
}
return null;

}

private void createResolutionSelectAction(String category) {
LinkedHashMap<String, Resolution> options = new LinkedHashMap<>();
options.put("Year", Resolution.YEAR);
options.put("Month", Resolution.MONTH);
options.put("Day", Resolution.DAY);
options.put("Hour", Resolution.HOUR);
options.put("Min", Resolution.MINUTE);
options.put("Sec", Resolution.SECOND);

createSelectAction("Resolution", category, options, "Year",
resolutionCommand);
}

private Command<T, Resolution> resolutionCommand = new Command<T, Resolution>() {

@Override
public void execute(T c, Resolution value, Object data) {
c.setResolution(value);

}
};
private Command<T, Boolean> lenientCommand = new Command<T, Boolean>() {

@Override
public void execute(T c, Boolean value, Object data) {
c.setLenient(false);

}
};
private Command<T, Boolean> weekNumberCommand = new Command<T, Boolean>() {

@Override
public void execute(T c, Boolean value, Object data) {
c.setShowISOWeekNumbers(value);

}
};
private Command<T, String> dateFormatCommand = new Command<T, String>() {

@Override
public void execute(T c, String value, Object data) {
c.setDateFormat(value);
}
};

}

+ 5
- 3
uitest/src/main/java/com/vaadin/tests/components/datefield/AriaDisabled.java 파일 보기

@@ -17,7 +17,8 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.VerticalLayout;

public class AriaDisabled extends AbstractTestUI {
@@ -28,12 +29,13 @@ public class AriaDisabled extends AbstractTestUI {
content.setMargin(true);
content.setSpacing(true);

final DateField disabledDateField = new DateField("Disabled DateField");
final AbstractDateField disabledDateField = new TestDateField(
"Disabled DateField");
disabledDateField.setEnabled(false);

setContent(content);
content.addComponent(disabledDateField);
content.addComponent(new DateField("Enabled DateField"));
content.addComponent(new TestDateField("Enabled DateField"));
}

@Override

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormat.java 파일 보기

@@ -5,7 +5,8 @@ import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class CustomDateFormat extends TestBase {

@@ -16,7 +17,7 @@ public class CustomDateFormat extends TestBase {
Calendar cal = Calendar.getInstance();
cal.set(2010, 0, 1);

DateField df = new DateField();
AbstractDateField df = new TestDateField();
df.setResolution(Resolution.DAY);
df.setLocale(locale);
df.setWidth("300px");

+ 4
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormatEEE.java 파일 보기

@@ -21,7 +21,8 @@ import java.util.Locale;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.VerticalLayout;

public class CustomDateFormatEEE extends AbstractTestUI {
@@ -31,7 +32,8 @@ public class CustomDateFormatEEE extends AbstractTestUI {
Calendar cal = Calendar.getInstance();
cal.set(2014, 2, 14); // Friday

DateField df = new DateField("Should display 14/03/2014 Fri");
AbstractDateField df = new TestDateField(
"Should display 14/03/2014 Fri");
df.setResolution(Resolution.DAY);
df.setLocale(new Locale("en", "US"));


+ 5
- 4
uitest/src/main/java/com/vaadin/tests/components/datefield/CustomDateFormats.java 파일 보기

@@ -9,8 +9,9 @@ import java.util.Set;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.v7.data.Item;
@@ -141,7 +142,7 @@ public class CustomDateFormats extends TestBase {

Label serversideValueLabel = new Label();

DateField df = new DateField();
AbstractDateField df = new TestDateField();
df.setResolution(Resolution.DAY);
df.setLocale(locale);
df.setWidth("300px");
@@ -159,7 +160,7 @@ public class CustomDateFormats extends TestBase {
df.setData(new Data(serversideValueLabel, pattern));
df.setValue(cal.getTime());
df.addValueChangeListener(event -> updateServerSideLabel(
(DateField) event.getConnector()));
(AbstractDateField) event.getConnector()));

Label patternLabel = new Label(pattern);
patternLabel.setWidth(null);
@@ -181,7 +182,7 @@ public class CustomDateFormats extends TestBase {
updateServerSideLabel(df);
}

private void updateServerSideLabel(DateField df) {
private void updateServerSideLabel(AbstractDateField df) {
Data data = (Data) df.getData();
String pattern = data.pattern;
Locale locale = df.getLocale();

+ 3
- 3
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldChangeResolution.java 파일 보기

@@ -21,10 +21,10 @@ import com.vaadin.tests.components.AbstractTestUI;
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.AbstractDateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class DateFieldChangeResolution extends AbstractTestUI {

@@ -34,7 +34,7 @@ public class DateFieldChangeResolution extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final DateField dateField = new PopupDateField("Enter date");
final AbstractDateField dateField = new DateField("Enter date");
dateField.setResolution(Resolution.YEAR);
dateField.setId(DATEFIELD_ID);
dateField.setImmediate(true);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldClose.java 파일 보기

@@ -17,7 +17,8 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DateFieldClose extends AbstractTestUI {

@@ -25,7 +26,7 @@ public class DateFieldClose extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setId(DATEFIELD_ID);
addComponent(df);
}

+ 5
- 4
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldDayResolutionOffset.java 파일 보기

@@ -8,7 +8,8 @@ import java.util.TimeZone;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Label;

public class DateFieldDayResolutionOffset extends AbstractTestUI {
@@ -22,7 +23,7 @@ public class DateFieldDayResolutionOffset extends AbstractTestUI {

final TimeZone timezone = TimeZone.getTimeZone("GMT");
final SimpleDateFormat dateformat = getDateFormat(timezone);
final DateField dateField = getDateField(timezone, dateformat);
final AbstractDateField dateField = getDateField(timezone, dateformat);

addComponent(dateValue);
addComponent(dateField);
@@ -31,9 +32,9 @@ public class DateFieldDayResolutionOffset extends AbstractTestUI {
.setValue(dateformat.format(dateField.getValue())));
}

private DateField getDateField(TimeZone timezone,
private AbstractDateField getDateField(TimeZone timezone,
SimpleDateFormat dateformat) {
final DateField dateField = new DateField();
final AbstractDateField dateField = new TestDateField();
try {
Date initialDate = dateformat.parse(initialDateString);
dateField.setResolution(Resolution.DAY);

uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldConnector.java → uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldElementUI.java 파일 보기

@@ -2,14 +2,14 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.PopupDateField;

public class PopupDateFieldConnector extends AbstractTestUI {
public class DateFieldElementUI extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
addComponent(new PopupDateField());
addComponent(new DateField());
addComponent(new TestDateField());
}

@Override
@@ -19,6 +19,6 @@ public class PopupDateFieldConnector extends AbstractTestUI {

@Override
protected String getTestDescription() {
return "PopupDateFieldElement should be accessible using TB4 PopupDateFieldElement.";
return "DateFieldElement should be accessible using TB4 DateFieldElement.";
}
}

+ 7
- 7
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldExtendedRange.java 파일 보기

@@ -8,10 +8,10 @@ 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.AbstractDateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@SuppressWarnings("serial")
public class DateFieldExtendedRange extends TestBase {
@@ -26,7 +26,7 @@ public class DateFieldExtendedRange extends TestBase {
layout.setWidth("600px");
layout.setSpacing(true);

final DateField[] fields = new DateField[6];
final AbstractDateField[] fields = new AbstractDateField[6];

Locale fi = new Locale("fi", "FI");
Locale us = new Locale("en", "US");
@@ -43,7 +43,7 @@ public class DateFieldExtendedRange extends TestBase {
"Finnish locale with week numbers");
fields[5].setShowISOWeekNumbers(true);

for (DateField f : fields) {
for (AbstractDateField f : fields) {
layout.addComponent(f);
}

@@ -53,7 +53,7 @@ public class DateFieldExtendedRange extends TestBase {
@Override
public void buttonClick(ClickEvent event) {
date.set(2010, 1, 16);
for (DateField f : fields) {
for (AbstractDateField f : fields) {
f.setValue(date.getTime());
}
}
@@ -70,9 +70,9 @@ public class DateFieldExtendedRange extends TestBase {
return 6718;
}

private DateField makeDateField(boolean isPopup, Locale locale,
private AbstractDateField makeDateField(boolean isPopup, Locale locale,
String caption) {
DateField df = isPopup ? new PopupDateField() : new InlineDateField();
AbstractDateField df = isPopup ? new DateField() : new InlineDateField();
df.setResolution(Resolution.DAY);
df.setValue(date.getTime());
df.setLocale(locale);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldIsValid.java 파일 보기

@@ -5,7 +5,8 @@ import java.util.Date;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DateFieldIsValid extends AbstractTestUIWithLog {

@@ -25,7 +26,7 @@ public class DateFieldIsValid extends AbstractTestUIWithLog {

@Override
protected void setup(VaadinRequest request) {
final DateField dateField = new DateField("Insert Date: ");
final AbstractDateField dateField = new TestDateField("Insert Date: ");
dateField.setImmediate(true);
dateField.setDateFormat(pattern);


+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldKeyboardInput.java 파일 보기

@@ -22,7 +22,7 @@ import java.util.Locale;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class DateFieldKeyboardInput extends AbstractTestUI {

@@ -30,7 +30,7 @@ public class DateFieldKeyboardInput extends AbstractTestUI {
protected void setup(VaadinRequest request) {
Calendar c = new GregorianCalendar(Locale.ENGLISH);
c.set(2014, 0, 15);
final PopupDateField dateField = new PopupDateField("Select date",
final DateField dateField = new DateField("Select date",
c.getTime());
dateField.setDateFormat("dd.MM.yyyy");
addComponent(dateField);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldLocale.java 파일 보기

@@ -5,16 +5,17 @@ import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.DateField;

public class DateFieldLocale extends TestBase {

@Override
public void setup() {
final DateField dateField = new DateField("DateField");
final AbstractDateField dateField = new TestDateField("DateField");
dateField.setLocale(new Locale("fi", "FI"));
dateField.setCaption(dateField.getLocale().toString());
dateField.setValue(new Date(2013 - 1900, 7 - 1, 27));

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldMinResolution.java 파일 보기

@@ -5,7 +5,8 @@ import java.util.Calendar;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.Label;

@@ -20,7 +21,7 @@ public class DateFieldMinResolution extends TestBase {
Calendar cal = Calendar.getInstance();
cal.set(2019, 1, 1, 1, 1);

DateField df = new DateField("foo");
AbstractDateField df = new TestDateField("foo");
df.setResolution(Resolution.MINUTE);
df.setDateFormat(dformat.toPattern());
df.setValue(cal.getTime());

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java 파일 보기

@@ -17,7 +17,8 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DateFieldPopupClosing extends AbstractTestUI {

@@ -25,7 +26,7 @@ public class DateFieldPopupClosing extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setId(DATEFIELD_ID);
addComponent(df);
}

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetach.java 파일 보기

@@ -22,7 +22,8 @@ import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DateFieldPopupClosingOnDetach extends AbstractTestUI {

@@ -31,7 +32,7 @@ public class DateFieldPopupClosingOnDetach extends AbstractTestUI {
// Use polling to notice the removal of DateField.
getUI().setPollInterval(500);

final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
getLayout().addLayoutClickListener(new LayoutClickListener() {

@Override

+ 5
- 4
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupOffScreen.java 파일 보기

@@ -5,8 +5,9 @@ import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.LegacyWindow;

@@ -29,7 +30,7 @@ public class DateFieldPopupOffScreen extends AbstractTestCase {
GridLayout mainLayout = new GridLayout(3, 3);
mainLayout.setSizeFull();

DateField df;
AbstractDateField df;

df = createDateField();
mainLayout.addComponent(df, 2, 0);
@@ -55,8 +56,8 @@ public class DateFieldPopupOffScreen extends AbstractTestCase {
setMainWindow(mainWindow);
}

private DateField createDateField() {
DateField df = new DateField();
private AbstractDateField createDateField() {
AbstractDateField df = new TestDateField();
df.setLocale(new Locale("fi"));
df.setResolution(Resolution.SECOND);
df.setDescription(

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java 파일 보기

@@ -19,7 +19,7 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

/**
* Test UI for date field Popup calendar.
@@ -35,7 +35,7 @@ public abstract class DateFieldPopupPosition extends AbstractTestUI {
Label gap = new Label();
gap.setWidth(250, Unit.PIXELS);
layout.addComponent(gap);
PopupDateField field = new PopupDateField();
DateField field = new DateField();
layout.addComponent(field);
}


+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldPrimaryStyleNames.java 파일 보기

@@ -1,16 +1,17 @@
package com.vaadin.tests.components.datefield;

import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.InlineDateField;

public class DateFieldPrimaryStyleNames extends TestBase {

@Override
protected void setup() {
final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setPrimaryStyleName("my-datefield");
addComponent(df);


+ 16
- 15
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldRanges.java 파일 보기

@@ -8,10 +8,11 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
@@ -30,17 +31,17 @@ public class DateFieldRanges extends AbstractTestUI {

private Label label = new Label();
private NativeSelect resoSelect = new NativeSelect("Resolution");
private DateField fromRange = new DateField("Range start");
private DateField toRange = new DateField("Range end");
private DateField valueDF = new DateField("Value");
private AbstractDateField fromRange = new TestDateField("Range start");
private AbstractDateField toRange = new TestDateField("Range end");
private AbstractDateField valueDF = new TestDateField("Value");
private CheckBox immediateCB = new CheckBox("Immediate");
private Button recreate = new Button("Recreate static datefields");
private Button clearRangeButton = new Button("Clear range");

private GridLayout currentStaticContainer;

private DateField inlineDynamicDateField;
private DateField dynamicDateField;
private AbstractDateField inlineDynamicDateField;
private AbstractDateField dynamicDateField;

private Calendar createCalendar() {
Calendar c = Calendar.getInstance();
@@ -183,11 +184,11 @@ public class DateFieldRanges extends AbstractTestUI {
endCal.add(Calendar.DATE, 30);
GridLayout gl = new GridLayout(2, 2);
gl.setSpacing(true);
DateField df = createDateField(startCal.getTime(), endCal.getTime(),
null, Resolution.DAY, false);
AbstractDateField df = createDateField(startCal.getTime(),
endCal.getTime(), null, Resolution.DAY, false);
gl.addComponent(df);
DateField inline = createDateField(startCal.getTime(), endCal.getTime(),
null, Resolution.DAY, true);
AbstractDateField inline = createDateField(startCal.getTime(),
endCal.getTime(), null, Resolution.DAY, true);
gl.addComponent(inline);
inline.setId("staticInline");
VerticalLayout vl = new VerticalLayout();
@@ -195,18 +196,18 @@ public class DateFieldRanges extends AbstractTestUI {
return gl;
}

private DateField createDateField(Date rangeStart, Date rangeEnd,
private AbstractDateField createDateField(Date rangeStart, Date rangeEnd,
Date value, Resolution resolution, boolean inline) {

DateField df = null;
AbstractDateField df = null;

if (inline) {
df = new InlineDateField();
} else {
df = new DateField();
df = new TestDateField();
}

final DateField gg = df;
final AbstractDateField gg = df;
updateValuesForDateField(df);

df.addValueChangeListener(event -> {
@@ -223,7 +224,7 @@ public class DateFieldRanges extends AbstractTestUI {

}

private void updateValuesForDateField(DateField df) {
private void updateValuesForDateField(AbstractDateField df) {
Date fromVal = fromRange.getValue();
Date toVal = toRange.getValue();
Date value = valueDF.getValue();

+ 4
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldReadOnly.java 파일 보기

@@ -6,10 +6,11 @@ import java.util.Locale;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.DateField;

public class DateFieldReadOnly extends AbstractTestUI {

@@ -25,7 +26,8 @@ public class DateFieldReadOnly extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final DateField timeField = new DateField("A read-only datefield");
final AbstractDateField timeField = new TestDateField(
"A read-only datefield");
timeField.setResolution(Resolution.SECOND);
timeField.setDateFormat("HH:mm:ss");
timeField.setCaption(null);

+ 26
- 119
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTest.java 파일 보기

@@ -1,145 +1,52 @@
package com.vaadin.tests.components.datefield;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
import com.vaadin.ui.DateField;

public class DateFieldTest<T extends DateField>
extends AbstractFieldTest<T, Date> {
public class DateFieldTest extends AbstractDateFieldTest<DateField> {

@SuppressWarnings("unchecked")
@Override
protected Class<T> getTestClass() {
return (Class<T>) DateField.class;
protected Class<DateField> getTestClass() {
return DateField.class;
}

private Command<T, Date> setValue = new Command<T, Date>() {

@Override
public void execute(T c, Date value, Object data) {
c.setValue(value);
}
};

@Override
protected void createActions() {
super.createActions();
createResolutionSelectAction(CATEGORY_FEATURES);
createBooleanAction("Lenient", CATEGORY_FEATURES, false,
lenientCommand);
createBooleanAction("Show week numbers", CATEGORY_FEATURES, false,
weekNumberCommand);
createDateFormatSelectAction(CATEGORY_FEATURES);
createSetValueAction(CATEGORY_FEATURES);

}

private void createSetValueAction(String category) {
LinkedHashMap<String, Date> options = new LinkedHashMap<>();
options.put("(null)", null);
options.put("(current time)", new Date());
Calendar c = Calendar.getInstance(new Locale("fi", "FI"));
c.clear();
c.set(2010, 12 - 1, 12, 12, 0, 0);
c.set(Calendar.MILLISECOND, 0);
options.put("2010-12-12 12:00:00.000", c.getTime());
c.clear();
c.set(2000, 1 - 1, 2, 3, 4, 5);
c.set(Calendar.MILLISECOND, 6);
options.put("2000-01-02 03:04:05.006", c.getTime());
createMultiClickAction("Set value", category, options, setValue, null);
createInputPromptSelectAction(CATEGORY_FEATURES);
createTextEnabledAction(CATEGORY_FEATURES);
}

private void createDateFormatSelectAction(String category) {
private void createInputPromptSelectAction(String category) {
LinkedHashMap<String, String> options = new LinkedHashMap<>();
options.put("<none>", null);
options.put("Please enter date", "Please enter date");
options.put("åäöÅÄÖ", "åäöÅÄÖ");

options.put("-", null);
options.put("d M yyyy", "d M yyyy");
options.put("d MM yyyy", "d MM yyyy");
options.put("d MMM yyyy", "d MMM yyyy");
options.put("d MMMM yyyy", "d MMMM yyyy");
options.put("dd M yyyy", "dd M yyyy");
options.put("ddd M yyyy", "ddd M yyyy");
options.put("d M y", "d M y");
options.put("d M yy", "d M yy");
options.put("d M yyy", "d M yyy");
options.put("d M yyyy", "d M yyyy");
options.put("d M 'custom text' yyyy", "d M 'custom text' yyyy");
options.put("'day:'d', month:'M', year: 'yyyy",
"'day:'d', month:'M', year: 'yyyy");
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.LONG),
getDatePattern(new Locale("fi", "FI"), DateFormat.LONG));
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM),
getDatePattern(new Locale("fi", "FI"), DateFormat.MEDIUM));
options.put(getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT),
getDatePattern(new Locale("fi", "FI"), DateFormat.SHORT));
createSelectAction("Input prompt", category, options, "<none>",
new Command<DateField, String>() {

createSelectAction("Date format", category, options, "-",
dateFormatCommand);
@Override
public void execute(DateField c, String value,
Object data) {
c.setInputPrompt(value);

}
});
}

private String getDatePattern(Locale locale, int dateStyle) {
DateFormat dateFormat = DateFormat.getDateInstance(dateStyle, locale);
private void createTextEnabledAction(String category) {
this.createBooleanAction("Text field enabled", category, true,
new Command<DateField, Boolean>() {

if (dateFormat instanceof SimpleDateFormat) {
String pattern = ((SimpleDateFormat) dateFormat).toPattern();
return pattern;
}
return null;
@Override
public void execute(DateField c, Boolean value,
Object data) {
c.setTextFieldEnabled(value);
}

});
}

private void createResolutionSelectAction(String category) {
LinkedHashMap<String, Resolution> options = new LinkedHashMap<>();
options.put("Year", Resolution.YEAR);
options.put("Month", Resolution.MONTH);
options.put("Day", Resolution.DAY);
options.put("Hour", Resolution.HOUR);
options.put("Min", Resolution.MINUTE);
options.put("Sec", Resolution.SECOND);

createSelectAction("Resolution", category, options, "Year",
resolutionCommand);
}

private Command<T, Resolution> resolutionCommand = new Command<T, Resolution>() {

@Override
public void execute(T c, Resolution value, Object data) {
c.setResolution(value);

}
};
private Command<T, Boolean> lenientCommand = new Command<T, Boolean>() {

@Override
public void execute(T c, Boolean value, Object data) {
c.setLenient(false);

}
};
private Command<T, Boolean> weekNumberCommand = new Command<T, Boolean>() {

@Override
public void execute(T c, Boolean value, Object data) {
c.setShowISOWeekNumbers(value);

}
};
private Command<T, String> dateFormatCommand = new Command<T, String>() {

@Override
public void execute(T c, String value, Object data) {
c.setDateFormat(value);
}
};

}

uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldTextEnabled.java → uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTextEnabled.java 파일 보기

@@ -2,16 +2,16 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class PopupDateFieldTextEnabled extends TestBase {
public class DateFieldTextEnabled extends TestBase {

private static final String ENABLED = "DateField text box enabled";
private static final String DISABLED = "DateField text box disabled";

@Override
public void setup() {
final PopupDateField field = new PopupDateField();
final DateField field = new DateField();
final CheckBox box = new CheckBox(ENABLED, true);
box.addValueChangeListener(event -> {
field.setTextFieldEnabled(event.getValue());

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldTimezone.java 파일 보기

@@ -10,8 +10,9 @@ import java.util.TimeZone;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.v7.data.Property;
import com.vaadin.v7.data.Property.ValueChangeEvent;
import com.vaadin.v7.shared.ui.combobox.FilteringMode;
@@ -22,7 +23,7 @@ public class DateFieldTimezone extends TestBase {
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
private static final Locale EN = Locale.ENGLISH;
private final Log log = new Log(5);
private final DateField dateField = new DateField();
private final AbstractDateField dateField = new TestDateField();
private static final String nullValue = "";

@Override

+ 5
- 5
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldUnparsableDate.java 파일 보기

@@ -4,12 +4,12 @@ import java.util.Date;

import com.vaadin.data.Result;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.v7.data.util.converter.Converter;

public class DateFieldUnparsableDate extends TestBase {

public class MyDateField extends DateField {
public class MyDateField extends AbstractDateField {
Date oldDate = null;

public MyDateField(String caption) {
@@ -24,7 +24,7 @@ public class DateFieldUnparsableDate extends TestBase {
}
}

public class MyDateField2 extends DateField {
public class MyDateField2 extends AbstractDateField {
public MyDateField2(String caption) {
super(caption);
}
@@ -36,7 +36,7 @@ public class DateFieldUnparsableDate extends TestBase {
}
}

public class MyDateField3 extends DateField {
public class MyDateField3 extends AbstractDateField {
public MyDateField3(String caption) {
super(caption);
}
@@ -48,7 +48,7 @@ public class DateFieldUnparsableDate extends TestBase {
}
}

public class MyDateField4 extends DateField {
public class MyDateField4 extends AbstractDateField {
public MyDateField4(String caption) {
super(caption);
}

uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldValueChangeEvents.java → uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldValueChangeEvents.java 파일 보기

@@ -25,7 +25,8 @@ import java.util.Calendar;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.v7.data.Property.ValueChangeEvent;
import com.vaadin.v7.data.Property.ValueChangeListener;
@@ -36,7 +37,7 @@ import com.vaadin.v7.ui.NativeSelect;
* @since
* @author Vaadin Ltd
*/
public class PopupDateFieldValueChangeEvents extends AbstractTestUIWithLog {
public class DateFieldValueChangeEvents extends AbstractTestUIWithLog {

private int count = 0;

@@ -55,7 +56,8 @@ public class PopupDateFieldValueChangeEvents extends AbstractTestUIWithLog {
Calendar calendar = Calendar.getInstance();
calendar.set(2010, 1, 1, 18, 19, 20);

final DateField df = new DateField(null, calendar.getTime());
final AbstractDateField df = new TestDateField(null,
calendar.getTime());
df.setResolution(Resolution.SECOND);
df.setImmediate(true);
hl.addComponent(df);

+ 12
- 11
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParent.java 파일 보기

@@ -4,9 +4,10 @@ import java.util.Date;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.VerticalLayout;

public class DateFieldWhenChangingValueAndEnablingParent
@@ -21,12 +22,12 @@ public class DateFieldWhenChangingValueAndEnablingParent
main.setMargin(true);
setContent(main);

final DateField df1 = createDateField(true);
final DateField df2 = createDateField(false);
final PopupDateField pdf1 = createPopupDateField(true, true);
final PopupDateField pdf2 = createPopupDateField(true, false);
final PopupDateField pdf3 = createPopupDateField(false, true);
final PopupDateField pdf4 = createPopupDateField(false, false);
final AbstractDateField df1 = createDateField(true);
final AbstractDateField df2 = createDateField(false);
final DateField pdf1 = createPopupDateField(true, true);
final DateField pdf2 = createPopupDateField(true, false);
final DateField pdf3 = createPopupDateField(false, true);
final DateField pdf4 = createPopupDateField(false, false);

sub.addComponent(df1);
sub.addComponent(df2);
@@ -49,17 +50,17 @@ public class DateFieldWhenChangingValueAndEnablingParent
});
}

private DateField createDateField(boolean enabled) {
DateField df = new DateField(
private AbstractDateField createDateField(boolean enabled) {
AbstractDateField df = new TestDateField(
"DateField, " + (enabled ? "enabled" : "disabled"));
df.setEnabled(enabled);
df.setId("DATEFIELD_" + (enabled ? "ENABLED" : "DISABLED"));
return df;
}

private PopupDateField createPopupDateField(boolean enabled,
private DateField createPopupDateField(boolean enabled,
boolean textInputEnabled) {
PopupDateField df = new PopupDateField("PopupDateField, "
DateField df = new DateField("PopupDateField, "
+ (enabled ? "enabled" : "disabled") + ", text input "
+ (textInputEnabled ? "enabled" : "disabled"));
df.setEnabled(enabled);

uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFields.java → uitest/src/main/java/com/vaadin/tests/components/datefield/DateFields.java 파일 보기

@@ -8,24 +8,24 @@ import java.util.Locale;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.ComponentTestCase;
import com.vaadin.ui.Component;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@SuppressWarnings("serial")
public class PopupDateFields extends ComponentTestCase<PopupDateField> {
public class DateFields extends ComponentTestCase<DateField> {

private static final Locale[] LOCALES = new Locale[] { Locale.US,
Locale.TAIWAN, new Locale("fi", "FI") };

@Override
protected Class<PopupDateField> getTestClass() {
return PopupDateField.class;
protected Class<DateField> getTestClass() {
return DateField.class;
}

@Override
protected void initializeComponents() {

for (Locale locale : LOCALES) {
PopupDateField pd = createPopupDateField("Undefined width", "-1",
DateField pd = createPopupDateField("Undefined width", "-1",
locale);
pd.setId("Locale-" + locale.toString() + "-undefined-wide");
addTestComponent(pd);
@@ -40,9 +40,9 @@ public class PopupDateFields extends ComponentTestCase<PopupDateField> {

}

private PopupDateField createPopupDateField(String caption, String width,
private DateField createPopupDateField(String caption, String width,
Locale locale) {
PopupDateField pd = new PopupDateField(
DateField pd = new DateField(
caption + "(" + locale.toString() + ")");
pd.setWidth(width);
pd.setValue(new Date(12312312313L));
@@ -74,10 +74,10 @@ public class PopupDateFields extends ComponentTestCase<PopupDateField> {
options.put("Min", Resolution.MINUTE);
options.put("Sec", Resolution.SECOND);
return createSelectAction("Resolution", options, "Year",
new Command<PopupDateField, Resolution>() {
new Command<DateField, Resolution>() {

@Override
public void execute(PopupDateField c, Resolution value,
public void execute(DateField c, Resolution value,
Object data) {
c.setResolution(value);

@@ -92,10 +92,10 @@ public class PopupDateFields extends ComponentTestCase<PopupDateField> {
options.put("åäöÅÄÖ", "åäöÅÄÖ");

return createSelectAction("Input prompt", options, "<none>",
new Command<PopupDateField, String>() {
new Command<DateField, String>() {

@Override
public void execute(PopupDateField c, String value,
public void execute(DateField c, String value,
Object data) {
c.setInputPrompt(value);


+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java 파일 보기

@@ -5,14 +5,15 @@ import java.util.Date;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DatePopupStyleName extends TestBase {
@Override
public void setup() {
setTheme("reindeer-tests");

final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setValue(new Date(1203910239L));
df.setResolution(Resolution.SECOND);
df.setWidth("200px");

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java 파일 보기

@@ -19,7 +19,7 @@ import java.util.Locale;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;

public class DateRangeWithSqlDate extends AbstractTestUI {
@@ -34,7 +34,7 @@ public class DateRangeWithSqlDate extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
DateField df = new InlineDateField();
AbstractDateField df = new InlineDateField();
df.setLocale(Locale.US);
df.setRangeStart(startDate);
df.setRangeEnd(endDate);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledDateFieldPopup.java 파일 보기

@@ -17,13 +17,14 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class DisabledDateFieldPopup extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
DateField field = new DateField();
AbstractDateField field = new TestDateField();
field.setEnabled(false);
addComponent(field);
}

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledDateFieldWidth.java 파일 보기

@@ -2,16 +2,17 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;

public class DisabledDateFieldWidth extends TestBase {
@Override
public void setup() {

final DateField dateField1 = new DateField("DateField");
final AbstractDateField dateField1 = new TestDateField("DateField");
dateField1.setResolution(Resolution.YEAR);
dateField1.setEnabled(false);


+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledInlineDateField.java 파일 보기

@@ -20,7 +20,7 @@ import java.util.Date;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;

public class DisabledInlineDateField extends AbstractTestUI {
@@ -34,7 +34,7 @@ public class DisabledInlineDateField extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
DateField df = new InlineDateField("Disabled");
AbstractDateField df = new InlineDateField("Disabled");
df.setValue(testDate);
df.setEnabled(false);
addComponent(df);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java 파일 보기

@@ -17,8 +17,9 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.DateField;
import com.vaadin.ui.VerticalLayout;

/**
@@ -35,7 +36,7 @@ public class DisabledParentLayout extends AbstractTestUI {
content.setMargin(true);

final VerticalLayout pane = new VerticalLayout();
DateField dateField = new DateField();
AbstractDateField dateField = new TestDateField();
// If the field is immediate, the UI behaves differently (the value is
// updated and an error is indicated earlier instead of showing the date
// selector on the first click as the test expects. Keeping as

+ 4
- 4
uitest/src/main/java/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java 파일 보기

@@ -7,9 +7,9 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.DateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.VerticalLayout;

/**
@@ -25,7 +25,7 @@ public class DynamicallyChangeDateRange extends AbstractTestUI {
layout.setMargin(true);
setContent(layout);

final PopupDateField df = new PopupDateField();
final DateField df = new DateField();
df.setValue(new Date(2012 - 1900, 5 - 1, 12));
setRange(df, 5);
layout.addComponent(df);
@@ -62,7 +62,7 @@ public class DynamicallyChangeDateRange extends AbstractTestUI {
* @param df
* @param i
*/
private void setRange(DateField df, int days) {
private void setRange(AbstractDateField df, int days) {
df.setRangeStart(
new Date(df.getValue().getTime() - days * 24 * 60 * 60 * 1000));
df.setRangeEnd(

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/datefield/InlineDateFieldTest.java 파일 보기

@@ -2,7 +2,7 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.ui.InlineDateField;

public class InlineDateFieldTest extends DateFieldTest<InlineDateField> {
public class InlineDateFieldTest extends AbstractDateFieldTest<InlineDateField> {

@Override
protected Class<InlineDateField> getTestClass() {

+ 6
- 5
uitest/src/main/java/com/vaadin/tests/components/datefield/LenientMode.java 파일 보기

@@ -7,8 +7,9 @@ import com.vaadin.data.HasValue.ValueChange;
import com.vaadin.data.HasValue.ValueChangeListener;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.DateField;

public class LenientMode extends TestBase implements ValueChangeListener<Date> {

@@ -30,14 +31,14 @@ public class LenientMode extends TestBase implements ValueChangeListener<Date> {
@SuppressWarnings("deprecation")
Date d = new Date(2009 - 1900, 12 - 1, 31, 23, 59, 59);

DateField df = new DateField("Lenient ");
AbstractDateField df = new TestDateField("Lenient ");
df.setLocale(new Locale("fi"));
df.setResolution(Resolution.DAY);
df.setLenient(true);
df.setImmediate(true);
df.setValue(d);

DateField df2 = new DateField("Normal ");
AbstractDateField df2 = new TestDateField("Normal ");
df2.setLocale(new Locale("fi"));
df2.setResolution(Resolution.DAY);
// df2.setLenient(false);
@@ -51,13 +52,13 @@ public class LenientMode extends TestBase implements ValueChangeListener<Date> {
df.addValueChangeListener(this);
df2.addValueChangeListener(this);

df = new DateField("Lenient with time");
df = new TestDateField("Lenient with time");
df.setLocale(new Locale("fi"));
df.setLenient(true);
df.setImmediate(true);
df.setValue(d);

df2 = new DateField("Normal with time");
df2 = new TestDateField("Normal with time");
df2.setLocale(new Locale("fi"));
// df2.setLenient(false);
df2.setValue(null);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/LocaleChange.java 파일 보기

@@ -23,10 +23,11 @@ import java.util.Locale;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.DateField;

public class LocaleChange extends AbstractTestUI {

@@ -46,7 +47,7 @@ public class LocaleChange extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setLocale(locale24hClock);
df.setResolution(Resolution.SECOND);
df.setValue(dateValue);

+ 3
- 3
uitest/src/main/java/com/vaadin/tests/components/datefield/LowResolution.java 파일 보기

@@ -5,14 +5,14 @@ import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@SuppressWarnings("serial")
public class LowResolution extends TestBase {

@Override
protected void setup() {
final PopupDateField dateField = new PopupDateField();
final DateField dateField = new DateField();
dateField.setValue(new java.util.Date());
dateField.setResolution(Resolution.MONTH);
dateField.addValueChangeListener(event -> getMainWindow()
@@ -20,7 +20,7 @@ public class LowResolution extends TestBase {
dateField.setImmediate(true);
getLayout().addComponent(dateField);

final PopupDateField dateField3 = new PopupDateField();
final DateField dateField3 = new DateField();
// dateField.setValue(new java.util.Date());
dateField3.setResolution(Resolution.YEAR);
dateField3.addValueChangeListener(event -> getMainWindow()

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/NarrowPopupDateFieldInTable.java 파일 보기

@@ -2,7 +2,7 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Component;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.v7.ui.Table;

public class NarrowPopupDateFieldInTable extends TestBase {
@@ -11,7 +11,7 @@ public class NarrowPopupDateFieldInTable extends TestBase {

@Override
public void setup() {
PopupDateField df = new PopupDateField();
DateField df = new DateField();
df.setWidth("100%");

Table t = new Table();

+ 6
- 5
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java 파일 보기

@@ -18,26 +18,27 @@ package com.vaadin.tests.components.datefield;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.VerticalLayout;

public class PopupClosingWithEsc extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
DateField df0 = new DateField("Minute");
AbstractDateField df0 = new TestDateField("Minute");
df0.setId("minute");
df0.setResolution(Resolution.MINUTE);

DateField df1 = new DateField("Day");
AbstractDateField df1 = new TestDateField("Day");
df1.setId("day");
df1.setResolution(Resolution.DAY);

DateField df2 = new DateField("Month");
AbstractDateField df2 = new TestDateField("Month");
df2.setId("month");
df2.setResolution(Resolution.MONTH);

DateField df3 = new DateField("Year");
AbstractDateField df3 = new TestDateField("Year");
df3.setId("year");
df3.setResolution(Resolution.YEAR);


+ 6
- 6
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java 파일 보기

@@ -9,7 +9,7 @@ import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@SuppressWarnings("serial")
public class PopupDateFieldExtendedRange extends AbstractTestUI {
@@ -22,7 +22,7 @@ public class PopupDateFieldExtendedRange extends AbstractTestUI {

getLayout().setSpacing(true);

final PopupDateField[] fields = new PopupDateField[3];
final DateField[] fields = new DateField[3];

fields[0] = makeDateField();
fields[0].setLocale(new Locale("fi", "FI"));
@@ -37,7 +37,7 @@ public class PopupDateFieldExtendedRange extends AbstractTestUI {
fields[2].setShowISOWeekNumbers(true);
fields[2].setCaption("Finnish locale with week numbers");

for (PopupDateField f : fields) {
for (DateField f : fields) {
addComponent(f);
}

@@ -45,7 +45,7 @@ public class PopupDateFieldExtendedRange extends AbstractTestUI {
@Override
public void buttonClick(ClickEvent event) {
date.set(2010, 1, 16);
for (PopupDateField f : fields) {
for (DateField f : fields) {
f.setValue(date.getTime());
}
}
@@ -62,8 +62,8 @@ public class PopupDateFieldExtendedRange extends AbstractTestUI {
return 6718;
}

private PopupDateField makeDateField() {
PopupDateField pdf = new PopupDateField();
private DateField makeDateField() {
DateField pdf = new DateField();
pdf.setResolution(Resolution.DAY);
pdf.setValue(date.getTime());
return pdf;

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldInputPrompt.java 파일 보기

@@ -17,7 +17,7 @@ package com.vaadin.tests.components.datefield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.TextField;

/**
@@ -29,7 +29,7 @@ import com.vaadin.ui.TextField;
public class PopupDateFieldInputPrompt extends AbstractTestUI {

private TextField text = new TextField("TextField");
private PopupDateField dateField = new PopupDateField();
private DateField dateField = new DateField();

@Override
protected void setup(VaadinRequest request) {

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldLocaleTest.java 파일 보기

@@ -6,7 +6,7 @@ import java.util.Locale;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class PopupDateFieldLocaleTest extends AbstractTestUI {

@@ -21,7 +21,7 @@ public class PopupDateFieldLocaleTest extends AbstractTestUI {
cal.set(Calendar.SECOND, 1);
cal.set(Calendar.MILLISECOND, 1);

final PopupDateField pdf = new PopupDateField();
final DateField pdf = new DateField();
pdf.setLocale(Locale.ENGLISH);
pdf.setValue(cal.getTime());
pdf.setImmediate(true);

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldPopup.java 파일 보기

@@ -5,7 +5,7 @@ import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class PopupDateFieldPopup extends TestBase {

@@ -20,7 +20,7 @@ public class PopupDateFieldPopup extends TestBase {
cal.set(Calendar.SECOND, 1);
cal.set(Calendar.MILLISECOND, 1);

PopupDateField pdf = new PopupDateField();
DateField pdf = new DateField();
pdf.setLocale(Locale.US);
pdf.setValue(cal.getTime());
pdf.setImmediate(true);

+ 3
- 3
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldStates.java 파일 보기

@@ -7,7 +7,7 @@ import java.util.GregorianCalendar;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

@SuppressWarnings("serial")
public class PopupDateFieldStates extends AbstractTestUI {
@@ -35,9 +35,9 @@ public class PopupDateFieldStates extends AbstractTestUI {
return 14565;
}

private static PopupDateField createPopupDateField(final boolean enabled,
private static DateField createPopupDateField(final boolean enabled,
final boolean textFieldEnabled) {
final PopupDateField popupDatefield = new PopupDateField();
final DateField popupDatefield = new DateField();

Calendar cal = GregorianCalendar.getInstance();
cal.set(Calendar.DATE, 3);

+ 0
- 52
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldTest.java 파일 보기

@@ -1,52 +0,0 @@
package com.vaadin.tests.components.datefield;

import java.util.LinkedHashMap;

import com.vaadin.ui.PopupDateField;

public class PopupDateFieldTest extends DateFieldTest<PopupDateField> {

@Override
protected Class<PopupDateField> getTestClass() {
return PopupDateField.class;
}

@Override
protected void createActions() {
super.createActions();

createInputPromptSelectAction(CATEGORY_FEATURES);
createTextEnabledAction(CATEGORY_FEATURES);
}

private void createInputPromptSelectAction(String category) {
LinkedHashMap<String, String> options = new LinkedHashMap<>();
options.put("<none>", null);
options.put("Please enter date", "Please enter date");
options.put("åäöÅÄÖ", "åäöÅÄÖ");

createSelectAction("Input prompt", category, options, "<none>",
new Command<PopupDateField, String>() {

@Override
public void execute(PopupDateField c, String value,
Object data) {
c.setInputPrompt(value);

}
});
}

private void createTextEnabledAction(String category) {
this.createBooleanAction("Text field enabled", category, true,
new Command<PopupDateField, Boolean>() {

@Override
public void execute(PopupDateField c, Boolean value,
Object data) {
c.setTextFieldEnabled(value);
}

});
}
}

+ 4
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/TestDatefieldYear.java 파일 보기

@@ -5,7 +5,8 @@ import java.util.Locale;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;

public class TestDatefieldYear extends TestBase {

@@ -22,7 +23,8 @@ public class TestDatefieldYear extends TestBase {
@Override
protected void setup() {
@SuppressWarnings("deprecation")
DateField df = new DateField("Year", new Date(2009 - 1900, 4 - 1, 1));
AbstractDateField df = new TestDateField("Year",
new Date(2009 - 1900, 4 - 1, 1));
df.setLocale(new Locale("en", "US"));
df.setResolution(Resolution.YEAR);
df.setResolution(Resolution.MONTH);

+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/datefield/WidthRecalculationOnEnableStateChange.java 파일 보기

@@ -4,16 +4,17 @@ import java.util.Date;

import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.DateField;

public class WidthRecalculationOnEnableStateChange extends TestBase {
@Override
public void setup() {
setTheme("reindeer-tests");

final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setValue(new Date(1203910239L));
df.setResolution(Resolution.SECOND);
df.setWidth("200px");

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/formlayout/FormLayoutErrorHover.java 파일 보기

@@ -18,14 +18,14 @@ package com.vaadin.tests.components.formlayout;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;

public class FormLayoutErrorHover extends AbstractTestUI {

@Override
protected void setup(VaadinRequest request) {
FormLayout formLayout = new FormLayout();
PopupDateField fromDate = new PopupDateField("Date");
DateField fromDate = new DateField("Date");
fromDate.setImmediate(true);
formLayout.addComponent(fromDate);


+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/gridlayout/LayoutAfterHidingError.java 파일 보기

@@ -19,10 +19,11 @@ package com.vaadin.tests.components.gridlayout;
import com.vaadin.server.UserError;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
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.Panel;

@@ -38,7 +39,7 @@ public class LayoutAfterHidingError extends AbstractTestUI {
gl.setWidth("100%");
panel.setContent(gl);

final DateField df = new DateField();
final AbstractDateField df = new TestDateField();
df.setWidth("100%");
gl.addComponent(df);


+ 3
- 2
uitest/src/main/java/com/vaadin/tests/components/table/TableChildMeasurementHint.java 파일 보기

@@ -2,11 +2,12 @@ package com.vaadin.tests.components.table;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.AbstractOrderedLayout;
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.HasChildMeasurementHint.ChildMeasurementHint;
import com.vaadin.ui.HorizontalLayout;
@@ -152,7 +153,7 @@ public class TableChildMeasurementHint extends AbstractTestUI {
table.addGeneratedColumn("First_Name" + 4, new Table.ColumnGenerator() {
@Override
public Object generateCell(Table components, Object o, Object o2) {
DateField b = new DateField("DateField");
AbstractDateField b = new TestDateField("DateField");
b.setWidthUndefined();
return b;
}

+ 3
- 3
uitest/src/main/java/com/vaadin/tests/components/tabsheet/ScrollbarsInNestedTabsheets.java 파일 보기

@@ -1,7 +1,7 @@
package com.vaadin.tests.components.tabsheet;

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.DateField;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.TabSheet;
@@ -32,14 +32,14 @@ public class ScrollbarsInNestedTabsheets extends TestBase {

private Layout getDummyLayout1() {
final VerticalLayout l = new VerticalLayout();
l.addComponent(new DateField("Date"));
l.addComponent(new TestDateField("Date"));

return l;
}

private Layout getDummyLayout2() {
final VerticalLayout l = new VerticalLayout();
l.addComponent(new DateField("Date"));
l.addComponent(new TestDateField("Date"));
l.addComponent(new TextField("TextField"));

return l;

+ 4
- 3
uitest/src/main/java/com/vaadin/tests/components/uitest/components/DatesCssTest.java 파일 보기

@@ -3,12 +3,13 @@ package com.vaadin.tests.components.uitest.components;
import java.util.Calendar;
import java.util.GregorianCalendar;

import com.vaadin.tests.components.TestDateField;
import com.vaadin.tests.components.uitest.TestSampler;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.themes.ChameleonTheme;

public class DatesCssTest extends GridLayout {
@@ -28,7 +29,7 @@ public class DatesCssTest extends GridLayout {
createDateFieldWith("Small", ChameleonTheme.DATEFIELD_SMALL, null);
createDateFieldWith("Big", ChameleonTheme.DATEFIELD_BIG, null);

DateField df = new PopupDateField("Popup date field");
AbstractDateField df = new DateField("Popup date field");
df.setId("datefield" + debugIdCounter++);
df.setValue(cal.getTime());
addComponent(df);
@@ -47,7 +48,7 @@ public class DatesCssTest extends GridLayout {

private void createDateFieldWith(String caption, String primaryStyleName,
String width) {
DateField df = new DateField("Date field");
AbstractDateField df = new TestDateField("Date field");
df.setId("datefield" + debugIdCounter++);
df.setValue(cal.getTime());


+ 3
- 3
uitest/src/main/java/com/vaadin/tests/declarative/PotusForm.java 파일 보기

@@ -17,7 +17,7 @@ package com.vaadin.tests.declarative;

import com.vaadin.annotations.DesignRoot;
import com.vaadin.ui.Button;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.declarative.Design;
import com.vaadin.v7.data.fieldgroup.PropertyId;
@@ -34,9 +34,9 @@ public class PotusForm extends VerticalLayout {
@PropertyId("party")
public ComboBox party;
@PropertyId("tookOffice")
public PopupDateField tookOffice;
public DateField tookOffice;
@PropertyId("leftOffice")
public PopupDateField leftOffice;
public DateField leftOffice;

public Button save;
public Button revert;

+ 2
- 3
uitest/src/main/java/com/vaadin/tests/fieldgroup/DateForm.java 파일 보기

@@ -79,8 +79,7 @@ public class DateForm extends AbstractTestUIWithLog {
protected void setup(VaadinRequest request) {
setLocale(Locale.US);
addComponent(log);
final FieldGroup fieldGroup = new BeanFieldGroup<>(
DateObject.class);
final FieldGroup fieldGroup = new BeanFieldGroup<>(DateObject.class);
fieldGroup.setBuffered(true);

fieldGroup.buildAndBindMemberFields(this);
@@ -128,7 +127,7 @@ public class DateForm extends AbstractTestUIWithLog {
addComponent(showBean);

DateObject d = new DateObject(new Date(443457289789L),
new Date(443457289789L), new Date(443457289789L),
new Date(443543689789L), new Date(443457289789L),
new Date(443457289789L));
fieldGroup.setItemDataSource(new BeanItem<>(d));
}

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/fields/TabIndexes.java 파일 보기

@@ -13,7 +13,7 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.DateField;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
import com.vaadin.v7.ui.ComboBox;
@@ -97,7 +97,7 @@ public class TabIndexes extends AbstractTestUIWithLog {
fields.add(new NativeSelect());
fields.add(new ListSelect());
fields.add(new TextField());
fields.add(new PopupDateField());
fields.add(new DateField());
fields.add(new InlineDateField());
OptionGroup og = new OptionGroup();
og.addItem("Item 1");

+ 5
- 4
uitest/src/main/java/com/vaadin/tests/fonticon/FontIcons.java 파일 보기

@@ -31,7 +31,6 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.DateField;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
@@ -50,6 +49,7 @@ import com.vaadin.v7.ui.ComboBox;
import com.vaadin.v7.ui.ListSelect;
import com.vaadin.v7.ui.NativeSelect;
import com.vaadin.v7.ui.OptionGroup;
import com.vaadin.v7.ui.PopupDateField;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.Table.Align;
import com.vaadin.v7.ui.Table.RowHeaderMode;
@@ -110,9 +110,10 @@ public class FontIcons extends AbstractTestUI {
layout.addComponent(gl);

// Basic components, caption icon only
Class<?>[] components = { Button.class, CheckBox.class, DateField.class,
NativeButton.class, Link.class, Label.class, Panel.class,
Slider.class, TextArea.class, TextField.class, Upload.class };
Class<?>[] components = { Button.class, CheckBox.class,
PopupDateField.class, NativeButton.class, Link.class,
Label.class, Panel.class, Slider.class, TextArea.class,
TextField.class, Upload.class };
for (Class<?> clazz : components) {
Component c;
try {

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java 파일 보기

@@ -7,6 +7,7 @@ import com.vaadin.data.HasRequired;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
@@ -15,7 +16,6 @@ import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
@@ -200,7 +200,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
components.add(new TextArea("Default TextArea."));
// components.add(new RichTextArea("Default RichtTextArea"));
components.add(new PasswordField("Default Password"));
components.add(new DateField("Default DateField"));
components.add(new TestDateField("Default DateField"));

// PopupDateField popupDateField = new
// PopupDateField("Default DateField");

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseRegError.java 파일 보기

@@ -16,10 +16,10 @@
package com.vaadin.tests.layouts.layouttester;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.ui.ComboBox;
@@ -52,7 +52,7 @@ public class BaseRegError extends BaseLayoutTestUI {
l1.addComponent(createLabelsFields(TextField.class, true, ""));

l2.addComponent(createLabelsFields(ComboBox.class, true, ""));
l2.addComponent(createLabelsFields(DateField.class, true, ""));
l2.addComponent(createLabelsFields(TestDateField.class, true, ""));
l2.addComponent(createLabelsFields(NativeSelect.class, true, ""));
l2.addComponent(createLabelsFields(CheckBox.class, true, ""));


+ 2
- 2
uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridLayoutRegError.java 파일 보기

@@ -16,9 +16,9 @@
package com.vaadin.tests.layouts.layouttester.GridLayout;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.ui.ComboBox;
@@ -46,7 +46,7 @@ public class GridLayoutRegError extends GridBaseLayoutTestUI {
layout.addComponent(createLabelsFields(TextField.class, true, ""));

layout.addComponent(createLabelsFields(ComboBox.class, true, ""));
layout.addComponent(createLabelsFields(DateField.class, true, ""));
layout.addComponent(createLabelsFields(TestDateField.class, true, ""));
layout.addComponent(createLabelsFields(NativeSelect.class, true, ""));
layout.addComponent(createLabelsFields(CheckBox.class, true, ""));


+ 28
- 28
uitest/src/main/java/com/vaadin/tests/themes/valo/DateFields.java 파일 보기

@@ -22,11 +22,12 @@ import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.InlineDateField;
@@ -50,16 +51,16 @@ public class DateFields extends VerticalLayout implements View {
row.setSpacing(true);
addComponent(row);

DateField date = new DateField("Default resolution");
AbstractDateField date = new TestDateField("Default resolution");
setDate(date);
row.addComponent(date);

date = new DateField("Error");
date = new TestDateField("Error");
setDate(date);
date.setComponentError(new UserError("Fix it, now!"));
row.addComponent(date);

date = new DateField("Error, borderless");
date = new TestDateField("Error, borderless");
setDate(date);
date.setComponentError(new UserError("Fix it, now!"));
date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
@@ -70,7 +71,7 @@ public class DateFields extends VerticalLayout implements View {
group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
row.addComponent(group);

final DateField date2 = new DateField();
final TestDateField date2 = new TestDateField();
group.addComponent(date2);

Button today = new Button("Today", new ClickListener() {
@@ -81,109 +82,109 @@ public class DateFields extends VerticalLayout implements View {
});
group.addComponent(today);

date = new DateField("Default resolution, explicit size");
date = new TestDateField("Default resolution, explicit size");
setDate(date);
row.addComponent(date);
date.setWidth("260px");
date.setHeight("60px");

date = new DateField("Second resolution");
date = new TestDateField("Second resolution");
setDate(date);
date.setResolution(Resolution.SECOND);
row.addComponent(date);

date = new DateField("Minute resolution");
date = new TestDateField("Minute resolution");
setDate(date);
date.setResolution(Resolution.MINUTE);
row.addComponent(date);

date = new DateField("Hour resolution");
date = new TestDateField("Hour resolution");
setDate(date);
date.setResolution(Resolution.HOUR);
row.addComponent(date);

date = new DateField("Disabled");
date = new TestDateField("Disabled");
setDate(date);
date.setResolution(Resolution.HOUR);
date.setEnabled(false);
row.addComponent(date);

date = new DateField("Day resolution");
date = new TestDateField("Day resolution");
setDate(date);
date.setResolution(Resolution.DAY);
row.addComponent(date);

date = new DateField("Month resolution");
date = new TestDateField("Month resolution");
setDate(date);
date.setResolution(Resolution.MONTH);
row.addComponent(date);

date = new DateField("Year resolution");
date = new TestDateField("Year resolution");
setDate(date);
date.setResolution(Resolution.YEAR);
row.addComponent(date);

date = new DateField("Custom color");
date = new TestDateField("Custom color");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color1");
row.addComponent(date);

date = new DateField("Custom color");
date = new TestDateField("Custom color");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color2");
row.addComponent(date);

date = new DateField("Custom color");
date = new TestDateField("Custom color");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName("color3");
row.addComponent(date);

date = new DateField("Small");
date = new TestDateField("Small");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName(ValoTheme.DATEFIELD_SMALL);
row.addComponent(date);

date = new DateField("Large");
date = new TestDateField("Large");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName(ValoTheme.DATEFIELD_LARGE);
row.addComponent(date);

date = new DateField("Borderless");
date = new TestDateField("Borderless");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
row.addComponent(date);

date = new DateField("Week numbers");
date = new TestDateField("Week numbers");
setDate(date);
date.setResolution(Resolution.DAY);
date.setLocale(new Locale("fi", "fi"));
date.setShowISOWeekNumbers(true);
row.addComponent(date);

date = new DateField("US locale");
date = new TestDateField("US locale");
setDate(date);
date.setResolution(Resolution.SECOND);
date.setLocale(new Locale("en", "US"));
row.addComponent(date);

date = new DateField("Custom format");
date = new TestDateField("Custom format");
setDate(date);
date.setDateFormat("E dd/MM/yyyy");
row.addComponent(date);

date = new DateField("Tiny");
date = new TestDateField("Tiny");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName(ValoTheme.DATEFIELD_TINY);
row.addComponent(date);

date = new DateField("Huge");
date = new TestDateField("Huge");
setDate(date);
date.setResolution(Resolution.DAY);
date.addStyleName(ValoTheme.DATEFIELD_HUGE);
@@ -201,8 +202,7 @@ public class DateFields extends VerticalLayout implements View {
row.addComponent(date);

PropertysetItem item = new PropertysetItem();
item.addItemProperty("date",
new ObjectProperty<>(getDefaultDate()));
item.addItemProperty("date", new ObjectProperty<>(getDefaultDate()));

FormLayout form = new FormLayout();
form.setMargin(false);
@@ -215,7 +215,7 @@ public class DateFields extends VerticalLayout implements View {
row.addComponent(form);
}

private void setDateRange(DateField date) {
private void setDateRange(AbstractDateField date) {
date.setRangeStart(getDefaultDate());

Date endDate = getDefaultDate();
@@ -223,7 +223,7 @@ public class DateFields extends VerticalLayout implements View {
date.setRangeEnd(endDate);
}

private void setDate(DateField date) {
private void setDate(AbstractDateField date) {
date.setValue(getDefaultDate());
}


+ 4
- 3
uitest/src/main/java/com/vaadin/tests/themes/valo/Forms.java 파일 보기

@@ -21,20 +21,21 @@ import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.UserError;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
import com.vaadin.v7.ui.ComboBox;
import com.vaadin.v7.ui.OptionGroup;
import com.vaadin.ui.RichTextArea;
import com.vaadin.v7.ui.TextArea;
import com.vaadin.v7.ui.TextField;

@@ -69,7 +70,7 @@ public class Forms extends VerticalLayout implements View {
name.setWidth("50%");
form.addComponent(name);

DateField birthday = new DateField("Birthday");
AbstractDateField birthday = new TestDateField("Birthday");
birthday.setValue(new Date(80, 0, 31));
form.addComponent(birthday);


+ 3
- 2
uitest/src/main/java/com/vaadin/tests/themes/valo/Tables.java 파일 보기

@@ -22,9 +22,10 @@ import com.vaadin.event.dd.acceptcriteria.AcceptAll;
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.tests.components.TestDateField;
import com.vaadin.ui.AbstractDateField;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
@@ -198,7 +199,7 @@ public class Tables extends VerticalLayout implements View {
@Override
public Object generateCell(Table source, Object itemId,
Object columnId) {
DateField tf = new DateField();
AbstractDateField tf = new TestDateField();
tf.addStyleName(ValoTheme.TABLE_COMPACT);
if ((Integer) itemId % 2 == 0) {
tf.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);

uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldTestTest.java → uitest/src/test/java/com/vaadin/tests/components/datefield/AbstractDateFieldTestTest.java 파일 보기

@@ -25,7 +25,7 @@ import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.elements.NotificationElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class DateFieldTestTest extends MultiBrowserTest {
public class AbstractDateFieldTestTest extends MultiBrowserTest {

@Test
public void testMakingRequired() throws InterruptedException {

+ 2
- 2
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldDayResolutionOffsetTest.java 파일 보기

@@ -7,7 +7,7 @@ import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

@@ -35,7 +35,7 @@ public class DateFieldDayResolutionOffsetTest extends MultiBrowserTest {
}

private void openDatePicker() {
DateFieldElement dateField = $(DateFieldElement.class).first();
AbstractDateFieldElement dateField = $(AbstractDateFieldElement.class).first();

dateField.findElement(By.tagName("button")).click();
}

+ 26
- 0
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldElementTest.java 파일 보기

@@ -0,0 +1,26 @@
package com.vaadin.tests.components.datefield;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

import org.junit.Test;

import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class DateFieldElementTest extends SingleBrowserTest {

@Test
public void dateFieldElementIsLocated() {
openTestURL();

assertThat($(DateFieldElement.class).all().size(), is(1));
assertThat($(AbstractDateFieldElement.class).all().size(), is(2));
}

@Override
protected Class<?> getUIClass() {
return DateFieldElementUI.class;
}
}

+ 2
- 2
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldIsValidTest.java 파일 보기

@@ -21,8 +21,8 @@ import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;

import com.vaadin.testbench.By;
import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
@@ -36,7 +36,7 @@ public class DateFieldIsValidTest extends MultiBrowserTest {

waitForElementVisible(By.id("Log"));
waitForElementVisible(By.className("v-datefield"));
WebElement dateTextbox = $(DateFieldElement.class).first()
WebElement dateTextbox = $(AbstractDateFieldElement.class).first()
.findElement(By.className("v-textfield"));
ButtonElement button = $(ButtonElement.class).first();


+ 2
- 1
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingOnDetachTest.java 파일 보기

@@ -20,6 +20,7 @@ import java.io.IOException;
import org.junit.Test;
import org.openqa.selenium.By;

import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

@@ -31,7 +32,7 @@ public class DateFieldPopupClosingOnDetachTest extends MultiBrowserTest {
openTestURL();

// Open the DateField popup.
DateFieldElement df = $(DateFieldElement.class).first();
DateFieldElement df = $(AbstractDateFieldElement.class).first();
df.findElement(By.tagName("button")).click();

// Test UI will remove the DateField after 1 second.

+ 2
- 1
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java 파일 보기

@@ -10,6 +10,7 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;

import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

@@ -69,7 +70,7 @@ public class DateFieldPopupClosingTest extends MultiBrowserTest {
}

private WebElement getToggleButton() {
DateFieldElement dateField = $(DateFieldElement.class).first();
DateFieldElement dateField = $(AbstractDateFieldElement.class).first();

return dateField.findElement(By.tagName("button"));
}

+ 2
- 2
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java 파일 보기

@@ -6,8 +6,8 @@ import org.junit.Test;
import org.openqa.selenium.Keys;

import com.vaadin.testbench.By;
import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class DateFieldReadOnlyTest extends MultiBrowserTest {
@@ -36,7 +36,7 @@ public class DateFieldReadOnlyTest extends MultiBrowserTest {
private void openPopup() {
// waiting for openPopup() in TB4 beta1:
// http://dev.vaadin.com/ticket/13766
$(DateFieldElement.class).first().findElement(By.tagName("button"))
$(AbstractDateFieldElement.class).first().findElement(By.tagName("button"))
.click();
}


uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldValueChangeEventsTest.java → uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldValueChangeEventsTest.java 파일 보기

@@ -23,12 +23,12 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.testbench.elements.NativeSelectElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class PopupDateFieldValueChangeEventsTest extends MultiBrowserTest {
public class DateFieldValueChangeEventsTest extends MultiBrowserTest {

@Test
public void tb2test() throws Exception {
@@ -53,7 +53,7 @@ public class PopupDateFieldValueChangeEventsTest extends MultiBrowserTest {
}

public WebElement getPopUpButton() {
DateFieldElement datefield = $(DateFieldElement.class).first();
AbstractDateFieldElement datefield = $(AbstractDateFieldElement.class).first();
return datefield.findElement((By.className("v-datefield-button")));
}


+ 9
- 12
uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParentTest.java 파일 보기

@@ -19,9 +19,9 @@ import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;

import com.vaadin.testbench.customelements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.elements.PopupDateFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class DateFieldWhenChangingValueAndEnablingParentTest
@@ -32,24 +32,21 @@ public class DateFieldWhenChangingValueAndEnablingParentTest
openTestURL();
$(CheckBoxElement.class).first().click();

assertState($(DateFieldElement.class).id("DATEFIELD_ENABLED"), true,
assertState($(AbstractDateFieldElement.class).id("DATEFIELD_ENABLED"), true,
true);
assertState($(DateFieldElement.class).id("DATEFIELD_DISABLED"), false,
false);
assertState($(AbstractDateFieldElement.class).id("DATEFIELD_DISABLED"),
false, false);

assertState(
$(PopupDateFieldElement.class).id("DATEFIELD_ENABLED_ENABLED"),
assertState($(DateFieldElement.class).id("DATEFIELD_ENABLED_ENABLED"),
true, true);
assertState(
$(PopupDateFieldElement.class).id("DATEFIELD_ENABLED_DISABLED"),
assertState($(DateFieldElement.class).id("DATEFIELD_ENABLED_DISABLED"),
true, false);

// disabling widget should always disable input
assertState(
$(PopupDateFieldElement.class).id("DATEFIELD_DISABLED_ENABLED"),
assertState($(DateFieldElement.class).id("DATEFIELD_DISABLED_ENABLED"),
false, false);
assertState($(DateFieldElement.class).id("DATEFIELD_DISABLED_DISABLED"),
false, false);
assertState($(PopupDateFieldElement.class)
.id("DATEFIELD_DISABLED_DISABLED"), false, false);

}


+ 0
- 21
uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldConnectorTest.java 파일 보기

@@ -1,21 +0,0 @@
package com.vaadin.tests.components.datefield;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

import org.junit.Test;

import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.testbench.elements.PopupDateFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;

public class PopupDateFieldConnectorTest extends SingleBrowserTest {

@Test
public void popupDateFieldElementIsLocated() {
openTestURL();

assertThat($(PopupDateFieldElement.class).all().size(), is(1));
assertThat($(DateFieldElement.class).all().size(), is(2));
}
}

+ 4
- 5
uitest/src/test/java/com/vaadin/tests/components/datefield/PopupDateFieldInputPromptTest.java 파일 보기

@@ -25,7 +25,7 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition;

import com.vaadin.testbench.elements.PopupDateFieldElement;
import com.vaadin.testbench.customelements.DateFieldElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

@@ -41,8 +41,7 @@ public class PopupDateFieldInputPromptTest extends MultiBrowserTest {
public void testInputPrompt() {
openTestURL();
TextFieldElement textField = $(TextFieldElement.class).first();
final PopupDateFieldElement dateField = $(PopupDateFieldElement.class)
.first();
final DateFieldElement dateField = $(DateFieldElement.class).first();

// ensure initial state
Assert.assertFalse("DateField required when it shouldn't be.",
@@ -63,7 +62,7 @@ public class PopupDateFieldInputPromptTest extends MultiBrowserTest {
}

private void waitForElementRequiredAndFocused(
final PopupDateFieldElement dateField, final By locator) {
final DateFieldElement dateField, final By locator) {
waitUntil(new ExpectedCondition<Boolean>() {

@Override
@@ -84,7 +83,7 @@ public class PopupDateFieldInputPromptTest extends MultiBrowserTest {
});
}

private boolean isRequired(PopupDateFieldElement dateField) {
private boolean isRequired(DateFieldElement dateField) {
return dateField.getAttribute("class").contains("v-required");
}
}

+ 0
- 0
uitest/src/test/java/com/vaadin/tests/components/uitest/ThemeTest.java 파일 보기


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.

Loading…
취소
저장