diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-01-21 11:33:53 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-01-26 15:53:36 +0000 |
commit | a6a3060fb21441cf9925f70c5ff4fed327b47ca6 (patch) | |
tree | 9a1d3b2a5cced73bdb81ec40978c476da1629a29 | |
parent | 425e91b77da4b7078a9ab1a4df141c3de71de355 (diff) | |
download | vaadin-framework-a6a3060fb21441cf9925f70c5ff4fed327b47ca6.tar.gz vaadin-framework-a6a3060fb21441cf9925f70c5ff4fed327b47ca6.zip |
Fix Grid not always showing select all checkbox (#16397)
Change-Id: I35f0e9fa615ab23153b638b80f12cd539bd2c52e
3 files changed, 82 insertions, 7 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 488dac37ef..827e366de0 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -490,13 +490,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements public void onStateChanged(final StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); - if (stateChangeEvent.hasPropertyChanged("selectionMode")) { - onSelectionModeChange(); - } - if (stateChangeEvent.hasPropertyChanged("selectedKeys")) { - updateSelectionFromState(); - } - // Column updates if (stateChangeEvent.hasPropertyChanged("columns")) { @@ -518,6 +511,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements } } + // Header and footer if (stateChangeEvent.hasPropertyChanged("header")) { updateHeaderFromState(getState().header); } @@ -526,19 +520,31 @@ public class GridConnector extends AbstractHasComponentsConnector implements updateFooterFromState(getState().footer); } + // Selection + if (stateChangeEvent.hasPropertyChanged("selectionMode")) { + onSelectionModeChange(); + } + if (stateChangeEvent.hasPropertyChanged("selectedKeys")) { + updateSelectionFromState(); + } + + // Sorting if (stateChangeEvent.hasPropertyChanged("sortColumns") || stateChangeEvent.hasPropertyChanged("sortDirs")) { onSortStateChange(); } + // Editor if (stateChangeEvent.hasPropertyChanged("editorEnabled")) { getWidget().setEditorEnabled(getState().editorEnabled); } + // Frozen columns if (stateChangeEvent.hasPropertyChanged("frozenColumnCount")) { getWidget().setFrozenColumnCount(getState().frozenColumnCount); } + // Theme features String activeTheme = getConnection().getUIConnector().getActiveTheme(); if (lastKnownTheme == null) { lastKnownTheme = activeTheme; diff --git a/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java b/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java new file mode 100644 index 0000000000..10d4977623 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java @@ -0,0 +1,34 @@ +/* + * 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 GridMultiSelectionOnInit extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid grid = new Grid(); + grid.addColumn("foo", String.class); + grid.addRow("Foo 1"); + grid.addRow("Foo 2"); + grid.setSelectionMode(SelectionMode.MULTI); + addComponent(grid); + } +} diff --git a/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java b/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java new file mode 100644 index 0000000000..5f5b4df8de --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/GridMultiSelectionOnInitTest.java @@ -0,0 +1,35 @@ +/* + * 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.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridMultiSelectionOnInitTest extends MultiBrowserTest { + + @Test + public void testSelectAllCheckBoxExists() { + openTestURL(); + assertTrue("The select all checkbox was missing.", + $(GridElement.class).first().getHeaderCell(0, 0) + .isElementPresent(By.tagName("input"))); + } +} |