From e4ba60c26a6a9616c9dc1ba19e15896a5e24d1d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leif=20=C3=85strand?= Date: Wed, 10 Dec 2014 09:48:38 +0200 Subject: [PATCH] Don't set frozen column count before columns have been updated (#13334) Change-Id: I63ab65dad6dacfb5dafe55147c18d3e4ec0e36a5 --- .../client/connectors/GridConnector.java | 5 +++ .../com/vaadin/shared/ui/grid/GridState.java | 1 - .../components/grid/InitialFrozenColumns.java | 41 +++++++++++++++++++ .../grid/InitialFrozenColumnsTest.java | 40 ++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumns.java create mode 100644 uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 556a5ad7aa..af5affde08 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -471,6 +471,11 @@ public class GridConnector extends AbstractHasComponentsConnector implements getState().editorRowEnabled); } + if (stateChangeEvent.hasPropertyChanged("frozenColumnCount")) { + getWidget().setFrozenColumnCount( + getState().frozenColumnCount); + } + } }); diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java index c30ebae474..aae4005d7f 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java @@ -116,7 +116,6 @@ public class GridState extends AbstractComponentState { public GridStaticSectionState footer = new GridStaticSectionState(); /** The number of frozen columns */ - @DelegateToWidget public int frozenColumnCount = 0; /** The height of the Grid in terms of body rows. */ diff --git a/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumns.java b/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumns.java new file mode 100644 index 0000000000..b6da30d314 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumns.java @@ -0,0 +1,41 @@ +/* + * 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.grid; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; + +public class InitialFrozenColumns extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid grid = new Grid(); + grid.setSelectionMode(SelectionMode.NONE); + + grid.addColumn("foo").setWidth(200); + grid.addColumn("bar").setWidth(200); + grid.addColumn("baz").setWidth(200); + + grid.addRow("a", "b", "c"); + + grid.setFrozenColumnCount(2); + + addComponent(grid); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java b/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java new file mode 100644 index 0000000000..2e5fc4815e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/InitialFrozenColumnsTest.java @@ -0,0 +1,40 @@ +/* + * 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.grid; + +import static org.junit.Assert.assertTrue; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.NotificationElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class InitialFrozenColumnsTest extends MultiBrowserTest { + @Test + public void testInitialFrozenColumns() { + setDebug(true); + openTestURL(); + + Assert.assertFalse("Notification was present", + isElementPresent(NotificationElement.class)); + + WebElement cell = $(GridElement.class).first().getCell(0, 0); + assertTrue(cell.getAttribute("class").contains("frozen")); + } +} -- 2.39.5