blob: 85c63b2446e37db65ecdbb44d7badfb0dbfa8d8f (
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
|
package com.itmill.toolkit.tests.tickets;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.terminal.ThemeResource;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.Embedded;
import com.itmill.toolkit.ui.GridLayout;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.Layout;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Panel;
import com.itmill.toolkit.ui.SplitPanel;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
import com.itmill.toolkit.ui.Button.ClickListener;
public class Ticket2048 extends Application {
private Embedded embedded;
private Panel p;
private SplitPanel splitPanel;
private GridLayout gridLayout;
private OrderedLayout orderedLayout;
public void init() {
Window w = new Window(getClass().getSimpleName());
setMainWindow(w);
// setTheme("tests-tickets");
// splitPanel = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
// getMainWindow().setLayout(splitPanel);
// GridLayout layout = new GridLayout(10, 10);
// w.setLayout(layout);
// gridLayout = new GridLayout(1, 1);
orderedLayout = new OrderedLayout();
getMainWindow().setLayout(orderedLayout);
// getMainWindow().setLayout(new GridLayout(1, 1));
getMainWindow().setSizeFull();
getMainWindow().getLayout().setSizeFull();
createUI(orderedLayout);
// createUI(gridLayout);
}
private void createUI(Layout layout) {
// Button sw = new Button("Switch", new ClickListener() {
//
// public void buttonClick(ClickEvent event) {
// Layout l = getMainWindow().getLayout();
// if (l == orderedLayout) {
// getMainWindow().setLayout(gridLayout);
// } else {
// getMainWindow().setLayout(orderedLayout);
// }
//
// }
// });
// layout.addComponent(sw);
Layout ol = new GridLayout(1, 2);
p = new Panel("Panel", ol);
p.setSizeFull();
Label l = new Label("Spacer");
l.setHeight("400px");
p.addComponent(l);
embedded = new Embedded(null, new ThemeResource(
"icons/64/folder-add.png"));
layout.addComponent(embedded);
Button b = new Button(
"Replace image with new embedded component (flashes)",
new ClickListener() {
public void buttonClick(ClickEvent event) {
Embedded newEmbedded = new Embedded(null,
new ThemeResource("icons/64/folder-add.png"));
getMainWindow().getLayout().replaceComponent(embedded,
newEmbedded);
embedded = newEmbedded;
}
});
p.addComponent(b);
b = new Button("Change image source (is fine)", new ClickListener() {
public void buttonClick(ClickEvent event) {
String img = "folder-add";
if (((ThemeResource) embedded.getSource()).getResourceId()
.contains("folder-add")) {
img = "folder-delete";
}
embedded
.setSource(new ThemeResource("icons/64/" + img + ".png"));
}
});
p.addComponent(b);
layout.addComponent(p);
}
}
|