3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
14 import java
.util
.HashSet
;
15 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import org
.eclipse
.core
.runtime
.jobs
.Job
;
19 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
20 import org
.eclipse
.swt
.widgets
.Combo
;
21 import org
.eclipse
.ui
.IWorkbench
;
22 import org
.eclipse
.ui
.progress
.IProgressConstants
;
24 import eu
.etaxonomy
.cdm
.io
.csv
.redlist
.demo
.CsvDemoExportConfigurator
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * @created Nov. 11, 2014
33 public class CsvExportWizard
extends AbstractExportWizard
<CsvDemoExportConfigurator
> {
35 private CsvDemoExportConfigurator configurator
;
36 private ExportToFileDestinationWizardPage page
;
38 private final String description
= "Export the contents of the currently selected database into Comma Separated Value format.";
42 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
43 * org.eclipse.jface.viewers.IStructuredSelection)
46 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
47 configurator
= CsvDemoExportConfigurator
.NewInstance(null, null);
54 * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
57 public CsvDemoExportConfigurator
getConfigurator() {
64 * @see org.eclipse.jface.wizard.Wizard#performFinish()
67 public boolean performFinish() {
68 String urlString
= page
.getFolderText() + File
.separator
69 + page
.getExportFileName();
71 final Combo combo
= page
.getCombo();
72 final List
<Classification
> listClassifications
= CdmStore
.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
74 int selectionIndex
= combo
.getSelectionIndex();
75 HashSet
<UUID
> set
= new HashSet
<UUID
>();
76 if(selectionIndex
== -1){
77 for(Classification c
:listClassifications
){
81 for(Classification c
:listClassifications
){
82 if(c
.getTitleCache().equalsIgnoreCase(combo
.getItem(selectionIndex
))){
86 configurator
.setClassificationUuids(set
);
87 configurator
.setDoTaxa(true);
88 configurator
.setHasHeaderLines(true);
89 configurator
.setClassification(true);
90 configurator
.setTaxonName(true);
91 configurator
.setAuthor(true);
92 configurator
.setRank(true);
93 configurator
.setLastChange(true);
96 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
98 Job job
= CdmStore
.getExportManager().createIOServiceJob(configurator
, new File(urlString
));
100 job
.setProperty(IProgressConstants
.KEEP_PROPERTY
, true);
106 configurator
.setDestination(new File(urlString
));
107 CdmStore
.getExportManager().run(configurator
);
115 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
118 public void addPages() {
119 //TODO create page with drop down menu for export for single classification.
124 page
= ExportToFileDestinationWizardPage
.Csv();