summaryrefslogtreecommitdiffstats
path: root/uitest
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 /uitest
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 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridCustomSelectionModel.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolled.java5
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java13
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java14
5 files changed, 18 insertions, 25 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridCustomSelectionModel.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridCustomSelectionModel.java
index 220f059f52..d729370ff5 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridCustomSelectionModel.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridCustomSelectionModel.java
@@ -32,9 +32,6 @@ public class GridCustomSelectionModel extends AbstractTestUI {
public static class MySelectionModel
extends MultiSelectionModelImpl<DataObject> {
- public MySelectionModel(Grid<DataObject> grid) {
- super(grid);
- }
}
private Grid<DataObject> grid;
@@ -47,9 +44,7 @@ public class GridCustomSelectionModel extends AbstractTestUI {
// Create grid
grid = new Grid<DataObject>() {
{
- MySelectionModel model = new MySelectionModel(this);
- setSelectionModel(model);
- model.extend(this);
+ setSelectionModel(new MySelectionModel());
}
};
grid.setItems(data);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java
index 46ac8ec260..b2d31200b6 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDisabledMultiselect.java
@@ -4,7 +4,7 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
+import com.vaadin.ui.Grid.SelectionMode;
public class GridDisabledMultiselect extends AbstractReindeerTestUI {
@@ -18,7 +18,7 @@ public class GridDisabledMultiselect extends AbstractReindeerTestUI {
addButton("Multi", new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
- grid.setSelectionModel(new MultiSelectionModelImpl<>(grid));
+ grid.setSelectionMode(SelectionMode.MULTI);
}
});
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolled.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolled.java
index 2875e18119..b251e740b7 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolled.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragSelectionWhileScrolled.java
@@ -20,10 +20,10 @@ import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.tests.components.grid.basics.DataObject;
import com.vaadin.tests.components.grid.basics.GridBasics;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Layout;
import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.renderers.DateRenderer;
import com.vaadin.ui.renderers.HtmlRenderer;
import com.vaadin.ui.renderers.NumberRenderer;
@@ -55,8 +55,7 @@ public class GridDragSelectionWhileScrolled extends AbstractTestUI {
.setCaption(GridBasics.COLUMN_CAPTIONS[5]);
grid.addColumn(DataObject::getBigRandom, new NumberRenderer())
.setCaption(GridBasics.COLUMN_CAPTIONS[6]);
-
- grid.setSelectionModel(new MultiSelectionModelImpl<>(grid));
+ grid.setSelectionMode(SelectionMode.MULTI);
layout.addComponent(grid);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java
index 356935f7b8..6ef8337c21 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java
@@ -21,6 +21,7 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.RadioButtonGroup;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisible;
@@ -32,9 +33,9 @@ public class GridMultiSelectionOnInit extends AbstractTestUI {
final Grid<String> grid = new Grid<>();
grid.setItems("Foo 1", "Foo 2");
grid.addColumn(item -> item);
- MultiSelectionModelImpl<String> model = new MultiSelectionModelImpl<>(
- grid);
- grid.setSelectionModel(model);
+ MultiSelectionModelImpl<String> selectionModel = (MultiSelectionModelImpl<String>) grid
+ .setSelectionMode(SelectionMode.MULTI);
+
addComponent(grid);
addComponent(new Button("Select rows",
@@ -48,9 +49,9 @@ public class GridMultiSelectionOnInit extends AbstractTestUI {
Arrays.asList(SelectAllCheckBoxVisible.VISIBLE,
SelectAllCheckBoxVisible.HIDDEN,
SelectAllCheckBoxVisible.DEFAULT));
- rbg.setValue(model.getSelectAllCheckBoxVisible());
- rbg.addValueChangeListener(
- event -> model.setSelectAllCheckBoxVisible(event.getValue()));
+ rbg.setValue(selectionModel.getSelectAllCheckBoxVisible());
+ rbg.addValueChangeListener(event -> selectionModel
+ .setSelectAllCheckBoxVisible(event.getValue()));
addComponent(rbg);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
index 6d5a678ca7..70b7eab470 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
@@ -31,6 +31,7 @@ import com.vaadin.ui.Grid.DetailsGenerator;
import com.vaadin.ui.Grid.FooterRow;
import com.vaadin.ui.Grid.HeaderRow;
import com.vaadin.ui.Grid.MultiSelectionModel;
+import com.vaadin.ui.Grid.SelectionMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.Command;
@@ -42,7 +43,6 @@ import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisible;
-import com.vaadin.ui.components.grid.NoSelectionModel;
import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
import com.vaadin.ui.renderers.DateRenderer;
import com.vaadin.ui.renderers.HtmlRenderer;
@@ -488,7 +488,7 @@ public class GridBasics extends AbstractTestUIWithLog {
null);
selectionModelItem.addItem("single", menuItem -> {
selectionListenerRegistration.remove();
- grid.setSelectionModel(new SingleSelectionModelImpl<>(grid));
+ grid.setSelectionMode(SelectionMode.SINGLE);
selectionListenerRegistration = ((SingleSelectionModelImpl<DataObject>) grid
.getSelectionModel())
.addSelectionListener(this::onSingleSelect);
@@ -498,7 +498,7 @@ public class GridBasics extends AbstractTestUIWithLog {
});
selectionModelItem.addItem("none", menuItem -> {
selectionListenerRegistration.remove();
- grid.setSelectionModel(new NoSelectionModel<>(grid));
+ grid.setSelectionMode(SelectionMode.NONE);
});
selectionModelItem.addItem("Select All", menuItem -> {
@@ -534,11 +534,9 @@ public class GridBasics extends AbstractTestUIWithLog {
private void switchToMultiSelect() {
if (!(grid.getSelectionModel() instanceof MultiSelectionModel)) {
selectionListenerRegistration.remove();
- MultiSelectionModelImpl<DataObject> model = new MultiSelectionModelImpl<>(
- grid);
- grid.setSelectionModel(model);
- selectionListenerRegistration = model
- .addSelectionListener(this::onMultiSelect);
+ ((MultiSelectionModelImpl<DataObject>) grid
+ .setSelectionMode(SelectionMode.MULTI))
+ .addSelectionListener(this::onMultiSelect);
}
}