blob: 908ef2a35a099a626d735e3748dc959e26fabea3 (
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
107
108
109
|
package com.itmill.toolkit.tests.tickets;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.data.util.ObjectProperty;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.CheckBox;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Window;
public class Ticket2151 extends Application {
private Label status;
@Override
public void init() {
Window w = new Window(getClass().getSimpleName());
setMainWindow(w);
// setTheme("tests-tickets");
createUI((OrderedLayout) w.getLayout());
}
private void createUI(OrderedLayout layout) {
Button b = new Button("This is a button");
CheckBox cb = new CheckBox("This is a checkbox");
cb.setImmediate(true);
setTheme("tests-tickets");
layout.setStyleName("mylayout");
status = new Label("Result:");
layout.addComponent(status);
layout.setSpacing(true);
layout.setMargin(true);
layout.addComponent(b);
layout.addComponent(cb);
layout.addComponent(new Label("a"));
layout.addComponent(new Label("b"));
layout.addComponent(new Label("c"));
check(Button.class);
check(CheckBox.class);
checkDataBinding(Button.class);
checkDataBinding(CheckBox.class);
}
private void check(Class<? extends Button> class1) {
boolean ok = false;
Button b;
try {
b = class1.newInstance();
b.setCaption("Button of type " + class1.getSimpleName());
try {
// This should throw an exception
b.setValue("ON");
} catch (IllegalArgumentException e) {
ok = true;
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e1) {
e1.printStackTrace();
return;
}
if (ok) {
status.setValue(status.getValue() + " "
+ class1.getClass().getSimpleName() + ": OK");
} else {
status.setValue(status.getValue() + " "
+ class1.getClass().getSimpleName() + ": FAILED");
}
}
private void checkDataBinding(Class<? extends Button> class1) {
boolean ok = false;
Button b;
try {
b = class1.newInstance();
b.setCaption("Button of type " + class1.getSimpleName());
try {
b.setWriteThrough(true);
b.setReadThrough(true);
ObjectProperty prop = new ObjectProperty("ABC 123");
/*
* This should throw an exception or somehow tell that the
* property was invalid (wrong type). See #2223.
*/
b.setPropertyDataSource(prop);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e1) {
e1.printStackTrace();
return;
}
if (ok) {
status.setValue(status.getValue() + " "
+ class1.getClass().getSimpleName() + "/DB: OK");
} else {
status.setValue(status.getValue() + " "
+ class1.getClass().getSimpleName() + "/DB: FAILED");
}
}
}
|