* @see java.lang.Runnable#run()
*/
public void run() {
dialog.setVisible(true);
if (!dialog.isCancelled()) {
ReportConfig config = reportTask.getConfiguration();
File source = new File(config.getSourceDirectory());
File target = new File(config.getReportFile());
ListingProcessor proc = new ListingProcessor(new File[] { source },
config.isRecursive(), target, config.getTransformType());
proc.setVerbose(true);
ListingProgressDialog lpd = new ListingProgressDialog(dialog);
if ((config.getTransformType() & ListingProcessor.REPORT_OTHER) > 0) {
lpd.setModal(false);
}
centerDialog(lpd);
proc.setListingProgressListener(lpd);
try {
Thread thread = proc.start();
lpd.setVisible(true);
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
if (config.getTransformType() == ListingProcessor.REPORT_OTHER
&& !lpd.abort()) {
/*
* Now we need to transform.
*/
try {
lpd
.appendMessage("\n"
+ LangageManager
.getProperty("listgen.transformation.start"));
FileOutputStream fos = new FileOutputStream(target);
ByteArrayInputStream bais = new ByteArrayInputStream(proc
.getLister().getContent().getBytes());
XslTransformer.process(bais, fos, config
.getTransformTarget());
fos.flush();
fos.close();
lpd.appendMessage("\n"
+ LangageManager
.getProperty("listgen.transformation.end"));
} catch (Exception e) {
e.printStackTrace();
lpd
.errorOccured("\n"
+ LangageManager
.getProperty("listgen.transformation.error")
+ ":" + e.getMessage());
}
// Because modality was not set with transformation we need to
// until the user closes the dialog.
while (lpd.isVisible()) {
try {
Thread.sleep(100);
} catch (Exception e) {
// Should not happen
}
}
}
lpd.dispose();
config.saveAsDefault();
}
dialog.dispose();
}