blob: cd7b454380a02bd9e6970b8bd0ab515bbb122ced (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
package com.vaadin.tests.components.grid;
import com.vaadin.annotations.Widgetset;
import com.vaadin.data.provider.ListDataProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Grid;
import com.vaadin.ui.TextField;
import java.util.ArrayList;
import java.util.List;
/**
* Shows a Grid with the only editable columns being the column 1 and 3. That
* will allow us to test that Tab/Shift+Tab skips cells that are not editable.
*/
@Widgetset("com.vaadin.DefaultWidgetSet")
public class GridEditorTabSkipsNonEditableCells extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
final List<TestBean> items = new ArrayList<>();
Grid<TestBean> grid = new Grid<TestBean>(TestBean.class);
for (int i = 0; i < 10; i++) {
items.add(new TestBean(i));
}
grid.setDataProvider(new ListDataProvider<>(items));
grid.setWidth("100%");
grid.setHeight("400px");
grid.getEditor().setEnabled(true);
grid.getColumn("col1").setEditorComponent(new TextField());
grid.getColumn("col3").setEditorComponent(new TextField());
final TextField disabledField = new TextField();
disabledField.setEnabled(false);
grid.getColumn("col5").setEditorComponent(disabledField);
final TextField readOnlyField = new TextField();
readOnlyField.setReadOnly(true);
grid.getColumn("col6").setEditorComponent(readOnlyField);
grid.setColumnOrder("col0", "col1", "col2", "col3", "col4", "col5",
"col6");
getLayout().addComponent(
new Button("Set Editor Buffered Mode On", event -> {
grid.getEditor().cancel();
grid.getEditor().setBuffered(true);
}));
getLayout().addComponent(
new Button("Set Editor Buffered Mode Off", event -> {
grid.getEditor().cancel();
grid.getEditor().setBuffered(false);
}));
getLayout().addComponent(grid);
}
@Override
protected Integer getTicketNumber() {
return 11573;
}
@Override
protected String getTestDescription() {
return "Pressing TAB doesn't shift the focus to non-editable cells when the Grid is in edit mode.";
}
public static class TestBean {
private final int row;
public TestBean(int row) {
this.row = row;
}
public String getCol0() {
return "col0_" + row;
}
public String getCol1() {
return "col1_" + row;
}
public String getCol2() {
return "col2_" + row;
}
public String getCol3() {
return "col3_" + row;
}
public String getCol4() {
return "col4_" + row;
}
public String getCol5() {
return "col5_" + row;
}
public String getCol6() {
return "col6_" + row;
}
public void setCol0(String value) {
}
public void setCol1(String value) {
}
public void setCol2(String value) {
}
public void setCol3(String value) {
}
public void setCol4(String value) {
}
public void setCol5(String value) {
}
public void setCol6(String value) {
}
}
}
|