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
|
package com.vaadin.tests.themes;
import com.vaadin.annotations.Theme;
import com.vaadin.event.Action;
import com.vaadin.event.Action.Handler;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.tests.util.PersonContainer;
import com.vaadin.ui.Button;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.ComboBox;
import com.vaadin.v7.ui.Table;
@Theme("reindeer")
public class LegacyComponentThemeChange extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
VerticalLayout vl = new VerticalLayout();
vl.setCaption("Change theme by clicking a button");
HorizontalLayout hl = new HorizontalLayout();
for (final String theme : new String[] { "reindeer", "runo" }) {
Button b = new Button(theme);
b.setId(theme + "");
b.addClickListener(event -> getUI().setTheme(theme));
hl.addComponent(b);
}
vl.addComponent(hl);
// Always wants to use icon from Runo, even if we change theme
ThemeResource alwaysTheSameIconImage = new ThemeResource(
"../runo/icons/16/ok.png");
ThemeResource varyingIcon = new ThemeResource("menubar-theme-icon.png");
MenuBar bar = new MenuBar();
bar.addItem("runo", alwaysTheSameIconImage, null);
bar.addItem("selectedtheme", varyingIcon, null);
MenuItem sub = bar.addItem("sub menu", null);
sub.addItem("runo", alwaysTheSameIconImage, null);
sub.addItem("selectedtheme", varyingIcon, null);
vl.addComponent(bar);
ComboBox cb = new ComboBox("ComboBox");
cb.addItem("No icon");
cb.addItem("Icon");
cb.setItemIcon("Icon", new ThemeResource("comboboxicon.png"));
cb.setValue("Icon");
vl.addComponent(cb);
Embedded e = new Embedded("embedded");
e.setMimeType("application/x-shockwave-flash");
e.setType(Embedded.TYPE_OBJECT);
e.setSource(new ThemeResource("embedded.src"));
vl.addComponent(e);
Table t = new Table();
t.addActionHandler(new Handler() {
@Override
public void handleAction(Action action, Object sender,
Object target) {
}
@Override
public Action[] getActions(Object target, Object sender) {
return new Action[] { new Action("Theme icon",
new ThemeResource("action-icon.png")) };
}
});
PersonContainer pc = PersonContainer.createWithTestData();
pc.addNestedContainerBean("address");
t.setContainerDataSource(pc);
vl.addComponent(t);
addComponent(vl);
}
}
|