Revision d018d823
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.io.wizard; |
11 | 11 |
|
12 |
import java.awt.Checkbox; |
|
13 | 12 |
import java.text.SimpleDateFormat; |
14 | 13 |
import java.util.Calendar; |
15 | 14 |
import java.util.Collections; |
... | ... | |
17 | 16 |
import java.util.List; |
18 | 17 |
import java.util.UUID; |
19 | 18 |
|
20 |
import org.apache.commons.lang.StringUtils; |
|
21 | 19 |
import org.eclipse.jface.wizard.WizardPage; |
22 | 20 |
import org.eclipse.swt.SWT; |
23 | 21 |
import org.eclipse.swt.events.SelectionAdapter; |
... | ... | |
28 | 26 |
import org.eclipse.swt.widgets.Button; |
29 | 27 |
import org.eclipse.swt.widgets.Combo; |
30 | 28 |
import org.eclipse.swt.widgets.Composite; |
31 |
import org.eclipse.swt.widgets.Control; |
|
32 | 29 |
import org.eclipse.swt.widgets.DirectoryDialog; |
33 | 30 |
import org.eclipse.swt.widgets.Event; |
34 | 31 |
import org.eclipse.swt.widgets.Label; |
... | ... | |
41 | 38 |
import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase; |
42 | 39 |
import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator; |
43 | 40 |
import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator; |
44 |
import eu.etaxonomy.cdm.io.csv.redlist.out.CsvTaxExportConfiguratorRedlist; |
|
45 | 41 |
import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator; |
46 | 42 |
import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; |
47 | 43 |
import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; |
... | ... | |
86 | 82 |
|
87 | 83 |
public static final String CSV = "csv"; |
88 | 84 |
|
89 |
|
|
90 |
|
|
91 | 85 |
public static final String ZIP = "zip"; |
92 | 86 |
|
93 | 87 |
private boolean csvExport = false; |
94 | 88 |
|
95 | 89 |
private boolean csvNameExport = false; |
96 | 90 |
|
97 |
|
|
98 |
|
|
99 | 91 |
private boolean csvPrintExport = false; |
100 | 92 |
|
101 | 93 |
private boolean outputModelExport = false; |
... | ... | |
116 | 108 |
|
117 | 109 |
private Classification selectedClassification; |
118 | 110 |
private Label classificationLabel; |
119 |
|
|
111 |
|
|
120 | 112 |
private ExportConfiguratorBase configurator; |
121 | 113 |
private Button checkUseSelectedtaxonNode; |
122 | 114 |
|
123 | 115 |
private Button checkUseSelectedClassification; |
124 | 116 |
|
125 |
/** |
|
126 |
* @param pageName |
|
127 |
* @param selection |
|
128 |
*/ |
|
129 | 117 |
protected ExportToFileDestinationWizardPage(String pageName, String type, |
130 | 118 |
String title, String description, String extension, ExportConfiguratorBase configurator) { |
131 | 119 |
super(pageName); |
... | ... | |
147 | 135 |
case DWCA_EXPORT: |
148 | 136 |
dwcaExport = true; |
149 | 137 |
break; |
150 |
|
|
138 |
|
|
151 | 139 |
} |
152 | 140 |
this.extension = extension; |
153 | 141 |
this.setTitle(title); |
154 | 142 |
this.setDescription(description); |
155 | 143 |
} |
156 | 144 |
|
157 |
/** |
|
158 |
* <p> |
|
159 |
* Jaxb |
|
160 |
* </p> |
|
161 |
* |
|
162 |
* @return a |
|
163 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
164 |
* object. |
|
165 |
*/ |
|
166 | 145 |
public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) { |
167 | 146 |
return new ExportToFileDestinationWizardPage( |
168 | 147 |
JAXB_EXPORT, |
... | ... | |
172 | 151 |
XML, configurator); |
173 | 152 |
} |
174 | 153 |
|
175 |
/** |
|
176 |
* <p> |
|
177 |
* Tcs |
|
178 |
* </p> |
|
179 |
* |
|
180 |
* @return a |
|
181 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
182 |
* object. |
|
183 |
*/ |
|
184 | 154 |
public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) { |
185 | 155 |
return new ExportToFileDestinationWizardPage( |
186 | 156 |
TCS_EXPORT, |
... | ... | |
190 | 160 |
XML, config); |
191 | 161 |
} |
192 | 162 |
|
193 |
/** |
|
194 |
* <p> |
|
195 |
* Sdd |
|
196 |
* </p> |
|
197 |
* |
|
198 |
* @return a |
|
199 |
* {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} |
|
200 |
* object. |
|
201 |
*/ |
|
202 | 163 |
public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) { |
203 | 164 |
return new ExportToFileDestinationWizardPage( |
204 | 165 |
SDD_EXPORT, |
... | ... | |
208 | 169 |
XML, config); |
209 | 170 |
} |
210 | 171 |
|
211 |
/** |
|
212 |
* @return |
|
213 |
*/ |
|
214 | 172 |
public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) { |
215 | 173 |
return new ExportToFileDestinationWizardPage( |
216 | 174 |
DWCA_EXPORT, |
... | ... | |
220 | 178 |
ZIP, config); |
221 | 179 |
} |
222 | 180 |
|
223 |
/** |
|
224 |
* @return |
|
225 |
*/ |
|
226 | 181 |
public static ExportToFileDestinationWizardPage OutputModel(CdmLightExportConfigurator config) { |
227 |
|
|
182 |
|
|
228 | 183 |
return new ExportToFileDestinationWizardPage( |
229 | 184 |
OUTPUT_MODEL_EXPORT, |
230 | 185 |
OUTPUT_MODEL_EXPORT, |
... | ... | |
233 | 188 |
CSV,config); |
234 | 189 |
} |
235 | 190 |
|
236 |
|
|
237 |
/** |
|
238 |
* @return |
|
239 |
*/ |
|
240 | 191 |
public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) { |
241 |
|
|
192 |
|
|
242 | 193 |
return new ExportToFileDestinationWizardPage( |
243 | 194 |
CSV_EXPORT, |
244 | 195 |
CSV_EXPORT, |
... | ... | |
247 | 198 |
CSV, config); |
248 | 199 |
} |
249 | 200 |
|
250 |
/** |
|
251 |
* @return |
|
252 |
*/ |
|
253 | 201 |
public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) { |
254 |
|
|
202 |
|
|
255 | 203 |
return new ExportToFileDestinationWizardPage( |
256 | 204 |
CSV_NAME_EXPORT, |
257 | 205 |
CSV_NAME_EXPORT, |
... | ... | |
260 | 208 |
CSV, config); |
261 | 209 |
} |
262 | 210 |
|
263 |
/** |
|
264 |
* @return |
|
265 |
*/ |
|
266 | 211 |
public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) { |
267 |
|
|
212 |
|
|
268 | 213 |
return new ExportToFileDestinationWizardPage( |
269 | 214 |
CSV_PRINT_EXPORT, |
270 | 215 |
CSV_NAME_EXPORT, |
... | ... | |
273 | 218 |
CSV, config); |
274 | 219 |
} |
275 | 220 |
|
276 |
/* |
|
277 |
* (non-Javadoc) |
|
278 |
* |
|
279 |
* @see |
|
280 |
* org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets |
|
281 |
* .Composite) |
|
282 |
*/ |
|
283 | 221 |
/** {@inheritDoc} */ |
284 | 222 |
@Override |
285 | 223 |
public void createControl(Composite parent) { |
... | ... | |
288 | 226 |
|
289 | 227 |
Composite composite = new Composite(parent, SWT.NONE); |
290 | 228 |
GridLayout gridLayout = new GridLayout(); |
291 |
|
|
229 |
|
|
292 | 230 |
gridLayout.numColumns = 2; |
293 | 231 |
TaxonNode node = null; |
294 |
|
|
232 |
|
|
295 | 233 |
composite.setLayout(gridLayout); |
296 | 234 |
if(classifications == null){ |
297 | 235 |
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null); |
... | ... | |
312 | 250 |
if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()){ |
313 | 251 |
selectedClassification = CdmStore.getService(IClassificationService.class).load(configurator.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid()); |
314 | 252 |
}else{ |
315 |
|
|
253 |
|
|
316 | 254 |
selectedClassification = classifications.iterator().next(); |
317 | 255 |
} |
318 | 256 |
} |
319 | 257 |
|
320 | 258 |
|
321 | 259 |
if(csvExport || csvPrintExport || outputModelExport|| csvNameExport || dwcaExport){ |
322 |
// Label comboBoxLabel = new Label(composite, SWT.NONE); |
|
323 |
// comboBoxLabel.setText("Classification"); |
|
324 |
|
|
325 | 260 |
if ((outputModelExport || dwcaExport)&& !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()){ |
326 | 261 |
Composite selectNodeOrClassification = new Composite(composite, SWT.NONE); |
327 | 262 |
GridLayout grid = new GridLayout(); |
... | ... | |
362 | 297 |
selectedClassification = node.getClassification(); |
363 | 298 |
} |
364 | 299 |
createClassificationSelectionCombo(composite); |
365 |
|
|
300 |
|
|
366 | 301 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, |
367 | 302 |
true, false, 2, 1)); |
368 | 303 |
if (checkUseSelectedtaxonNode != null){ |
369 |
|
|
304 |
|
|
370 | 305 |
if (checkUseSelectedtaxonNode.getSelection()){ |
371 | 306 |
classificationSelectionCombo.setVisible(false); |
372 | 307 |
classificationLabel.setVisible(false); |
373 | 308 |
} |
374 | 309 |
} |
375 |
|
|
376 |
|
|
310 |
|
|
377 | 311 |
} |
378 |
|
|
379 | 312 |
|
380 | 313 |
Label folderLabel = new Label(composite, SWT.NONE); |
381 | 314 |
folderLabel.setText("Select Folder for exported files"); |
... | ... | |
397 | 330 |
button.setText("Browse..."); |
398 | 331 |
|
399 | 332 |
button.addSelectionListener(new SelectionAdapter() { |
400 |
/* |
|
401 |
* (non-Javadoc) |
|
402 |
* |
|
403 |
* @see |
|
404 |
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
405 |
* .swt.events.SelectionEvent) |
|
406 |
*/ |
|
407 | 333 |
@Override |
408 | 334 |
public void widgetSelected(SelectionEvent e) { |
409 | 335 |
super.widgetSelected(e); |
... | ... | |
417 | 343 |
} |
418 | 344 |
}); |
419 | 345 |
if (!outputModelExport){ |
420 |
|
|
346 |
|
|
421 | 347 |
Label fileLabel = new Label(composite, SWT.NONE); |
422 | 348 |
fileLabel.setText("File"); |
423 | 349 |
text_exportFileName = new Text(composite, SWT.BORDER); |
... | ... | |
451 | 377 |
return buffer.toString(); |
452 | 378 |
} |
453 | 379 |
|
454 |
/** |
|
455 |
* <p> |
|
456 |
* getExportFileName |
|
457 |
* </p> |
|
458 |
* |
|
459 |
* @return the exportFileName |
|
460 |
*/ |
|
461 | 380 |
public String getExportFileName() { |
462 | 381 |
return text_exportFileName.getText(); |
463 | 382 |
} |
464 | 383 |
|
465 |
/** |
|
466 |
* <p> |
|
467 |
* getFolderText |
|
468 |
* </p> |
|
469 |
* |
|
470 |
* @return the folderText |
|
471 |
*/ |
|
472 | 384 |
public String getFolderText() { |
473 | 385 |
return text_folder.getText(); |
474 | 386 |
} |
475 |
|
|
476 |
/** |
|
477 |
* <p> |
|
478 |
* getFolderComposite |
|
479 |
* </p> |
|
480 |
* |
|
481 |
* @return the folderText |
|
482 |
*/ |
|
387 |
|
|
483 | 388 |
public Text getFolderComposite() { |
484 | 389 |
return text_folder; |
485 | 390 |
} |
486 | 391 |
|
487 | 392 |
private void createClassificationSelectionCombo(Composite parent){ |
488 |
// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null); |
|
489 | 393 |
|
490 | 394 |
Composite classificationSelection = new Composite(parent, SWT.NULL); |
491 | 395 |
classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1)); |
... | ... | |
496 | 400 |
classificationLabel = new Label(classificationSelection, SWT.NULL); |
497 | 401 |
// TODO not working is not really true but leave it here to remind everyone that this is under construction |
498 | 402 |
classificationLabel.setText("Export complete classification"); |
499 |
|
|
403 |
|
|
500 | 404 |
classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY); |
501 | 405 |
classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2,1)); |
502 | 406 |
|
... | ... | |
543 | 447 |
return checkUseSelectedtaxonNode.getSelection(); |
544 | 448 |
} |
545 | 449 |
|
546 |
|
|
547 | 450 |
@Override |
548 | 451 |
public boolean canFlipToNextPage() { |
549 | 452 |
return getFolderText() != null; |
550 | 453 |
} |
551 |
|
|
552 |
|
|
553 |
|
|
554 | 454 |
|
555 | 455 |
} |
Also available in: Unified diff
ref #7008 Migrate export wizards