for (Iterator iter = formulas(); iter.hasNext(); )
((Formula)iter.next()).useCache();
resetCachedValues();
rset = null;
StatusDialog statusDialog = null;
try {
if (ErrorHandler.usingGUI()) {
statusDialog = new StatusDialog(getDesignFrame(),
I18N.get("Report.status_title"),
true,
I18N.get("Report.status_running"));
}
if (!layoutEngine.wantsMoreData())
return;
rset = dataSource.execute();
boolean layoutStarted = false;
while (layoutEngine.wantsMoreData() && rset.next()) {
if (statusDialog != null) {
if (statusDialog.isCancelled())
throw new UserCancellationException();
statusDialog.update(I18N.get("Report.processing_row") + ' '
+ rowNumber());
}
if (!layoutStarted) {
layoutEngine.start();
layoutStarted = true;
}
processResultRow();
}
rset.last(); // Recall last row so we can access the data
if (!layoutStarted) { // No rows in report
layoutEngine.start();
layoutEngine.end();
}
else { // Output group footers and end of report
layoutEngine.groupFooters(true);
layoutEngine.end();
}
}
catch (UserCancellationException uce) {
layoutEngine.cancel();
}
catch (SQLException sqle) {
layoutEngine.cancel();
ErrorHandler.error(dataSource.getQuery().toString(), sqle);
}
catch (Exception e) {
e.printStackTrace();
layoutEngine.cancel();
ErrorHandler.error(e);
}
finally {
if (rset != null) rset.close();
aggregateFields = null;
for (Iterator iter = groups.iterator(); iter.hasNext(); )
((Group)iter.next()).reset();
resetCachedValues();
if (statusDialog != null)
statusDialog.dispose();
}
}