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
|
import java.net.URI;
|
15
|
|
16
|
import org.eclipse.core.runtime.jobs.Job;
|
17
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
18
|
import org.eclipse.ui.IWorkbench;
|
19
|
|
20
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
|
22
|
import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
|
23
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24
|
|
25
|
|
26
|
/**
|
27
|
* <p>ExcelNormalExplicitTaxaImportWizard class.</p>
|
28
|
*
|
29
|
* @author n.hoffmann
|
30
|
* @created Sep 22, 2009
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class ExcelNormalExplicitTaxaImportWizard extends AbstractImportWizard<NormalExplicitImportConfigurator>{
|
34
|
|
35
|
private NormalExplicitImportConfigurator configurator;
|
36
|
|
37
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
38
|
|
39
|
/* (non-Javadoc)
|
40
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
|
41
|
*/
|
42
|
/** {@inheritDoc} */
|
43
|
@Override
|
44
|
public NormalExplicitImportConfigurator getConfigurator() {
|
45
|
return configurator;
|
46
|
}
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
50
|
*/
|
51
|
/** {@inheritDoc} */
|
52
|
@Override
|
53
|
public boolean performFinish() {
|
54
|
URI source = dataSourcePage.getUri();
|
55
|
configurator.setSource(source);
|
56
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
57
|
|
58
|
if(CdmStore.getCurrentSessionManager().isRemoting()) {
|
59
|
Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
|
60
|
CdmStore.getImportManager().run(job);
|
61
|
} else {
|
62
|
CdmStore.getImportManager().run(configurator);
|
63
|
}
|
64
|
|
65
|
|
66
|
return true;
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
71
|
*/
|
72
|
/** {@inheritDoc} */
|
73
|
@Override
|
74
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
75
|
super.init(workbench, selection);
|
76
|
configurator = CdmStore.getImportManager().NormalExplicitConfigurator();
|
77
|
}
|
78
|
|
79
|
/* (non-Javadoc)
|
80
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
|
81
|
*/
|
82
|
/** {@inheritDoc} */
|
83
|
@Override
|
84
|
public void addPages() {
|
85
|
super.addPages();
|
86
|
|
87
|
dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose NormalExplicit",
|
88
|
"Please choose an xls file in the NormalExplicit format.", new String[]{"*.xlsx", "*.xls", "*.*"});
|
89
|
addPage(dataSourcePage);
|
90
|
}
|
91
|
}
|