Integer pushSize = (Integer) dataSize.getConvertedValue();
Integer pushInterval = (Integer) interval.getConvertedValue();
Integer pushDuration = (Integer) duration.getConvertedValue();
- PushRunnable r = new PushRunnable(pushSize, pushInterval,
- pushDuration);
+ PushRunnable r = new PushRunnable(getUI(), pushSize,
+ pushInterval, pushDuration);
executor.execute(r);
log.log("Starting push, size: " + pushSize + ", interval: "
+ pushInterval + "ms, duration: " + pushDuration
private Integer size;
private Integer interval;
private Integer duration;
+ private final UI ui;
- public PushRunnable(Integer size, Integer interval, Integer duration) {
+ public PushRunnable(UI ui, Integer size, Integer interval,
+ Integer duration) {
this.size = size;
this.interval = interval;
this.duration = duration;
+ this.ui = ui;
}
@Override
int packageIndex = 1;
while (System.currentTimeMillis() < endTime) {
final int idx = packageIndex++;
- UI.getCurrent().access(new Runnable() {
+ ui.access(new Runnable() {
@Override
public void run() {
- PushLargeData ui = (PushLargeData) UI.getCurrent();
+ PushLargeData pushUi = (PushLargeData) ui;
// Using description as it is not rendered to the DOM
// immediately
- ui.getDataLabel().setDescription(
+ pushUi.getDataLabel().setDescription(
System.currentTimeMillis() + ": " + data);
- ui.log("Package " + idx + " pushed");
+ pushUi.log("Package " + idx + " pushed");
}
});
try {
return;
}
}
- UI.getCurrent().access(new Runnable() {
+ ui.access(new Runnable() {
@Override
public void run() {
- PushLargeData ui = (PushLargeData) UI.getCurrent();
- ui.log("Push complete");
+ PushLargeData pushUi = (PushLargeData) ui;
+ pushUi.log("Push complete");
}
});