diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-07-04 14:37:48 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-07-07 10:21:35 +0300 |
commit | a2db5af7e6978da165748f6b5ab94880a52d5f96 (patch) | |
tree | bab51e1fea1d533445410be552dde6f66ac54dbb | |
parent | 87e64d5af9cc1dc2a8d79be6227661b64b2077b5 (diff) | |
download | vaadin-framework-a2db5af7e6978da165748f6b5ab94880a52d5f96.tar.gz vaadin-framework-a2db5af7e6978da165748f6b5ab94880a52d5f96.zip |
Fix setting SelectionMode on application start (#13334)
Change-Id: I7993a1e7c0ecfc1f75adfe0c156cd41528fea329
3 files changed, 22 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/GridConnector.java b/client/src/com/vaadin/client/ui/grid/GridConnector.java index 9873ca3d2f..9ba1e9f038 100644 --- a/client/src/com/vaadin/client/ui/grid/GridConnector.java +++ b/client/src/com/vaadin/client/ui/grid/GridConnector.java @@ -119,8 +119,8 @@ public class GridConnector extends AbstractComponentConnector { // find new deselections for (String key : selectedKeys) { - changed = true; if (!stateKeys.contains(key)) { + changed = true; deselectByHandle(dataSource.getHandleByKey(key)); } } @@ -203,7 +203,7 @@ public class GridConnector extends AbstractComponentConnector { * Maps a generated column id to a grid column instance */ private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<String, CustomGridColumn>(); - private AbstractRowHandleSelectionModel<JSONObject> selectionModel = new SelectionModelMulti<JSONObject>(); + private AbstractRowHandleSelectionModel<JSONObject> selectionModel = createSelectionModel(SharedSelectionMode.NONE); private RpcDataSource dataSource; private final RowKeyHelper rowKeyHelper = new RowKeyHelper(); @@ -495,7 +495,9 @@ public class GridConnector extends AbstractComponentConnector { if (!model.getClass().equals(selectionModel.getClass())) { selectionModel = model; getWidget().setSelectionModel(model); + rowKeyHelper.selectedKeys.clear(); } + } private Logger getLogger() { diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java index d7310d4264..995188db5c 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeatures.java @@ -128,6 +128,8 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { grid.getColumn("Column" + col).setWidth(100 + col * 50); } + grid.setSelectionMode(SelectionMode.NONE); + createGridActions(); createColumnActions(); @@ -165,7 +167,7 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { selectionModes.put("single", SelectionMode.SINGLE); selectionModes.put("multi", SelectionMode.MULTI); selectionModes.put("none", SelectionMode.NONE); - createSelectAction("Selection mode", "State", selectionModes, "multi", + createSelectAction("Selection mode", "State", selectionModes, "none", new Command<Grid, Grid.SelectionMode>() { @Override public void execute(Grid grid, SelectionMode selectionMode, diff --git a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java index 3dc8ac814f..2546def990 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridBasicFeaturesTest.java @@ -306,6 +306,8 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { public void testSelectOnOff() throws Exception { openTestURL(); + setSelectionModelMulti(); + assertFalse("row shouldn't start out as selected", isSelected(getRow(0))); toggleFirstRowSelection(); @@ -317,6 +319,9 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { @Test public void testSelectOnScrollOffScroll() throws Exception { openTestURL(); + + setSelectionModelMulti(); + assertFalse("row shouldn't start out as selected", isSelected(getRow(0))); toggleFirstRowSelection(); @@ -332,6 +337,9 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { @Test public void testSelectScrollOnScrollOff() throws Exception { openTestURL(); + + setSelectionModelMulti(); + assertFalse("row shouldn't start out as selected", isSelected(getRow(0))); @@ -349,6 +357,9 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { @Test public void testSelectScrollOnOffScroll() throws Exception { openTestURL(); + + setSelectionModelMulti(); + assertFalse("row shouldn't start out as selected", isSelected(getRow(0))); @@ -395,6 +406,10 @@ public class GridBasicFeaturesTest extends MultiBrowserTest { assertTrue(vscrollStyleName.contains(stylename + "-scroller-vertical")); } + private void setSelectionModelMulti() { + selectMenuPath("Component", "State", "Selection mode", "multi"); + } + private WebElement getBodyCellByRowAndColumn(int row, int column) { return getGridElement().getCell(row, column); } |