blob: 55efd7d1f7bcdcd26cbb3fcb3ad38a183e7ae9db (
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.nativeselect;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Button;
@Widgetset("com.vaadin.DefaultWidgetSet")
public class NativeSelectsInGrid extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout(new Label(
"Keep opening the editor and selecting an enum value. Eventually the list will not show "
+ "all options"),
createGrid());
NativeSelect<Enum> ns = new NativeSelect<>();
ns.setEmptySelectionAllowed(false);
ns.setItems(Enum.values());
NativeSelect<Enum> ns2 = new NativeSelect<>();
ns2.setItems(Enum.values());
addComponent(ns);
addComponent(ns2);
addComponent(new Button("Change visibility of NS", e -> {
ns2.setVisible(!ns2.isVisible());
}));
addComponent(layout);
}
public Component createGrid() {
Grid<Person> grid = new Grid<>();
grid.setItems(new Person(Enum.baz), new Person(Enum.foo),
new Person(Enum.bizzle));
grid.setSizeFull();
grid.setSelectionMode(Grid.SelectionMode.NONE);
NativeSelect<Enum> ns = new NativeSelect<>();
ns.setEmptySelectionAllowed(false);
ns.setItems(Enum.values());
grid.addColumn(Person::getEnumValue).setCaption("Enum value")
.setEditorComponent(ns, Person::setEnumValue);
grid.getEditor().setEnabled(true);
return grid;
}
enum Enum {
foo, bar, baz, bizzle, quux
}
public static class Person {
Enum enumValue;
public Person(Enum progress) {
this.enumValue = progress;
}
public Enum getEnumValue() {
return enumValue;
}
public void setEnumValue(Enum enumValue) {
this.enumValue = enumValue;
}
}
}
|