]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added testcase for #1983
authorMarc Englund <marc.englund@itmill.com>
Thu, 28 Aug 2008 12:29:37 +0000 (12:29 +0000)
committerMarc Englund <marc.englund@itmill.com>
Thu, 28 Aug 2008 12:29:37 +0000 (12:29 +0000)
svn changeset:5289/svn branch:trunk

src/com/itmill/toolkit/tests/tickets/Ticket1983.java [new file with mode: 0644]

diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket1983.java b/src/com/itmill/toolkit/tests/tickets/Ticket1983.java
new file mode 100644 (file)
index 0000000..0948cb8
--- /dev/null
@@ -0,0 +1,86 @@
+package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.data.util.IndexedContainer;
+import com.itmill.toolkit.terminal.Sizeable;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.Layout;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.SplitPanel;
+import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.Window;
+
+/**
+ * Test class for ticket 1983
+ */
+public class Ticket1983 extends Application {
+
+    public void init() {
+        Window main = new Window("Test for ticket 1983");
+        main.setLayout(new TestLayout());
+        setMainWindow(main);
+    }
+
+    private static class TestLayout extends SplitPanel {
+        boolean isLong = true;
+
+        public TestLayout() {
+            super(ORIENTATION_HORIZONTAL);
+
+            setSplitPosition(200, Sizeable.UNITS_PIXELS);
+            setMargin(false);
+            setLocked(true);
+
+            final SplitPanel leftSide = initLeftSide();
+            setFirstComponent(leftSide);
+
+            final Layout rightSide = new OrderedLayout();
+            rightSide.setHeight("100%");
+            setSecondComponent(rightSide);
+        }
+
+        private SplitPanel initLeftSide() {
+            final SplitPanel leftSide = new SplitPanel(ORIENTATION_VERTICAL);
+            leftSide.setHeight("100%");
+
+            final IndexedContainer dataSource = new IndexedContainer();
+            final String propId = "col";
+            dataSource.addContainerProperty(propId, String.class, null);
+            final Object itemId = dataSource.addItem();
+            dataSource.getItem(itemId).getItemProperty(propId).setValue(
+                    "Very long value that makes a scrollbar appear for sure");
+
+            final Table table = new Table();
+            table.setSizeFull();
+            table.setContainerDataSource(dataSource);
+            table.setVisibleColumns(new Object[] { propId });
+
+            leftSide.setSecondComponent(table);
+
+            Button button = new Button("Change col value to short");
+            button.addListener(new Button.ClickListener() {
+                public void buttonClick(Button.ClickEvent event) {
+                    // Change the column value to a short one --> Should remove
+                    // the scrollbar
+                    if (isLong) {
+                        dataSource.getItem(itemId).getItemProperty(propId)
+                                .setValue("Short value");
+                        isLong = false;
+                    } else {
+                        dataSource
+                                .getItem(itemId)
+                                .getItemProperty(propId)
+                                .setValue(
+                                        "Very long value that makes a scrollbar appear for sure");
+                        isLong = true;
+                    }
+                    // Works the same way with or without repaint request
+                    table.requestRepaint();
+                }
+            });
+            leftSide.setFirstComponent(button);
+
+            return leftSide;
+        }
+    }
+}