From: Leif Åstrand Date: Mon, 12 Mar 2012 12:29:55 +0000 (+0200) Subject: Only run sizeInit after the actual layout (#8313) X-Git-Tag: 7.0.0.alpha2~369 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=80a249b7583b30a236743b311a53aec111bc6bce;p=vaadin-framework.git Only run sizeInit after the actual layout (#8313) --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/TableConnector.java b/src/com/vaadin/terminal/gwt/client/ui/TableConnector.java index 1a5b535da3..b2a183ac5a 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/TableConnector.java +++ b/src/com/vaadin/terminal/gwt/client/ui/TableConnector.java @@ -16,7 +16,7 @@ import com.vaadin.terminal.gwt.client.UIDL; import com.vaadin.terminal.gwt.client.Util; public class TableConnector extends AbstractComponentContainerConnector - implements DirectionalManagedLayout { + implements DirectionalManagedLayout, PostLayoutListener { /* * (non-Javadoc) @@ -256,6 +256,10 @@ public class TableConnector extends AbstractComponentContainerConnector } public void layoutHorizontally() { - getWidget().updateWidth(); + // getWidget().updateWidth(); + } + + public void postLayout() { + getWidget().sizeInit(); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index a4764f2550..e2d52f76fd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -456,6 +456,8 @@ public class VScrollTable extends FlowPanel implements HasWidgets, int serverCacheFirst = -1; int serverCacheLast = -1; + private boolean sizeNeedsInit = true; + public VScrollTable() { setMultiSelectMode(MULTISELECT_MODE_DEFAULT); @@ -838,9 +840,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, tFoot.setHorizontalScrollPosition(0); initialContentReceived = true; - if (isAttached()) { - sizeInit(); - } + sizeNeedsInit = true; scrollBody.restoreRowVisibility(); } @@ -965,7 +965,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (oldPageLength != pageLength && initializedAndAttached) { // page length changed, need to update size - sizeInit(); + sizeNeedsInit = true; } } @@ -1580,14 +1580,6 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } } - @Override - protected void onAttach() { - super.onAttach(); - if (initialContentReceived) { - sizeInit(); - } - } - @Override protected void onDetach() { rowRequestHandler.cancel(); @@ -1611,7 +1603,11 @@ public class VScrollTable extends FlowPanel implements HasWidgets, * * * Makes deferred request to get some cache rows */ - private void sizeInit() { + void sizeInit() { + if (!sizeNeedsInit) { + return; + } + sizeNeedsInit = false; /* * We will use browsers table rendering algorithm to find proper column * widths. If content and header take less space than available, we will @@ -5521,6 +5517,15 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } + @Override + public void setWidth(String width) { + String oldWidth = getElement().getStyle().getWidth(); + if (!oldWidth.equals(width)) { + super.setWidth(width); + updateWidth(); + } + } + void updateWidth() { if (!isVisible()) { /* @@ -5543,8 +5548,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } else { - // Readjust size of table - sizeInit(); + sizeNeedsInit = true; // readjust undefined width columns triggerLazyColumnAdjustment(false);