]> source.dussan.org Git - vaadin-framework.git/commitdiff
Remove unselected rows from selection on client side (#13008)
authorJarno Rantala <jarno.rantala@vaadin.com>
Tue, 14 Jan 2014 08:02:34 +0000 (10:02 +0200)
committerVaadin Code Review <review@vaadin.com>
Thu, 16 Jan 2014 12:31:17 +0000 (12:31 +0000)
When server communicates the selected rows to the client side, client
side datastructure of selected row keys is updated such that also the
keys that has been unselected on server side are removed. This makes
the test MultiSelectWithRemovedRow to pass.

Change-Id: I7b6123436171972ecf345b07ddfb6d9965ca4f0c

client/src/com/vaadin/client/ui/VScrollTable.java

index bb431bf1323011ff498d3e83f8c20771bd636814..3c574f8f9206f40fa507ad9ea84fbb7c79965038 100644 (file)
@@ -1060,6 +1060,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
         if (uidl.hasVariable("selected")) {
             final Set<String> selectedKeys = uidl
                     .getStringArrayVariableAsSet("selected");
+            removeUnselectedRowKeys(selectedKeys);
+
             if (scrollBody != null) {
                 Iterator<Widget> iterator = scrollBody.iterator();
                 while (iterator.hasNext()) {
@@ -1102,6 +1104,16 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
         return keyboardSelectionOverRowFetchInProgress;
     }
 
+    private void removeUnselectedRowKeys(final Set<String> selectedKeys) {
+        List<String> unselectedKeys = new ArrayList<String>(0);
+        for (String key : selectedRowKeys) {
+            if (!selectedKeys.contains(key)) {
+                unselectedKeys.add(key);
+            }
+        }
+        selectedRowKeys.removeAll(unselectedKeys);
+    }
+
     /** For internal use only. May be removed or replaced in the future. */
     public void updateSortingProperties(UIDL uidl) {
         oldSortColumn = sortColumn;