}
}
}
- if (isImmediate()) {
- getClient().sendPendingVariableChanges();
- }
}
}
import java.util.Date;
+import com.google.gwt.event.logical.shared.CloseEvent;
+import com.google.gwt.event.logical.shared.CloseHandler;
+import com.google.gwt.user.client.ui.PopupPanel;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.DateTimeService;
import com.vaadin.client.UIDL;
@Connect(DateField.class)
public class PopupDateFieldConnector extends TextualDateConnector {
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.client.ui.AbstractConnector#init()
+ */
+ @Override
+ protected void init() {
+ getWidget().popup.addCloseHandler(new CloseHandler<PopupPanel>() {
+
+ @Override
+ public void onClose(CloseEvent<PopupPanel> event) {
+ /*
+ * FIXME This is a hack so we do not have to rewrite half of the
+ * datefield so values are not sent while selecting a date
+ * (#6252).
+ *
+ * The datefield will now only set the date UIDL variables while
+ * the user is selecting year/month/date/time and not send them
+ * directly. Only when the user closes the popup (by clicking on
+ * a day/enter/clicking outside of popup) then the new value is
+ * communicated to the server.
+ */
+ if (getWidget().isImmediate()) {
+ getConnection().sendPendingVariableChanges();
+ }
+ }
+ });
+ }
+
/*
* (non-Javadoc)
*
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:7171/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.datefield.PopupDateFieldValueChangeEvents?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+ <td>12,11</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[3]/span</td>
+ <td>18,12</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]/domChild[0]</td>
+ <td>Value changes: 1</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+ <td>12,11</td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[3]/td/div/select</td>
+ <td>label=01</td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[3]/td/div/select[2]</td>
+ <td>label=02</td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[3]/td/div/select[3]</td>
+ <td>label=03</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[3]/td/div/select[3]</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[0]/VLabel[0]</td>
+ <td>410,9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]/domChild[0]</td>
+ <td>Value changes: 2</td>
+</tr>
+<tr>
+ <td>select</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[1]/VNativeSelect[0]/domChild[0]</td>
+ <td>label=MONTH</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VHorizontalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+ <td>14,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>xpath=(//button[@type='button'])[4]</td>
+ <td>3,13</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>xpath=(//button[@type='button'])[5]</td>
+ <td>9,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>xpath=(//button[@type='button'])[4]</td>
+ <td>7,8</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>xpath=(//button[@type='button'])[4]</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentsdatefieldPopupDateFieldValueChangeEvents::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VLabel[0]/domChild[0]</td>
+ <td>Value changes: 3</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright 2000-2013 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.datefield;
+
+import java.util.Arrays;
+import java.util.Calendar;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.datefield.Resolution;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.NativeSelect;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+public class PopupDateFieldValueChangeEvents extends AbstractTestUI {
+
+ private int count = 0;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ HorizontalLayout hl = new HorizontalLayout();
+ addComponent(hl);
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2010, 1, 1, 18, 19, 20);
+
+ final DateField df = new DateField(null, calendar.getTime());
+ df.setResolution(Resolution.SECOND);
+ df.setImmediate(true);
+ hl.addComponent(df);
+
+ NativeSelect resolution = new NativeSelect(null,
+ Arrays.asList(Resolution.values()));
+ resolution.setImmediate(true);
+ resolution.setValue(df.getResolution());
+ hl.addComponent(resolution);
+ resolution.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ df.setResolution((Resolution) event.getProperty().getValue());
+ }
+ });
+
+ final Label log = new Label("", ContentMode.PREFORMATTED);
+ addComponent(log);
+
+ df.addValueChangeListener(new Property.ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ log.setValue("Value changes: " + (++count));
+
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "DateField Time resolution fields should only send events when focus is removed";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 6252;
+ }
+
+}