blob: 76673021bb2c29b375e531e93a2bc6c6d6636adb (
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
|
package com.vaadin.tests.tickets;
import java.util.Date;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.ProgressIndicator;
public class Ticket1581 extends com.vaadin.server.LegacyApplication {
private Label time;
private ProgressIndicator poller;
private Thread thread;
@Override
public void init() {
final LegacyWindow main = new LegacyWindow(getClass().getName()
.substring(getClass().getName().lastIndexOf(".") + 1));
setMainWindow(main);
main.addComponent(new Label("Test the second issue in ticket #1581"));
time = new Label();
poller = new ProgressIndicator();
poller.setPollingInterval(200);
main.addComponent(time);
main.addComponent(poller);
thread = new Thread() {
@Override
public void run() {
super.run();
while (true) {
time.setValue(new Date().toString());
try {
sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
thread.start();
final Button stop = new Button("Stop updating", new ClickListener() {
boolean active = true;
@Override
public void buttonClick(ClickEvent event) {
if (active) {
main.removeComponent(poller);
event.getButton().setCaption("Resume");
} else {
main.addComponent(poller);
event.getButton().setCaption("Stop updating");
}
active = !active;
}
});
main.addComponent(stop);
}
}
|