@Override
protected void doOnce() {
ViewDescriptorRegistry viewDescriptorRegistry = (ViewDescriptorRegistry) ApplicationServicesLocator.services().getService(ViewDescriptorRegistry.class);
final DualEventDescriptor view = (DualEventDescriptor) viewDescriptorRegistry.getViewDescriptor("dualEventView");
final List<DualEvent> eventsList = view.getDualEvents();
final Dao<Event> dao = view.getDao();
final StatusBar bar = getApplicationWindow().getStatusBar();
bar.getProgressMonitor().taskStarted(tr.get(ID + ".startTask"), 100);
MySwingWorker sw = new MySwingWorker(ID) {
@Override
protected void myconstruct() throws Exception {
double delta = 90.0 / dao.getAll().size();
double counter = 1;
for (Event a : dao.getAll()) {
bar.getProgressMonitor().worked((int) counter);
counter += delta;
if (!firstEvent(a))
continue;
for (Event b : dao.getAll()) {
if (a == b || !firstEvent(b))
continue;
eventsList.add(new DualEvent(a, b));
}
}
logger.info("Read dual events:" + eventsList.size());
}
private boolean firstEvent(Event ev) {
DifferentDayConstraint constr = ev.getConstraint(DifferentDayConstraint.class);
if (constr != null) {
// only one event of the event group
if (constr.getEvents().size() > 0
&& ev == constr.getEvents().iterator().next())
return true;
}
return false;
}
@Override
protected void done() {
bar.getProgressMonitor().worked(95);
view.createShowViewCommand(getApplicationWindow()).execute();
super.done();
}
};
sw.execute();