Search in sources :

Example 1 with HiddenMonitor

use of eu.ggnet.saft.api.progress.HiddenMonitor in project dwoss by gg-net.

the class BackgroundProgressAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Ui.exec(() -> {
        Ui.progress().call(() -> {
            HiddenMonitor m = new HiddenMonitor();
            m.title("TestMonitor");
            progressObserver.add(m);
            m.start();
            for (int i = 0; i < 20; i++) {
                m.worked(5, "Working on " + i);
                Thread.sleep(500);
            }
            m.finish();
            return null;
        });
    });
}
Also used : HiddenMonitor(eu.ggnet.saft.api.progress.HiddenMonitor)

Example 2 with HiddenMonitor

use of eu.ggnet.saft.api.progress.HiddenMonitor in project dwoss by gg-net.

the class MonitorFactory method newSubMonitor.

/**
 * Creates a new Submonitor, with initial work remaing.
 * <p>
 * @param title
 * @param workRemaining
 * @return a new Submonitor.
 */
public SubMonitor newSubMonitor(String title, int workRemaining) {
    L.debug("creating Submonitor {}", title);
    HiddenMonitor monitor = new HiddenMonitor();
    monitor.title(title);
    monitors.put(monitor.hashCode(), monitor);
    return SubMonitor.convert(monitor, workRemaining);
}
Also used : HiddenMonitor(eu.ggnet.saft.api.progress.HiddenMonitor)

Example 3 with HiddenMonitor

use of eu.ggnet.saft.api.progress.HiddenMonitor in project dwoss by gg-net.

the class MonitorFactory method cleanUp.

@Schedule(second = "0", minute = "*/5", hour = "*", dayOfMonth = "*", month = "*", year = "*", info = "Cleanup of Montiors", persistent = false)
private void cleanUp() {
    L.debug("cleanUp called by Timer @ {}", new Date());
    for (Integer key : new HashSet<>(monitors.keySet())) {
        if (monitors.get(key).isFinished()) {
            HiddenMonitor m = monitors.remove(key);
            L.info("Evicting finished Monitor {}", m);
            lastProgress.remove(key);
        } else if (monitors.get(key).isStale()) {
            HiddenMonitor m = monitors.remove(key);
            L.warn("Evicting stale Monitor {}", m);
            lastProgress.remove(key);
        }
    }
}
Also used : HiddenMonitor(eu.ggnet.saft.api.progress.HiddenMonitor) Schedule(javax.ejb.Schedule)

Example 4 with HiddenMonitor

use of eu.ggnet.saft.api.progress.HiddenMonitor 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

HiddenMonitor (eu.ggnet.saft.api.progress.HiddenMonitor)4 ProgressObserver (eu.ggnet.saft.api.progress.ProgressObserver)1 Progress (eu.ggnet.saft.runtime.HiddenMonitorDisplayTask.Progress)1 Schedule (javax.ejb.Schedule)1