]> source.dussan.org Git - vaadin-framework.git/commitdiff
Ensure calendar panel is updated when range changes (#11940)
authorArtur Signell <artur@vaadin.com>
Tue, 28 May 2013 14:55:44 +0000 (17:55 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 28 May 2013 14:59:27 +0000 (14:59 +0000)
Change-Id: Ic270e5c0aa1b28947b735fcb258bc9629d53cc21

client/src/com/vaadin/client/ui/VCalendarPanel.java
uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java [new file with mode: 0644]

index 311932b819ca9338ed0469fd15217c377a603af0..1f402987603bb143742c2c606452cd978505ac78 100644 (file)
@@ -2216,6 +2216,11 @@ public class VCalendarPanel extends FocusableFlexTable implements
      */
     public void setRangeStart(Date rangeStart) {
         this.rangeStart = rangeStart;
+        if (initialRenderDone) {
+            // Dynamic updates to the range needs to render the calendar to
+            // update the element stylenames
+            renderCalendar();
+        }
 
     }
 
@@ -2228,6 +2233,10 @@ public class VCalendarPanel extends FocusableFlexTable implements
      */
     public void setRangeEnd(Date rangeEnd) {
         this.rangeEnd = rangeEnd;
-
+        if (initialRenderDone) {
+            // Dynamic updates to the range needs to render the calendar to
+            // update the element stylenames
+            renderCalendar();
+        }
     }
 }
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.html
new file mode 100644 (file)
index 0000000..77c610f
--- /dev/null
@@ -0,0 +1,121 @@
+<?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:8888/" />
+<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.DynamicallyChangeDateRange?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+       <td>11,8</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[6]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[7]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::</td>
+       <td>201,401</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+       <td>14,16</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[4]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[2]/td[5]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[5]/td[4]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[5]/td[5]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::</td>
+       <td>237,338</td>
+</tr>
+<tr>
+       <td>click</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+       <td></td>
+</tr>
+<tr>
+       <td>mouseClick</td>
+       <td>vaadin=runcomvaadintestscomponentsdatefieldDynamicallyChangeDateRange::/VVerticalLayout[0]/Slot[0]/VPopupCalendar[0]#popupButton</td>
+       <td>14,15</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertNotCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[6]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[4]/td[7]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+<tr>
+       <td>assertCSSClass</td>
+       <td>//table[@id='PID_VAADIN_POPUPCAL']/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/span</td>
+       <td>v-datefield-calendarpanel-day-outside-range</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java b/uitest/src/com/vaadin/tests/components/datefield/DynamicallyChangeDateRange.java
new file mode 100644 (file)
index 0000000..9288b04
--- /dev/null
@@ -0,0 +1,91 @@
+package com.vaadin.tests.components.datefield;
+
+import java.util.Date;
+
+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.InlineDateField;
+import com.vaadin.ui.PopupDateField;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * Main UI class
+ */
+@SuppressWarnings("serial")
+public class DynamicallyChangeDateRange extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final VerticalLayout layout = new VerticalLayout();
+        layout.setMargin(true);
+        setContent(layout);
+
+        final PopupDateField df = new PopupDateField();
+        df.setValue(new Date(2012 - 1900, 5 - 1, 12));
+        setRange(df, 5);
+        layout.addComponent(df);
+
+        final InlineDateField df2 = new InlineDateField();
+        df2.setValue(new Date(2012 - 1900, 11 - 1, 16));
+
+        setRange(df2, 5);
+        // layout.addComponent(df2);
+
+        Button button1 = new Button("Set Range Now+/-5d");
+        button1.addClickListener(new Button.ClickListener() {
+            @Override
+            public void buttonClick(ClickEvent event) {
+                setRange(df, 5);
+                setRange(df2, 5);
+            }
+        });
+        layout.addComponent(button1);
+
+        Button button2 = new Button("Set Range Now+/-10d");
+        button2.addClickListener(new Button.ClickListener() {
+            @Override
+            public void buttonClick(ClickEvent event) {
+                setRange(df, 10);
+                setRange(df2, 10);
+            }
+        });
+        layout.addComponent(button2);
+    }
+
+    /**
+     * @since
+     * @param df
+     * @param i
+     */
+    private void setRange(DateField df, int days) {
+        df.setRangeStart(new Date(df.getValue().getTime() - days * 24 * 60 * 60
+                * 1000));
+        df.setRangeEnd(new Date(df.getValue().getTime() + days * 24 * 60 * 60
+                * 1000));
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+     */
+    @Override
+    protected String getTestDescription() {
+        return "Verifies that the allowed date range can be updated dynamically";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+     */
+    @Override
+    protected Integer getTicketNumber() {
+        return 11940;
+    }
+
+}
\ No newline at end of file