/**
* Exports the report into a plain text file.
*/
public void run()
{
PageableReportProcessor proc = null;
OutputStream out = null;
File file = null;
try
{
file = new File(fileName).getCanonicalFile();
final File directory = file.getParentFile();
if (directory != null)
{
if (directory.exists() == false)
{
if (directory.mkdirs() == false)
{
PlainTextExportTask.logger.warn("Can't create directories. Hoping and praying now.."); //$NON-NLS-1$
}
}
}
out = new BufferedOutputStream(new FileOutputStream(file));
final PageableTextOutputProcessor outputProcessor = new PageableTextOutputProcessor
(getPrinterCommandSet(out), report.getConfiguration());
proc = new PageableReportProcessor(report, outputProcessor);
if (progressDialog != null)
{
progressDialog.setModal(false);
progressDialog.setVisible(true);
proc.addReportProgressListener(progressDialog);
}
proc.processReport();
if (statusListener != null)
{
statusListener.setStatus
(StatusType.INFORMATION, messages.getString("PlainTextExportTask.USER_TASK_FINISHED"), null); //$NON-NLS-1$
}
}
catch (ReportInterruptedException re)
{
if (statusListener != null)
{
statusListener.setStatus
(StatusType.WARNING, messages.getString("PlainTextExportTask.USER_TASK_ABORTED"), null); //$NON-NLS-1$
}
try
{
out.close();
out = null;
if (file.delete() == false)
{
PlainTextExportTask.logger.warn("Unable to delete incomplete export:" + file); //$NON-NLS-1$
}
}
catch (SecurityException se)
{
// ignore me
}
catch (IOException ioe)
{
// ignore me...
}
}
catch (Exception re)
{
PlainTextExportTask.logger.error("PlainText export failed", re); //$NON-NLS-1$
if (statusListener != null)
{
statusListener.setStatus
(StatusType.ERROR, messages.getString("PlainTextExportTask.USER_TASK_FAILED"), re); //$NON-NLS-1$
}
}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (Exception e)
{
PlainTextExportTask.logger.error("Unable to close the output stream.", e); //$NON-NLS-1$
// if there is already another error, this exception is
// just a minor obstactle. Something big crashed before ...
}
if (progressDialog != null)
{
proc.removeReportProgressListener(progressDialog);
}
}
if (progressDialog != null)
{