Search in sources :

Example 1 with Progress

use of eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress in project dwoss by gg-net.

the class HiddenMonitorDisplayTask method process.

@Override
protected void process(List<Progress> chunks) {
    Progress last = chunks.get(chunks.size() - 1);
    if (!progressBar.isVisible())
        progressBar.setVisible(true);
    if (last.getProgress() > 0 && progressBar.isIndeterminate())
        progressBar.setIndeterminate(false);
    messageBar.setText(last.getMessage());
    progressBar.setValue(last.getProgress());
}
Also used : Progress(eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress)

Example 2 with Progress

use of eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress in project dwoss by gg-net.

the class HiddenMonitorDisplayTask method doInBackground.

@Override
@SuppressWarnings("SleepWhileInLoop")
protected Void doInBackground() throws Exception {
    // Hint: the supplied Monitor has a length of 100;
    HiddenMonitor hm = Dl.remote().lookup(ProgressObserver.class).getMonitor(key);
    while (hm != null && !hm.isFinished()) {
        int progress = 100 - hm.getAbsolutRemainingTicks();
        if (progress < 0)
            progress = 0;
        if (progress > 100)
            progress = 100;
        publish(new Progress(progress, hm.getTitle() + ":" + StringUtils.defaultIfBlank(hm.getMessage(), "")));
        Thread.sleep(250);
        hm = Dl.remote().lookup(ProgressObserver.class).getMonitor(key);
    }
    publish(new Progress(100, ""));
    keys.remove(key);
    return null;
}
Also used : Progress(eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress) ProgressObserver(eu.ggnet.saft.api.progress.ProgressObserver) HiddenMonitor(eu.ggnet.saft.api.progress.HiddenMonitor)

Aggregations

Progress (eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress)2 HiddenMonitor (eu.ggnet.saft.api.progress.HiddenMonitor)1 ProgressObserver (eu.ggnet.saft.api.progress.ProgressObserver)1