]> source.dussan.org Git - vaadin-framework.git/commitdiff
Regression fixes after fixes for #6677 #6934
authorJohn Alhroos <john.ahlroos@itmill.com>
Fri, 5 Aug 2011 08:23:28 +0000 (08:23 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Fri, 5 Aug 2011 08:23:28 +0000 (08:23 +0000)
svn changeset:20128/svn branch:6.6

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index 7608e2f028729b9464aac5fd62caf57817604d27..fc5994aee2b9302f4874a44a5f06272a681d19fa 100644 (file)
@@ -1616,6 +1616,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             // natural size is smaller than available space
             final int extraSpace = availW - total;
             final int totalWidthR = total - totalExplicitColumnsWidths;
+            int checksum = 0;
             needsReLayout = true;
 
             if (extraSpace == 1) {
@@ -1623,6 +1624,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 // undefined column
                 headCells = tHead.iterator();
                 i = 0;
+                checksum = availW;
                 while (headCells.hasNext()) {
                     HeaderCell hc = (HeaderCell) headCells.next();
                     if (!hc.isDefinedWidth()) {
@@ -1632,64 +1634,65 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     i++;
                 }
 
-            } else if (expandRatioDivider > 0 || totalWidthR > 0) {
-                int checksum = 0;
-                if(expandRatioDivider > 0){
-                    // visible columns have some active expand ratios, excess
-                    // space is divided according to them
-                    headCells = tHead.iterator();
-                    i = 0;
-                    checksum = 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;
-                            checksum += w;
-                        }
-                        i++;
+            } else 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 = Math.round((extraSpace * (hCell
+                                .getExpandRatio() / expandRatioDivider)));
+                        w += newSpace;
+                        widths[i] = w;
+                        checksum += w;
+                    } else {
+                        checksum += widths[i];
                     }
-                } else {
-                    // no expand ratios defined, we will share extra space
-                    // relatively to "natural widths" among those without
-                    // explicit width
-                    headCells = tHead.iterator();
-                    i = 0;
-                    checksum = 0;
-                    while (headCells.hasNext()) {
-                        HeaderCell hCell = (HeaderCell) headCells.next();
-                        if (!hCell.isDefinedWidth()) {
-                            int w = widths[i];
-                            final int newSpace = Math.round((float) extraSpace
-                                    * (float) w / totalWidthR);
-                            w += newSpace;
-                            widths[i] = w;
-                            checksum += 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 = Math.round((float) extraSpace
+                                * (float) w / totalWidthR);
+                        w += newSpace;
+                        widths[i] = w;
+                        checksum += w;
+                    } else {
+                        checksum += hCell.getWidth();
                     }
+                    i++;
                 }
-                
-                if (checksum != availW) {
-                    /*
-                     *  There might be in some cases a rounding error of 1px
-                     *  so if there is one then we give the first undefined column 1 more pixel
-                     */
-                    headCells = tHead.iterator();
-                    i = 0;
-                    while (headCells.hasNext()) {
-                        HeaderCell hc = (HeaderCell) headCells.next();
-                        if (!hc.isDefinedWidth()) {
-                            widths[i] += availW - checksum;
-                            break;
-                        }
-                        i++;
+            }
+
+            if (checksum != availW) {
+                /*
+                 * There might be in some cases a rounding error of 1px so if
+                 * there is one then we give the first undefined column 1 more
+                 * pixel
+                 */
+                headCells = tHead.iterator();
+                i = 0;
+                while (headCells.hasNext()) {
+                    HeaderCell hc = (HeaderCell) headCells.next();
+                    if (!hc.isDefinedWidth()) {
+                        widths[i] += availW - checksum;
+                        break;
                     }
+                    i++;
                 }
             }
+
         } else {
             // bodys size will be more than available and scrollbar will appear
         }
@@ -2748,7 +2751,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         }
 
         public HeaderCell getHeaderCell(int index) {
-            if (index < visibleCells.size()) {
+            if (index >= 0 && index < visibleCells.size()) {
                 return (HeaderCell) visibleCells.get(index);
             } else {
                 return null;
@@ -5072,27 +5075,31 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     int newSpace;
                     if (expandRatioDivider > 0) {
                         // divide excess space by expand ratios
-                        newSpace = Math.round(w + extraSpace
-                                * hCell.getExpandRatio() / expandRatioDivider);
+                        newSpace = Math.round((w + extraSpace
+                                * hCell.getExpandRatio() / expandRatioDivider));
                     } else {
                         if (totalUndefinedNaturaWidths != 0) {
                             // divide relatively to natural column widths
                             newSpace = Math.round(w + (float) extraSpace
-                                    * (float) w / totalUndefinedNaturaWidths);
+                                    * (float) w
+                                    / totalUndefinedNaturaWidths);
                         } else {
                             newSpace = w;
                         }
                     }
                     checksum += newSpace;
                     setColWidth(colIndex, newSpace, false);
+                } else {
+                    checksum += hCell.getWidth();
                 }
                 colIndex++;
             }
-            
+
             if (checksum != availW) {
                 /*
-                 *  There might be in some cases a rounding error of 1px
-                 *  so if there is one then we give the first undefined column 1 more pixel
+                 * There might be in some cases a rounding error of 1px so if
+                 * there is one then we give the first undefined column 1 more
+                 * pixel
                  */
                 headCells = tHead.iterator();
                 colIndex = 0;
@@ -5106,7 +5113,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     colIndex++;
                 }
             }
-            
+
             if ((height == null || "".equals(height))
                     && totalRows == pageLength) {
                 // fix body height (may vary if lazy loading is offhorizontal