diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2016-11-29 16:58:17 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2016-12-09 09:39:00 +0200 |
commit | aeae310b7e16f40745992e075626fc19ca90321d (patch) | |
tree | 0bd8e3486ebe849cc0dafb9e9e8d9e4c00f6cefe | |
parent | acc261b184646501c9f1d305cd82676bff440436 (diff) | |
download | vaadin-framework-aeae310b7e16f40745992e075626fc19ca90321d.tar.gz vaadin-framework-aeae310b7e16f40745992e075626fc19ca90321d.zip |
Migrate Escalator changes to compatibility escalator
Change-Id: Ie19f0f2c2202dcdcaebc67dd5d16df91c18633be
-rw-r--r-- | compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java index 0804a0ad5e..f343d45f6f 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java @@ -859,8 +859,8 @@ public class Escalator extends Widget if (position instanceof AbsolutePosition) { /* * we don't want to put "top: 0" on the footer, since it'll - * render wrong, as we already have - * "bottom: $footer-height". + * render wrong, as we already have "bottom: $footer-height" + * . */ footElem.getStyle().setLeft(-scrollLeft, Unit.PX); } else { @@ -5584,8 +5584,22 @@ public class Escalator extends Widget // init default dimensions setHeight(null); setWidth(null); + + publishJSHelpers(root); + } + + private int getBodyRowCount() { + return getBody().getRowCount(); } + private native void publishJSHelpers(Element root) + /*-{ + var self = this; + root.getBodyRowCount = $entry(function () { + return self.@Escalator::getBodyRowCount()(); + }); + }-*/; + private void setupScrollbars(final Element root) { ScrollHandler scrollHandler = new ScrollHandler() { @@ -6630,15 +6644,19 @@ public class Escalator extends Widget } else if (type.equalsIgnoreCase("cell")) { // If wanted row is not visible, we need to scroll there. Range visibleRowRange = getVisibleRowRange(); - if (indices.length > 0 && !visibleRowRange.contains(indices[0])) { - try { - scrollToRow(indices[0], ScrollDestination.ANY, 0); - } catch (IllegalArgumentException e) { - getLogger().log(Level.SEVERE, e.getMessage()); + if (indices.length > 0) { + // Contains a row number, ensure it is available and visible + boolean rowInCache = visibleRowRange.contains(indices[0]); + + // Scrolling might be a no-op if row is already in the viewport + scrollToRow(indices[0], ScrollDestination.ANY, 0); + + if (!rowInCache) { + // Row was not in cache, scrolling caused lazy loading and + // the caller needs to wait and call this method again to be + // able to get the requested element + return null; } - // Scrolling causes a lazy loading event. No element can - // currently be retrieved. - return null; } container = getBody(); } else if (type.equalsIgnoreCase("footer")) { |