Revision 0b4f079d
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java | ||
---|---|---|
33 | 33 |
import org.eclipse.swt.widgets.Text; |
34 | 34 |
|
35 | 35 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
36 |
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator; |
|
37 |
import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase; |
|
38 |
import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator; |
|
39 |
import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator; |
|
40 |
import eu.etaxonomy.cdm.io.csv.redlist.out.CsvTaxExportConfiguratorRedlist; |
|
41 |
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator; |
|
42 |
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; |
|
43 |
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; |
|
44 |
import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator; |
|
36 | 45 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
37 | 46 |
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository; |
47 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
38 | 48 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException; |
39 | 49 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
40 | 50 |
|
... | ... | |
66 | 76 |
public static final String CSV_EXPORT = "CSV_EXPORT"; |
67 | 77 |
public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT"; |
68 | 78 |
private static final String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT"; |
69 |
|
|
79 |
private static final String EXPORT_FOLDER ="EXPORT_FOLDER"; |
|
70 | 80 |
public static final String XML = "xml"; |
71 | 81 |
|
72 | 82 |
public static final String CSV = "csv"; |
... | ... | |
99 | 109 |
private List<Classification> classifications; |
100 | 110 |
|
101 | 111 |
private Classification selectedClassification; |
102 |
private String lastDirectory; |
|
112 |
|
|
113 |
private ExportConfiguratorBase configurator; |
|
103 | 114 |
|
104 | 115 |
/** |
105 | 116 |
* @param pageName |
106 | 117 |
* @param selection |
107 | 118 |
*/ |
108 | 119 |
protected ExportToFileDestinationWizardPage(String pageName, String type, |
109 |
String title, String description, String extension) { |
|
120 |
String title, String description, String extension, ExportConfiguratorBase configurator) {
|
|
110 | 121 |
super(pageName); |
111 |
|
|
122 |
this.configurator = configurator; |
|
112 | 123 |
this.type = type; |
113 | 124 |
switch(type) { |
114 | 125 |
case CSV_EXPORT : |
... | ... | |
139 | 150 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
140 | 151 |
* object. |
141 | 152 |
*/ |
142 |
public static ExportToFileDestinationWizardPage Jaxb() { |
|
153 |
public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) {
|
|
143 | 154 |
return new ExportToFileDestinationWizardPage( |
144 | 155 |
JAXB_EXPORT, |
145 | 156 |
"jaxb", |
146 | 157 |
"JAXB Export", |
147 | 158 |
"Exports the contents of the currently selected database into the cdm jaxb format.", |
148 |
XML); |
|
159 |
XML, configurator);
|
|
149 | 160 |
} |
150 | 161 |
|
151 | 162 |
/** |
... | ... | |
157 | 168 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
158 | 169 |
* object. |
159 | 170 |
*/ |
160 |
public static ExportToFileDestinationWizardPage Tcs() { |
|
171 |
public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) {
|
|
161 | 172 |
return new ExportToFileDestinationWizardPage( |
162 | 173 |
TCS_EXPORT, |
163 | 174 |
"tcs", |
164 | 175 |
"Tcs Export", |
165 | 176 |
"Export the contents of the currently selected database into TCS format.", |
166 |
XML); |
|
177 |
XML, config);
|
|
167 | 178 |
} |
168 | 179 |
|
169 | 180 |
/** |
... | ... | |
175 | 186 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
176 | 187 |
* object. |
177 | 188 |
*/ |
178 |
public static ExportToFileDestinationWizardPage Sdd() { |
|
189 |
public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) {
|
|
179 | 190 |
return new ExportToFileDestinationWizardPage( |
180 | 191 |
SDD_EXPORT, |
181 | 192 |
"sdd", |
182 | 193 |
"Sdd Export", |
183 | 194 |
"Export the contents of the currently selected database into SDD format.", |
184 |
XML); |
|
195 |
XML, config);
|
|
185 | 196 |
} |
186 | 197 |
|
187 | 198 |
/** |
188 | 199 |
* @return |
189 | 200 |
*/ |
190 |
public static ExportToFileDestinationWizardPage Dwca() { |
|
201 |
public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) {
|
|
191 | 202 |
return new ExportToFileDestinationWizardPage( |
192 | 203 |
DWCA_EXPORT, |
193 | 204 |
DWCA_EXPORT, |
194 | 205 |
"DwC-Archive Export", |
195 | 206 |
"Export the contents of the currently selected database into Darwin Core Archive format.", |
196 |
ZIP); |
|
207 |
ZIP, config);
|
|
197 | 208 |
} |
198 | 209 |
|
199 | 210 |
/** |
200 | 211 |
* @return |
201 | 212 |
*/ |
202 |
public static ExportToFileDestinationWizardPage OutputModel() { |
|
213 |
public static ExportToFileDestinationWizardPage OutputModel(CdmLightExportConfigurator config) {
|
|
203 | 214 |
|
204 | 215 |
return new ExportToFileDestinationWizardPage( |
205 | 216 |
OUTPUT_MODEL_EXPORT, |
206 | 217 |
OUTPUT_MODEL_EXPORT, |
207 | 218 |
"Output Model Export", |
208 | 219 |
"Export the contents of the currently selected database into the output model format.", |
209 |
CSV); |
|
220 |
CSV,config);
|
|
210 | 221 |
} |
211 | 222 |
|
212 | 223 |
|
213 | 224 |
/** |
214 | 225 |
* @return |
215 | 226 |
*/ |
216 |
public static ExportToFileDestinationWizardPage Csv() { |
|
227 |
public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) {
|
|
217 | 228 |
|
218 | 229 |
return new ExportToFileDestinationWizardPage( |
219 | 230 |
CSV_EXPORT, |
220 | 231 |
CSV_EXPORT, |
221 | 232 |
"CSV Export", |
222 | 233 |
"Export the contents of the currently selected database into Comma Separated Value format.", |
223 |
CSV); |
|
234 |
CSV, config);
|
|
224 | 235 |
} |
225 | 236 |
|
226 | 237 |
/** |
227 | 238 |
* @return |
228 | 239 |
*/ |
229 |
public static ExportToFileDestinationWizardPage CsvNames() { |
|
240 |
public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) {
|
|
230 | 241 |
|
231 | 242 |
return new ExportToFileDestinationWizardPage( |
232 | 243 |
CSV_NAME_EXPORT, |
233 | 244 |
CSV_NAME_EXPORT, |
234 | 245 |
"CSV Name Export", |
235 | 246 |
"Export the names of the currently selected database into Semicolon Separated Value format.", |
236 |
CSV); |
|
247 |
CSV, config);
|
|
237 | 248 |
} |
238 | 249 |
|
239 | 250 |
/** |
240 | 251 |
* @return |
241 | 252 |
*/ |
242 |
public static ExportToFileDestinationWizardPage CsvPrint() { |
|
253 |
public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) {
|
|
243 | 254 |
|
244 | 255 |
return new ExportToFileDestinationWizardPage( |
245 | 256 |
CSV_PRINT_EXPORT, |
246 | 257 |
CSV_NAME_EXPORT, |
247 | 258 |
"CSV Print Export", |
248 | 259 |
"Export the content of the currently selected database into Semicolon Separated Value format.", |
249 |
CSV); |
|
260 |
CSV, config);
|
|
250 | 261 |
} |
251 | 262 |
|
252 | 263 |
/* |
... | ... | |
298 | 309 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
299 | 310 |
true, false, 2, 1)); |
300 | 311 |
} |
301 |
if (!outputModelExport){ |
|
302 |
Label fileLabel = new Label(composite, SWT.NONE); |
|
303 |
fileLabel.setText("File"); |
|
304 |
text_exportFileName = new Text(composite, SWT.BORDER); |
|
305 |
text_exportFileName.setText(generateFilename()); |
|
306 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
307 |
true, false)); |
|
312 |
if (outputModelExport){ |
|
313 |
Label zipLabel = new Label(composite, SWT.NONE); |
|
314 |
zipLabel.setText("Create zip-File"); |
|
315 |
Button zip = new Button(composite, SWT.CHECK); |
|
316 |
zip.addSelectionListener(new SelectionAdapter() { |
|
317 |
/* |
|
318 |
* (non-Javadoc) |
|
319 |
* |
|
320 |
* @see |
|
321 |
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
322 |
* .swt.events.SelectionEvent) |
|
323 |
*/ |
|
324 |
@Override |
|
325 |
public void widgetSelected(SelectionEvent e) { |
|
326 |
super.widgetSelected(e); |
|
327 |
((CdmLightExportConfigurator)configurator).setCreateZipFile(zip.getSelection()); |
|
328 |
} |
|
329 |
}); |
|
330 |
}else { |
|
331 |
Label fileLabel = new Label(composite, SWT.NONE); |
|
332 |
fileLabel.setText("File"); |
|
333 |
text_exportFileName = new Text(composite, SWT.BORDER); |
|
334 |
text_exportFileName.setText(generateFilename()); |
|
335 |
text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
|
336 |
true, false)); |
|
308 | 337 |
} |
309 | 338 |
|
310 | 339 |
Label folderLabel = new Label(composite, SWT.NONE); |
... | ... | |
317 | 346 |
text_folder.setEditable(false); |
318 | 347 |
text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, |
319 | 348 |
false)); |
349 |
if (PreferencesUtil.getPreferenceStore().getString(EXPORT_FOLDER) != null){ |
|
350 |
text_folder.setText(PreferencesUtil.getPreferenceStore().getString(EXPORT_FOLDER)); |
|
351 |
setPageComplete(true); |
|
352 |
} |
|
320 | 353 |
|
321 | 354 |
Button button = new Button(composite, SWT.PUSH); |
322 | 355 |
button.setText("Browse..."); |
... | ... | |
335 | 368 |
String path = folderDialog.open(); |
336 | 369 |
if (path != null) { // a folder was selected |
337 | 370 |
text_folder.setText(path); |
371 |
PreferencesUtil.getPreferenceStore().setValue(EXPORT_FOLDER, path); |
|
338 | 372 |
setPageComplete(true); |
339 | 373 |
} |
340 | 374 |
} |
... | ... | |
453 | 487 |
|
454 | 488 |
|
455 | 489 |
|
456 |
private void loadLastState() { |
|
457 |
if(lastDirectory!=null){ |
|
458 |
Text text = this.getFolderComposite(); |
|
459 |
Listener[] listeners = text.getListeners(SWT.Modify); |
|
460 |
for (int i = 0; i < listeners.length; i++) { |
|
461 |
text.removeListener(SWT.Modify, listeners[i]); |
|
462 |
} |
|
463 |
text.setText(lastDirectory); |
|
464 |
for (int i = 0; i < listeners.length; i++) { |
|
465 |
text.addListener(SWT.Modify, listeners[i]); |
|
466 |
} |
|
467 |
|
|
468 |
} |
|
469 |
} |
|
470 |
|
|
471 |
public void saveLastState() { |
|
472 |
lastDirectory = this.getFolderText(); |
|
473 |
} |
|
490 |
|
|
474 | 491 |
|
475 | 492 |
} |
Also available in: Unified diff
cdmLight Export create zip is configurable and save last export folder