merge
[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 }
45
46 /*
47 * (non-Javadoc)
48 *
49 * @see
50 * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
51 */
52 @Override
53 public CsvNameExportConfigurator getConfigurator() {
54 return configurator;
55 }
56
57 /*
58 * (non-Javadoc)
59 *
60 * @see org.eclipse.jface.wizard.Wizard#performFinish()
61 */
62 @Override
63 public boolean performFinish() {
64 String urlString = page.getFolderText() + File.separator
65 + page.getExportFileName();
66
67 final Combo combo = page.getCombo();
68
69 if(CdmStore.getCurrentSessionManager().isRemoting()) {
70 // create job
71 Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
72 // configure the job
73 job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
74 job.setUser(true);
75 // schedule job
76 job.schedule();
77 } else {
78 configurator.setDestination(new File(urlString));
79 CdmStore.getExportManager().run(configurator);
80 }
81 return true;
82 }
83
84 /*
85 * (non-Javadoc)
86 *
87 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
88 */
89 @Override
90 public void addPages() {
91 //TODO create page with drop down menu for export for single classification.
92 // super.addPages();
93
94
95 //standard page
96 page = ExportToFileDestinationWizardPage.CsvNames();
97
98 addPage(page);
99 }
100 }
101