aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2016-12-05 13:11:59 +0200
committerDenis <denis@vaadin.com>2016-12-05 14:11:59 +0300
commit0cef38513b58f4b486dfb1c0e3c154eed6039743 (patch)
tree062df7cbcdb34c0047e01464662bf2a773990367 /server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java
parent154a6a01148e84344e9730f9654ca3fc0190d907 (diff)
downloadvaadin-framework-0cef38513b58f4b486dfb1c0e3c154eed6039743.tar.gz
vaadin-framework-0cef38513b58f4b486dfb1c0e3c154eed6039743.zip
Add a SelectionMode shorthand for Grid. (#83)
* Add a SelectionMode shorthand for Grid. Hides setSelectionModel(...) by making it protected. Refactores the usage of constructor / extend method for Abstract-, Single- and MultiSelectionModelImpl. Fixes vaadin/framework8-issues#519 Change-Id: I48c30886450506639be9ee6e21c45b0c06755c88
Diffstat (limited to 'server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java')
-rw-r--r--server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java b/server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java
index e31b2ab188..703ed9e170 100644
--- a/server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java
+++ b/server/src/test/java/com/vaadin/data/GridAsMultiSelectInBinder.java
@@ -24,9 +24,9 @@ import com.vaadin.tests.data.bean.BeanWithEnums;
import com.vaadin.tests.data.bean.Sex;
import com.vaadin.tests.data.bean.TestEnum;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.MultiSelect;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
public class GridAsMultiSelectInBinder
extends BinderTestBase<Binder<BeanWithEnums>, BeanWithEnums> {
@@ -50,10 +50,6 @@ public class GridAsMultiSelectInBinder
private class CustomMultiSelectModel extends MultiSelectionModelImpl<Sex> {
- public CustomMultiSelectModel(Grid<Sex> grid) {
- super(grid);
- }
-
@Override
public void updateSelection(Set<Sex> addedItems, Set<Sex> removedItems,
boolean userOriginated) {
@@ -72,7 +68,7 @@ public class GridAsMultiSelectInBinder
item = new BeanWithEnums();
grid = new Grid<>();
grid.setItems(TestEnum.values());
- grid.setSelectionModel(new MultiSelectionModelImpl<>(grid));
+ grid.setSelectionMode(SelectionMode.MULTI);
select = grid.asMultiSelect();
converterBinder.forField(select)
@@ -82,7 +78,7 @@ public class GridAsMultiSelectInBinder
@Test(expected = IllegalStateException.class)
public void boundGridInBinder_selectionModelChanged_throws() {
- grid.setSelectionModel(new SingleSelectionModelImpl<>(grid));
+ grid.setSelectionMode(SelectionMode.SINGLE);
select.select(TestEnum.ONE);
}
@@ -204,9 +200,12 @@ public class GridAsMultiSelectInBinder
@Test
public void addValueChangeListener_selectionUpdated_eventTriggeredForMultiSelect() {
- Grid<Sex> grid = new Grid<>();
- CustomMultiSelectModel model = new CustomMultiSelectModel(grid);
- grid.setSelectionModel(model);
+ CustomMultiSelectModel model = new CustomMultiSelectModel();
+ Grid<Sex> grid = new Grid<Sex>() {
+ {
+ setSelectionModel(model);
+ }
+ };
grid.setItems(Sex.values());
MultiSelect<Sex> select = grid.asMultiSelect();