From d89f7a9947ebd1e8e7b40917540b06ac3c16364b Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 12 Dec 2013 14:48:46 +0200 Subject: Fixed escalator attach/detach logic #12645 Change-Id: If1ba80802010e31362d555023b2b5e5850d2962b --- .../src/com/vaadin/client/ui/grid/Escalator.java | 69 ++++++++++------------ 1 file changed, 30 insertions(+), 39 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java index 548d79192a..20a187e1a5 100644 --- a/client/src/com/vaadin/client/ui/grid/Escalator.java +++ b/client/src/com/vaadin/client/ui/grid/Escalator.java @@ -35,7 +35,6 @@ import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Unit; -import com.google.gwt.event.logical.shared.AttachEvent; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Window; @@ -3037,49 +3036,41 @@ public class Escalator extends Widget { setStylePrimaryName("v-escalator"); - /* - * Size calculations work only after the Escalator has been attached to - * the DOM. It doesn't matter if the table is populated or not by this - * point, there's a lot of other stuff to calculate also. All sizes - * start working once the first sizes have been initialized. - */ - addAttachHandler(new AttachEvent.Handler() { - @Override - public void onAttachOrDetach(final AttachEvent event) { - if (event.isAttached()) { - - /* - * this specific order of method calls matters: header and - * footer get defined heights, the body assumes to get the - * rest. - */ - header.paintInsertRows(0, header.getRowCount()); - footer.paintInsertRows(0, footer.getRowCount()); - recalculateElementSizes(); - body.paintInsertRows(0, body.getRowCount()); - - scroller.attachScrollListener(verticalScrollbar - .getElement()); - scroller.attachScrollListener(horizontalScrollbar - .getElement()); - scroller.attachMousewheelListener(getElement()); - scroller.attachTouchListeners(getElement()); - } else { - scroller.detachScrollListener(verticalScrollbar - .getElement()); - scroller.detachScrollListener(horizontalScrollbar - .getElement()); - scroller.detachMousewheelListener(getElement()); - scroller.detachTouchListeners(getElement()); - } - } - }); - // init default dimensions setHeight(null); setWidth(null); } + @Override + protected void onLoad() { + super.onLoad(); + + header.paintInsertRows(0, header.getRowCount()); + footer.paintInsertRows(0, footer.getRowCount()); + recalculateElementSizes(); + body.paintInsertRows(0, body.getRowCount()); + + scroller.attachScrollListener(verticalScrollbar.getElement()); + scroller.attachScrollListener(horizontalScrollbar.getElement()); + scroller.attachMousewheelListener(getElement()); + scroller.attachTouchListeners(getElement()); + } + + @Override + protected void onUnload() { + + scroller.detachScrollListener(verticalScrollbar.getElement()); + scroller.detachScrollListener(horizontalScrollbar.getElement()); + scroller.detachMousewheelListener(getElement()); + scroller.detachTouchListeners(getElement()); + + header.paintRemoveRows(0, header.getRowCount()); + footer.paintRemoveRows(0, footer.getRowCount()); + body.paintRemoveRows(0, body.getRowCount()); + + super.onUnload(); + } + private void detectAndApplyPositionFunction() { /* * firefox has a bug in its translate operation, showing white space -- cgit v1.2.3