private void buildOneCarPerWorkspaceDeclaration(final File outputDirectory, final CarBuilder.BuilderOptions options) {
// Set up the progress monitor for the potentially length export process
final ExportCarProgressMonitor monitor = new ExportCarProgressMonitor();
// Set up a SwingWorker to run the export process in a separate thread.
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
CarBuilder.buildOneCarPerWorkspaceDeclaration(workspaceManager, monitor, outputDirectory, options);
// Display a status message.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String statusMessage = GemCutterMessages.getString("SM_CarExported", outputDirectory.getAbsolutePath());
statusMessageManager.displayMessage(GemCutter.this, statusMessage, StatusMessageDisplayer.MessageType.TRANSIENT, true);
}
});
} catch (final IOException e) {
// Inform the user.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
showActionFailureDialog(getResourceString("ExportWorkspaceToCarFailedDialogTitle"), getResourceString("ExportWorkspaceToCarFailedDialogMessage"), e);
}
});
}
return null;
}
};
// Start the CarBuilder worker and then launch the progress monitor (which is modal and would block the UI until
// either the progress reaches 100% or the monitor is canceled)
worker.start();
monitor.showDialog();
// there is no interesting value to get from the worker, but a call to get() effectively does a join
// on the worker thread
worker.get();
}