blob: 055820210a3e1d1c373a46c4ddcbc08ac4167bde (
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
|
package com.vaadin.tests.components.table;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Table;
/**
* Setting table height and setting column header mode as hidden leaves the body
* height of the table as it would be with the headers visible and leaves an
* empty area below the body.
*
*/
@SuppressWarnings("serial")
public class TableHeightWhenHidingHeaders extends AbstractTestCase {
@Override
public void init() {
LegacyWindow mainWindow = new LegacyWindow();
setMainWindow(mainWindow);
final Table table = new Table("Test table");
table.addContainerProperty("Name", String.class, null, "Name", null,
null);
table.setItemCaptionPropertyId("Name");
table.setHeight("100px");
table.setImmediate(true);
table.addItem("1").getItemProperty("Name").setValue("Item 1");
table.addItem("2").getItemProperty("Name").setValue("Item 2");
CheckBox showHeaders = new CheckBox("Show headers");
showHeaders.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if ((Boolean) event.getProperty().getValue()) {
// table body height is now 77px, which together
// with header makes 100px
table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
} else {
table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
// header disappears, but table body height stays at
// 77px
// and below the body is an empty area (same height
// as header would
// have)
}
}
});
showHeaders.setValue(true);
showHeaders.setImmediate(true);
mainWindow.addComponent(showHeaders);
mainWindow.addComponent(table);
}
@Override
protected String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
protected Integer getTicketNumber() {
return 4507;
}
}
|