Merge branch 'release/4.3.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / CsvNameExportWizard.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.io.wizard;
12
13 import java.io.File;
14
15 import org.eclipse.core.runtime.jobs.Job;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.swt.widgets.Combo;
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.progress.IProgressConstants;
20
21 import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23
24 /**
25 * @author k.luther
26 * @created Apr. 12, 2015
27 * @version 1.0
28 */
29 public class CsvNameExportWizard extends AbstractExportWizard<CsvNameExportConfigurator> {
30
31 protected CsvNameExportConfigurator configurator;
32 protected ExportToFileDestinationWizardPage page;
33
34 private final String description = "Export the names of the currently selected database into Semicolon Separated Value format.";
35 /*
36 * (non-Javadoc)
37 *
38 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
39 * org.eclipse.jface.viewers.IStructuredSelection)
40 */
41 @Override
42 public void init(IWorkbench workbench, IStructuredSelection selection) {
43 configurator = CsvNameExportConfigurator.NewInstance(null,null);
44 configurator.setNamesOnly(true);
45 }
46
47 /*
48 * (non-Javadoc)
49 *
50 * @see
51 * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
52 */
53 @Override
54 public CsvNameExportConfigurator getConfigurator() {
55 return configurator;
56 }
57
58 /*
59 * (non-Javadoc)
60 *
61 * @see org.eclipse.jface.wizard.Wizard#performFinish()
62 */
63 @Override
64 public boolean performFinish() {
65 String urlString = page.getFolderText() + File.separator
66 + page.getExportFileName();
67
68 final Combo combo = page.getCombo();
69 configurator.setClassificationUUID(page.getSelectedClassificationUUID());
70
71 // create job
72 Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
73 // configure the job
74 job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
75 job.setUser(true);
76 // schedule job
77 job.schedule();
78
79 return true;
80 }
81
82 /*
83 * (non-Javadoc)
84 *
85 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
86 */
87 @Override
88 public void addPages() {
89 //TODO create page with drop down menu for export for single classification.
90 // super.addPages();
91
92
93 //standard page
94 page = ExportToFileDestinationWizardPage.CsvNames();
95
96 addPage(page);
97 }
98 }
99