blob: a36beb86fa7b98789d77fe2bc04024398c4889a9 (
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
|
package com.vaadin.tests.elements.table;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Notification;
import com.vaadin.v7.ui.Table;
public class TableElementContextMenu extends AbstractTestUI {
Table table = new Table();
private int COLUMNS = 4;
private int ROWS = 10;
@Override
protected void setup(VaadinRequest request) {
fillTable(table);
table.addActionHandler(new TableActionHandler());
addComponent(table);
}
@Override
protected String getTestDescription() {
return "Tests that calling TableElement.contextClick() opens the context menu";
}
@Override
protected Integer getTicketNumber() {
return 14385;
}
// set up the properties (columns)
private void initProperties(Table table) {
for (int i = 0; i < COLUMNS; i++) {
table.addContainerProperty("property" + i, String.class,
"some value");
}
}
// fill the table with some random data
private void fillTable(Table table) {
initProperties(table);
for (int i = 0; i < ROWS; i++) {
String[] line = new String[COLUMNS];
for (int j = 0; j < COLUMNS; j++) {
line[j] = "col=" + j + " row=" + i;
}
table.addItem(line, null);
}
}
public class TableActionHandler implements Handler {
@Override
public Action[] getActions(Object target, Object sender) {
Action[] actions = new Action[2];
actions[0] = new Action("Add");
actions[1] = new Action("Edit");
return actions;
}
@Override
public void handleAction(Action action, Object sender, Object target) {
Notification.show(action.getCaption());
}
}
}
|