diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-16 14:10:24 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-07-16 14:10:24 +0000 |
commit | 1428b25db38f8ff58ae74752265b4c6c2384c467 (patch) | |
tree | 8d059f0691e384c44c2abd5a3c367b8ff39cd8e7 | |
parent | d0c4bbd0bc18a9569c569589da99ef8b148c26d9 (diff) | |
download | vaadin-framework-1428b25db38f8ff58ae74752265b4c6c2384c467.tar.gz vaadin-framework-1428b25db38f8ff58ae74752265b4c6c2384c467.zip |
fixes keyboard navigation related issues #5347 and #5368
svn changeset:14232/svn branch:6.4
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index d917f68a91..18efae185e 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -687,10 +687,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, if (uidl.hasVariable("selected")) { final Set<String> selectedKeys = uidl .getStringArrayVariableAsSet("selected"); - for (String string : selectedKeys) { - VScrollTableRow row = getRenderedRowByKey(string); - if (row != null && !row.isSelected()) { - row.toggleSelection(); + if (scrollBody != null) { + Iterator<Widget> iterator = scrollBody.iterator(); + while (iterator.hasNext()) { + VScrollTableRow row = (VScrollTableRow) iterator.next(); + boolean selected = selectedKeys.contains(row.getKey()); + if (selected != row.isSelected()) { + row.toggleSelection(); + } } } } @@ -792,6 +796,10 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, hideScrollPositionAnnotation(); purgeUnregistryBag(); + // selection is no in sync with server, avoid excessive server visits by + // clearing to flag used during the normal operation + selectionChanged = false; + // This is called when the Home button has been pressed and the pages // changes if (selectFirstItemInNextRender) { @@ -817,7 +825,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, } if (focusedRow != null) { - setRowFocus(getRenderedRowByKey(focusedRow.getKey())); + if (!focusedRow.isAttached()) { + // focused row has orphaned, can't focus + focusedRow = null; + } else { + setRowFocus(getRenderedRowByKey(focusedRow.getKey())); + } } if (!isFocusable()) { @@ -4838,20 +4851,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, // Set new focused row focusedRow = row; - // Scroll up or down if needed - int rowTop = focusedRow.getElement().getAbsoluteTop(); - int scrollTop = scrollBodyPanel.getElement().getAbsoluteTop(); - int scrollBottom = scrollTop - + scrollBodyPanel.getElement().getOffsetHeight(); - if (rowTop > scrollBottom - focusedRow.getOffsetHeight()) { - scrollBodyPanel.setScrollPosition(scrollBodyPanel - .getScrollPosition() - + focusedRow.getOffsetHeight()); - } else if (rowTop < scrollTop) { - scrollBodyPanel.setScrollPosition(scrollBodyPanel - .getScrollPosition() - - focusedRow.getOffsetHeight()); - } + row.getElement().scrollIntoView(); return true; } |