summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java20
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java24
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java31
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java24
4 files changed, 74 insertions, 25 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index 274daeacb4..383139135e 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -2299,8 +2299,26 @@ public class Grid<T> extends ResizeComposite implements
}
});
checkBox.setValue(selected);
-
selectionCell.setWidget(checkBox);
+ // Select all with space when "select all" cell is active
+ addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
+ @Override
+ public void onKeyUp(GridKeyUpEvent event) {
+ if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE) {
+ return;
+ }
+ HeaderRow targetHeaderRow = getHeader().getRow(
+ event.getFocusedCell().getRowIndex());
+ if (!targetHeaderRow.isDefault()) {
+ return;
+ }
+ if (event.getFocusedCell().getColumn() == SelectionColumn.this) {
+ // Send events to ensure row selection state is
+ // updated
+ checkBox.setValue(!checkBox.getValue(), true);
+ }
+ }
+ });
}
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java
index 5d15e53a20..0a1b1735fa 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicClientFeaturesTest.java
@@ -87,4 +87,28 @@ public abstract class GridBasicClientFeaturesTest extends GridBasicFeaturesTest
selectMenuPath("Component", "State", "Column Reordering");
}
+ protected boolean isRowSelected(int index) {
+ boolean selected = getGridElement().getRow(index).isSelected();
+ return selected;
+ }
+
+ protected void setSelectionModelMulti() {
+ setSelectionModel("multi");
+ }
+
+ protected void setSelectionModelSingle(boolean deselectAllowed) {
+ String mode = "single";
+ if (!deselectAllowed) {
+ mode += " (no deselect)";
+ }
+ setSelectionModel(mode);
+ }
+
+ protected void setSelectionModelNone() {
+ setSelectionModel("none");
+ }
+
+ protected void setSelectionModel(String model) {
+ selectMenuPath("Component", "State", "Selection mode", model);
+ }
}
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java
index dc4dedd3a0..bb8edee4b5 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientKeyEventsTest.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
+import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
@@ -85,6 +86,36 @@ public class GridClientKeyEventsTest extends GridBasicClientFeaturesTest {
}
@Test
+ public void selectAllUsingKeyboard() {
+ openTestURL();
+
+ selectMenuPath("Component", "Header", "Prepend row");
+ selectMenuPath("Component", "Header", "Append row");
+ selectMenuPath("Component", "State", "Selection mode", "multi");
+
+ // Focus cell above select all checkbox
+ getGridElement().getHeaderCell(0, 0).click();
+ Assert.assertFalse(isRowSelected(1));
+ new Actions(getDriver()).sendKeys(" ").perform();
+ Assert.assertFalse(isRowSelected(1));
+
+ // Move down to select all checkbox cell
+ new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
+ Assert.assertFalse(isRowSelected(1));
+ new Actions(getDriver()).sendKeys(" ").perform(); // select all
+ Assert.assertTrue(isRowSelected(1));
+ new Actions(getDriver()).sendKeys(" ").perform(); // deselect all
+ Assert.assertFalse(isRowSelected(1));
+
+ // Move down to header below select all checkbox cell
+ new Actions(getDriver()).sendKeys(Keys.ARROW_DOWN).perform();
+ Assert.assertFalse(isRowSelected(1));
+ new Actions(getDriver()).sendKeys(" ").perform(); // deselect all
+ Assert.assertFalse(isRowSelected(1));
+
+ }
+
+ @Test
public void testFooterKeyEvents() throws IOException {
openTestURL();
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java
index 57950de5e2..a341e39b74 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridClientSelectionTest.java
@@ -195,28 +195,4 @@ public class GridClientSelectionTest extends GridBasicClientFeaturesTest {
isRowSelected(1));
}
- private boolean isRowSelected(int index) {
- boolean selected = getGridElement().getRow(index).isSelected();
- return selected;
- }
-
- private void setSelectionModelMulti() {
- setSelectionModel("multi");
- }
-
- private void setSelectionModelSingle(boolean deselectAllowed) {
- String mode = "single";
- if (!deselectAllowed) {
- mode += " (no deselect)";
- }
- setSelectionModel(mode);
- }
-
- private void setSelectionModelNone() {
- setSelectionModel("none");
- }
-
- private void setSelectionModel(String model) {
- selectMenuPath("Component", "State", "Selection mode", model);
- }
}