blob: b81d57eccd3addb38fdfc5ccaf313c1c9eda95ba (
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
|
package com.vaadin.tests.integration;
import com.vaadin.annotations.DesignRoot;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.ClassResource;
import com.vaadin.server.Resource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.declarative.Design;
public class ServletIntegrationUI extends UI {
@Override
protected void init(VaadinRequest request) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
final Table table = new Table();
table.addContainerProperty("icon", Resource.class, null);
table.setItemIconPropertyId("icon");
table.addContainerProperty("country", String.class, null);
table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY);
table.setImmediate(true);
table.setSelectable(true);
table.setVisibleColumns(new Object[] { "country" });
layout.addComponent(table);
Item item = table.addItem("FI");
item.getItemProperty("icon").setValue(new ClassResource("fi.gif"));
item.getItemProperty("country").setValue("Finland");
item = table.addItem("SE");
item.getItemProperty("icon").setValue(new FlagSeResource());
item.getItemProperty("country").setValue("Sweden");
final Label selectedLabel = new LabelFromDesign();
table.addValueChangeListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
selectedLabel.setValue(String.valueOf(table.getValue()));
}
});
layout.addComponent(selectedLabel);
}
@DesignRoot
public static class LabelFromDesign extends Label {
public LabelFromDesign() {
Design.read(this);
}
}
}
|