summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-01-07 16:17:00 +0200
committerJohannes Dahlström <johannesd@vaadin.com>2015-01-08 09:15:23 +0000
commit81165cf0bdb7821f28aa40e9689969adfddb666f (patch)
tree4b28996ae22c6a59846e7d8fdb261993f1dceed4
parent864c5c70dc96a4d79985eb3b4fadb952d320f928 (diff)
downloadvaadin-framework-81165cf0bdb7821f28aa40e9689969adfddb666f.tar.gz
vaadin-framework-81165cf0bdb7821f28aa40e9689969adfddb666f.zip
Change Grid default selection model to Single (#15435)
Change-Id: Iba651c043fa47125b12d17371947042cbb03a589
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java7
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java2
-rw-r--r--server/src/com/vaadin/ui/Grid.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java8
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridAddRow.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridColspans.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java8
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java2
9 files changed, 21 insertions, 16 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index 31bc2ac673..c3d46a4295 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -326,7 +326,7 @@ public class GridConnector extends AbstractHasComponentsConnector implements
*/
private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<String, CustomGridColumn>();
- private AbstractRowHandleSelectionModel<JsonObject> selectionModel = createSelectionModel(SharedSelectionMode.NONE);
+ private AbstractRowHandleSelectionModel<JsonObject> selectionModel;
private Set<String> selectedKeys = new LinkedHashSet<String>();
private List<String> columnOrder = new ArrayList<String>();
@@ -396,8 +396,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
});
- getWidget().setSelectionModel(selectionModel);
-
getWidget().addSelectionHandler(internalSelectionChangeHandler);
getWidget().addSortHandler(new SortHandler<JsonObject>() {
@@ -751,7 +749,8 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
AbstractRowHandleSelectionModel<JsonObject> model = createSelectionModel(mode);
- if (!model.getClass().equals(selectionModel.getClass())) {
+ if (selectionModel == null
+ || !model.getClass().equals(selectionModel.getClass())) {
selectionModel = model;
getWidget().setSelectionModel(model);
selectedKeys.clear();
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index 28cc1000ce..8c1b833acc 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -3398,7 +3398,7 @@ public class Grid<T> extends ResizeComposite implements
editor.setGrid(this);
- setSelectionMode(SelectionMode.MULTI);
+ setSelectionMode(SelectionMode.SINGLE);
escalator.addScrollHandler(new ScrollHandler() {
@Override
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index 5b29d1f10b..d9f1b266a2 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -2578,7 +2578,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
* Grid initial setup
*/
private void initGrid() {
- setSelectionMode(SelectionMode.MULTI);
+ setSelectionMode(SelectionMode.SINGLE);
addSelectionListener(new SelectionListener() {
@Override
public void select(SelectionEvent event) {
diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java
index 07a138c6ca..7f09677b50 100644
--- a/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java
+++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridSelection.java
@@ -99,8 +99,8 @@ public class GridSelection {
}
@Test
- public void defaultSelectionModeIsMulti() {
- assertTrue(grid.getSelectionModel() instanceof SelectionModel.Multi);
+ public void defaultSelectionModeIsSingle() {
+ assertTrue(grid.getSelectionModel() instanceof SelectionModel.Single);
}
@Test(expected = IllegalStateException.class)
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java
index 38ce49b622..ceaceb661d 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridAddAndRemoveDataOnInitTest.java
@@ -31,14 +31,14 @@ public class GridAddAndRemoveDataOnInitTest extends MultiBrowserTest {
openTestURL();
GridElement gridAdd = $(GridElement.class).first();
- if (!gridAdd.isElementPresent(By.vaadin("#cell[9][1]"))
- || gridAdd.isElementPresent(By.vaadin("#cell[10][1]"))) {
+ if (!gridAdd.isElementPresent(By.vaadin("#cell[9][0]"))
+ || gridAdd.isElementPresent(By.vaadin("#cell[10][0]"))) {
Assert.fail("Grid with added data contained incorrect rows");
}
GridElement gridRemove = $(GridElement.class).get(1);
- if (!gridRemove.isElementPresent(By.vaadin("#cell[4][1]"))
- || gridRemove.isElementPresent(By.vaadin("#cell[5][1]"))) {
+ if (!gridRemove.isElementPresent(By.vaadin("#cell[4][0]"))
+ || gridRemove.isElementPresent(By.vaadin("#cell[5][0]"))) {
Assert.fail("Grid with removed data contained incorrect rows");
}
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java b/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java
index 74beb20914..fa2d7b5399 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridAddRow.java
@@ -20,6 +20,7 @@ import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
public class GridAddRow extends AbstractTestUI {
@@ -27,6 +28,7 @@ public class GridAddRow extends AbstractTestUI {
protected void setup(VaadinRequest request) {
final Grid grid = new Grid();
+ grid.setSelectionMode(SelectionMode.MULTI);
grid.addColumn("firstName");
grid.addColumn("age", Integer.class);
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridColspans.java b/uitest/src/com/vaadin/tests/components/grid/GridColspans.java
index f61a39a1f2..80337971b6 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridColspans.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridColspans.java
@@ -25,6 +25,7 @@ import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.renderer.NumberRenderer;
public class GridColspans extends AbstractTestUI {
@@ -48,6 +49,7 @@ public class GridColspans extends AbstractTestUI {
grid = new Grid(dataSource);
grid.setWidth("600px");
grid.getColumn("zipCode").setRenderer(new NumberRenderer());
+ grid.setSelectionMode(SelectionMode.MULTI);
addComponent(grid);
HeaderRow row = grid.prependHeaderRow();
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java
index af9aa3aad3..c71dd80360 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridGeneratedPropertiesTest.java
@@ -34,7 +34,7 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest {
openTestURL();
GridElement grid = $(GridElement.class).first();
assertEquals("Miles header wasn't present.", "miles", grid
- .getHeaderCell(0, 3).getText().toLowerCase());
+ .getHeaderCell(0, 2).getText().toLowerCase());
}
@Test
@@ -43,13 +43,13 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest {
GridElement grid = $(GridElement.class).first();
// Overwritten foo property should not be sortable
- GridCellElement fooHeader = grid.getHeaderCell(0, 1);
+ GridCellElement fooHeader = grid.getHeaderCell(0, 0);
fooHeader.click();
assertFalse("Column foo was unexpectedly sorted.", fooHeader
.getAttribute("class").contains("sort"));
// Generated property miles is not sortable
- GridCellElement milesHeader = grid.getHeaderCell(0, 3);
+ GridCellElement milesHeader = grid.getHeaderCell(0, 2);
milesHeader.click();
assertFalse("Column miles was unexpectedly sorted.", milesHeader
.getAttribute("class").contains("sort"));
@@ -61,7 +61,7 @@ public class GridGeneratedPropertiesTest extends MultiBrowserTest {
GridElement grid = $(GridElement.class).first();
// Generated property baz is sortable
- GridCellElement bazHeader = grid.getHeaderCell(0, 4);
+ GridCellElement bazHeader = grid.getHeaderCell(0, 3);
bazHeader.click();
assertTrue("Column baz was not sorted ascending", bazHeader
.getAttribute("class").contains("sort-asc"));
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java
index 7c9eb66012..765cd01812 100644
--- a/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java
+++ b/uitest/src/com/vaadin/tests/components/grid/GridHeaderStyleNames.java
@@ -27,6 +27,7 @@ import com.vaadin.ui.Grid.FooterCell;
import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderCell;
import com.vaadin.ui.Grid.HeaderRow;
+import com.vaadin.ui.Grid.SelectionMode;
@Theme("valo")
public class GridHeaderStyleNames extends AbstractTestUIWithLog {
@@ -40,6 +41,7 @@ public class GridHeaderStyleNames extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
Grid grid = new Grid();
+ grid.setSelectionMode(SelectionMode.MULTI);
grid.setContainerDataSource(BeanItemContainerGenerator
.createContainer(100));