fix #5759 remove all switches for remoting and standalone
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / ExcelNormalExplicitTaxaImportWizard.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 import java.net.URI;
15
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;
20
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;
26
27
28 /**
29 * <p>ExcelNormalExplicitTaxaImportWizard class.</p>
30 *
31 * @author n.hoffmann
32 * @created Sep 22, 2009
33 * @version 1.0
34 */
35 public class ExcelNormalExplicitTaxaImportWizard extends AbstractImportWizard<NormalExplicitImportConfigurator>{
36
37 private NormalExplicitImportConfigurator configurator;
38
39 private ImportFromFileDataSourceWizardPage dataSourcePage;
40
41 /* (non-Javadoc)
42 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
43 */
44 /** {@inheritDoc} */
45 @Override
46 public NormalExplicitImportConfigurator getConfigurator() {
47 return configurator;
48 }
49
50 /* (non-Javadoc)
51 * @see org.eclipse.jface.wizard.Wizard#performFinish()
52 */
53 /** {@inheritDoc} */
54 @Override
55 public boolean performFinish() {
56 URI source = dataSourcePage.getUri();
57 configurator.setSource(source);
58 configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
59
60 Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
61 CdmStore.getImportManager().run(job);
62
63 return true;
64 }
65
66 /* (non-Javadoc)
67 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
68 */
69 /** {@inheritDoc} */
70 @Override
71 public void init(IWorkbench workbench, IStructuredSelection selection) {
72 super.init(workbench, selection);
73 configurator = CdmStore.getImportManager().NormalExplicitConfigurator();
74 if (selection instanceof TreeSelection && !selection.isEmpty()){
75 TaxonNode node = (TaxonNode)selection.getFirstElement();
76 configurator.setParentUUID(node.getTaxon().getUuid());
77 configurator.setClassificationUuid(node.getClassification().getUuid());
78 }
79 }
80
81 /* (non-Javadoc)
82 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
83 */
84 /** {@inheritDoc} */
85 @Override
86 public void addPages() {
87 super.addPages();
88
89 dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose NormalExplicit",
90 "Please choose an xls file in the NormalExplicit format.", new String[]{"*.xlsx", "*.xls", "*.*"});
91 addPage(dataSourcePage);
92 }
93 }