]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged fix for #2747 - table height calculation issue
authorArtur Signell <artur.signell@itmill.com>
Fri, 20 Mar 2009 15:41:45 +0000 (15:41 +0000)
committerArtur Signell <artur.signell@itmill.com>
Fri, 20 Mar 2009 15:41:45 +0000 (15:41 +0000)
svn changeset:7122/svn branch:6.0

src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java [new file with mode: 0644]

index 91623c29fb63120e05b1371152eda26868581040..7470662828596bbea5d070dde7e089b92df44b75 100644 (file)
@@ -560,16 +560,6 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
 
         tHead.disableBrowserIntelligence();
 
-        // fix "natural" height if height not set
-        if (height == null || "".equals(height)) {
-            /*
-             * We must force an update of the row height as this point as it
-             * might have been (incorrectly) calculated earlier
-             */
-            bodyContainer.setHeight((tBody.getRowHeight(true) * pageLength)
-                    + "px");
-        }
-
         // fix "natural" width if width not set
         if (width == null || "".equals(width)) {
             int w = total;
@@ -581,6 +571,13 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
         // Hey IE, are you really sure about this?
         availW = tBody.getAvailableWidth();
 
+        boolean verticalScrollbarVisible = (pageLength < totalRows);
+
+        if (verticalScrollbarVisible) {
+            // There will be a vertical scrollbar and its width is not included in availW
+            availW -= Util.getNativeScrollbarSize();
+        }
+
         boolean needsReLayout = false;
 
         if (availW > total) {
@@ -596,7 +593,9 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
                  */
                 int scrollbarWidth = getScrollbarWidth();
                 scrollbarWidth = Util.getNativeScrollbarSize();
-                if (relativeWidth && totalWidthR >= scrollbarWidth) {
+                if (!verticalScrollbarVisible && relativeWidth
+                        && totalWidthR >= scrollbarWidth) {
+
                     scrollbarWidthReserved = scrollbarWidth + 1; // 
                     int columnindex = tHead.getVisibleCellCount() - 1;
                     widths[columnindex] += scrollbarWidthReserved;
@@ -643,6 +642,19 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
             tBody.reLayoutComponents();
         }
 
+        /*
+         * Fix "natural" height if height is not set. This must be after width
+         * fixing so the components' widths have been adjusted.
+         */
+        if (height == null || "".equals(height)) {
+            /*
+             * We must force an update of the row height as this point as it
+             * might have been (incorrectly) calculated earlier
+             */
+            int bodyHeight = (tBody.getRowHeight(true) * pageLength);
+            bodyContainer.setHeight(bodyHeight + "px");
+        }
+
         isNewBody = false;
 
         if (firstvisible > 0) {
diff --git a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java
new file mode 100644 (file)
index 0000000..39f6a51
--- /dev/null
@@ -0,0 +1,53 @@
+package com.itmill.toolkit.tests.components.table;
+
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.tests.components.TestBase;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.HorizontalLayout;
+import com.itmill.toolkit.ui.Table;
+
+public class TableRowHeight2 extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "The table contains 2 rows, which both should be shown completely as the table height is undefined.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 2747;
+    }
+
+    @Override
+    protected void setup() {
+        setTheme("tests-tickets");
+        HorizontalLayout vl = new HorizontalLayout();
+        vl.setSizeFull();
+
+        Table table = new Table();
+        table.setWidth("300px");
+        table.setPageLength(0);
+        table.setColumnWidth("title", 200);
+        table.setColumnWidth("test", 98);
+        table.addContainerProperty("title", Button.class, "");
+        table.addContainerProperty("test", Button.class, "");
+        for (int i = 0; i < 2; i++) {
+            Item item = table.addItem(new Object());
+
+            Button b = new Button();
+
+            b
+                    .setCaption("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper, elit quis elementum iaculis, dui est rutrum risus, at cursus sem leo eget arcu. Proin vel eros ut tortor luctus pretium. Nulla facilisi. Donec in dui. Proin ac diam vitae massa tempus faucibus. Fusce eu risus. Nunc ac risus. Cras libero.");
+
+            b.setStyleName(Button.STYLE_LINK);
+            item.getItemProperty("title").setValue(b);
+
+            Button c = new Button("test");
+            item.getItemProperty("test").setValue(c);
+        }
+
+        vl.addComponent(table);
+
+        addComponent(vl);
+    }
+}