From: Matti Tahvonen Date: Tue, 1 Sep 2009 08:11:04 +0000 (+0000) Subject: fixes #3143, initial expand algorithm now works equally to the resize algorithm if... X-Git-Tag: 6.7.0.beta1~2558 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e6f3f883f1d4a000be56e72614988a6710696dd;p=vaadin-framework.git fixes #3143, initial expand algorithm now works equally to the resize algorithm if only expanded and fixed columns svn changeset:8603/svn branch:6.1 --- diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index b89eb94c97..e25fc815ef 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -624,46 +624,46 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler { availW -= Util.getNativeScrollbarSize(); } + // TODO refactor this code to be the same as in resize timer boolean needsReLayout = false; if (availW > total) { // natural size is smaller than available space final int extraSpace = availW - total; final int totalWidthR = total - totalExplicitColumnsWidths; - if (totalWidthR > 0) { - needsReLayout = true; - - if (expandRatioDivider > 0) { - // visible columns have some active expand ratios, excess - // space is divided according to them - headCells = tHead.iterator(); - i = 0; - while (headCells.hasNext()) { - HeaderCell hCell = (HeaderCell) headCells.next(); - if (hCell.getExpandRatio() > 0) { - int w = widths[i]; - final int newSpace = (int) (extraSpace * (hCell - .getExpandRatio() / expandRatioDivider)); - w += newSpace; - widths[i] = w; - } - i++; + needsReLayout = true; + + if (expandRatioDivider > 0) { + // visible columns have some active expand ratios, excess + // space is divided according to them + headCells = tHead.iterator(); + i = 0; + while (headCells.hasNext()) { + HeaderCell hCell = (HeaderCell) headCells.next(); + if (hCell.getExpandRatio() > 0) { + int w = widths[i]; + final int newSpace = (int) (extraSpace * (hCell + .getExpandRatio() / expandRatioDivider)); + w += newSpace; + widths[i] = w; } - } else { - // now we will share this sum relatively to those without - // explicit width - headCells = tHead.iterator(); - i = 0; - while (headCells.hasNext()) { - HeaderCell hCell = (HeaderCell) headCells.next(); - if (!hCell.isDefinedWidth()) { - int w = widths[i]; - final int newSpace = extraSpace * w / totalWidthR; - w += newSpace; - widths[i] = w; - } - i++; + i++; + } + } else if (totalWidthR > 0) { + // no expand ratios defined, we will share extra space + // relatively to "natural widths" among those without + // explicit width + headCells = tHead.iterator(); + i = 0; + while (headCells.hasNext()) { + HeaderCell hCell = (HeaderCell) headCells.next(); + if (!hCell.isDefinedWidth()) { + int w = widths[i]; + final int newSpace = extraSpace * w / totalWidthR; + w += newSpace; + widths[i] = w; } + i++; } }