From 9b2f51ca9ff48ad9484b8ee67770ab1a58352b35 Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Wed, 18 Feb 2015 10:05:25 +0200 Subject: Update server side state when columns are reordered. (#16643) Change-Id: I96c65dbb96614a5f5782b747fb8588647211cf4b --- .../grid/basicfeatures/GridBasicFeatures.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java') diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java index 3a6aca11f2..792ef89d42 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -248,10 +248,25 @@ public class GridBasicFeatures extends AbstractComponentTest { addFilterActions(); + addInternalActions(); + this.grid = grid; return grid; } + private void addInternalActions() { + createClickAction("Update column order without updating client", + "Internals", new Command() { + @Override + public void execute(Grid grid, Void value, Object data) { + List columns = grid.getColumns(); + grid.setColumnOrder(columns.get(1).getPropertyId(), + columns.get(0).getPropertyId()); + grid.getUI().getConnectorTracker().markClean(grid); + } + }, null); + } + private void addFilterActions() { createClickAction("Column 1 starts with \"(23\"", "Filter", new Command() { @@ -658,6 +673,33 @@ public class GridBasicFeatures extends AbstractComponentTest { } } }, null, c); + createClickAction("Move left", getColumnProperty(c), + new Command() { + + @Override + public void execute(Grid grid, String value, Object data) { + final String columnProperty = getColumnProperty((Integer) data); + List cols = grid.getColumns(); + List reordered = new ArrayList(); + boolean addAsLast = false; + for (int i = 0; i < cols.size(); i++) { + Column col = cols.get(i); + if (col.getPropertyId().equals(columnProperty)) { + if (i == 0) { + addAsLast = true; + } else { + reordered.add(i - 1, columnProperty); + } + } else { + reordered.add(col.getPropertyId()); + } + } + if (addAsLast) { + reordered.add(columnProperty); + } + grid.setColumnOrder(reordered.toArray()); + } + }, null, c); createBooleanAction("Sortable", getColumnProperty(c), true, new Command() { -- cgit v1.2.3