Merge branch 'release/4.0.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
70 if(CdmStore.getCurrentSessionManager().isRemoting()) {
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 } else {
79 configurator.setDestination(new File(urlString));
80 CdmStore.getExportManager().run(configurator);
81 }
82 return true;
83 }
84
85 /*
86 * (non-Javadoc)
87 *
88 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
89 */
90 @Override
91 public void addPages() {
92 //TODO create page with drop down menu for export for single classification.
93 // super.addPages();
94
95
96 //standard page
97 page = ExportToFileDestinationWizardPage.CsvNames();
98
99 addPage(page);
100 }
101 }
102