// if a SummaryRowLayer is in the layer stack, we need to ensure that
// the values are calculated
layer.doCommand(new CalculateSummaryRowValuesCommand());
ProgressBar progressBar = null;
if (shell != null) {
Shell childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM
| SWT.APPLICATION_MODAL);
childShell.setText(Messages.getString("NatExporter.exporting")); //$NON-NLS-1$
int startRow = 0;
int endRow = layer.getRowCount() - 1;
progressBar = new ProgressBar(childShell, SWT.SMOOTH);
progressBar.setMinimum(startRow);
progressBar.setMaximum(endRow);
progressBar.setBounds(0, 0, 400, 25);
progressBar.setFocus();
childShell.pack();
childShell.open();
}
try {
exporter.exportLayerBegin(outputStream, layerName);
for (int rowPosition = 0; rowPosition < layer.getRowCount(); rowPosition++) {
exporter.exportRowBegin(outputStream, rowPosition);
if (progressBar != null) {
progressBar.setSelection(rowPosition);
}
for (int columnPosition = 0; columnPosition < layer
.getColumnCount(); columnPosition++) {
ILayerCell cell = layer.getCellByPosition(columnPosition,
rowPosition);
IExportFormatter exportFormatter = configRegistry
.getConfigAttribute(
ExportConfigAttributes.EXPORT_FORMATTER,
cell.getDisplayMode(), cell
.getConfigLabels().getLabels());
Object exportDisplayValue = exportFormatter
.formatForExport(cell, configRegistry);
exporter.exportCell(outputStream, exportDisplayValue, cell,
configRegistry);
}
exporter.exportRowEnd(outputStream, rowPosition);
}
exporter.exportLayerEnd(outputStream, layerName);
} catch (Exception e) {
e.printStackTrace(System.err);
}
// These must be fired at the end of the thread execution
layer.setClientAreaProvider(originalClientAreaProvider);
layer.doCommand(new TurnViewportOnCommand());
if (progressBar != null) {
Shell childShell = progressBar.getShell();
progressBar.dispose();
childShell.dispose();
}
}