From 65a4fd14bff1043ab62c045d7d176d2097242fb2 Mon Sep 17 00:00:00 2001
From: Anna Miroshnik
Date: Tue, 25 Nov 2014 12:19:05 +0300
Subject: Position tooltips in the visible area (#15129).
Based on Mika's reverted patch, with additional fix and test for
regression "an empty tooltip appears while the application is
initializing".
Change-Id: I8237fc9340265708a05a7576a5d9e8e374dc1fea
---
.../vaadin/tests/components/TooltipPosition.java | 70 +++++++++
.../tests/components/TooltipPositionTest.java | 173 +++++++++++++++++++++
.../tests/components/menubar/MenuTooltipTest.java | 1 +
3 files changed, 244 insertions(+)
create mode 100644 uitest/src/com/vaadin/tests/components/TooltipPosition.java
create mode 100644 uitest/src/com/vaadin/tests/components/TooltipPositionTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/uitest/src/com/vaadin/tests/components/TooltipPosition.java b/uitest/src/com/vaadin/tests/components/TooltipPosition.java
new file mode 100644
index 0000000000..30222722d9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/TooltipPosition.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2000-2014 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 com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+/**
+ * This UI is used for testing that a tooltip is not positioned partially
+ * outside the browser window when there is enough space to display it.
+ *
+ * @author Vaadin Ltd
+ */
+public class TooltipPosition extends AbstractTestUI {
+
+ public static final int NUMBER_OF_BUTTONS = 5;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ // These tooltip delay settings can be removed once #13854 is resolved.
+ getTooltipConfiguration().setOpenDelay(0);
+ getTooltipConfiguration().setQuickOpenDelay(0);
+ getTooltipConfiguration().setCloseTimeout(1000);
+
+ VerticalLayout layout = new VerticalLayout();
+ layout.setSpacing(true);
+ layout.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(),
+ Unit.PIXELS);
+ addComponent(layout);
+ for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
+ Button button = new Button("Button");
+ button.setDescription(generateTooltipText());
+ layout.addComponent(button);
+ }
+ }
+
+ private String generateTooltipText() {
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < 50; i++) {
+ result.append("This is the line ").append(i)
+ .append(" of the long tooltip text. ");
+ }
+ return result.toString();
+ }
+
+ @Override
+ public String getTestDescription() {
+ return "The tooltips of the buttons should not be clipped when there is enough space to display them.";
+ }
+
+ @Override
+ public Integer getTicketNumber() {
+ return 15129;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java b/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java
new file mode 100644
index 0000000000..4106374d64
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/TooltipPositionTest.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2000-2014 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.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.Point;
+import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebDriver.Window;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests that the tooltip is positioned so that it fits in the displayed area.
+ *
+ * @author Vaadin Ltd
+ */
+public class TooltipPositionTest extends MultiBrowserTest {
+
+ @Test
+ public void testRegression_EmptyTooltipShouldNotBeAppearedDuringInitialization()
+ throws Exception {
+ openTestURL();
+
+ waitForElementVisible(By.cssSelector(".v-tooltip"));
+ WebElement tooltip = driver.findElement(By.cssSelector(".v-tooltip"));
+
+ Assert.assertTrue(
+ "This init tooltip with text ' ' is present in the DOM and should be entirely outside the browser window",
+ isOutsideOfWindow(tooltip));
+ }
+
+ @Test
+ public void testTooltipPosition() throws Exception {
+ openTestURL();
+ for (int i = 0; i < TooltipPosition.NUMBER_OF_BUTTONS; i++) {
+ ButtonElement button = $(ButtonElement.class).get(i);
+ // Move the mouse to display the tooltip.
+ Actions actions = new Actions(driver);
+ actions.moveToElement(button, 10, 10);
+ actions.build().perform();
+ waitUntil(tooltipToBeInsideWindow(By.cssSelector(".v-tooltip"),
+ driver.manage().window()));
+
+ if (i < TooltipPosition.NUMBER_OF_BUTTONS - 1) {
+ // Remove the tooltip by moving the mouse.
+ actions = new Actions(driver);
+ actions.moveByOffset(300, 0);
+ actions.build().perform();
+ waitUntil(tooltipNotToBeShown(By.cssSelector(".v-tooltip"),
+ driver.manage().window()));
+ }
+ }
+ }
+
+ /*
+ * An expectation for checking that the tooltip found by the given locator
+ * is present in the DOM and entirely inside the browser window. The
+ * coordinate of the top left corner of the window is supposed to be (0, 0).
+ */
+ private ExpectedCondition tooltipToBeInsideWindow(
+ final By tooltipLocator, final Window window) {
+ return new ExpectedCondition() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ List elements = findElements(tooltipLocator);
+ if (elements.isEmpty()) {
+ return false;
+ }
+ WebElement element = elements.get(0);
+ try {
+ if (!element.isDisplayed()) {
+ return false;
+ }
+ Point topLeft = element.getLocation();
+ int xLeft = topLeft.getX();
+ int yTop = topLeft.getY();
+ if (xLeft < 0 || yTop < 0) {
+ return false;
+ }
+ Dimension elementSize = element.getSize();
+ int xRight = xLeft + elementSize.getWidth() - 1;
+ int yBottom = yTop + elementSize.getHeight() - 1;
+ Dimension browserSize = window.getSize();
+ return xRight < browserSize.getWidth()
+ && yBottom < browserSize.getHeight();
+ } catch (StaleElementReferenceException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "the tooltip to be displayed inside the window";
+ }
+ };
+ };
+
+ /*
+ * An expectation for checking that the tooltip found by the given locator
+ * is not shown in the window, even partially. The top left corner of window
+ * should have coordinates (0, 0).
+ */
+ private ExpectedCondition tooltipNotToBeShown(
+ final By tooltipLocator, final Window window) {
+ return new ExpectedCondition() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ List elements = findElements(tooltipLocator);
+ if (elements.isEmpty()) {
+ return true;
+ }
+ WebElement tooltip = elements.get(0);
+ try {
+ return isOutsideOfWindow(tooltip);
+ } catch (StaleElementReferenceException e) {
+ return true;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "the tooltip not to be displayed inside the window";
+ }
+
+ };
+ }
+
+ private boolean isOutsideOfWindow(WebElement tooltip) {
+ if (!tooltip.isDisplayed()) {
+ return true;
+ }
+ // The tooltip is shown, at least partially, if
+ // its intervals of both horizontal and vertical coordinates
+ // overlap those of the window.
+ Point topLeft = tooltip.getLocation();
+ Dimension tooltipSize = tooltip.getSize();
+ Dimension windowSize = driver.manage().window().getSize();
+ int xLeft = topLeft.getX();
+ int yTop = topLeft.getY();
+ int xRight = xLeft + tooltipSize.getWidth() - 1;
+ int yBottom = yTop + tooltipSize.getHeight() - 1;
+ boolean overlapHorizontally = !(xRight < 0 || xLeft >= windowSize
+ .getWidth());
+ boolean overlapVertically = !(yBottom < 0 || yTop >= windowSize
+ .getHeight());
+ return !(overlapHorizontally && overlapVertically);
+ }
+}
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
index 24025b9f39..091f7be954 100644
--- a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
@@ -49,6 +49,7 @@ public class MenuTooltipTest extends MultiBrowserTest {
Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class)
.first());
+ sleep(1000);
Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
--
cgit v1.2.3
From 551c06548831c05e9519836c1e068011b3a95c40 Mon Sep 17 00:00:00 2001
From: Sauli Tähkäpää
Date: Tue, 25 Nov 2014 14:41:48 +0200
Subject: Converted SetCurrentPageFirstItemIndex to TB4. (#15286)
Change-Id: Iea990c243e083b3302fd1e448402ac3aa3db08ac
---
.../table/SetCurrentPageFirstItemIndex.html | 43 ---------------
.../table/SetCurrentPageFirstItemIndexTest.java | 63 ++++++++++++++++++++++
2 files changed, 63 insertions(+), 43 deletions(-)
delete mode 100644 uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html
create mode 100644 uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html
deleted file mode 100644
index 904f3b0470..0000000000
--- a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndex.html
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-New Test
-
-
-
-
-
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java
new file mode 100644
index 0000000000..8102f82834
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/SetCurrentPageFirstItemIndexTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2014 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.table;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import junit.framework.Assert;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openqa.selenium.NoSuchElementException;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ *
+ * @since
+ * @author Vaadin Ltd
+ */
+@Ignore
+// Enable after #15286 is fixed.
+public class SetCurrentPageFirstItemIndexTest extends MultiBrowserTest {
+
+ @Test
+ public void currentPageIndexChangesTwice() {
+ openTestURL();
+
+ ButtonElement button = $(ButtonElement.class).first();
+ button.click(); // change to 20
+ button.click(); // change to 5
+
+ // When failing, the index stays on 20.
+ assertThatRowIsVisible(5);
+ }
+
+ private void assertThatRowIsVisible(int index) {
+ try {
+ TableElement table = $(TableElement.class).first();
+ TestBenchElement cell = table.getCell(index, 0);
+
+ assertThat(cell.getText(), is(Integer.toString(index + 1)));
+ } catch (NoSuchElementException e) {
+ Assert.fail(String.format("Can't locate row for index: %s", index));
+ }
+ }
+
+}
--
cgit v1.2.3
From d9829d6636e046b452fdf6f93194c55db9c3997c Mon Sep 17 00:00:00 2001
From: Sergey Budkin
Date: Fri, 7 Nov 2014 12:38:05 +0200
Subject: One pixel discrepancy in headers and rows border with minimal width
(#15118)
Disabled old patch for VTreeTable, which caused the problem.
Change-Id: I3fdf6b0890307b27e32ceff4492cb7d0bfc6b680
---
client/src/com/vaadin/client/ui/VScrollTable.java | 3 +-
client/src/com/vaadin/client/ui/VTreeTable.java | 2 +
.../components/treetable/MinimalWidthColumns.java | 44 ++++++++++++++++++++++
.../treetable/MinimalWidthColumnsTest.java | 31 +++++++++++++++
4 files changed, 79 insertions(+), 1 deletion(-)
create mode 100644 uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java
create mode 100644 uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 6c241f1033..14e4c658ad 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -5392,6 +5392,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private Map cellToolTips = new HashMap();
private boolean isDragging = false;
private String rowStyle = null;
+ protected boolean applyZeroWidthFix = true;
private VScrollTableRow(int rowKey) {
this.rowKey = rowKey;
@@ -5497,7 +5498,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
* definition of zero width table cells. Instead, use 1px
* and compensate with a negative margin.
*/
- if (width == 0) {
+ if (applyZeroWidthFix && width == 0) {
wrapperWidth = 1;
wrapperStyle.setMarginRight(-1, Unit.PX);
} else {
diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java
index 9b7e9702b2..9e5940a2f2 100644
--- a/client/src/com/vaadin/client/ui/VTreeTable.java
+++ b/client/src/com/vaadin/client/ui/VTreeTable.java
@@ -155,6 +155,8 @@ public class VTreeTable extends VScrollTable {
public VTreeTableRow(UIDL uidl, char[] aligns2) {
super(uidl, aligns2);
+ // this fix causes #15118 and doesn't work for treetable anyway
+ applyZeroWidthFix = false;
}
@Override
diff --git a/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java
new file mode 100644
index 0000000000..c4679f739b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumns.java
@@ -0,0 +1,44 @@
+package com.vaadin.tests.components.treetable;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.TreeTable;
+
+@Theme("valo")
+public class MinimalWidthColumns extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ TreeTable tt = new TreeTable();
+ tt.addContainerProperty("Foo", String.class, "");
+ tt.addContainerProperty("Bar", String.class, "");
+
+ Object item1 = tt.addItem(new Object[] { "f", "Bar" }, null);
+ Object item2 = tt.addItem(new Object[] { "Foo2", "Bar2" }, null);
+
+ tt.setParent(item2, item1);
+
+ tt.setColumnWidth("Foo", 0);
+ tt.setColumnWidth("Bar", 50);
+ tt.setWidth("300px");
+ addComponent(tt);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(15118);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "There should be no 1px discrepancy between vertical borders in headers and rows";
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java
new file mode 100644
index 0000000000..46c2f397b6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/treetable/MinimalWidthColumnsTest.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2014 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.treetable;
+
+import org.junit.Test;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class MinimalWidthColumnsTest extends MultiBrowserTest {
+
+ @Test
+ public void testFor1pxDifference() throws Exception {
+ openTestURL();
+ sleep(500);
+ compareScreen("onepixdifference");
+ }
+
+}
--
cgit v1.2.3
From a0f4c3dfb37b1e742b74a78d8133b1bb4a399052 Mon Sep 17 00:00:00 2001
From: Fabian Lange
Date: Thu, 30 Oct 2014 11:58:26 +0100
Subject: Window modalitycurtain will now respect $v-animations-enabled
(#15135)
Change-Id: I80beea694c2a103aaf1fb479e1de48c515428fbb
---
.../tests-valo-disabled-animations/_variables.scss | 3 ++
.../tests-valo-disabled-animations/styles.scss | 6 ++++
.../VAADIN/themes/valo/components/_window.scss | 11 +++----
.../vaadin/tests/themes/valo/ModalWindowTest.java | 34 ++++++++++++++++++++++
4 files changed, 49 insertions(+), 5 deletions(-)
create mode 100644 WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss
create mode 100644 WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss
create mode 100644 uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss b/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss
new file mode 100644
index 0000000000..d2411c675c
--- /dev/null
+++ b/WebContent/VAADIN/themes/tests-valo-disabled-animations/_variables.scss
@@ -0,0 +1,3 @@
+$v-animations-enabled: false;
+
+@import "../valo/valo";
diff --git a/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss b/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss
new file mode 100644
index 0000000000..b941c1b3d1
--- /dev/null
+++ b/WebContent/VAADIN/themes/tests-valo-disabled-animations/styles.scss
@@ -0,0 +1,6 @@
+@import "variables";
+@import "../tests-valo/valotest";
+
+.tests-valo-disabled-animations {
+ @include valotest;
+}
diff --git a/WebContent/VAADIN/themes/valo/components/_window.scss b/WebContent/VAADIN/themes/valo/components/_window.scss
index ce7a530c98..23fa5338c2 100644
--- a/WebContent/VAADIN/themes/valo/components/_window.scss
+++ b/WebContent/VAADIN/themes/valo/components/_window.scss
@@ -89,11 +89,12 @@ $v-window-modality-curtain-background-color: #222 !default;
left: 0;
@include radial-gradient(circle at 50% 50%, $v-window-modality-curtain-background-color, darken($v-window-modality-curtain-background-color, valo-gradient-opacity()), $fallback: $v-window-modality-curtain-background-color);
@include opacity(max(0.2, 0.8 - valo-gradient-opacity()/100%));
- @include valo-animate-in-fade($duration: 400ms, $delay: 100ms);
-
- .v-op12 & {
- // Opera 12 has a shitbreak with the fade-in (flickers)
- @include animation(none);
+ @if $v-animations-enabled {
+ @include valo-animate-in-fade($duration: 400ms, $delay: 100ms);
+ .v-op12 & {
+ // Opera 12 has a shitbreak with the fade-in (flickers)
+ @include animation(none);
+ }
}
}
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java b/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java
new file mode 100644
index 0000000000..b97ce43ed6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/themes/valo/ModalWindowTest.java
@@ -0,0 +1,34 @@
+package com.vaadin.tests.themes.valo;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.ModalWindow;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class ModalWindowTest extends SingleBrowserTest {
+
+ @Override
+ protected Class> getUIClass() {
+ return ModalWindow.class;
+ }
+
+ @Test
+ public void modalAnimationsAreDisabled() {
+ openTestURL("theme=tests-valo-disabled-animations");
+
+ openModalWindow();
+
+ WebElement modalityCurtain = findElement(By.className("v-window-modalitycurtain"));
+
+ assertThat(modalityCurtain.getCssValue("-webkit-animation-name"), is("none"));
+ }
+
+ private void openModalWindow() {
+ $(ButtonElement.class).get(1).click();
+ }
+}
\ No newline at end of file
--
cgit v1.2.3
From 53f87e5bf3014382f0bf9cd7acb18c56709ba1f7 Mon Sep 17 00:00:00 2001
From: Denis Anisimov
Date: Sun, 19 Oct 2014 14:54:47 +0300
Subject: Show push version information in debug window (#14904).
Change-Id: Id1761abbf2b2dc29b4138520f11ce51bb4d423fc
---
.../vaadin/client/ApplicationConfiguration.java | 45 +++++++++
.../vaadin/client/debug/internal/InfoSection.java | 8 ++
server/src/com/vaadin/server/BootstrapHandler.java | 2 +
.../com/vaadin/tests/debug/PushVersionInfo.java | 51 +++++++++++
.../vaadin/tests/debug/PushVersionInfoTest.java | 102 +++++++++++++++++++++
5 files changed, 208 insertions(+)
create mode 100644 uitest/src/com/vaadin/tests/debug/PushVersionInfo.java
create mode 100644 uitest/src/com/vaadin/tests/debug/PushVersionInfoTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/client/src/com/vaadin/client/ApplicationConfiguration.java b/client/src/com/vaadin/client/ApplicationConfiguration.java
index 12b1585292..4865e38a4a 100644
--- a/client/src/com/vaadin/client/ApplicationConfiguration.java
+++ b/client/src/com/vaadin/client/ApplicationConfiguration.java
@@ -172,6 +172,33 @@ public class ApplicationConfiguration implements EntryPoint {
return this.getConfig("versionInfo").vaadinVersion;
}-*/;
+ /**
+ * Gets the version of the Atmosphere framework.
+ *
+ * @return a string with the version
+ *
+ * @see org.atmosphere.util#getRawVersion()
+ */
+ private native String getAtmosphereVersion()
+ /*-{
+ return this.getConfig("versionInfo").atmosphereVersion;
+ }-*/;
+
+ /**
+ * Gets the JS version used in the Atmosphere framework.
+ *
+ * @return a string with the version
+ */
+ private native String getAtmosphereJSVersion()
+ /*-{
+ if ($wnd.jQueryVaadin != undefined){
+ return $wnd.jQueryVaadin.atmosphere.version;
+ }
+ else {
+ return null;
+ }
+ }-*/;
+
private native String getUIDL()
/*-{
return this.getConfig("uidl");
@@ -461,6 +488,24 @@ public class ApplicationConfiguration implements EntryPoint {
return getJsoConfiguration(id).getVaadinVersion();
}
+ /**
+ * Return Atmosphere version.
+ *
+ * @return Atmosphere version.
+ */
+ public String getAtmosphereVersion() {
+ return getJsoConfiguration(id).getAtmosphereVersion();
+ }
+
+ /**
+ * Return Atmosphere JS version.
+ *
+ * @return Atmosphere JS version.
+ */
+ public String getAtmosphereJSVersion() {
+ return getJsoConfiguration(id).getAtmosphereJSVersion();
+ }
+
public Class extends ServerConnector> getConnectorClassByEncodedTag(
int tag) {
Class extends ServerConnector> type = classes.get(tag);
diff --git a/client/src/com/vaadin/client/debug/internal/InfoSection.java b/client/src/com/vaadin/client/debug/internal/InfoSection.java
index a7a84f5f8f..dfb31cdd18 100644
--- a/client/src/com/vaadin/client/debug/internal/InfoSection.java
+++ b/client/src/com/vaadin/client/debug/internal/InfoSection.java
@@ -193,6 +193,9 @@ public class InfoSection implements Section {
ApplicationConfiguration applicationConfiguration) {
String clientVersion = Version.getFullVersion();
String servletVersion = applicationConfiguration.getServletVersion();
+ String atmosphereVersion = applicationConfiguration
+ .getAtmosphereVersion();
+ String jsVersion = applicationConfiguration.getAtmosphereJSVersion();
String themeVersion;
boolean themeOk;
@@ -213,6 +216,11 @@ public class InfoSection implements Section {
addRow("Server engine version", servletVersion, servletOk ? null
: ERROR_STYLE);
addRow("Theme version", themeVersion, themeOk ? null : ERROR_STYLE);
+ if (jsVersion != null) {
+ addRow("Push server version", atmosphereVersion);
+ addRow("Push client version", jsVersion
+ + " (note: does not need to match server version)");
+ }
}
/**
diff --git a/server/src/com/vaadin/server/BootstrapHandler.java b/server/src/com/vaadin/server/BootstrapHandler.java
index f0666f63fc..c34e986fce 100644
--- a/server/src/com/vaadin/server/BootstrapHandler.java
+++ b/server/src/com/vaadin/server/BootstrapHandler.java
@@ -469,6 +469,8 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler {
JsonObject versionInfo = Json.createObject();
versionInfo.put("vaadinVersion", Version.getFullVersion());
+ versionInfo.put("atmosphereVersion",
+ org.atmosphere.util.Version.getRawVersion());
appConfig.put("versionInfo", versionInfo);
appConfig.put("widgetset", context.getWidgetsetName());
diff --git a/uitest/src/com/vaadin/tests/debug/PushVersionInfo.java b/uitest/src/com/vaadin/tests/debug/PushVersionInfo.java
new file mode 100644
index 0000000000..d8c23a390f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/debug/PushVersionInfo.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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.debug;
+
+import org.atmosphere.util.Version;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.communication.PushMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+
+/**
+ * Test UI for PUSH version string in debug window.
+ *
+ * @author Vaadin Ltd
+ */
+public class PushVersionInfo extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ if (request.getParameter("enablePush") != null) {
+ getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
+ Label label = new Label(Version.getRawVersion());
+ label.addStyleName("atmosphere-version");
+ addComponent(label);
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "Debug window shows Push version in info Tab.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14904;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/debug/PushVersionInfoTest.java b/uitest/src/com/vaadin/tests/debug/PushVersionInfoTest.java
new file mode 100644
index 0000000000..90ea645ab8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/debug/PushVersionInfoTest.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2000-2014 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.debug;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.annotations.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for PUSH version string in debug window.
+ *
+ * @author Vaadin Ltd
+ */
+@TestCategory("push")
+public class PushVersionInfoTest extends MultiBrowserTest {
+
+ @Test
+ public void testDisabledPush() {
+ setDebug(true);
+ openTestURL();
+
+ selectInfoTab();
+ Assert.assertNull("Found push info server string for disabled Push",
+ getPushRowValue("Push server version"));
+ Assert.assertNull("Found push info client string for disabled Push",
+ getPushRowValue("Push client version"));
+ }
+
+ @Test
+ public void testEnabledPush() {
+ setDebug(true);
+ openTestURL("enablePush=true");
+
+ selectInfoTab();
+ WebElement pushRow = getPushRowValue("Push server version");
+ String atmVersion = findElement(By.className("atmosphere-version"))
+ .getText();
+ Assert.assertTrue("Push row doesn't contain Atmosphere version",
+ pushRow.getText().contains(atmVersion));
+ String jsString = getPushRowValue("Push client version").getText();
+ Assert.assertTrue(
+ "Push client version doesn't contain 'vaadin' string",
+ jsString.contains("vaadin"));
+ Assert.assertTrue(
+ "Push client version doesn't contain 'jquery' string",
+ jsString.contains("jquery"));
+ }
+
+ private void selectInfoTab() {
+ if (isElementPresent(By.className("v-ie8"))) {
+
+ int size = findElements(By.className("v-debugwindow-tab")).size();
+ for (int i = 0; i < size; i++) {
+ WebElement tab = findElement(By
+ .className("v-debugwindow-tab-selected"));
+ String title = tab.getAttribute("title");
+ if (title != null && title.startsWith("General information")) {
+ break;
+ }
+ Actions actions = new Actions(getDriver());
+ actions.sendKeys(Keys.TAB);
+ actions.sendKeys(Keys.SPACE);
+ actions.build().perform();
+ }
+ } else {
+ findElements(By.className("v-debugwindow-tab")).get(0).click();
+ findElements(By.className("v-debugwindow-tab")).get(1).click();
+ }
+ }
+
+ private WebElement getPushRowValue(String key) {
+ List rows = findElements(By.className("v-debugwindow-row"));
+ for (WebElement row : rows) {
+ WebElement caption = row.findElement(By.className("caption"));
+ if (caption.getText().startsWith(key)) {
+ return row.findElement(By.className("value"));
+ }
+ }
+ return null;
+ }
+}
--
cgit v1.2.3
From e8868a225504dd90dbecaceb1d6eb9df40116355 Mon Sep 17 00:00:00 2001
From: Sauli Tähkäpää
Date: Sun, 23 Nov 2014 14:16:02 +0200
Subject: Fix opacity for disabled links in Valo. (#15253)
Change-Id: I865526499a6d55a835758f0194a977c36c10304a
---
WebContent/VAADIN/themes/valo/components/_link.scss | 8 ++++++--
uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java | 5 +++++
uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java | 2 +-
3 files changed, 12 insertions(+), 3 deletions(-)
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/WebContent/VAADIN/themes/valo/components/_link.scss b/WebContent/VAADIN/themes/valo/components/_link.scss
index b568df1d7b..270de1aace 100644
--- a/WebContent/VAADIN/themes/valo/components/_link.scss
+++ b/WebContent/VAADIN/themes/valo/components/_link.scss
@@ -20,8 +20,8 @@ $v-link-cursor: pointer !default;
/**
*
*
- * @param {string} $primary-stylename (v-link) -
- * @param {bool} $include-additional-styles -
+ * @param {string} $primary-stylename (v-link) -
+ * @param {bool} $include-additional-styles -
*
* @group link
*/
@@ -74,4 +74,8 @@ $v-link-cursor: pointer !default;
&:hover {
color: lighten($v-link-font-color, 10%);
}
+
+ &.v-disabled {
+ @include opacity($v-disabled-opacity);
+ }
}
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java b/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java
index e66cd2668b..9ed48896eb 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ButtonsAndLinks.java
@@ -178,6 +178,11 @@ public class ButtonsAndLinks extends VerticalLayout implements View {
link.setIcon(testIcon.get());
link.addStyleName("large");
row.addComponent(link);
+
+ link = new Link("Disabled", new ExternalResource("https://vaadin.com"));
+ link.setIcon(testIcon.get());
+ link.setEnabled(false);
+ row.addComponent(link);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
index 92cb837b38..a826d9a8f2 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
@@ -39,7 +39,7 @@ public class ValoThemeUITest extends MultiBrowserTest {
public void buttonsLinks() throws Exception {
openTestURL("test");
open("Buttons & Links", "Buttons");
- compareScreen("buttonsLinks");
+ compareScreen("buttonsLinks_with_disabled");
}
@Test
--
cgit v1.2.3
From 285b4bc21f85a4570b5f3b45fc4fd120104b4d11 Mon Sep 17 00:00:00 2001
From: Jouni Koivuviita
Date: Thu, 4 Dec 2014 15:58:07 +0200
Subject: Fix opacity for disabled checkboxes and option groups. (#15239)
Change-Id: I2d09a116d07621053f2fc9524f95e47bf7fc834e
---
.../VAADIN/themes/valo/components/_checkbox.scss | 36 ++++++++++------------
.../com/vaadin/tests/themes/valo/CheckBoxes.java | 16 ++++++++++
.../vaadin/tests/themes/valo/ValoThemeUITest.java | 2 +-
3 files changed, 34 insertions(+), 20 deletions(-)
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/WebContent/VAADIN/themes/valo/components/_checkbox.scss b/WebContent/VAADIN/themes/valo/components/_checkbox.scss
index 3c418ec9b7..7283c4cbbf 100644
--- a/WebContent/VAADIN/themes/valo/components/_checkbox.scss
+++ b/WebContent/VAADIN/themes/valo/components/_checkbox.scss
@@ -99,7 +99,7 @@
}
& ~ label:before {
- @include valo-button-style($background-color: $background-color, $unit-size: $size, $border-radius: min(round($size/3), $v-border-radius));
+ @include valo-button-style($background-color: $background-color, $unit-size: $size, $border-radius: min(round($size/3), $v-border-radius), $states: normal);
padding: 0;
height: round($size);
}
@@ -119,24 +119,6 @@
&:checked ~ label:after {
color: $selection-color;
}
-
- &[disabled] {
- ~ label,
- ~ label .v-icon,
- ~ .v-icon {
- cursor: default;
- }
-
- ~ label:before,
- ~ label:after {
- @include opacity($v-disabled-opacity);
- }
-
- &:active ~ label:after {
- background: transparent;
- }
- }
-
}
& > .v-icon,
@@ -146,4 +128,20 @@
cursor: pointer;
}
+ &.v-disabled {
+ > label,
+ > .v-icon {
+ cursor: default;
+ @include opacity($v-disabled-opacity);
+ }
+
+ > label > .v-icon {
+ cursor: default;
+ }
+
+ :root & > input:active ~ label:after {
+ background: transparent;
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java b/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java
index c7a2610a21..c79447bd86 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/CheckBoxes.java
@@ -79,6 +79,11 @@ public class CheckBoxes extends VerticalLayout implements View {
check.addStyleName("large");
row.addComponent(check);
+ check = new CheckBox("Disabled", true);
+ check.setEnabled(false);
+ check.setIcon(testIcon.get());
+ row.addComponent(check);
+
h1 = new Label("Option Groups");
h1.addStyleName("h1");
addComponent(h1);
@@ -184,6 +189,17 @@ public class CheckBoxes extends VerticalLayout implements View {
options.setItemIcon(two, testIcon.get());
options.setItemIcon("Option Three", testIcon.get());
row.addComponent(options);
+
+ options = new OptionGroup("Disabled items");
+ options.setEnabled(false);
+ options.addItem("Option One");
+ options.addItem("Option Two");
+ options.addItem("Option Three");
+ options.select("Option One");
+ options.setItemIcon("Option One", testIcon.get());
+ options.setItemIcon("Option Two", testIcon.get());
+ options.setItemIcon("Option Three", testIcon.get(true));
+ row.addComponent(options);
}
@Override
diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
index a826d9a8f2..13b0c7144c 100644
--- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
+++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java
@@ -85,7 +85,7 @@ public class ValoThemeUITest extends MultiBrowserTest {
public void checkboxes() throws Exception {
openTestURL("test");
open("Check Boxes & Option Groups", "Check Boxes");
- compareScreen("checkboxes");
+ compareScreen("checkboxes_with_disabled");
}
@Test
--
cgit v1.2.3
From 7e8b23a73a5dd1bef54b8fc5ddc4d3c431c298af Mon Sep 17 00:00:00 2001
From: Anna Miroshnik
Date: Mon, 8 Dec 2014 17:25:00 +0300
Subject: Hierarchy change markAsDirty to AbstractComponentContainer (#14227)
Change-Id: I7a05ad72dfa3d16d85aa4d0cdd235572ec01e31a
---
server/src/com/vaadin/ui/AbsoluteLayout.java | 2 -
.../com/vaadin/ui/AbstractComponentContainer.java | 2 +
server/src/com/vaadin/ui/AbstractSplitPanel.java | 2 -
server/src/com/vaadin/ui/CssLayout.java | 4 --
server/src/com/vaadin/ui/CustomLayout.java | 4 +-
server/src/com/vaadin/ui/GridLayout.java | 3 --
server/src/com/vaadin/ui/TabSheet.java | 11 +++--
.../ComponentAttachDetachListenerTest.java | 50 ++++++++++++++++++++++
.../tests/minitutorials/v7a2/WidgetContainer.java | 2 -
9 files changed, 59 insertions(+), 21 deletions(-)
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java
index afc73f5ecc..af47981db6 100644
--- a/server/src/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/com/vaadin/ui/AbsoluteLayout.java
@@ -153,7 +153,6 @@ public class AbsoluteLayout extends AbstractLayout implements
internalRemoveComponent(c);
throw e;
}
- markAsDirty();
}
/**
@@ -197,7 +196,6 @@ public class AbsoluteLayout extends AbstractLayout implements
public void removeComponent(Component c) {
internalRemoveComponent(c);
super.removeComponent(c);
- markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractComponentContainer.java b/server/src/com/vaadin/ui/AbstractComponentContainer.java
index e70b0fa0ce..1095331602 100644
--- a/server/src/com/vaadin/ui/AbstractComponentContainer.java
+++ b/server/src/com/vaadin/ui/AbstractComponentContainer.java
@@ -209,6 +209,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
c.setParent(this);
fireComponentAttachEvent(c);
+ markAsDirty();
}
/**
@@ -223,6 +224,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent
if (equals(c.getParent())) {
c.setParent(null);
fireComponentDetachEvent(c);
+ markAsDirty();
}
}
diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java
index e9b37f8cff..a78f192fa2 100644
--- a/server/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -214,7 +214,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
} else if (c == getSecondComponent()) {
getState().secondChild = null;
}
- markAsDirty();
}
/*
@@ -256,7 +255,6 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
} else if (oldComponent == getSecondComponent()) {
setSecondComponent(newComponent);
}
- markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/CssLayout.java b/server/src/com/vaadin/ui/CssLayout.java
index e7b63cc87a..350423576f 100644
--- a/server/src/com/vaadin/ui/CssLayout.java
+++ b/server/src/com/vaadin/ui/CssLayout.java
@@ -118,7 +118,6 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.add(c);
try {
super.addComponent(c);
- markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -141,7 +140,6 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.addFirst(c);
try {
super.addComponent(c);
- markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -170,7 +168,6 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
components.add(index, c);
try {
super.addComponent(c);
- markAsDirty();
} catch (IllegalArgumentException e) {
components.remove(c);
throw e;
@@ -187,7 +184,6 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier {
public void removeComponent(Component c) {
components.remove(c);
super.removeComponent(c);
- markAsDirty();
}
/**
diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java
index f4fe7fa66c..a9c266b0b9 100644
--- a/server/src/com/vaadin/ui/CustomLayout.java
+++ b/server/src/com/vaadin/ui/CustomLayout.java
@@ -144,8 +144,8 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
}
slots.put(location, c);
getState().childLocations.put(c, location);
- c.setParent(this);
- fireComponentAttachEvent(c);
+
+ super.addComponent(c);
}
/**
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 0dd16a03e7..96854c5b1b 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -255,8 +255,6 @@ public class GridLayout extends AbstractLayout implements
cursorY = row1;
}
}
-
- markAsDirty();
}
/**
@@ -390,7 +388,6 @@ public class GridLayout extends AbstractLayout implements
getState().childData.remove(component);
components.remove(component);
-
super.removeComponent(component);
}
diff --git a/server/src/com/vaadin/ui/TabSheet.java b/server/src/com/vaadin/ui/TabSheet.java
index d3410464a2..88002104b1 100644
--- a/server/src/com/vaadin/ui/TabSheet.java
+++ b/server/src/com/vaadin/ui/TabSheet.java
@@ -195,7 +195,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
if (component != null && components.contains(component)) {
int componentIndex = components.indexOf(component);
-
super.removeComponent(component);
keyMapper.remove(component);
components.remove(component);
@@ -232,7 +231,6 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
fireSelectedTabChange();
}
}
- markAsDirty();
}
}
@@ -394,8 +392,9 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
setSelected(tabComponent);
fireSelectedTabChange();
}
+
super.addComponent(tabComponent);
- markAsDirty();
+
return tab;
}
}
@@ -967,16 +966,16 @@ public class TabSheet extends AbstractComponentContainer implements Focusable,
/**
* Gets the icon alt text for the tab.
- *
+ *
* @since 7.2
*/
public String getIconAlternateText();
/**
* Sets the icon alt text for the tab.
- *
+ *
* @since 7.2
- *
+ *
* @param iconAltText
* the icon to set
*/
diff --git a/server/tests/src/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java b/server/tests/src/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
index df515795eb..d8b366ffbc 100644
--- a/server/tests/src/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
+++ b/server/tests/src/com/vaadin/tests/server/components/ComponentAttachDetachListenerTest.java
@@ -9,6 +9,7 @@ import com.vaadin.ui.AbsoluteLayout.ComponentPosition;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.CustomLayout;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.GridLayout.Area;
import com.vaadin.ui.HasComponents;
@@ -25,6 +26,7 @@ public class ComponentAttachDetachListenerTest extends TestCase {
private GridLayout gridlayout;
private AbsoluteLayout absolutelayout;
private CssLayout csslayout;
+ private CustomLayout customlayout;
// General variables
private int attachCounter = 0;
@@ -143,6 +145,10 @@ public class ComponentAttachDetachListenerTest extends TestCase {
csslayout = new CssLayout();
csslayout.addComponentAttachListener(new MyAttachListener());
csslayout.addComponentDetachListener(new MyDetachListener());
+
+ customlayout = new CustomLayout("");
+ customlayout.addComponentAttachListener(new MyAttachListener());
+ customlayout.addComponentDetachListener(new MyDetachListener());
}
public void testOrderedLayoutAttachListener() {
@@ -342,4 +348,48 @@ public class ComponentAttachDetachListenerTest extends TestCase {
// The detached component should not be found in the container
assertFalse(foundInContainer);
}
+
+ public void testCustomLayoutAttachListener() {
+ // Reset state variables
+ resetVariables();
+
+ // Add component -> Should trigger attach listener
+ Component comp = new Label();
+ customlayout.addComponent(comp, "loc");
+
+ assertEquals("Attach counter should get incremented", 1, attachCounter);
+
+ assertSame("The attached component should be the label", comp,
+ attachedComponent);
+
+ assertSame("The attached target should be the layout", customlayout,
+ attachTarget);
+
+ assertTrue("The attached component should be found in the container",
+ foundInContainer);
+ }
+
+ public void testCustomLayoutDetachListener() {
+ // Add a component to detach
+ Component comp = new Label();
+ customlayout.addComponent(comp);
+
+ // Reset state variables (since they are set by the attach listener)
+ resetVariables();
+
+ // Detach the component -> triggers the detach listener
+ customlayout.removeComponent(comp);
+
+ assertEquals("Detach counter should get incremented", 1, detachCounter);
+
+ assertSame("The detached component should be the label", comp,
+ detachedComponent);
+
+ assertSame("The detached target should be the layout", customlayout,
+ detachedTarget);
+
+ assertFalse(
+ "The detached component should not be found in the container",
+ foundInContainer);
+ }
}
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java b/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
index 8c14ba8bd7..850fa1044f 100644
--- a/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
+++ b/uitest/src/com/vaadin/tests/minitutorials/v7a2/WidgetContainer.java
@@ -15,14 +15,12 @@ public class WidgetContainer extends AbstractComponentContainer {
public void addComponent(Component c) {
children.add(c);
super.addComponent(c);
- markAsDirty();
}
@Override
public void removeComponent(Component c) {
children.remove(c);
super.removeComponent(c);
- markAsDirty();
}
@Override
--
cgit v1.2.3
From 206055708b0a8e1c17a8c63d482a5e202d3ebf6d Mon Sep 17 00:00:00 2001
From: Teemu Pöntelin
Date: Mon, 8 Dec 2014 23:21:08 +0200
Subject: Fix issues when using java.sql.Date as DateField range (#15342)
Change-Id: I656cc0600f929239605e17ab9cf71dc1ba96582f
---
server/src/com/vaadin/ui/DateField.java | 14 +++---
.../components/datefield/DateRangeWithSqlDate.java | 54 ++++++++++++++++++++++
.../datefield/DateRangeWithSqlDateTest.java | 51 ++++++++++++++++++++
3 files changed, 113 insertions(+), 6 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDateTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/server/src/com/vaadin/ui/DateField.java b/server/src/com/vaadin/ui/DateField.java
index 030bd5f6c2..d5700c4b65 100644
--- a/server/src/com/vaadin/ui/DateField.java
+++ b/server/src/com/vaadin/ui/DateField.java
@@ -316,10 +316,10 @@ public class DateField extends AbstractField implements
throw new IllegalStateException(
"startDate cannot be later than endDate");
}
- getState().rangeStart = startDate;
- // rangeStart = startDate;
- // This has to be done to correct for the resolution
- // updateRangeState();
+
+ // Create a defensive copy against issues when using java.sql.Date (and
+ // also against mutable Date).
+ getState().rangeStart = new Date(startDate.getTime());
updateRangeValidator();
}
@@ -436,8 +436,10 @@ public class DateField extends AbstractField implements
throw new IllegalStateException(
"endDate cannot be earlier than startDate");
}
- // rangeEnd = endDate;
- getState().rangeEnd = endDate;
+
+ // Create a defensive copy against issues when using java.sql.Date (and
+ // also against mutable Date).
+ getState().rangeEnd = new Date(endDate.getTime());
updateRangeValidator();
}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java b/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java
new file mode 100644
index 0000000000..74d3e85892
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDate.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2014 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 com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.InlineDateField;
+
+public class DateRangeWithSqlDate extends AbstractTestUI {
+
+ // 2014-12-01
+ private static final java.sql.Date startDate = new java.sql.Date(
+ 1417467822699L);
+
+ // 2014-12-02
+ private static final java.sql.Date endDate = new java.sql.Date(
+ 1417554763317L);
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ DateField df = new InlineDateField();
+ df.setRangeStart(startDate);
+ df.setRangeEnd(endDate);
+
+ df.setValue(startDate);
+
+ addComponent(df);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test that java.sql.Date can be given to specify date range start and end dates.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 15342;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDateTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDateTest.java
new file mode 100644
index 0000000000..2352011585
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateRangeWithSqlDateTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2014 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 static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DateRangeWithSqlDateTest extends MultiBrowserTest {
+
+ @Test
+ public void testDateRange() {
+ openTestURL();
+
+ // Get all cells of the inline datefield.
+ List cells = driver.findElements(By
+ .className("v-inline-datefield-calendarpanel-day"));
+
+ // Verify the range is rendered correctly.
+ assertCell(cells.get(0), "30", true);
+ assertCell(cells.get(1), "1", false);
+ assertCell(cells.get(2), "2", false);
+ assertCell(cells.get(3), "3", true);
+ }
+
+ private void assertCell(WebElement cell, String text, boolean outsideRange) {
+ assertEquals(text, cell.getText());
+ assertEquals(outsideRange,
+ cell.getAttribute("class").contains("outside-range"));
+ }
+
+}
--
cgit v1.2.3
From 153129d52d0167a4d54d7c133155eeec7d407a19 Mon Sep 17 00:00:00 2001
From: Alexey Fansky
Date: Wed, 3 Dec 2014 17:07:43 -0800
Subject: Returning all validation errors in the exception cause when
submitting a field group (#14742)
Following the similar logic as in AbstractField when multiple validation errors occur. Catching all InvalidValueExceptions and putting them together wrapped into the exception.
Change-Id: Ied08fd2155412539b28ef94bc74e6c989c62f709
---
.../src/com/vaadin/data/fieldgroup/FieldGroup.java | 86 ++++++++++++++++------
uitest/ivy.xml | 2 +
.../tests/fieldgroup/MultipleValidationErrors.java | 72 ++++++++++++++++++
.../fieldgroup/MultipleValidationErrorsTest.java | 37 ++++++++++
.../PersonBeanWithValidationAnnotations.java | 31 ++++++++
5 files changed, 205 insertions(+), 23 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
create mode 100644 uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrorsTest.java
create mode 100644 uitest/src/com/vaadin/tests/fieldgroup/PersonBeanWithValidationAnnotations.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
index 5a4e877554..bcfa8395df 100644
--- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
+++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
@@ -26,6 +26,7 @@ import java.util.List;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
+import com.vaadin.data.Validator;
import com.vaadin.data.Validator.InvalidValueException;
import com.vaadin.data.util.TransactionalPropertyWrapper;
import com.vaadin.ui.AbstractField;
@@ -452,6 +453,54 @@ public class FieldGroup implements Serializable {
// Not using buffered mode, nothing to do
return;
}
+
+ startTransactions();
+
+ try {
+ firePreCommitEvent();
+
+ List invalidValueExceptions = commitFields();
+
+ if(invalidValueExceptions.isEmpty()) {
+ firePostCommitEvent();
+ commitTransactions();
+ } else {
+ throwInvalidValueException(invalidValueExceptions);
+ }
+ } catch (Exception e) {
+ rollbackTransactions();
+
+ throw new CommitException("Commit failed", e);
+ }
+
+ }
+
+ private List commitFields() {
+ List invalidValueExceptions = new ArrayList();
+
+ for (Field> f : fieldToPropertyId.keySet()) {
+ try {
+ f.commit();
+ } catch (InvalidValueException e) {
+ invalidValueExceptions.add(e);
+ }
+ }
+
+ return invalidValueExceptions;
+ }
+
+ private void throwInvalidValueException(List invalidValueExceptions) {
+ if(invalidValueExceptions.size() == 1) {
+ throw invalidValueExceptions.get(0);
+ } else {
+ InvalidValueException[] causes = invalidValueExceptions.toArray(
+ new InvalidValueException[invalidValueExceptions.size()]);
+
+ throw new InvalidValueException(null, causes);
+ }
+ }
+
+ private void startTransactions() throws CommitException {
for (Field> f : fieldToPropertyId.keySet()) {
Property.Transactional> property = (Property.Transactional>) f
.getPropertyDataSource();
@@ -462,33 +511,24 @@ public class FieldGroup implements Serializable {
}
property.startTransaction();
}
- try {
- firePreCommitEvent();
- // Commit the field values to the properties
- for (Field> f : fieldToPropertyId.keySet()) {
- f.commit();
- }
- firePostCommitEvent();
+ }
- // Commit the properties
- for (Field> f : fieldToPropertyId.keySet()) {
- ((Property.Transactional>) f.getPropertyDataSource())
- .commit();
- }
+ private void commitTransactions() {
+ for (Field> f : fieldToPropertyId.keySet()) {
+ ((Property.Transactional>) f.getPropertyDataSource())
+ .commit();
+ }
+ }
- } catch (Exception e) {
- for (Field> f : fieldToPropertyId.keySet()) {
- try {
- ((Property.Transactional>) f.getPropertyDataSource())
- .rollback();
- } catch (Exception rollbackException) {
- // FIXME: What to do ?
- }
+ private void rollbackTransactions() {
+ for (Field> f : fieldToPropertyId.keySet()) {
+ try {
+ ((Property.Transactional>) f.getPropertyDataSource())
+ .rollback();
+ } catch (Exception rollbackException) {
+ // FIXME: What to do ?
}
-
- throw new CommitException("Commit failed", e);
}
-
}
/**
diff --git a/uitest/ivy.xml b/uitest/ivy.xml
index 14c8bc6ce3..78171f9a9c 100644
--- a/uitest/ivy.xml
+++ b/uitest/ivy.xml
@@ -27,6 +27,8 @@
+
diff --git a/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java b/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
new file mode 100644
index 0000000000..5110bf6dcf
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrors.java
@@ -0,0 +1,72 @@
+package com.vaadin.tests.fieldgroup;
+
+import com.vaadin.data.Validator;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.validator.BeanValidator;
+import com.vaadin.server.AbstractErrorMessage;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import org.apache.commons.lang.StringEscapeUtils;
+
+public class MultipleValidationErrors extends AbstractTestUI {
+
+ public static final String FIRST_NAME_NOT_NULL_VALIDATION_MESSAGE = "first name is null";
+ public static final String LAST_NAME_NOT_NULL_VALIDATION_MESSAGE = "last name is null";
+ public static final String FIRST_NAME_NOT_EMPTY_VALIDATION_MESSAGE = "first name is empty";
+ public static final String LAST_NAME_NOT_EMPTY_VALIDATION_MESSAGE = "last name is empty";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ BeanItem item = new BeanItem(
+ new PersonBeanWithValidationAnnotations());
+ final FieldGroup fieldGroup = new FieldGroup(item);
+
+ bindTextField(item, fieldGroup, "First Name", "firstName");
+ bindTextField(item, fieldGroup, "Last Name", "lastName");
+
+ final Label validationErrors = new Label();
+ validationErrors.setId("validationErrors");
+ addComponent(validationErrors);
+
+ addButton("Submit", new Button.ClickListener() {
+ @Override
+ public void buttonClick(Button.ClickEvent event) {
+ validationErrors.setValue("");
+ try {
+ fieldGroup.commit();
+ } catch (FieldGroup.CommitException e) {
+ if (e.getCause() != null && e.getCause() instanceof Validator.InvalidValueException) {
+ validationErrors.setValue(StringEscapeUtils.unescapeHtml(
+ AbstractErrorMessage.getErrorMessageForException(e.getCause()).getFormattedHtmlMessage()));
+ }
+ }
+
+
+ }
+ });
+ }
+
+ private void bindTextField(BeanItem item, FieldGroup fieldGroup,
+ String caption, String propertyId) {
+ TextField textfield = new TextField(caption, item.getItemProperty(propertyId));
+ textfield.addValidator(new BeanValidator(PersonBeanWithValidationAnnotations.class, propertyId));
+
+ fieldGroup.bind(textfield, propertyId);
+
+ addComponent(textfield);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14742;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "All validation errors should be included when committing a field group.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrorsTest.java b/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrorsTest.java
new file mode 100644
index 0000000000..175b650be6
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/fieldgroup/MultipleValidationErrorsTest.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.fieldgroup;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class MultipleValidationErrorsTest extends MultiBrowserTest {
+
+ private void commitTextFields() {
+ $(ButtonElement.class).caption("Submit").first().click();
+ }
+
+ private void clearTextField(String caption) {
+ TextFieldElement textField = $(TextFieldElement.class).caption(caption).first();
+ textField.clear();
+ }
+
+ @Test
+ public void validationErrorsIncludeBothErrors() {
+ openTestURL();
+
+ clearTextField("First Name");
+ clearTextField("Last Name");
+
+ commitTextFields();
+
+ String validationErrors = $(LabelElement.class).id("validationErrors").getText();
+
+ assertThat(validationErrors, containsString(MultipleValidationErrors.FIRST_NAME_NOT_EMPTY_VALIDATION_MESSAGE));
+ assertThat(validationErrors, containsString(MultipleValidationErrors.LAST_NAME_NOT_EMPTY_VALIDATION_MESSAGE));
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/fieldgroup/PersonBeanWithValidationAnnotations.java b/uitest/src/com/vaadin/tests/fieldgroup/PersonBeanWithValidationAnnotations.java
new file mode 100644
index 0000000000..5f81ee248b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/fieldgroup/PersonBeanWithValidationAnnotations.java
@@ -0,0 +1,31 @@
+package com.vaadin.tests.fieldgroup;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+public class PersonBeanWithValidationAnnotations implements Serializable {
+ @NotNull(message = MultipleValidationErrors.FIRST_NAME_NOT_NULL_VALIDATION_MESSAGE)
+ @Size(min = 1, message = MultipleValidationErrors.FIRST_NAME_NOT_EMPTY_VALIDATION_MESSAGE)
+ private String firstName;
+
+ @NotNull(message = MultipleValidationErrors.LAST_NAME_NOT_NULL_VALIDATION_MESSAGE)
+ @Size(min = 1, message = MultipleValidationErrors.LAST_NAME_NOT_EMPTY_VALIDATION_MESSAGE)
+ private String lastName;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
\ No newline at end of file
--
cgit v1.2.3
From 8ce89592362226d6687e1267632a75d85774b67d Mon Sep 17 00:00:00 2001
From: Denis Anisimov
Date: Thu, 6 Nov 2014 09:15:15 +0200
Subject: Position calendar popup on the left side if there is no space
(#14757).
Change-Id: I83836bbf077033712a569c8eff52576b012b4dee
---
.../VAADIN/themes/valo/components/_datefield.scss | 2 +
.../src/com/vaadin/client/ui/VPopupCalendar.java | 165 ++++++++++++++-------
.../datefield/DateFieldPopupPosition.java | 52 +++++++
.../datefield/DateFieldPopupPositionTest.java | 68 +++++++++
.../datefield/DefaultDateFieldPopupPosition.java | 27 ++++
.../DefaultDateFieldPopupPositionTest.java | 43 ++++++
.../datefield/ValoDateFieldPopupPosition.java | 30 ++++
.../datefield/ValoDateFieldPopupPositionTest.java | 43 ++++++
8 files changed, 376 insertions(+), 54 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java
create mode 100644 uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/WebContent/VAADIN/themes/valo/components/_datefield.scss b/WebContent/VAADIN/themes/valo/components/_datefield.scss
index 3201288120..6d36ade43a 100644
--- a/WebContent/VAADIN/themes/valo/components/_datefield.scss
+++ b/WebContent/VAADIN/themes/valo/components/_datefield.scss
@@ -276,6 +276,8 @@
@include valo-overlay-style;
margin-top: ceil($v-unit-size/8) !important;
+ margin-bottom: ceil($v-unit-size/8) !important;
+ margin-right: ceil($v-unit-size/8) !important;
cursor: default;
width: auto;
diff --git a/client/src/com/vaadin/client/ui/VPopupCalendar.java b/client/src/com/vaadin/client/ui/VPopupCalendar.java
index 51b2ee22ec..15302f0784 100644
--- a/client/src/com/vaadin/client/ui/VPopupCalendar.java
+++ b/client/src/com/vaadin/client/ui/VPopupCalendar.java
@@ -42,6 +42,7 @@ import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.ComputedStyle;
import com.vaadin.client.VConsole;
import com.vaadin.client.ui.VCalendarPanel.FocusOutListener;
import com.vaadin.client.ui.VCalendarPanel.SubmitListener;
@@ -372,60 +373,7 @@ public class VPopupCalendar extends VTextualDate implements Field,
// clear previous values
popup.setWidth("");
popup.setHeight("");
- popup.setPopupPositionAndShow(new PositionCallback() {
- @Override
- public void setPosition(int offsetWidth, int offsetHeight) {
- final int w = offsetWidth;
- final int h = offsetHeight;
- final int browserWindowWidth = Window.getClientWidth()
- + Window.getScrollLeft();
- final int browserWindowHeight = Window.getClientHeight()
- + Window.getScrollTop();
- int t = calendarToggle.getAbsoluteTop();
- int l = calendarToggle.getAbsoluteLeft();
-
- // Add a little extra space to the right to avoid
- // problems with IE7 scrollbars and to make it look
- // nicer.
- int extraSpace = 30;
-
- boolean overflowRight = false;
- if (l + +w + extraSpace > browserWindowWidth) {
- overflowRight = true;
- // Part of the popup is outside the browser window
- // (to the right)
- l = browserWindowWidth - w - extraSpace;
- }
-
- if (t + h + calendarToggle.getOffsetHeight() + 30 > browserWindowHeight) {
- // Part of the popup is outside the browser window
- // (below)
- t = browserWindowHeight - h
- - calendarToggle.getOffsetHeight() - 30;
- if (!overflowRight) {
- // Show to the right of the popup button unless we
- // are in the lower right corner of the screen
- l += calendarToggle.getOffsetWidth();
- }
- }
-
- popup.setPopupPosition(l,
- t + calendarToggle.getOffsetHeight() + 2);
-
- /*
- * We have to wait a while before focusing since the popup
- * needs to be opened before we can focus
- */
- Timer focusTimer = new Timer() {
- @Override
- public void run() {
- setFocus(true);
- }
- };
-
- focusTimer.schedule(100);
- }
- });
+ popup.setPopupPositionAndShow(new PopupPositionCallback());
} else {
VConsole.error("Cannot reopen popup, it is already open!");
}
@@ -642,4 +590,113 @@ public class VPopupCalendar extends VTextualDate implements Field,
calendar.setRangeEnd(rangeEnd);
}
+ private class PopupPositionCallback implements PositionCallback {
+
+ @Override
+ public void setPosition(int offsetWidth, int offsetHeight) {
+ final int width = offsetWidth;
+ final int height = offsetHeight;
+ final int browserWindowWidth = Window.getClientWidth()
+ + Window.getScrollLeft();
+ final int windowHeight = Window.getClientHeight()
+ + Window.getScrollTop();
+ int left = calendarToggle.getAbsoluteLeft();
+
+ // Add a little extra space to the right to avoid
+ // problems with IE7 scrollbars and to make it look
+ // nicer.
+ int extraSpace = 30;
+
+ boolean overflow = left + width + extraSpace > browserWindowWidth;
+ if (overflow) {
+ // Part of the popup is outside the browser window
+ // (to the right)
+ left = browserWindowWidth - width - extraSpace;
+ }
+
+ int top = calendarToggle.getAbsoluteTop();
+ int extraHeight = 2;
+ boolean verticallyRepositioned = false;
+ ComputedStyle style = new ComputedStyle(popup.getElement());
+ int[] margins = style.getMargin();
+ int desiredPopupBottom = top + height
+ + calendarToggle.getOffsetHeight() + margins[0]
+ + margins[2];
+
+ if (desiredPopupBottom > windowHeight) {
+ int updatedLeft = left;
+ left = getLeftPosition(left, width, style, overflow);
+
+ // if position has not been changed then it means there is no
+ // space to make popup fully visible
+ if (updatedLeft == left) {
+ // let's try to show popup on the top of the field
+ int updatedTop = top - extraHeight - height - margins[0]
+ - margins[2];
+ verticallyRepositioned = updatedTop >= 0;
+ if (verticallyRepositioned) {
+ top = updatedTop;
+ }
+ }
+ // Part of the popup is outside the browser window
+ // (below)
+ if (!verticallyRepositioned) {
+ verticallyRepositioned = true;
+ top = windowHeight - height - extraSpace + extraHeight;
+ }
+ }
+ if (verticallyRepositioned) {
+ popup.setPopupPosition(left, top);
+ } else {
+ popup.setPopupPosition(left,
+ top + calendarToggle.getOffsetHeight() + extraHeight);
+ }
+ doSetFocus();
+ }
+
+ private int getLeftPosition(int left, int width, ComputedStyle style,
+ boolean overflow) {
+ if (positionRightSide()) {
+ // Show to the right of the popup button unless we
+ // are in the lower right corner of the screen
+ if (overflow) {
+ return left;
+ } else {
+ return left + calendarToggle.getOffsetWidth();
+ }
+ } else {
+ int[] margins = style.getMargin();
+ int desiredLeftPosition = calendarToggle.getAbsoluteLeft()
+ - width - margins[1] - margins[3];
+ if (desiredLeftPosition >= 0) {
+ return desiredLeftPosition;
+ } else {
+ return left;
+ }
+ }
+ }
+
+ private boolean positionRightSide() {
+ int buttonRightSide = calendarToggle.getAbsoluteLeft()
+ + calendarToggle.getOffsetWidth();
+ int textRightSide = text.getAbsoluteLeft() + text.getOffsetWidth();
+ return buttonRightSide >= textRightSide;
+ }
+
+ private void doSetFocus() {
+ /*
+ * We have to wait a while before focusing since the popup needs to
+ * be opened before we can focus
+ */
+ Timer focusTimer = new Timer() {
+ @Override
+ public void run() {
+ setFocus(true);
+ }
+ };
+
+ focusTimer.schedule(100);
+ }
+ }
+
}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
new file mode 100644
index 0000000000..4469ad3b1a
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPosition.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 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 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;
+
+/**
+ * Test UI for date field Popup calendar.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class DateFieldPopupPosition extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ HorizontalLayout layout = new HorizontalLayout();
+ addComponent(layout);
+ Label gap = new Label();
+ gap.setWidth(250, Unit.PIXELS);
+ layout.addComponent(gap);
+ PopupDateField field = new PopupDateField();
+ layout.addComponent(field);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14757;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Calendar popup should not placed on the top of text field when "
+ + "there is no space on bottom.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..f896519aae
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupPositionTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2014 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 org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test for date field popup calendar position.
+ *
+ * @author Vaadin Ltd
+ */
+public abstract class DateFieldPopupPositionTest extends MultiBrowserTest {
+
+ @Test
+ public void testPopupPosition() {
+ openTestURL();
+
+ int height = getFieldBottom() + 150;
+ adjustBrowserWindow(height);
+
+ openPopup();
+
+ checkPopupPosition();
+ }
+
+ protected abstract void checkPopupPosition();
+
+ protected WebElement getPopup() {
+ return findElement(By.className("v-datefield-popup"));
+ }
+
+ private void adjustBrowserWindow(int height) {
+ Dimension size = getDriver().manage().window().getSize();
+ getDriver().manage().window()
+ .setSize(new Dimension(size.getWidth(), height));
+ }
+
+ private int getFieldBottom() {
+ DateFieldElement dateField = $(DateFieldElement.class).first();
+ return dateField.getLocation().getY() + dateField.getSize().getHeight();
+ }
+
+ private void openPopup() {
+ findElement(By.className("v-datefield-button")).click();
+ if (!isElementPresent(By.className("v-datefield-popup"))) {
+ findElement(By.className("v-datefield-button")).click();
+ }
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java
new file mode 100644
index 0000000000..8e4de77837
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPosition.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2000-2014 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;
+
+/**
+ * Test UI for date field Popup calendar in default theme.
+ *
+ * All UI initialization is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class DefaultDateFieldPopupPosition extends DateFieldPopupPosition {
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..61cc876a3f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DefaultDateFieldPopupPositionTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 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 org.junit.Assert;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+
+/**
+ * Test for date field popup calendar position in default theme.
+ *
+ * Test method is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class DefaultDateFieldPopupPositionTest extends
+ DateFieldPopupPositionTest {
+
+ @Override
+ protected void checkPopupPosition() {
+ DateFieldElement field = $(DateFieldElement.class).first();
+ int right = field.getLocation().getX() + field.getSize().getWidth();
+ WebElement popup = getPopup();
+
+ Assert.assertTrue("Calendar popup has wrong X coordinate="
+ + popup.getLocation().getX() + " , right side of the field is "
+ + right, popup.getLocation().getX() >= right);
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java
new file mode 100644
index 0000000000..59ff6aa9e8
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPosition.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2014 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 com.vaadin.annotations.Theme;
+
+/**
+ * Test UI for date field Popup calendar in Valo theme.
+ *
+ * All UI initialization is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+@Theme("valo")
+public class ValoDateFieldPopupPosition extends DateFieldPopupPosition {
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java
new file mode 100644
index 0000000000..4009b9d991
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/ValoDateFieldPopupPositionTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 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 org.junit.Assert;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+
+/**
+ * Test for date field popup calendar position in Valo theme.
+ *
+ * Test method is defined in super class.
+ *
+ * @author Vaadin Ltd
+ */
+public class ValoDateFieldPopupPositionTest extends DateFieldPopupPositionTest {
+
+ @Override
+ protected void checkPopupPosition() {
+ DateFieldElement field = $(DateFieldElement.class).first();
+ WebElement popup = getPopup();
+ int left = field.getLocation().getX();
+ int popupRight = popup.getLocation().getX()
+ + popup.getSize().getWidth();
+
+ Assert.assertTrue("Calendar popup has wrong X coordinate=" + popupRight
+ + " , left side of the field is " + left, popupRight <= left);
+ }
+}
--
cgit v1.2.3
From e1b335022ec359061e696cf2711327663267e704 Mon Sep 17 00:00:00 2001
From: Sergey Budkin
Date: Tue, 25 Nov 2014 19:35:13 +0200
Subject: Long events aren't displayed properly when using Container (#15242)
Rewrote event selection.
Change-Id: I8f0dd1c5ec736ea14037619b1656a79b7e3532be
---
.../calendar/ContainerEventProvider.java | 74 ++++++----------------
.../calendar/BeanItemContainerLongEventTest.java | 55 ++++++++++++++++
.../calendar/BeanItemContainerTestUI.java | 8 +++
3 files changed, 81 insertions(+), 56 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
index fcaabcc079..2f51b21f7c 100644
--- a/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
+++ b/server/src/com/vaadin/ui/components/calendar/ContainerEventProvider.java
@@ -249,71 +249,33 @@ public class ContainerEventProvider implements CalendarEditableEventProvider,
@Override
public List getEvents(Date startDate, Date endDate) {
eventCache.clear();
-
- int[] rangeIndexes = getFirstAndLastEventIndex(startDate, endDate);
- for (int i = rangeIndexes[0]; i <= rangeIndexes[1]
- && i < container.size(); i++) {
- eventCache.add(getEvent(i));
- }
- return Collections.unmodifiableList(eventCache);
- }
-
- /**
- * Get the first event for a date
- *
- * @param date
- * The date to search for, NUll returns first event in container
- * @return Returns an array where the first item is the start index and the
- * second item is the end item
- */
- private int[] getFirstAndLastEventIndex(Date start, Date end) {
- int startIndex = 0;
int size = container.size();
assert size >= 0;
- int endIndex = size - 1;
- if (start != null) {
- /*
- * Iterating from the start of the container, if range is in the end
- * of the container then this will be slow TODO This could be
- * improved by using some sort of divide and conquer algorithm
- */
- while (startIndex < size) {
- Object id = container.getIdByIndex(startIndex);
- Item item = container.getItem(id);
- Date d = (Date) item.getItemProperty(startDateProperty)
+ for (int i = 0; i < size; i++) {
+ Object id = container.getIdByIndex(i);
+ Item item = container.getItem(id);
+ boolean add = true;
+ if (startDate != null) {
+ Date eventEnd = (Date) item.getItemProperty(endDateProperty)
.getValue();
- if (d.compareTo(start) >= 0) {
- break;
+ if (eventEnd.compareTo(startDate) < 0) {
+ add = false;
}
- startIndex++;
}
- }
-
- if (end != null) {
- /*
- * Iterate from the start index until range ends
- */
- endIndex = startIndex;
- while (endIndex < size - 1) {
- Object id = container.getIdByIndex(endIndex);
- Item item = container.getItem(id);
- Date d = (Date) item.getItemProperty(endDateProperty)
- .getValue();
- if (d == null) {
- // No end date present, use start date
- d = (Date) item.getItemProperty(startDateProperty)
- .getValue();
+ if (add && endDate != null) {
+ Date eventStart = (Date) item
+ .getItemProperty(startDateProperty).getValue();
+ if (eventStart.compareTo(endDate) >= 0) {
+ break; // because container is sorted, all further events
+ // will be even later
}
- if (d.compareTo(end) >= 0) {
- endIndex--;
- break;
- }
- endIndex++;
+ }
+ if (add) {
+ eventCache.add(getEvent(i));
}
}
-
- return new int[] { startIndex, endIndex };
+ return Collections.unmodifiableList(eventCache);
}
/*
diff --git a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
new file mode 100644
index 0000000000..0ec196f266
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2000-2014 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.calendar;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests if long event which began before the view period is shown (#15242)
+ */
+public class BeanItemContainerLongEventTest extends MultiBrowserTest {
+
+ @Override
+ protected String getDeploymentPath() {
+ return "/run/BeanItemContainerTestUI?restartApplication";
+ }
+
+ @Test
+ public void testEventDisplayedInWeekView() {
+ openTestURL();
+ WebElement target = driver.findElements(
+ By.className("v-calendar-week-number")).get(1);
+ target.click();
+ target = driver.findElement(By.className("v-calendar-event"));
+ Assert.assertEquals("Wrong event name", "Long event", target.getText());
+ }
+
+ @Test
+ public void testEventDisplayedInDayView() {
+ openTestURL();
+ WebElement target = driver.findElements(
+ By.className("v-calendar-day-number")).get(5);
+ target.click();
+ target = driver.findElement(By.className("v-calendar-event"));
+ Assert.assertEquals("Wrong event name", "Long event", target.getText());
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java
index 83fc4a03cb..bda3b34875 100644
--- a/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java
+++ b/uitest/src/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java
@@ -17,6 +17,7 @@ package com.vaadin.tests.components.calendar;
import java.util.Arrays;
import java.util.Date;
+import java.util.GregorianCalendar;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
@@ -69,6 +70,13 @@ public class BeanItemContainerTestUI extends UI {
table.setVisibleColumns(new Object[] { "caption", "description",
"start", "end" });
content.addComponent(table);
+
+ BasicEvent longEvent = new BasicEvent();
+ longEvent.setCaption("Long event");
+ longEvent.setAllDay(true);
+ longEvent.setStart(new GregorianCalendar(2000, 1, 3).getTime());
+ longEvent.setEnd(new GregorianCalendar(2000, 2, 5).getTime());
+ events.addBean(longEvent);
}
/**
--
cgit v1.2.3
From 98d0eec7bb50e4af342358d2aa2ed80fe4564c85 Mon Sep 17 00:00:00 2001
From: Jouni Koivuviita
Date: Wed, 10 Dec 2014 10:42:37 +0200
Subject: MenuBar submenus close unexpectedly if use Valo theme (#15255)
This fix is for animation-in and animation-out.
Fix was done in VMenuBar. VOverlay provides now hide() method with
possibility to enable/disable the animations via parameters boolean
animateIn, boolean animateOut. By default they are true (not to break
animate-in, animate-out for VWindow and VNotification)
Change-Id: I49981952c7c18a02edd7fa9e6d247bb18f660207
---
.../VAADIN/themes/valo/components/_menubar.scss | 4 -
client/src/com/vaadin/client/ui/VMenuBar.java | 28 +++++--
client/src/com/vaadin/client/ui/VOverlay.java | 91 ++++++++++++++--------
.../menubar/MenuBarSubmenusClosingValo.java | 60 ++++++++++++++
.../menubar/MenuBarSubmenusClosingValoTest.java | 72 +++++++++++++++++
5 files changed, 212 insertions(+), 43 deletions(-)
create mode 100644 uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValo.java
create mode 100644 uitest/src/com/vaadin/tests/components/menubar/MenuBarSubmenusClosingValoTest.java
(limited to 'uitest/src/com/vaadin/tests')
diff --git a/WebContent/VAADIN/themes/valo/components/_menubar.scss b/WebContent/VAADIN/themes/valo/components/_menubar.scss
index 9075eb7ba8..0f9c61d2ce 100644
--- a/WebContent/VAADIN/themes/valo/components/_menubar.scss
+++ b/WebContent/VAADIN/themes/valo/components/_menubar.scss
@@ -70,10 +70,6 @@
.#{$primary-stylename}-popup {
@include valo-menubar-popup-style($primary-stylename);
-
- &.#{$primary-stylename}-popup-animate-out {
- @include animation(none);
- }
}
diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java
index 5102e6faea..66160e691d 100644
--- a/client/src/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/com/vaadin/client/ui/VMenuBar.java
@@ -476,7 +476,8 @@ public class VMenuBar extends SimpleFocusablePanel implements
if (menuVisible && visibleChildMenu != item.getSubMenu()
&& popup != null) {
- popup.hide();
+ // #15255 - disable animation-in/out when hide in this case
+ popup.hide(false, false, false);
}
if (menuVisible && item.getSubMenu() != null
@@ -707,9 +708,22 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Recursively hide all child menus
*/
public void hideChildren() {
+ hideChildren(true, true);
+ }
+
+ /**
+ *
+ * Recursively hide all child menus
+ *
+ * @param animateIn
+ * enable/disable animate-in animation when hide popup
+ * @param animateOut
+ * enable/disable animate-out animation when hide popup
+ */
+ public void hideChildren(boolean animateIn, boolean animateOut) {
if (visibleChildMenu != null) {
- visibleChildMenu.hideChildren();
- popup.hide();
+ visibleChildMenu.hideChildren(animateIn, animateOut);
+ popup.hide(false, animateIn, animateOut);
}
}
@@ -1326,7 +1340,8 @@ public class VMenuBar extends SimpleFocusablePanel implements
VMenuBar root = getParentMenu();
root.getSelected().getSubMenu().setSelected(null);
- root.hideChildren();
+ // #15255 - disable animate-in/out when hide popup
+ root.hideChildren(false, false);
// Get the root menus items and select the previous one
int idx = root.getItems().indexOf(root.getSelected());
@@ -1383,8 +1398,9 @@ public class VMenuBar extends SimpleFocusablePanel implements
root = root.getParentMenu();
}
- // Hide the submenu
- root.hideChildren();
+ // Hide the submenu (#15255 - disable animate-in/out when hide
+ // popup)
+ root.hideChildren(false, false);
// Get the root menus items and select the next one
int idx = root.getItems().indexOf(root.getSelected());
diff --git a/client/src/com/vaadin/client/ui/VOverlay.java b/client/src/com/vaadin/client/ui/VOverlay.java
index dfd81faf94..9071b6ee47 100644
--- a/client/src/com/vaadin/client/ui/VOverlay.java
+++ b/client/src/com/vaadin/client/ui/VOverlay.java
@@ -51,7 +51,7 @@ import com.vaadin.client.Util;
* temporary float over other components like context menus etc. This is to deal
* stacking order correctly with VWindow objects.
*
- *
+ *
*
Shadow
*
* The separate shadow element underneath the main overlay element is
@@ -62,7 +62,7 @@ import com.vaadin.client.Util;
* supports, add -webkit-box-shadow and the standard
* box-shadow properties.
*
- *
+ *
*
* For IE8, which doesn't support CSS box-shadow, you can use the proprietary
* DropShadow filter. It doesn't provide the exact same features as box-shadow,
@@ -70,7 +70,7 @@ import com.vaadin.client.Util;
* border or a pseudo-element underneath the overlay which mimics a shadow, or
* any combination of these.
*