summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-03-20 15:41:45 +0000
committerArtur Signell <artur.signell@itmill.com>2009-03-20 15:41:45 +0000
commit37362aa752f7edd7c2b37706090ebcd791230ad1 (patch)
tree48373e1a1136b46bd1066f7748d3f3cb16219d76 /src
parent9b549761439c275fb5949833d97da289315e36c3 (diff)
downloadvaadin-framework-37362aa752f7edd7c2b37706090ebcd791230ad1.tar.gz
vaadin-framework-37362aa752f7edd7c2b37706090ebcd791230ad1.zip
Merged fix for #2747 - table height calculation issue
svn changeset:7122/svn branch:6.0
Diffstat (limited to 'src')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java34
-rw-r--r--src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java53
2 files changed, 76 insertions, 11 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 91623c29fb..7470662828 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
@@ -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
index 0000000000..39f6a51c49
--- /dev/null
+++ b/src/com/itmill/toolkit/tests/components/table/TableRowHeight2.java
@@ -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);
+ }
+}