blob: d25808332d1b3cdf66b11485d8a66a2188524057 (
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
|
package com.vaadin.tests.tickets;
import com.vaadin.Application;
import com.vaadin.data.Container;
import com.vaadin.data.Container.Filterable;
import com.vaadin.data.Item;
import com.vaadin.data.util.filter.SimpleStringFilter;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI.LegacyWindow;
public class Ticket1995 extends Application {
private static final Object PROPERTY_1 = "Test";
private Table table;
@Override
public void init() {
final LegacyWindow mainWin = new LegacyWindow(getClass().getName());
setMainWindow(mainWin);
table = new Table();
table.addContainerProperty(PROPERTY_1, String.class, "");
table.setPageLength(4);
Item item = table.addItem("1");
item.getItemProperty(PROPERTY_1).setValue("Row 1");
item = table.addItem("2");
item.getItemProperty(PROPERTY_1).setValue("Row 2");
Filterable filterable = (Container.Filterable) table
.getContainerDataSource();
filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
true, false));
table.setColumnHeader(PROPERTY_1, "Test (filter: Row)");
mainWin.addComponent(table);
mainWin.addComponent(new Button("Add item",
new com.vaadin.ui.Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addItem();
}
}));
}
protected void addItem() {
Filterable filterable = (Container.Filterable) table
.getContainerDataSource();
Item i = table.addItem("abc");
String res = "";
if (i == null) {
res = "FAILED";
} else {
res = "OK!";
}
getMainWindow().showNotification("Tried to add item 'abc', " + res);
filterable.addContainerFilter(new SimpleStringFilter(PROPERTY_1, "Row",
true, false));
}
}
|