blob: 8d4ff119ab8c583f8996647fff0e7ee5339bcc66 (
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
|
package com.vaadin.tests.components.table;
import java.util.ArrayList;
import java.util.List;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.data.util.BeanItemContainer;
import com.vaadin.v7.ui.Table;
public class TableScrollsOnRefresh extends AbstractTestUI {
private Table table = new Table(
"scroll down table, so it loads next page, and then click 'refresh' button");
private Button refresh = new Button("refresh");
private BeanItemContainer<TableItem> container = new BeanItemContainer<TableItem>(
TableItem.class);
@Override
protected void setup(VaadinRequest request) {
refresh.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
table.refreshRowCache();
}
});
table.setSizeFull();
addComponents(refresh, table);
VerticalLayout vl = getLayout();
vl.setExpandRatio(table, 1f);
vl.setSizeFull();
vl.getParent().setSizeFull();
table.setContainerDataSource(container);
populateContainer();
}
private void populateContainer() {
List<TableItem> items = new ArrayList<TableItem>();
for (int i = 0; i < 1000; i++) {
items.add(new TableItem("Item " + Integer.toString(i),
"Item description " + Integer.toString(i)));
}
container.addAll(items);
}
@Override
protected String getTestDescription() {
return "Refreshing row cache shouldn't change scroll position.";
}
@Override
protected Integer getTicketNumber() {
return 8707;
}
public class TableItem {
private String name;
private String description;
public TableItem(String name, String description) {
this.name = name;
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
}
|