From a15f2847950126bc87751c54d977d2f4edd45c04 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Wed, 4 Feb 2015 18:33:30 +0200 Subject: Grid columns can now be marked as non-editable (#16538) Non-editable columns are not assigned editor fields. When the editor is active, any non-editable content is not displayed (this should changein the future). This is separate from setting the property or editor field read-only - in those cases the field is still used to display the data which may not be desired and will fail if there is no converter. Also add Column.setEditorField(Field) and the corresponding getter. Change-Id: Ice17c357895cb63a8e1bfd6abaffc1d803399e98 --- .../tests/server/component/grid/GridColumns.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'server/tests') diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java index 5e96f4eeae..ab17e47393 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -37,6 +38,7 @@ import com.vaadin.shared.ui.grid.GridState; import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.Grid; import com.vaadin.ui.Grid.Column; +import com.vaadin.ui.TextField; public class GridColumns { @@ -242,6 +244,35 @@ public class GridColumns { noSortColumn.setSortable(true); } + @Test + public void testColumnsEditableByDefault() { + for (Column c : grid.getColumns()) { + assertTrue(c + " should be editable", c.isEditable()); + } + } + + @Test + public void testPropertyAndColumnEditorFieldsMatch() { + grid.setEditorField("column1", new TextField()); + assertSame(grid.getEditorField("column1"), grid.getColumn("column1") + .getEditorField()); + + grid.getColumn("column2").setEditorField(new TextField()); + assertSame(grid.getEditorField("column2"), grid.getColumn("column2") + .getEditorField()); + } + + @Test + public void testUneditableColumnHasNoField() { + Column col = grid.getColumn("column1"); + + col.setEditable(false); + + assertFalse("Column should be uneditable", col.isEditable()); + assertNull("Uneditable column should not be auto-assigned a Field", + col.getEditorField()); + } + private GridColumnState getColumnState(Object propertyId) { String columnId = columnIdMapper.key(propertyId); for (GridColumnState columnState : state.columns) { -- cgit v1.2.3