3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
16 import org
.eclipse
.core
.runtime
.jobs
.Job
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.jface
.viewers
.TreeSelection
;
19 import org
.eclipse
.ui
.IWorkbench
;
21 import eu
.etaxonomy
.cdm
.database
.DbSchemaValidation
;
22 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
.SOURCE_TYPE
;
23 import eu
.etaxonomy
.cdm
.io
.excel
.taxa
.NormalExplicitImportConfigurator
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * <p>ExcelNormalExplicitTaxaImportWizard class.</p>
32 * @created Sep 22, 2009
35 public class ExcelNormalExplicitTaxaImportWizard
extends AbstractImportWizard
<NormalExplicitImportConfigurator
>{
37 private NormalExplicitImportConfigurator configurator
;
39 private ImportFromFileDataSourceWizardPage dataSourcePage
;
42 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
46 public NormalExplicitImportConfigurator
getConfigurator() {
51 * @see org.eclipse.jface.wizard.Wizard#performFinish()
55 public boolean performFinish() {
56 URI source
= dataSourcePage
.getUri();
57 configurator
.setSource(source
);
58 configurator
.setDbSchemaValidation(DbSchemaValidation
.CREATE
);
60 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
61 Job job
= CdmStore
.getImportManager().createIOServiceJob(configurator
, new File(source
), SOURCE_TYPE
.URI
);
62 CdmStore
.getImportManager().run(job
);
64 CdmStore
.getImportManager().run(configurator
);
72 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
76 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
77 super.init(workbench
, selection
);
78 configurator
= CdmStore
.getImportManager().NormalExplicitConfigurator();
79 if (selection
instanceof TreeSelection
&& !selection
.isEmpty()){
80 TaxonNode node
= (TaxonNode
)selection
.getFirstElement();
81 configurator
.setParentUUID(node
.getTaxon().getUuid());
82 configurator
.setClassificationUuid(node
.getClassification().getUuid());
87 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
91 public void addPages() {
94 dataSourcePage
= new ImportFromFileDataSourceWizardPage("Choose NormalExplicit",
95 "Please choose an xls file in the NormalExplicit format.", new String
[]{"*.xlsx", "*.xls", "*.*"});
96 addPage(dataSourcePage
);