From 1c8cd9014d378b690b46c9eb593cb3f68a5f1135 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Mon, 10 Sep 2007 09:40:32 +0000 Subject: [PATCH] added test for table column widths svn changeset:2256/svn branch:trunk --- ...ablesInitialColumnWidthLogicRendering.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java diff --git a/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java new file mode 100644 index 0000000000..33727289f5 --- /dev/null +++ b/src/com/itmill/toolkit/tests/TestForTablesInitialColumnWidthLogicRendering.java @@ -0,0 +1,130 @@ +package com.itmill.toolkit.tests; + +import java.util.Vector; + +import com.itmill.toolkit.ui.Button; +import com.itmill.toolkit.ui.CustomComponent; +import com.itmill.toolkit.ui.Label; +import com.itmill.toolkit.ui.OrderedLayout; +import com.itmill.toolkit.ui.Table; + +/** + * + * This Component contains some simple test to see that component + * updates its contents propertly. + * + * @author IT Mill Ltd. + */ +public class TestForTablesInitialColumnWidthLogicRendering extends CustomComponent { + + + private OrderedLayout main = new OrderedLayout(); + + public TestForTablesInitialColumnWidthLogicRendering() { + + setCompositionRoot(main); + createNewView(); + } + + public void createNewView() { + main.removeAllComponents(); + main.addComponent(new Label("Below are same tables that all should render somewhat nice. Also when testing, you might want to try resizing window.")); + + Table t; + +// t = new Table("Empty table"); +// main.addComponent(t); + + + t = getTestTable(5, 0); + t.setCaption("Table with only headers"); +// main.addComponent(t); + + t = getTestTable(5, 200); + t.setCaption("Table with some cols and lot of rows"); + main.addComponent(t); + + + t = getTestTable(12, 4); + t.setCaption("Table with some rows and lot of columns"); + main.addComponent(t); + + t = getTestTable(3, 40); + t.setCaption("Table with some columns and wide explicit width. (Ought to widen columns to use all space)"); + t.setWidth(1000); + main.addComponent(t); + + + t = getTestTable(12, 4); + t.setCaption("Table with some rows and lot of columns, width == 100%"); + t.setWidth(100); + t.setWidthUnits(Table.UNITS_PERCENTAGE); + main.addComponent(t); + + t = getTestTable(12, 100); + t.setCaption("Table with lot of rows and lot of columns, width == 50%"); + t.setWidth(50); + t.setWidthUnits(Table.UNITS_PERCENTAGE); + main.addComponent(t); + + + t = getTestTable(5, 100); + t.setCaption("Table with 40 rows"); +// main.addComponent(t); + + t = getTestTable(4, 4); + t.setCaption("Table with some rows and width = 200px"); + + t.setWidth(200); + main.addComponent(t); + + Button b = new Button("refresh view", this, "createNewView"); + main.addComponent(b); + + } + + public Table getTestTable(int cols, int rows) { + Table t = new Table(); + t.setColumnCollapsingAllowed(true); + for(int i = 0; i < cols; i++) { + t.addContainerProperty(testString[i], String.class, ""); + } + for(int i = 0; i < rows; i++) { + Vector content = new Vector(); + for(int j = 0; j < cols;j++) { + content.add(rndString()); + } + t.addItem(content.toArray(), ""+i); + } + return t; + } + + static String[] testString = new String[] { + "DSFdsfs", + "böö", + "1", + "sdf sdfsd fsdfsdf sdf", + "SDF SADds FASDF dsaf", + "foo", + "VADSFA", + "DSFSD FS", + "whattaa", + " sdf sdfsd ", + "DSf sdf sdf", + "foods f", + "VADsd fSFA", + "DSFsd fSD FS", + "wha sdf ttaa", + " sd sdff sdfsd ", + "DSf sdf sdf", + "SDFsd sd fadsfadfs" + }; + + + public static String rndString() { + return testString[(int) (Math.random()*testString.length)]; + } + +} + + -- 2.39.5