01: package com.quantum.flatfiles.wizard;
02:
03: import java.io.File;
04: import java.io.IOException;
05:
06: import com.quantum.flatfiles.MessageUtil;
07: import com.quantum.flatfiles.converter.Converter;
08: import com.quantum.flatfiles.converter.ConverterFactory;
09: import com.quantum.sql.SQLResultSetResults;
10: import com.quantum.ui.dialog.ExceptionDisplayDialog;
11:
12: import org.eclipse.jface.dialogs.MessageDialog;
13: import org.eclipse.jface.wizard.Wizard;
14:
15: /**
16: * @author BC Holmes
17: */
18: public class ExportResultSetDataWizard extends Wizard {
19:
20: private SQLResultSetResults resultSet;
21: private ExportResultSetDataWizardPage page;
22:
23: public ExportResultSetDataWizard(SQLResultSetResults resultSet) {
24: this .resultSet = resultSet;
25: setWindowTitle(MessageUtil.getString(getClass(), "windowTitle"));
26: }
27:
28: public boolean performFinish() {
29: boolean done = false;
30: try {
31: String fileName = this .page.getFileName();
32: File file = new File(fileName);
33: if (!file.exists()) {
34: export(fileName);
35: done = true;
36: } else if (this .page.overwriteFile()
37: || MessageDialog.openQuestion(getShell(),
38: MessageUtil.getString(getClass(),
39: "overwriteTitle"), MessageUtil
40: .getString(getClass(),
41: "overwriteMessage",
42: new String[] { fileName }))) {
43: export(fileName);
44: done = true;
45: }
46: } catch (IOException e) {
47: ExceptionDisplayDialog.openError(getShell(), null, null, e);
48: }
49:
50: return done;
51: }
52:
53: /**
54: *
55: * @param fileName
56: * @throws IOException
57: */
58: private void export(String fileName) throws IOException {
59: Converter converter = ConverterFactory.getConverter(this .page
60: .getExportType());
61: converter.convert(fileName, this .resultSet);
62: }
63:
64: public void addPages() {
65: this .page = new ExportResultSetDataWizardPage("page1",
66: this.resultSet);
67: addPage(this.page);
68: }
69: }
|