blob: dd4cf5e7e2e0f3427141cb4f16958848484c5b11 (
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
|
package com.vaadin.tests.components.grid;
import java.util.Arrays;
import java.util.List;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Grid;
public class GridEventSentOnColumnVisibilityChange
extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
List<Person> people = Arrays.asList(
new Person("Nicolaus Copernicus", 1543),
new Person("Galileo Galilei", 1564),
new Person("Johannes Kepler", 1571));
Grid<Person> grid = new Grid<>();
grid.setItems(people);
grid.addColumn(Person::getName).setId("name").setCaption("Name")
.setHidable(true);
grid.addColumn(Person::getBirthYear).setCaption("Year of birth")
.setHidable(true);
grid.setSizeFull();
grid.addColumnVisibilityChangeListener(
event -> log("UserOriginated: " + event.isUserOriginated()));
addComponent(grid);
}
private class Person {
private final String name;
private final int birthYear;
public Person(String name, int birthYear) {
this.name = name;
this.birthYear = birthYear;
}
public String getName() {
return name;
}
public int getBirthYear() {
return birthYear;
}
}
@Override
public String getDescription() {
return "Every time when the user changes the visibility of the column,"
+ " there should have only one event sent";
}
@Override
protected Integer getTicketNumber() {
return 11419;
}
}
|