ref #10448: set family string in configurator
[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.Event;
33 import org.eclipse.swt.widgets.Label;
34 import org.eclipse.swt.widgets.Listener;
35 import org.eclipse.swt.widgets.Text;
36
37 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
38 import eu.etaxonomy.cdm.api.service.IClassificationService;
39 import eu.etaxonomy.cdm.filter.LogicFilter;
40 import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator;
41 import eu.etaxonomy.cdm.io.coldp.ColDpExportConfigurator;
42 import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase;
43 import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
44 import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
45 import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
46 import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
47 import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator;
48 import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
49 import eu.etaxonomy.cdm.io.wfo.out.WfoExportConfigurator;
50 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
51 import eu.etaxonomy.cdm.model.name.Rank;
52 import eu.etaxonomy.cdm.model.taxon.Classification;
53 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
54 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator;
55 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator;
56 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator;
57 import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum;
58 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
59 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
60 import eu.etaxonomy.taxeditor.store.CdmStore;
61
62 /**
63 * ExportToFileDestinationWizardPage class.
64 *
65 * @author n.hoffmann
66 * @created 15.06.2009
67 */
68 public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
69
70 /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
71 public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
72
73 /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
74 public static final String JAXB_EXPORT = "JAXB_EXPORT";
75
76 /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
77 public static final String TCS_EXPORT = "TCS_EXPORT";
78
79 /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
80 public static final String SDD_EXPORT = "SDD_EXPORT";
81
82 public static final String DWCA_EXPORT = "DWCA_EXPORT";
83 public static final String WFO_EXPORT = "WFO_EXPORT";
84 public static final String CDM_LIGHT_EXPORT = "CDM_LIGHT(CSV)";
85 public static final String COL_DP_EXPORT = "COL DP";
86 public static final String CSV_EXPORT = "CSV_EXPORT";
87 public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
88 private static final String CSV_PRINT_EXPORT = "CSV_PRINT_EXPORT";
89 private static final String EXPORT_FOLDER = "EXPORT_FOLDER";
90 public static final String XML = "xml";
91
92 public static final String CSV = "csv";
93
94 public static final String ZIP = "zip";
95
96 private boolean csvExport = false;
97
98 private boolean csvNameExport = false;
99
100 private boolean csvPrintExport = false;
101
102 private boolean cdmLightExport = false;
103
104 private boolean colDPExport = false;
105 private boolean dwcaExport = false;
106 private boolean wfoExport = false;
107
108 private DirectoryDialog folderDialog;
109 private Text text_exportFileName;
110
111 private Text text_folder;
112
113 private final String type;
114
115 private final String extension;
116
117 private Combo classificationSelectionCombo;
118
119 private List<Classification> classifications;
120
121 private Classification selectedClassification;
122
123 private ExportConfiguratorBase<?, ?, ?> configurator;
124 private Button checkUseSelectedTaxonNode;
125
126 private Button checkUseSelectedClassification;
127 private Button checkUseAllClassification;
128
129 private Button checkExportUnpublished;
130 private Button checkExportFactualData;
131 private Button checkExportUnpublishedFactualData;
132
133 private Combo orderSelectionCombo;
134
135 private Text text_familyString;
136
137 protected ExportToFileDestinationWizardPage(String pageName, String type, String title, String description,
138 String extension, ExportConfiguratorBase<?, ?, ?> configurator) {
139 super(pageName);
140 this.configurator = configurator;
141 this.type = type;
142 switch (type) {
143 case CSV_EXPORT:
144 csvExport = true;
145 break;
146 case CSV_NAME_EXPORT:
147 csvNameExport = true;
148 break;
149 case CDM_LIGHT_EXPORT:
150 cdmLightExport = true;
151 break;
152 case COL_DP_EXPORT:
153 colDPExport = true;
154 break;
155 case CSV_PRINT_EXPORT:
156 csvPrintExport = true;
157 break;
158 case DWCA_EXPORT:
159 dwcaExport = true;
160 break;
161 case WFO_EXPORT:
162 wfoExport = true;
163 break;
164 default:
165 throw new RuntimeException("Export type not yet handeled: " + type);
166 }
167 this.extension = extension;
168 this.setTitle(title);
169 this.setDescription(description);
170 }
171
172 public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) {
173 return new ExportToFileDestinationWizardPage(JAXB_EXPORT, "jaxb", "JAXB Export",
174 "Exports the content of the currently selected database into the cdm jaxb format.", XML, configurator);
175 }
176
177 public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) {
178 return new ExportToFileDestinationWizardPage(TCS_EXPORT, "tcs", "Tcs Export",
179 "Export the content of the currently selected database into TCS format.", XML, config);
180 }
181
182 public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) {
183 return new ExportToFileDestinationWizardPage(SDD_EXPORT, "sdd", "Sdd Export",
184 "Export the content of the currently selected database into SDD format.", XML, config);
185 }
186
187 public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) {
188 return new ExportToFileDestinationWizardPage(DWCA_EXPORT, DWCA_EXPORT, "DwC-Archive Export",
189 "Export the content of the currently selected database into Darwin Core Archive format.", ZIP, config);
190 }
191 public static ExportToFileDestinationWizardPage WFO(WfoExportConfigurator config) {
192 return new ExportToFileDestinationWizardPage(WFO_EXPORT, WFO_EXPORT, "WFO Export",
193 "Export the content of the currently selected database into WFO "
194 , ZIP, config);
195 }
196
197 public static ExportToFileDestinationWizardPage CdmLight(CdmLightExportConfigurator config) {
198
199 return new ExportToFileDestinationWizardPage(CDM_LIGHT_EXPORT, CDM_LIGHT_EXPORT, "CDM Light Export (csv)",
200 "Export the content of the currently selected database into the CDM light (csv) format.", CSV, config);
201 }
202
203 public static ExportToFileDestinationWizardPage ColDp(ColDpExportConfigurator config) {
204
205 return new ExportToFileDestinationWizardPage(COL_DP_EXPORT, COL_DP_EXPORT, "Col DP Export (zip)",
206 "Export the content of the currently selected database into the Catalogue of Life Data Package (Col DP) format.", ZIP, config);
207 }
208
209 public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) {
210
211 return new ExportToFileDestinationWizardPage(CSV_EXPORT, CSV_EXPORT, "CSV Export",
212 "Export the content of the currently selected database into Comma Separated Value format.", CSV,
213 config);
214 }
215
216 public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) {
217
218 return new ExportToFileDestinationWizardPage(CSV_NAME_EXPORT, CSV_NAME_EXPORT, "CSV Name Export",
219 "Export the names of the currently selected database into Semicolon Separated Value format.", CSV,
220 config);
221 }
222
223 public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) {
224
225 return new ExportToFileDestinationWizardPage(CSV_PRINT_EXPORT, CSV_NAME_EXPORT, "CSV Print Export",
226 "Export the content of the currently selected database into Semicolon Separated Value format.", CSV,
227 config);
228 }
229
230 /** {@inheritDoc} */
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) {
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 || wfoExport) {
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 selectNodeOrClassification.setLayout(grid);
304 if ((cdmLightExport || dwcaExport || colDPExport || wfoExport) && !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()) {
305 if (!wfoExport) {
306 checkUseSelectedTaxonNode = new Button(selectNodeOrClassification, SWT.RADIO);
307 }
308 String taxonStr = "";
309 int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size();
310 List<TaxonNode> selectedNodes = new ArrayList<>();
311 for (LogicFilter<TaxonNode> filter : configurator.getTaxonNodeFilter().getSubtreeFilter()) {
312 node = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
313 selectedNodes.add(node);
314 count--;
315 if (node.hasTaxon()) {
316 taxonStr += node.getTaxon().getName().getTitleCache();
317 if (count > 0) {
318 taxonStr += ", ";
319 }
320 }
321 }
322 if (!wfoExport) {
323 checkUseSelectedTaxonNode.setText("Export all selected subtree(s) (" + taxonStr + ")");
324 checkUseSelectedTaxonNode.addListener(SWT.Selection, e -> {
325 Button b = (Button) e.widget;
326 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
327 data.exclude = b.getSelection();
328 if (classificationSelectionCombo != null) {
329 classificationSelectionCombo.setEnabled(!data.exclude);
330 }
331 });
332 checkUseSelectedTaxonNode.setSelection(true);
333 }else {
334 Composite wfoComp = new Composite(selectNodeOrClassification, SWT.NONE);
335 grid = new GridLayout();
336 grid.numColumns = 2;
337 wfoComp.setLayout(grid);
338
339 Label label = new Label(wfoComp, SWT.NONE);
340 label.setText("Export all selected subtree(s) (" + taxonStr + ")");
341 GridData gridData = new GridData();
342 gridData.horizontalSpan = 2;
343 gridData.grabExcessHorizontalSpace = true;
344 label.setLayoutData(gridData);
345
346 Label familyString = new Label(wfoComp, SWT.NONE);
347 familyString.setText("Family");
348 text_familyString = new Text(wfoComp, SWT.BORDER);
349 text_familyString.setText(generateFamilyName(selectedNodes));
350 text_familyString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
351
352 }
353 }
354
355 if (cdmLightExport || dwcaExport || colDPExport ) {
356 if (dwcaExport) {
357 checkUseAllClassification = new Button(selectNodeOrClassification, SWT.RADIO);
358 checkUseAllClassification.setText("Export all classifications");
359 checkUseAllClassification.addListener(SWT.Selection, new Listener() {
360 @Override
361 public void handleEvent(Event e) {
362 Button b = (Button) e.widget;
363 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
364 data.exclude = b.getSelection();
365 classificationSelectionCombo.setEnabled(!data.exclude);
366
367 }
368 });
369 }
370 checkUseSelectedClassification = new Button(selectNodeOrClassification, SWT.RADIO);
371 checkUseSelectedClassification.setText("Export selected classification");
372 checkUseSelectedClassification.addListener(SWT.Selection, e -> {
373 Button b = (Button) e.widget;
374 GridData data = (GridData) classificationSelectionCombo.getLayoutData();
375 data.exclude = b.getSelection();
376 classificationSelectionCombo.setEnabled(data.exclude);
377 });
378 }
379
380 if (node != null) {
381 selectedClassification = node.getClassification();
382 }
383 if (!wfoExport) {
384 createClassificationSelectionCombo(selectNodeOrClassification);
385 }
386 if (cdmLightExport) {
387 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
388 GridData gridDataSep = new GridData();
389 gridDataSep = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
390 gridDataSep.horizontalSpan = 2;
391 separator.setLayoutData(gridDataSep);
392
393 Composite comp = new Composite(composite, SWT.NONE);
394
395 GridData gridData = new GridData();
396 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
397 gridData.horizontalSpan = 2;
398 comp.setLayoutData(gridData);
399
400 Label label = new Label(comp, SWT.NONE);
401 label.setText("Sorting of taxa");
402
403 orderSelectionCombo = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
404
405 GridLayoutFactory.fillDefaults().applyTo(comp);
406 for (NavigatorOrderEnum display : NavigatorOrderEnum.values()) {
407 orderSelectionCombo.add(display.getLabel());
408 }
409
410 int index = 0;
411 if (PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()) != null) {
412 NavigatorOrderEnum orderInNavigator = NavigatorOrderEnum
413 .valueOf(PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
414
415 for (String itemLabel : orderSelectionCombo.getItems()) {
416 if (itemLabel.equalsIgnoreCase(orderInNavigator.getLabel())) {
417 orderSelectionCombo.select(index);
418 setComparatorToConfig();
419 break;
420 }
421 index++;
422 }
423 }
424
425 orderSelectionCombo.addSelectionListener(new SelectionListener() {
426
427 @Override
428 public void widgetSelected(SelectionEvent e) {
429 setComparatorToConfig();
430 }
431
432 @Override
433 public void widgetDefaultSelected(SelectionEvent e) {
434 // TODO Auto-generated method stub
435 }
436 });
437 }
438
439 if (classificationSelectionCombo != null) {
440 if (checkUseSelectedTaxonNode != null) {
441 if (checkUseSelectedTaxonNode.getSelection()) {
442 classificationSelectionCombo.setEnabled(false);
443 }
444 } else {
445 classificationSelectionCombo.setEnabled(true);
446 classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
447 }
448 }
449 Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
450 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
451 gridData.horizontalSpan = 2;
452 separator.setLayoutData(gridData);
453
454 }
455
456 Label folderLabel = new Label(composite, SWT.NONE);
457 folderLabel.setText("Select Folder for exported files");
458 folderLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
459 folderDialog = new DirectoryDialog(parent.getShell());
460 String exportFolder = PreferencesUtil.getStringValue(EXPORT_FOLDER, true);
461 folderDialog.setFilterPath(exportFolder);
462
463 text_folder = new Text(composite, SWT.BORDER);
464 text_folder.setEditable(false);
465 text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
466 if (exportFolder != null) {
467 text_folder.setText(exportFolder);
468 setPageComplete(true);
469 }
470
471 Button button = new Button(composite, SWT.PUSH);
472 button.setText("Browse...");
473
474 button.addSelectionListener(new SelectionAdapter() {
475 @Override
476 public void widgetSelected(SelectionEvent e) {
477 super.widgetSelected(e);
478
479 String path = folderDialog.open();
480 if (path != null) { // a folder was selected
481 text_folder.setText(path);
482 PreferencesUtil.setStringValue(EXPORT_FOLDER, path);
483 setPageComplete(true);
484 }
485 }
486 });
487 if (!cdmLightExport) {
488
489 Label fileLabel = new Label(composite, SWT.NONE);
490 fileLabel.setText("Filename");
491 text_exportFileName = new Text(composite, SWT.BORDER);
492 text_exportFileName.setText(generateFilename());
493 text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
494 }
495
496 // make the composite the wizard pages control
497 setControl(composite);
498 }
499
500 /**
501 * @return
502 */
503 private String generateFamilyName(List<TaxonNode> nodes) {
504 if (nodes.size() == 1){
505 TaxonNode node = nodes.get(0);
506 if (node.getTaxon() != null) {
507 if(node.getTaxon().getName().getRank().getOrderIndex() >= Rank.FAMILY().getOrderIndex()) {
508 TaxonNode familyNode = node.getAncestorOfRank(Rank.FAMILY());
509 if (familyNode != null && familyNode.getTaxon() != null) {
510 return familyNode.getTaxon().getName().getNameCache();
511 }
512
513 }
514 }
515
516 }
517 return "";
518 }
519
520 protected void setComparatorToConfig() {
521 if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.NaturalOrder.getLabel())) {
522 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoNaturalComparator());
523 } else if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.AlphabeticalOrder.getLabel())) {
524 ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoByNameComparator());
525 } else {
526 ((CdmLightExportConfigurator) configurator)
527 .setTaxonNodeComparator(new TaxonNodeDtoByRankAndNameComparator());
528 }
529 }
530
531 protected String generateFilename() {
532 StringBuffer buffer = new StringBuffer();
533
534 Calendar cal = Calendar.getInstance();
535 SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
536 buffer.append(sdf.format(cal.getTime()));
537
538 buffer.append("-");
539 buffer.append(type + "_");
540
541 String source = ((ICdmRemoteSource) CdmStore.getActiveCdmSource()).toString();
542 source = source.substring(source.indexOf("/") + 1);
543 buffer.append(source);
544
545 buffer.append(".");
546 buffer.append(extension);
547
548 return buffer.toString();
549 }
550
551 public String getExportFileName() {
552 return text_exportFileName.getText();
553 }
554
555 /**
556 * @return the familyString
557 */
558 public String getFamilyString() {
559 return text_familyString.getText();
560 }
561
562 public String getFolderText() {
563 return text_folder.getText();
564 }
565
566 public Text getFolderComposite() {
567 return text_folder;
568 }
569
570 public boolean isExportUnpublishedData() {
571 return checkExportUnpublished.getSelection();
572 }
573
574 public boolean isExportFactualData() {
575 return checkExportFactualData.getSelection();
576 }
577
578 public boolean isExportUnpublishedFactualData() {
579 return checkExportUnpublishedFactualData.getSelection();
580 }
581
582 private void createClassificationSelectionCombo(Composite parent) {
583
584 GridData gridData = new GridData();
585 gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
586 gridData.horizontalIndent = 5;
587
588 classificationSelectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
589 classificationSelectionCombo.setLayoutData(gridData);
590 for (Classification tree : classifications) {
591 classificationSelectionCombo.add(tree.getTitleCache(), classifications.indexOf(tree));
592 }
593
594 classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
595
596 // TODO remember last selection
597 classificationSelectionCombo.addSelectionListener(this);
598
599 }
600
601 public Combo getCombo() {
602 return classificationSelectionCombo;
603 }
604
605 @Override
606 public void widgetSelected(SelectionEvent e) {
607 selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
608 }
609
610 public Classification getSelectedClassification() {
611 return selectedClassification;
612 }
613
614 @Override
615 public void widgetDefaultSelected(SelectionEvent e) {
616 // not needed here
617 }
618
619 public UUID getSelectedClassificationUUID() {
620 return selectedClassification.getUuid();
621 }
622
623 public boolean getCheckUseSelectedTaxonNode() {
624 if (checkUseSelectedTaxonNode == null) {
625 return false;
626 }
627 return checkUseSelectedTaxonNode.getSelection();
628 }
629
630 public boolean getCheckUseAllClassifications() {
631 if (checkUseAllClassification == null) {
632 return false;
633 }
634 return checkUseAllClassification.getSelection();
635 }
636
637 public Set<UUID> getAllClassificationUuids() {
638 Set<UUID> allClassificationUuids = new HashSet<>();
639 for (Classification classification : this.classifications) {
640 allClassificationUuids.add(classification.getUuid());
641 }
642 return allClassificationUuids;
643 }
644
645 @Override
646 public boolean canFlipToNextPage() {
647 return getFolderText() != null;
648 }
649 }