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;
});
});
}
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);
}
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);
}
}
}
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;
}
Aggregations