use of io.jmix.ui.executor.BackgroundTaskHandler in project jmix-docs by Haulmont.
the class ProgressBarScreen method onInit.
@Subscribe
protected void onInit(InitEvent event) {
BackgroundTask<Integer, Void> task = new BackgroundTask<Integer, Void>(100) {
@Override
public Void run(TaskLifeCycle<Integer> taskLifeCycle) throws Exception {
for (int i = 1; i <= ITERATIONS; i++) {
// <1>
TimeUnit.SECONDS.sleep(1);
taskLifeCycle.publish(i);
}
return null;
}
@Override
public void progress(List<Integer> changes) {
double lastValue = changes.get(changes.size() - 1);
// <2>
progressBar.setValue(lastValue / ITERATIONS);
}
};
BackgroundTaskHandler taskHandler = backgroundWorker.handle(task);
taskHandler.execute();
}
use of io.jmix.ui.executor.BackgroundTaskHandler in project jmix-docs by Haulmont.
the class DialogsScreen method onBackgroundDlgBtnClick.
// end::create-exception-dialog[]
@Subscribe("backgroundDlgBtn")
public void onBackgroundDlgBtnClick(Button.ClickEvent event) {
BackgroundTask<Integer, Void> task = new BackgroundTask<Integer, Void>(300, this) {
@Override
public Void run(TaskLifeCycle<Integer> taskLifeCycle) throws Exception {
for (int i = 1; i <= ITERATIONS; i++) {
TimeUnit.SECONDS.sleep(2);
taskLifeCycle.publish(i);
}
return null;
}
@Override
public void progress(List<Integer> changes) {
double lastValue = changes.get(changes.size() - 1);
// progressBar.setValue((lastValue / ITERATIONS));
}
};
BackgroundTaskHandler taskHandler = backgroundWorker.handle(task);
taskHandler.execute();
dialogs.createBackgroundWorkDialog(this, task).withCaption("Please wait").withMessage("Data loading continues").withShowProgressInPercentage(true).withCancelAllowed(true).show();
}
use of io.jmix.ui.executor.BackgroundTaskHandler in project jmix by jmix-framework.
the class ImapMessageEdit method initBody.
protected void initBody(ImapMessage msg, AtomicInteger loadProgress) {
BackgroundTaskHandler taskHandler = backgroundWorker.handle(new InitBodyTask(msg, loadProgress));
taskHandler.execute();
}
use of io.jmix.ui.executor.BackgroundTaskHandler in project jmix by jmix-framework.
the class ImapMessageEdit method initAttachments.
protected void initAttachments(ImapMessage msg, AtomicInteger loadProgress) {
if (!Boolean.TRUE.equals(msg.getAttachmentsLoaded())) {
BackgroundTaskHandler taskHandler = backgroundWorker.handle(new InitAttachmentTask(msg, loadProgress));
taskHandler.execute();
} else {
hideProgressBar(loadProgress);
}
}
Aggregations