diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-02-04 18:33:30 +0200 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2015-02-05 15:47:46 +0000 |
commit | a15f2847950126bc87751c54d977d2f4edd45c04 (patch) | |
tree | 200d9866abb2c9334ca9c38ef58639954c562d27 /server/tests | |
parent | 50724f2d0d1e225b5c24d097d3c4b8529b7a8f3f (diff) | |
download | vaadin-framework-a15f2847950126bc87751c54d977d2f4edd45c04.tar.gz vaadin-framework-a15f2847950126bc87751c54d977d2f4edd45c04.zip |
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
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java | 31 |
1 files changed, 31 insertions, 0 deletions
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) { |