summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/src/com/vaadin/ui/Grid.java4
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java91
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java72
3 files changed, 167 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java
index e5eebff879..e9469c5bca 100644
--- a/server/src/com/vaadin/ui/Grid.java
+++ b/server/src/com/vaadin/ui/Grid.java
@@ -5821,6 +5821,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
editorActive = false;
editorFieldGroup.discard();
editorFieldGroup.setItemDataSource(null);
+
+ // Mark Grid as dirty so the client side gets to know that the editors
+ // are no longer attached
+ markAsDirty();
}
void resetEditor() {
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java
new file mode 100644
index 0000000000..e6aff73532
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplay.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import java.io.Serializable;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+
+public class GridCheckBoxDisplay extends AbstractTestUI {
+
+ private static final long serialVersionUID = -5575892909354637168L;
+ private BeanItemContainer<Todo> todoContainer = new BeanItemContainer<Todo>(
+ Todo.class);
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ todoContainer.addBean(new Todo("Done task", true));
+ todoContainer.addBean(new Todo("Not done", false));
+
+ Grid grid = new Grid(todoContainer);
+ grid.setSizeFull();
+
+ grid.setColumnOrder("done", "task");
+ grid.getColumn("done").setWidth(75);
+ grid.getColumn("task").setExpandRatio(1);
+
+ grid.setSelectionMode(Grid.SelectionMode.SINGLE);
+
+ grid.setEditorEnabled(true);
+ grid.setImmediate(true);
+
+ getLayout().addComponent(grid);
+ getLayout().setExpandRatio(grid, 1);
+
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 16976;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Verify that checkbox state is correct for all items in editor";
+ }
+
+ public class Todo implements Serializable {
+ private static final long serialVersionUID = -5961103142478316018L;
+
+ private boolean done;
+ private String task = "";
+
+ public Todo(String task, boolean done) {
+ this.task = task;
+ this.done = done;
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
+ public String getTask() {
+ return task;
+ }
+
+ public void setTask(String task) {
+ this.task = task;
+ }
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java
new file mode 100644
index 0000000000..c430821534
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+@TestCategory("grid")
+public class GridCheckBoxDisplayTest extends SingleBrowserTest {
+ @Test
+ public void testAddRow() {
+ openTestURL();
+
+ GridElement grid = $(GridElement.class).first();
+
+ Assert.assertEquals("First item had wrong value", "true",
+ grid.getCell(0, 0).getText());
+ Assert.assertEquals("Second item had wrong value", "false", grid
+ .getCell(1, 0).getText());
+
+ // First edit false item and see that the CheckBox is unchecked
+ grid.getCell(1, 0).doubleClick();
+
+ CheckBoxElement checkbox = $(CheckBoxElement.class).first();
+ Assert.assertEquals("CheckBox was checked", "unchecked",
+ checkbox.getValue());
+
+ closeEditor();
+
+ // Edit true item and see that the CheckBox is checked
+ grid.getCell(0, 0).doubleClick();
+
+ checkbox = $(CheckBoxElement.class).first();
+ Assert.assertEquals("CheckBox was not checked.", "checked",
+ checkbox.getValue());
+
+ closeEditor();
+
+ // Edit false item and confirm that the CheckBox is unchecked again
+ grid.getCell(1, 0).doubleClick();
+
+ checkbox = $(CheckBoxElement.class).first();
+ Assert.assertEquals("CheckBox was checked", "unchecked",
+ checkbox.getValue());
+ }
+
+ /**
+ * Closes the grids editor using the cancel button
+ */
+ private void closeEditor() {
+ findElement(By.className("v-grid-editor-cancel")).click();
+ }
+}