blob: 34aaa6326d69d6ba2deab79a4ba1cc47c719a0b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
package com.vaadin.tests.components.table;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.v7.data.util.BeanItemContainer;
import com.vaadin.v7.ui.Table;
@SuppressWarnings("serial")
public class ReloadWidgets extends AbstractReindeerTestUI {
int pressed = 0;
@Override
protected void setup(VaadinRequest request) {
final Table table = new Table(null,
new BeanItemContainer<>(Bean.class));
table.setId("table");
table.setSizeFull();
table.setColumnHeader("col1", "Text");
table.setColumnHeader("col2", "Button");
fillTable(table);
Button button = new Button("Refresh");
button.setId("refresh");
button.addClickListener(event -> {
table.removeAllItems();
fillTable(table);
});
getLayout().addComponent(button);
getLayout().addComponent(table);
getLayout().setExpandRatio(table, 1f);
}
@Override
protected String getTestDescription() {
return "Table should always populate button widgets to column 2";
}
@Override
protected Integer getTicketNumber() {
return 16611;
}
private void fillTable(Table table) {
int i = 0;
int size = pressed % 2 == 0 ? 500 : 499;
pressed++;
for (int step = 0; step < i + size; step++) {
String caption = Integer.toString(step);
Button button = new Button(caption);
button.setId(caption);
Bean itemId = new Bean(caption, button);
table.addItem(itemId);
}
}
public class Bean {
private String col1;
private Button col2;
public Bean(String col1, Button col2) {
this.col1 = col1;
this.col2 = col2;
}
public String getCol1() {
return col1;
}
public void setCol1(String col1) {
this.col1 = col1;
}
public Button getCol2() {
return col2;
}
public void setCol2(Button col2) {
this.col2 = col2;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Bean bean = (Bean) o;
if (!col1.equals(bean.col1)) {
return false;
}
if (!col2.equals(bean.col2)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = col1.hashCode();
result = 31 * result + col2.hashCode();
return result;
}
}
}
|