1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents 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
|
|
10
|
package eu.etaxonomy.taxeditor.io.e4.out.csv.name;
|
11
|
|
12
|
import java.io.File;
|
13
|
|
14
|
import javax.inject.Inject;
|
15
|
import javax.inject.Named;
|
16
|
|
17
|
import org.eclipse.core.runtime.jobs.Job;
|
18
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
19
|
import org.eclipse.e4.core.di.annotations.Optional;
|
20
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
21
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
22
|
import org.eclipse.jface.viewers.TreeSelection;
|
23
|
import org.eclipse.swt.widgets.Combo;
|
24
|
import org.eclipse.ui.progress.IProgressConstants;
|
25
|
|
26
|
import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator;
|
27
|
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
28
|
import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
|
29
|
import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
|
30
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
31
|
|
32
|
/**
|
33
|
* @author k.luther
|
34
|
* @created Apr. 12, 2015
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class CsvNameExportWizardE4 extends AbstractExportWizardE4<CsvNameExportConfigurator> {
|
38
|
|
39
|
|
40
|
protected CsvNameExportConfigurator configurator;
|
41
|
protected ExportToFileDestinationWizardPage page;
|
42
|
|
43
|
@Inject
|
44
|
public CsvNameExportWizardE4(IEclipseContext context,
|
45
|
@Optional@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection) {
|
46
|
super(context, selection);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public void init() {
|
51
|
configurator = CsvNameExportConfigurator.NewInstance(null,null);
|
52
|
configurator.setNamesOnly(true);
|
53
|
if (selection instanceof TreeSelection && !selection.isEmpty()){
|
54
|
TaxonNodeDto node = (TaxonNodeDto)selection.getFirstElement();
|
55
|
configurator.setClassificationUUID(node.getClassificationUUID());
|
56
|
}
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public CsvNameExportConfigurator getConfigurator() {
|
61
|
return configurator;
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public boolean performFinish() {
|
66
|
String urlString = page.getFolderText() + File.separator
|
67
|
+ page.getExportFileName();
|
68
|
|
69
|
final Combo combo = page.getCombo();
|
70
|
configurator.setClassificationUUID(page.getSelectedClassificationUUID());
|
71
|
|
72
|
// create job
|
73
|
Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
|
74
|
// configure the job
|
75
|
job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
|
76
|
job.setUser(true);
|
77
|
// schedule job
|
78
|
job.schedule();
|
79
|
|
80
|
return true;
|
81
|
}
|
82
|
|
83
|
@Override
|
84
|
public void addPages() {
|
85
|
//TODO create page with drop down menu for export for single classification.
|
86
|
// super.addPages();
|
87
|
|
88
|
|
89
|
//standard page
|
90
|
page = ExportToFileDestinationWizardPage.CsvNames(configurator);
|
91
|
|
92
|
addPage(page);
|
93
|
}
|
94
|
}
|
95
|
|