blob: 1947101af2737ec11c802ad36190e05c78b21904 (
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
|
package com.vaadin.tests.components.table;
import java.util.Map;
import com.vaadin.annotations.Theme;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.Table;
@SuppressWarnings("serial")
@Theme("reindeer")
public class ExpandingContainerVisibleRowRaceCondition extends UI {
static final String TABLE = "table";
@Override
public void init(VaadinRequest request) {
final VerticalLayout rootLayout = new VerticalLayout();
rootLayout.setSpacing(true);
rootLayout.setSizeFull();
rootLayout.setMargin(true);
final Label sizeLabel = new Label();
final ExpandingContainer container = new ExpandingContainer(sizeLabel);
container.logDetails(false);
Table table = new Table(null, container) {
@Override
public void changeVariables(Object source,
Map<String, Object> variables) {
if (variables.containsKey("firstvisible")) {
int index = (Integer) variables.get("firstvisible");
container.checkExpand(index);
}
if (variables.containsKey("reqfirstrow")
|| variables.containsKey("reqrows")) {
try {
int index = ((Integer) variables
.get("lastToBeRendered")).intValue();
container.checkExpand(index);
} catch (Exception e) {
// do nothing
}
}
super.changeVariables(source, variables);
}
};
table.setId(TABLE);
table.setCacheRate(0);
table.setSizeFull();
table.setVisibleColumns((Object[]) ExpandingContainer.PROPERTY_IDS
.toArray(new String[ExpandingContainer.PROPERTY_IDS.size()]));
table.setCurrentPageFirstItemIndex(120);
rootLayout.addComponent(table);
rootLayout.setExpandRatio(table, 1);
rootLayout.addComponent(sizeLabel);
setContent(rootLayout);
container.checkExpand(300);
}
}
|