aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Fansky <alexey.fansky@effective-soft.com>2015-03-23 11:55:55 -0700
committerVaadin Code Review <review@vaadin.com>2015-03-25 14:31:33 +0000
commitf665aed236f64da849862d4e463d80deecc33d9a (patch)
tree10e73fe6fe12daa312c76a064514b9aeb77b79ef
parent140844eaff3de1b926460081405eb7d53ec811f8 (diff)
downloadvaadin-framework-f665aed236f64da849862d4e463d80deecc33d9a.tar.gz
vaadin-framework-f665aed236f64da849862d4e463d80deecc33d9a.zip
Disables selection when Grid's editor is open (#17132).
Change-Id: Ibbbffbfe2e8bcb763031ac277c2c36ce4eb4e3fc
-rw-r--r--client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java1
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java13
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselect.java35
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java55
4 files changed, 104 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
index 5024c8bffa..ddbf690970 100644
--- a/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
+++ b/client/src/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
@@ -569,6 +569,7 @@ public class MultiSelectionRenderer<T> extends ComplexRenderer<Boolean> {
InputElement checkbox = InputElement.as(cell.getElement()
.getFirstChildElement());
checkbox.setChecked(data.booleanValue());
+ checkbox.setDisabled(grid.isEditorActive());
checkbox.setPropertyInt(LOGICAL_ROW_PROPERTY_INT, cell.getRowIndex());
}
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index f4a5b0961c..d9845bcdc8 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -1157,6 +1157,7 @@ public class Grid<T> extends ResizeComposite implements
+ "Grid editor");
grid.getEscalator().setScrollLocked(Direction.VERTICAL,
false);
+ updateSelectionCheckboxesAsNeeded(true);
}
}
};
@@ -1256,6 +1257,16 @@ public class Grid<T> extends ResizeComposite implements
null);
handler.cancel(request);
state = State.INACTIVE;
+ updateSelectionCheckboxesAsNeeded(true);
+ }
+
+ private void updateSelectionCheckboxesAsNeeded(boolean isEnabled) {
+ if (grid.getSelectionModel() instanceof Multi) {
+ grid.refreshBody();
+ CheckBox checkBox = (CheckBox) grid.getDefaultHeaderRow()
+ .getCell(grid.selectionColumn).getWidget();
+ checkBox.setEnabled(isEnabled);
+ }
}
/**
@@ -1282,6 +1293,7 @@ public class Grid<T> extends ResizeComposite implements
EditorRequest<T> request = new EditorRequestImpl<T>(grid, rowIndex,
saveRequestCallback);
handler.save(request);
+ updateSelectionCheckboxesAsNeeded(true);
}
/**
@@ -1346,6 +1358,7 @@ public class Grid<T> extends ResizeComposite implements
rowIndex, bindRequestCallback);
handler.bind(request);
grid.getEscalator().setScrollLocked(Direction.VERTICAL, true);
+ updateSelectionCheckboxesAsNeeded(false);
}
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselect.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselect.java
new file mode 100644
index 0000000000..b80a9d1153
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselect.java
@@ -0,0 +1,35 @@
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+
+public class GridEditorMultiselect extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Grid grid = new Grid();
+
+ grid.addColumn("name");
+ grid.addColumn("age", Integer.class);
+
+ for (int i = 0; i < 30; i++) {
+ grid.addRow("name " + i, i);
+ }
+
+ grid.setEditorEnabled(true);
+ grid.setSelectionMode(Grid.SelectionMode.MULTI);
+
+ addComponent(grid);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 17132;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Grid Multiselect: Edit mode allows invalid selection";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java b/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java
new file mode 100644
index 0000000000..ba689fb5e1
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridEditorMultiselectTest.java
@@ -0,0 +1,55 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridEditorMultiselectTest extends MultiBrowserTest {
+
+ @Test
+ public void testSelectCheckboxesDisabled() {
+ openTestURL();
+ GridElement grid = openEditor();
+ assertCheckboxesEnabled(grid, false);
+ }
+
+ @Test
+ public void testSelectCheckboxesEnabledBackOnSave() {
+ openTestURL();
+ GridElement grid = openEditor();
+ grid.getEditor().save();
+ assertCheckboxesEnabled(grid, true);
+ }
+
+ @Test
+ public void testSelectCheckboxesEnabledBackOnCancel() {
+ openTestURL();
+ GridElement grid = openEditor();
+ grid.getEditor().cancel();
+ assertCheckboxesEnabled(grid, true);
+ }
+
+ private GridElement openEditor() {
+ GridElement grid = $(GridElement.class).first();
+ grid.getRow(0).doubleClick();
+ Assert.assertTrue("Grid editor should be displayed.", grid.getEditor()
+ .isDisplayed());
+ return grid;
+ }
+
+ private void assertCheckboxesEnabled(GridElement grid, boolean isEnabled) {
+ List<WebElement> checkboxes = grid.findElements(By
+ .xpath("//input[@type='checkbox']"));
+ for (WebElement checkbox : checkboxes) {
+ Assert.assertEquals("Select checkboxes should be "
+ + (isEnabled ? "enabled" : "disabled"), isEnabled,
+ checkbox.isEnabled());
+ }
+ }
+}