]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merged fix for #2747: Wrapping link-style Button text inside Table breaks the height...
authorArtur Signell <artur.signell@itmill.com>
Tue, 31 Mar 2009 09:10:43 +0000 (09:10 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 31 Mar 2009 09:10:43 +0000 (09:10 +0000)
http://dev.itmill.com/ticket/2747

svn changeset:7243/svn branch:6.0

WebContent/ITMILL/themes/tests-tickets/styles.css
src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java
src/com/itmill/toolkit/tests/components/table/TableRowHeight3.java [new file with mode: 0644]

index 0cdad264dd16c4e0c25ed24f241bb7851b824c57..225bbd6d1d384a220965b433399ef9cdbe901595 100644 (file)
@@ -1,5 +1,7 @@
 @import url(../default/styles.css);
 
+/* DO NOT ADD GENERIC RULES LIKE .i-table IN THIS FILE */
+
 /*****************************************************************************/
 /* Ticket 1904                                                               */
 /*****************************************************************************/
@@ -442,10 +444,12 @@ padding:2px;
 .i-table-row:hover, .i-table-row-odd:hover {
     background: #c8def9;
 }
+/*
 .i-table-header-wrap {
     background: #d4e7fe url(img/table/column_header_bg.png) top left repeat-x;
     height: 25px;
 }
+*/
 .i-table-header-cell:hover, 
 .i-table-header-cell-asc:hover, 
 .i-table-header-cell-desc:hover {
@@ -456,7 +460,7 @@ padding:2px;
     border-right: 1px solid #e3e7f0; 
     margin: 0;
     padding: 2px 2px 2px 3px;
-    height: 20px;
+/*    height: 20px;*/
 }
 .i-table-header-cell-asc .i-table-caption-container {
     background: url(img/table/order_asc.png) right 50% no-repeat;  
@@ -1266,4 +1270,10 @@ padding:2px;
 /* #2434 */
 .i-table-bordered .i-table-body td {   
        border-bottom: 1px solid red;
-}
\ No newline at end of file
+}
+
+/* #2747 */
+.i-button-nowraplink span {
+   white-space: normal;
+}
+   
index 7470662828596bbea5d070dde7e089b92df44b75..bd832749fac30a73e236147b47172d3039919ca1 100644 (file)
@@ -574,7 +574,8 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
         boolean verticalScrollbarVisible = (pageLength < totalRows);
 
         if (verticalScrollbarVisible) {
-            // There will be a vertical scrollbar and its width is not included in availW
+            // There will be a vertical scrollbar and its width is not included
+            // in availW
             availW -= Util.getNativeScrollbarSize();
         }
 
@@ -651,8 +652,17 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
              * 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");
+            if (pageLength == totalRows) {
+                /*
+                 * We want to show all rows so the bodyHeight should be equal to
+                 * the table height
+                 */
+                int bodyHeight = tBody.getTableHeight();
+                bodyContainer.setHeight(bodyHeight + "px");
+            } else {
+                int bodyHeight = (tBody.getRowHeight(true) * pageLength);
+                bodyContainer.setHeight(bodyHeight + "px");
+            }
         }
 
         isNewBody = false;
@@ -1935,8 +1945,7 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
                 return rowHeight;
             } else {
                 if (DOM.getChildCount(tBody) > 0) {
-                    rowHeight = tBody.getParentElement().getOffsetHeight()
-                            / DOM.getChildCount(tBody);
+                    rowHeight = getTableHeight() / DOM.getChildCount(tBody);
                 } else {
                     return DEFAULT_ROW_HEIGHT;
                 }
@@ -1945,6 +1954,10 @@ public class IScrollTable extends FlowPanel implements Table, ScrollListener {
             }
         }
 
+        public int getTableHeight() {
+            return table.getOffsetHeight();
+        }
+
         public int getColWidth(int i) {
             if (initDone) {
                 final Element e = DOM.getChild(DOM.getChild(tBody, 0), i);
index 39f6a51c49e7b4f33d9d9f6b74f40e4af5dba415..f02a110bab73c70f794cca11cda992b0b525464d 100644 (file)
@@ -35,11 +35,13 @@ public class TableRowHeight2 extends TestBase {
             Item item = table.addItem(new Object());
 
             Button b = new Button();
+            b.setWidth("100%");
+            b.setStyleName(Button.STYLE_LINK);
+            b.addStyleName("nowraplink");
 
             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");
diff --git a/src/com/itmill/toolkit/tests/components/table/TableRowHeight3.java b/src/com/itmill/toolkit/tests/components/table/TableRowHeight3.java
new file mode 100644 (file)
index 0000000..56f4289
--- /dev/null
@@ -0,0 +1,61 @@
+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 TableRowHeight3 extends TestBase {
+
+    @Override
+    protected String getDescription() {
+        return "All rows should be visible and the table height should match the height of the rows (no vertical scrollbar)";
+    }
+
+    @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("320px");
+        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 < 6; i++) {
+            Item item = table.addItem(new Object());
+
+            Button b = new Button();
+            b.setWidth("100%");
+            b.setStyleName(Button.STYLE_LINK);
+            b.addStyleName("nowraplink");
+            if (i < 2) {
+                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.");
+            } else if (2 <= i && i < 4) {
+                b.setCaption("One line");
+            } else {
+                b.setCaption("This button caption should use up two lines");
+            }
+            item.getItemProperty("title").setValue(b);
+
+            Button c = new Button("test");
+            item.getItemProperty("test").setValue(c);
+        }
+
+        vl.addComponent(table);
+
+        addComponent(vl);
+
+    }
+
+}