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
|
package com.vaadin.tests.components.table;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
public class ColumnCollapsingAndColumnExpansion extends TestBase {
private Table table;
@Override
public void setup() {
table = new Table();
table.addContainerProperty("Col1", String.class, null);
table.addContainerProperty("Col2", String.class, null);
table.addContainerProperty("Col3", String.class, null);
table.setColumnCollapsingAllowed(true);
table.setSizeFull();
for (int y = 1; y < 5; y++) {
table.addItem(new Object[] { "cell " + 1 + "-" + y,
"cell " + 2 + "-" + y, "cell " + 3 + "-" + y, },
new Object());
}
addComponent(table);
HorizontalLayout hl = new HorizontalLayout();
final TextField tf = new TextField("Column name");
Button hide = new Button("Collapse", new ClickListener() {
public void buttonClick(ClickEvent event) {
try {
table.setColumnCollapsed(tf.getValue(), true);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Button show = new Button("Show", new ClickListener() {
public void buttonClick(ClickEvent event) {
try {
table.setColumnCollapsed(tf.getValue(), false);
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
hl.addComponent(tf);
hl.addComponent(hide);
hl.addComponent(show);
hl.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
hl.setComponentAlignment(hide, Alignment.BOTTOM_LEFT);
hl.setComponentAlignment(show, Alignment.BOTTOM_LEFT);
addComponent(hl);
}
@Override
protected String getDescription() {
return "After hiding column 2 the remaining columns (1 and 3) should use all available space in the table";
}
@Override
protected Integer getTicketNumber() {
return 3246;
}
}
|