1 package com.vaadin.tests.components.table;
3 import java.util.ArrayList;
6 import com.vaadin.server.VaadinRequest;
7 import com.vaadin.tests.components.AbstractTestUI;
8 import com.vaadin.ui.Button;
9 import com.vaadin.ui.VerticalLayout;
10 import com.vaadin.v7.data.util.BeanItemContainer;
11 import com.vaadin.v7.ui.Table;
13 public class ColumnWidthsAfterChangeTableColumnsCountOrOrder
14 extends AbstractTestUI {
16 protected static final String BUTTON_CHANGE_ORDER_AND_WIDTH_ID = "buttonChangeOrderAndWidth";
17 protected static final String BUTTON_CHANGE_COLUMN_COUNT_AND_WIDTH = "buttonChangeColumnCountAndWidth";
18 protected static final int NEW_COLUMN_WIDTH = 17;
21 protected void setup(VaadinRequest request) {
22 List<TestBean> beanList = new ArrayList<TestBean>();
23 beanList.add(new TestBean(1, "name1", "descr1"));
24 beanList.add(new TestBean(2, "name2", "descr2"));
25 beanList.add(new TestBean(3, "name3", "descr3"));
26 beanList.add(new TestBean(4, "name4", "descr4"));
27 beanList.add(new TestBean(5, "name5", "descr5"));
29 BeanItemContainer<TestBean> container = new BeanItemContainer<TestBean>(
30 TestBean.class, beanList);
32 VerticalLayout layout = new VerticalLayout();
34 final Table table = new Table("Test Table");
35 table.setContainerDataSource(container);
36 table.setVisibleColumns(new Object[] { "id", "name", "descr" });
37 layout.addComponent(table);
39 Button buttonChangeOrderAndWidth = new Button("Change order and width",
40 new Button.ClickListener() {
42 public void buttonClick(Button.ClickEvent clickEvent) {
43 table.setVisibleColumns(
44 new Object[] { "name", "descr", "id" });
45 table.setColumnWidth("descr", NEW_COLUMN_WIDTH);
48 buttonChangeOrderAndWidth.setId(BUTTON_CHANGE_ORDER_AND_WIDTH_ID);
50 Button buttonChangeColumnCountAndWidth = new Button(
51 "Change columns count and width", new Button.ClickListener() {
53 public void buttonClick(Button.ClickEvent clickEvent) {
54 table.setVisibleColumns(
55 new Object[] { "name", "descr" });
56 table.setColumnWidth("descr", NEW_COLUMN_WIDTH);
59 buttonChangeColumnCountAndWidth
60 .setId(BUTTON_CHANGE_COLUMN_COUNT_AND_WIDTH);
62 layout.addComponent(buttonChangeOrderAndWidth);
63 layout.addComponent(buttonChangeColumnCountAndWidth);
65 addComponents(layout);
68 public class TestBean {
73 public TestBean(int id, String name, String descr) {
83 public void setId(int id) {
87 public String getName() {
91 public void setName(String name) {
95 public String getDescr() {
99 public void setDescr(String descr) {
104 public String toString() {
105 return "TestBean{" + "id=" + id + ", name='" + name + '\''
106 + ", descr='" + descr + '\'' + '}';
111 protected String getTestDescription() {
112 return "Tests that properties of columns are changed correctly after changing column's order/count";
116 protected Integer getTicketNumber() {