]> source.dussan.org Git - vaadin-framework.git/commitdiff
Testcase and untested fix for #7143
authorJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Fri, 26 Aug 2011 07:03:59 +0000 (07:03 +0000)
committerJonatan Kronqvist <jonatan.kronqvist@itmill.com>
Fri, 26 Aug 2011 07:03:59 +0000 (07:03 +0000)
svn changeset:20671/svn branch:6.7

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
tests/src/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java [new file with mode: 0644]

index 6cb09043539487e7baf562eb23fc01787d078b93..d43e1d423a0136d043b528eaf9037c4aff3f5d9e 100644 (file)
@@ -2643,6 +2643,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         public void setExpandRatio(float floatAttribute) {
             expandRatio = floatAttribute;
+            triggerLazyColumnAdjustment(false);
         }
 
         public float getExpandRatio() {
diff --git a/tests/src/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java b/tests/src/com/vaadin/tests/components/table/HiddenColumnsExpandRatios.java
new file mode 100644 (file)
index 0000000..36299ca
--- /dev/null
@@ -0,0 +1,74 @@
+package com.vaadin.tests.components.table;
+
+import java.util.Random;
+
+import com.vaadin.data.Item;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+
+public class HiddenColumnsExpandRatios extends TestBase {
+
+    @Override
+    protected void setup() {
+        final Table table = new Table();
+        table.setWidth("800px");
+        addComponent(table);
+        table.addContainerProperty("foo", String.class, "");
+        table.addContainerProperty("bar", String.class, "");
+        table.addContainerProperty("baz", String.class, "");
+        table.addContainerProperty("asdf", String.class, "");
+        table.addContainerProperty("sdfg", String.class, "");
+        table.addContainerProperty("dfgh", String.class, "");
+        table.setColumnExpandRatio("bar", 1.0f);
+        for (int i = 0; i < 10; i++) {
+            Item item = table.addItem(i);
+            item.getItemProperty("foo").setValue(genValue());
+            item.getItemProperty("bar").setValue(genValue());
+            item.getItemProperty("baz").setValue(genValue());
+            item.getItemProperty("asdf").setValue(genValue());
+            item.getItemProperty("sdfg").setValue(genValue());
+            item.getItemProperty("dfgh").setValue(genValue());
+        }
+
+        addComponent(new Button("All", new ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                table.setVisibleColumns(table.getContainerPropertyIds()
+                        .toArray());
+            }
+        }));
+        addComponent(new Button("Some", new ClickListener() {
+            public void buttonClick(ClickEvent event) {
+                table.setWidth("100px");
+                table.setWidth("800px");
+                table.setVisibleColumns(new Object[] { "foo", "bar", "baz" });
+            }
+        }));
+    }
+
+    private String genValue() {
+        Random rnd = new Random();
+        StringBuffer str = new StringBuffer("");
+        String[] strings = new String[] { "foo", "bar", "baz" };
+        for (int i = 0; i < 5; i++) {
+            str.append(strings[Math.abs(rnd.nextInt() % strings.length)])
+                    .append(" ");
+        }
+        return str.toString();
+    }
+
+    @Override
+    protected String getDescription() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}