diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-03-31 09:10:43 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-03-31 09:10:43 +0000 |
commit | a5eecfa4f802061110b9941237b65f8a84ba3edd (patch) | |
tree | 37360873710938017e106a7091fba07a017969d9 /src | |
parent | 5a29c5b3faf7285c888d95c518b7c20ed46ee739 (diff) | |
download | vaadin-framework-a5eecfa4f802061110b9941237b65f8a84ba3edd.tar.gz vaadin-framework-a5eecfa4f802061110b9941237b65f8a84ba3edd.zip |
Merged fix for #2747: Wrapping link-style Button text inside Table breaks the height calculation of Table
http://dev.itmill.com/ticket/2747
svn changeset:7243/svn branch:6.0
Diffstat (limited to 'src')
3 files changed, 82 insertions, 6 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index 7470662828..bd832749fa 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -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); diff --git a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java index 39f6a51c49..f02a110bab 100644 --- a/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java +++ b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java @@ -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 index 0000000000..56f4289605 --- /dev/null +++ b/src/com/itmill/toolkit/tests/components/table/TableRowHeight3.java @@ -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); + + } + +} |