adapt master to develop
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / ExportToFileDestinationWizardPage.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The content of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.io.wizard;
10
11 import java.text.SimpleDateFormat;
12 import java.util.ArrayList;
13 import java.util.Calendar;
14 import java.util.Collections;
15 import java.util.HashSet;
16 import java.util.List;
17 import java.util.Set;
18 import java.util.UUID;
19
20 import org.eclipse.jface.layout.GridLayoutFactory;
21 import org.eclipse.jface.wizard.WizardPage;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.SelectionAdapter;
24 import org.eclipse.swt.events.SelectionEvent;
25 import org.eclipse.swt.events.SelectionListener;
26 import org.eclipse.swt.layout.GridData;
27 import org.eclipse.swt.layout.GridLayout;
28 import org.eclipse.swt.widgets.Button;
29 import org.eclipse.swt.widgets.Combo;
30 import org.eclipse.swt.widgets.Composite;
31 import org.eclipse.swt.widgets.DirectoryDialog;
32 import org.eclipse.swt.widgets.Display;
33 import org.eclipse.swt.widgets.Event;
34 import org.eclipse.swt.widgets.Label;
35 import org.eclipse.swt.widgets.Listener;
36 import org.eclipse.swt.widgets.Text;
37
38 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
39 import eu.etaxonomy.cdm.api.service.IClassificationService;
40 import eu.etaxonomy.cdm.filter.LogicFilter;
41 import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
42 import eu.etaxonomy.cdm.io.coldp.ColDpExportConfigurator;
43 import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
44 import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
45 import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
46 import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
47 import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
48 import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
49 import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
50 import eu.etaxonomy.cdm.io.wfo.out.WfoBackboneExportConfigurator;
51 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
52 import eu.etaxonomy.cdm.model.name.Rank;
53 import eu.etaxonomy.cdm.model.taxon.Classification;
54 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
55 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
56 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
57 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
58 import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum;
59 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
60 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
61 import eu.etaxonomy.taxeditor.store.CdmStore;
62
63 /**
64 * ExportToFileDestinationWizardPage class.
65 *
66 * @author n.hoffmann
67 * @created 15.06.2009
68 */
69 public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
70
71 /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
72 public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
73
74 /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
75 public static final String JAXB_EXPORT = "JAXB_EXPORT";
76
77 /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
78 public static final String TCS_EXPORT = "TCS_EXPORT";
79
80 /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
81 public static final String SDD_EXPORT = "SDD_EXPORT";
82
83 public static final String DWCA_EXPORT = "DWCA_EXPORT";
84 public static final String WFO_BACKBONE_EXPORT = "WFO_BACKBONE_EXPORT";
85 public static final String CDM_LIGHT_EXPORT = "CDM_LIGHT(CSV)";
86 public static final String COL_DP_EXPORT = "COL DP";
87 public static final String CSV_EXPORT = "CSV_EXPORT";
88 public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
89 private static final String CSV_PRINT_EXPORT = "CSV_PRINT_EXPORT";
90 private static final String EXPORT_FOLDER = "EXPORT_FOLDER";
91 public static final String XML = "xml";
92
93 public static final String CSV = "csv";
94
95 public static final String ZIP = "zip";
96
97 private boolean csvExport = false;
98
99 private boolean csvNameExport = false;
100
101 private boolean csvPrintExport = false;
102
103 private boolean cdmLightExport = false;
104
105 private boolean colDPExport = false;
106 private boolean dwcaExport = false;
107 private boolean wfoBackboneExport = false;
108
109 private DirectoryDialog folderDialog;
110 private Text text_exportFileName;
111
112 private Text text_folder;
113
114 private final String type;
115
116 private final String extension;
117
118 private Combo classificationSelectionCombo;
119
120 private List<Classification> classifications;
121
122 private Classification selectedClassification;
123
124 private ExportConfiguratorBase<?, ?, ?> configurator;
125 private Button checkUseSelectedTaxonNode;
126
127 private Button checkUseSelectedClassification;
128 private Button checkUseAllClassification;
129
130 private Button checkExportUnpublished;
131 private Button checkExportFactualData;
132 private Button checkExportUnpublishedFactualData;
133
134 private Combo orderSelectionCombo;
135
136 private Text text_familyString;
137
138 private Text text_baseUrl;
139
140 protected ExportToFileDestinationWizardPage(String pageName, String type, String title, String description,
141 String extension, ExportConfiguratorBase<?, ?, ?> configurator) {
142 super(pageName);
143 this.configurator = configurator;
144 this.type = type;
145 switch (type) {
146 case CSV_EXPORT:
147 csvExport = true;
148 break;
149 case CSV_NAME_EXPORT:
150 csvNameExport = true;
151 break;
152 case CDM_LIGHT_EXPORT:
153 cdmLightExport = true;
154 break;
155 case COL_DP_EXPORT:
156 colDPExport = true;
157 break;
158 case CSV_PRINT_EXPORT:
159 csvPrintExport = true;
160 break;
161 case DWCA_EXPORT:
162 dwcaExport = true;
163 break;
164 case WFO_BACKBONE_EXPORT:
165 wfoBackboneExport = true;
166 break;
167 default:
168 throw new RuntimeException("Export type not yet handeled: " + type);
169 }
170 this.extension = extension;
171 this.setTitle(title);
172 this.setDescription(description);
173 }
174
175 public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) {
176 return new ExportToFileDestinationWizardPage(JAXB_EXPORT, "jaxb", "JAXB Export",
177 "Exports the content of the currently selected database into the cdm jaxb format.", XML, configurator);
178 }
179
180 public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) {
181 return new ExportToFileDestinationWizardPage(TCS_EXPORT, "tcs", "Tcs Export",
182 "Export the content of the currently selected database into TCS format.", XML, config);
183 }
184
185 public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) {
186 return new ExportToFileDestinationWizardPage(SDD_EXPORT, "sdd", "Sdd Export",
187 "Export the content of the currently selected database into SDD format.", XML, config);
188 }
189
190 public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) {
191 return new ExportToFileDestinationWizardPage(DWCA_EXPORT, DWCA_EXPORT, "DwC-Archive Export",
192 "Export the content of the currently selected database into Darwin Core Archive format.", ZIP, config);
193 }
194
195 public static ExportToFileDestinationWizardPage WFO(WfoBackboneExportConfigurator config) {
196 return new ExportToFileDestinationWizardPage(WFO_BACKBONE_EXPORT, WFO_BACKBONE_EXPORT, "WFO Backbone Export",
197 "Export the content of the currently selected database into WFO Backbone format."
198 , CSV, config);
199 }
200
201 public static ExportToFileDestinationWizardPage CdmLight(CdmLightExportConfigurator config) {
202 return new ExportToFileDestinationWizardPage(CDM_LIGHT_EXPORT, CDM_LIGHT_EXPORT, "CDM Light Export (csv)",
203 "Export the content of the currently selected database into the CDM light (csv) format.",
204 CSV, config);
205 }
206
207 public static ExportToFileDestinationWizardPage ColDp(ColDpExportConfigurator config) {
208 return new ExportToFileDestinationWizardPage(COL_DP_EXPORT, COL_DP_EXPORT, "Col DP Export (zip)",
209 "Export the content of the currently selected database into the Catalogue of Life Data Package (Col DP) format.",
210 ZIP, config);
211 }
212
213 public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) {
214 return new ExportToFileDestinationWizardPage(CSV_EXPORT, CSV_EXPORT, "CSV Export",
215 "Export the content of the currently selected database into Comma Separated Value format.",
216 CSV, config);
217 }
218
219 public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) {
220 return new ExportToFileDestinationWizardPage(CSV_NAME_EXPORT, CSV_NAME_EXPORT, "CSV Name Export",
221 "Export the names of the currently selected database into Semicolon Separated Value format.",
222 CSV, config);
223 }
224
225 public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) {
226 return new ExportToFileDestinationWizardPage(CSV_PRINT_EXPORT, CSV_NAME_EXPORT, "CSV Print Export",
227 "Export the content of the currently selected database into Semicolon Separated Value format.",
228 CSV, config);
229 }
230
231 @Override
232 public void createControl(Composite parent) {
233
234 setPageComplete(false);
235
236 Composite composite = new Composite(parent, SWT.NONE);
237 GridLayout gridLayout = new GridLayout();
238
239 gridLayout.numColumns = 2;
240 TaxonNode node = null;
241
242 composite.setLayout(gridLayout);
243 if (cdmLightExport || dwcaExport || colDPExport) {
244 checkExportUnpublished = new Button(composite, SWT.CHECK);
245 checkExportUnpublished.setText("Export unpublished taxa");
246 Label emptyLabel = new Label(composite, SWT.NONE);
247 checkExportFactualData = new Button(composite, SWT.CHECK);
248 checkExportFactualData.setText("Export factual data");
249 checkExportFactualData.setSelection(true);
250 checkExportFactualData.addListener(SWT.Selection, e -> {
251 Button b = (Button) e.widget;
252 GridData data = (GridData) checkExportUnpublishedFactualData.getLayoutData();
253 data.exclude = b.getSelection();
254 checkExportUnpublishedFactualData.setEnabled(data.exclude);
255 });
256 if (cdmLightExport || colDPExport) {
257 emptyLabel = new Label(composite, SWT.NONE);
258
259 checkExportUnpublishedFactualData = new Button(composite, SWT.CHECK);
260 checkExportUnpublishedFactualData.setText("Export unpublished factual data");
261 checkExportUnpublishedFactualData.setSelection(false);
262 GridData gridData = new GridData();
263 gridData.horizontalIndent = 20;
264 checkExportUnpublishedFactualData.setLayoutData(gridData);
265 }
266
267 @SuppressWarnings("unused")
268 Label nope = new Label(composite, SWT.NONE);
269
270 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
271 GridData gridDataSep = new GridData(GridData.FILL_HORIZONTAL);
272 gridDataSep.horizontalSpan = 2;
273 separator.setLayoutData(gridDataSep);
274 }
275 if (classifications == null && !wfoBackboneExport) {
276 classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
277 Collections.sort(classifications, (o1, o2) -> {
278 if (o1.equals(o2)) {
279 return 0;
280 }
281 int result = o1.getTitleCache().compareTo(o2.getTitleCache());
282 if (result == 0) {
283 return o1.getUuid().compareTo(o2.getUuid());
284 }
285 return result;
286 });
287 if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()) {
288 selectedClassification = CdmStore.getService(IClassificationService.class)
289 .load(configurator.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid());
290 } else {
291
292 selectedClassification = classifications.iterator().next();
293 }
294 }
295
296 if (csvExport || csvPrintExport || cdmLightExport || csvNameExport || dwcaExport || colDPExport || wfoBackboneExport) {
297
298 // Label comboBoxLabel = new Label(composite, SWT.NONE);
299 // comboBoxLabel.setText("Classification");
300 Composite selectNodeOrClassification = new Composite(composite, SWT.NONE);
301 GridLayout grid = new GridLayout();
302 grid.numColumns = 1;
303 GridData gridDataNode = new GridData(SWT.FILL, SWT.FILL, true, false);
304 gridDataNode.horizontalSpan = 2;
305
306 selectNodeOrClassification.setLayout(grid);
307 selectNodeOrClassification.setLayoutData(gridDataNode);
308 if ((cdmLightExport || dwcaExport || colDPExport || wfoBackboneExport) && !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()) {
309 if (!wfoBackboneExport) {
310 checkUseSelectedTaxonNode = new Button(selectNodeOrClassification, SWT.RADIO);
311 }
312 String taxonStr = "";
313 int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
314 List<TaxonNode> selectedNodes = new ArrayList<>();
315 for (LogicFilter<TaxonNode> filter : configurator.getTaxonNodeFilter().getSubtreeFilter()) {
316 node = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
317 selectedNodes.add(node);
318 count--;
319 if (node.hasTaxon()) {
320 taxonStr += node.getTaxon().getName().getTitleCache();
321 if (count > 0) {
322 taxonStr += ", ";
323 }
324 }
325 }
326 if (!wfoBackboneExport) {
327 checkUseSelectedTaxonNode.setText("Export all selected subtree(s) (" + taxonStr + ")");
328 checkUseSelectedTaxonNode.addListener(SWT.Selection, e -> {
329 Button b = (Button) e.widget;
330 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
331 data.exclude = b.getSelection();
332 if (classificationSelectionCombo != null) {
333 classificationSelectionCombo.setEnabled(!data.exclude);
334 }
335 });
336 checkUseSelectedTaxonNode.setSelection(true);
337 }else {
338 Composite wfoComp = new Composite(selectNodeOrClassification, SWT.NONE);
339 grid = new GridLayout();
340 grid.numColumns = 2;
341 GridData gridDataWfo = new GridData(SWT.FILL, SWT.FILL, true, false);
342 gridDataWfo.grabExcessHorizontalSpace=true;
343 // gridDataWfo.horizontalSpan=2;
344 wfoComp.setLayout(grid);
345 wfoComp.setLayoutData(gridDataWfo);
346
347 Label label = new Label(wfoComp, SWT.NONE);
348 label.setText("Export all selected subtree(s) (" + taxonStr + ")");
349 GridData gridData = new GridData();
350 gridData.horizontalSpan = 3;
351 gridData.grabExcessHorizontalSpace = true;
352 label.setLayoutData(gridData);
353
354 Label familyString = new Label(wfoComp, SWT.NONE);
355 familyString.setText("Family");
356 text_familyString = new Text(wfoComp, SWT.BORDER);
357 text_familyString.setText(generateFamilyName(selectedNodes));
358 GridData gridFamily = new GridData(SWT.FILL, SWT.FILL, true, false);
359
360 text_familyString.setLayoutData(gridFamily);
361
362
363 Label baseUrlString = new Label(wfoComp, SWT.NONE);
364 baseUrlString.setText("Base url");
365 text_baseUrl = new Text(wfoComp, SWT.BORDER);
366
367 GridData gridDataBaseUrl = new GridData(SWT.FILL, SWT.FILL, true, false);
368
369 text_baseUrl.setLayoutData(gridDataBaseUrl);
370 text_baseUrl.setToolTipText("The base url without /cdm_dataportal/taxon/{uuid} e.g. https://portal.cybertaxonomy.org/salvador");
371
372
373
374 }
375 }else if (wfoBackboneExport) {
376
377 Label label = new Label(composite, SWT.NONE);
378 label.setText("WFO Backbone export is only available for subtrees, not for classifications");
379 GridData gridData = new GridData();
380 gridData.horizontalSpan = 2;
381 gridData.grabExcessHorizontalSpace = true;
382 label.setLayoutData(gridData);
383 label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
384 }
385
386 if (cdmLightExport || dwcaExport || colDPExport ) {
387 if (dwcaExport) {
388 checkUseAllClassification = new Button(selectNodeOrClassification, SWT.RADIO);
389 checkUseAllClassification.setText("Export all classifications");
390 checkUseAllClassification.addListener(SWT.Selection, new Listener() {
391 @Override
392 public void handleEvent(Event e) {
393 Button b = (Button) e.widget;
394 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
395 data.exclude = b.getSelection();
396 classificationSelectionCombo.setEnabled(!data.exclude);
397
398 }
399 });
400 }
401 checkUseSelectedClassification = new Button(selectNodeOrClassification, SWT.RADIO);
402 checkUseSelectedClassification.setText("Export selected classification");
403 checkUseSelectedClassification.addListener(SWT.Selection, e -> {
404 Button b = (Button) e.widget;
405 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
406 data.exclude = b.getSelection();
407 classificationSelectionCombo.setEnabled(data.exclude);
408 });
409 }
410
411 if (node != null && !wfoBackboneExport) {
412 selectedClassification = node.getClassification();
413 }
414 if (!wfoBackboneExport) {
415 createClassificationSelectionCombo(selectNodeOrClassification);
416 }
417 if (cdmLightExport) {
418 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
419 GridData gridDataSep = new GridData();
420 gridDataSep = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
421 gridDataSep.horizontalSpan = 2;
422 separator.setLayoutData(gridDataSep);
423
424 Composite comp = new Composite(composite, SWT.NONE);
425
426 GridData gridData = new GridData();
427 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
428 gridData.horizontalSpan = 2;
429 comp.setLayoutData(gridData);
430
431 Label label = new Label(comp, SWT.NONE);
432 label.setText("Sorting of taxa");
433
434 orderSelectionCombo = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
435
436 GridLayoutFactory.fillDefaults().applyTo(comp);
437 for (NavigatorOrderEnum display : NavigatorOrderEnum.values()) {
438 orderSelectionCombo.add(display.getLabel());
439 }
440
441 int index = 0;
442 if (PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()) != null) {
443 NavigatorOrderEnum orderInNavigator = NavigatorOrderEnum
444 .valueOf(PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
445
446 for (String itemLabel : orderSelectionCombo.getItems()) {
447 if (itemLabel.equalsIgnoreCase(orderInNavigator.getLabel())) {
448 orderSelectionCombo.select(index);
449 setComparatorToConfig();
450 break;
451 }
452 index++;
453 }
454 }
455
456 orderSelectionCombo.addSelectionListener(new SelectionListener() {
457
458 @Override
459 public void widgetSelected(SelectionEvent e) {
460 setComparatorToConfig();
461 }
462
463 @Override
464 public void widgetDefaultSelected(SelectionEvent e) {
465 // TODO Auto-generated method stub
466 }
467 });
468 }
469
470 if (classificationSelectionCombo != null) {
471 if (checkUseSelectedTaxonNode != null) {
472 if (checkUseSelectedTaxonNode.getSelection()) {
473 classificationSelectionCombo.setEnabled(false);
474 }
475 } else {
476 classificationSelectionCombo.setEnabled(true);
477 classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
478 }
479 }
480 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
481 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
482 gridData.horizontalSpan = 2;
483 separator.setLayoutData(gridData);
484
485 }
486
487 Label folderLabel = new Label(composite, SWT.NONE);
488 folderLabel.setText("Select Folder for exported files");
489 folderLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
490 folderDialog = new DirectoryDialog(parent.getShell());
491 String exportFolder = PreferencesUtil.getStringValue(EXPORT_FOLDER, true);
492 folderDialog.setFilterPath(exportFolder);
493
494 text_folder = new Text(composite, SWT.BORDER);
495 text_folder.setEditable(false);
496 text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
497 if (exportFolder != null) {
498 text_folder.setText(exportFolder);
499 setPageComplete(true);
500 }
501
502 Button button = new Button(composite, SWT.PUSH);
503 button.setText("Browse...");
504
505 button.addSelectionListener(new SelectionAdapter() {
506 @Override
507 public void widgetSelected(SelectionEvent e) {
508 super.widgetSelected(e);
509
510 String path = folderDialog.open();
511 if (path != null) { // a folder was selected
512 text_folder.setText(path);
513 PreferencesUtil.setStringValue(EXPORT_FOLDER, path);
514 setPageComplete(true);
515 }
516 }
517 });
518 if (!cdmLightExport && !wfoBackboneExport) {
519
520 Label fileLabel = new Label(composite, SWT.NONE);
521 fileLabel.setText("Filename");
522 text_exportFileName = new Text(composite, SWT.BORDER);
523 text_exportFileName.setText(generateFilename());
524 text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
525 }
526
527 // make the composite the wizard pages control
528 setControl(composite);
529 }
530
531 /**
532 * @return
533 */
534 private String generateFamilyName(List<TaxonNode> nodes) {
535 if (nodes.size() == 1){
536 TaxonNode node = nodes.get(0);
537 if (node.getTaxon() != null) {
538 if(node.getTaxon().getName().getRank().getOrderIndex() >= Rank.FAMILY().getOrderIndex()) {
539 TaxonNode familyNode = node.getAncestorOfRank(Rank.FAMILY());
540 if (familyNode != null && familyNode.getTaxon() != null) {
541 return familyNode.getTaxon().getName().getNameCache();
542 }
543
544 }
545 }
546
547 }
548 return "";
549 }
550
551 protected void setComparatorToConfig() {
552 if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.NaturalOrder.getLabel())) {
553 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoNaturalComparator());
554 } else if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.AlphabeticalOrder.getLabel())) {
555 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoByNameComparator());
556 } else {
557 ((CdmLightExportConfigurator) configurator)
558 .setTaxonNodeComparator(new TaxonNodeDtoByRankAndNameComparator());
559 }
560 }
561
562 protected String generateFilename() {
563 StringBuffer buffer = new StringBuffer();
564
565 Calendar cal = Calendar.getInstance();
566 SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
567 buffer.append(sdf.format(cal.getTime()));
568
569 buffer.append("-");
570 buffer.append(type + "_");
571
572 String source = ((ICdmRemoteSource) CdmStore.getActiveCdmSource()).toString();
573 source = source.substring(source.indexOf("/") + 1);
574 buffer.append(source);
575
576 buffer.append(".");
577 buffer.append(extension);
578
579 return buffer.toString();
580 }
581
582 public String getExportFileName() {
583 return text_exportFileName.getText();
584 }
585
586 public String getFamilyString() {
587 return text_familyString.getText();
588 }
589
590 public String getFolderText() {
591 return text_folder.getText();
592 }
593
594 public String get_baseUrl() {
595 return text_baseUrl.getText();
596 }
597
598 public Text getFolderComposite() {
599 return text_folder;
600 }
601
602 public boolean isExportUnpublishedData() {
603 return checkExportUnpublished.getSelection();
604 }
605
606 public boolean isExportFactualData() {
607 return checkExportFactualData.getSelection();
608 }
609
610 public boolean isExportUnpublishedFactualData() {
611 return checkExportUnpublishedFactualData.getSelection();
612 }
613
614 private void createClassificationSelectionCombo(Composite parent) {
615
616 GridData gridData = new GridData();
617 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
618 gridData.horizontalIndent = 5;
619
620 classificationSelectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
621 classificationSelectionCombo.setLayoutData(gridData);
622 for (Classification tree : classifications) {
623 classificationSelectionCombo.add(tree.getTitleCache(), classifications.indexOf(tree));
624 }
625
626 classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
627
628 // TODO remember last selection
629 classificationSelectionCombo.addSelectionListener(this);
630
631 }
632
633 public Combo getCombo() {
634 return classificationSelectionCombo;
635 }
636
637 @Override
638 public void widgetSelected(SelectionEvent e) {
639 selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
640 }
641
642 public Classification getSelectedClassification() {
643 return selectedClassification;
644 }
645
646 @Override
647 public void widgetDefaultSelected(SelectionEvent e) {
648 // not needed here
649 }
650
651 public UUID getSelectedClassificationUUID() {
652 return selectedClassification.getUuid();
653 }
654
655 public boolean getCheckUseSelectedTaxonNode() {
656 if (checkUseSelectedTaxonNode == null) {
657 return false;
658 }
659 return checkUseSelectedTaxonNode.getSelection();
660 }
661
662 public boolean getCheckUseAllClassifications() {
663 if (checkUseAllClassification == null) {
664 return false;
665 }
666 return checkUseAllClassification.getSelection();
667 }
668
669 public Set<UUID> getAllClassificationUuids() {
670 Set<UUID> allClassificationUuids = new HashSet<>();
671 for (Classification classification : this.classifications) {
672 allClassificationUuids.add(classification.getUuid());
673 }
674 return allClassificationUuids;
675 }
676
677 @Override
678 public boolean canFlipToNextPage() {
679 return getFolderText() != null && !(wfoBackboneExport && configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty());
680 }
681 }