Revision 43527305
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/SddImportWizard.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.taxeditor.io.wizard; |
12 | 12 |
|
13 |
import java.io.File; |
|
13 | 14 |
import java.net.URI; |
14 | 15 |
|
16 |
import org.eclipse.core.runtime.jobs.Job; |
|
15 | 17 |
import org.eclipse.jface.viewers.IStructuredSelection; |
16 | 18 |
import org.eclipse.ui.IWorkbench; |
17 | 19 |
|
18 | 20 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
21 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE; |
|
19 | 22 |
import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator; |
20 | 23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
21 | 24 |
|
... | ... | |
29 | 32 |
public class SddImportWizard extends AbstractImportWizard<SDDImportConfigurator> { |
30 | 33 |
|
31 | 34 |
private SDDImportConfigurator configurator; |
32 |
|
|
35 |
|
|
33 | 36 |
private ImportFromFileDataSourceWizardPage dataSourcePage; |
34 |
|
|
37 |
|
|
35 | 38 |
/* (non-Javadoc) |
36 | 39 |
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator() |
37 | 40 |
*/ |
... | ... | |
40 | 43 |
public SDDImportConfigurator getConfigurator() { |
41 | 44 |
return configurator; |
42 | 45 |
} |
43 |
|
|
46 |
|
|
44 | 47 |
/* |
45 | 48 |
* (non-Javadoc) |
46 | 49 |
* @see org.eclipse.jface.wizard.Wizard#addPage(org.eclipse.jface.wizard.IWizardPage) |
... | ... | |
49 | 52 |
@Override |
50 | 53 |
public void addPages() { |
51 | 54 |
super.addPages(); |
52 |
|
|
53 |
dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose File",
|
|
55 |
|
|
56 |
dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose File", |
|
54 | 57 |
"Please choose an XML file in the SDD format.", new String[]{"*.xml", "*.sdd"}); |
55 | 58 |
addPage(dataSourcePage); |
56 | 59 |
} |
57 |
|
|
60 |
|
|
58 | 61 |
/* (non-Javadoc) |
59 | 62 |
* @see org.eclipse.jface.wizard.Wizard#performFinish() |
60 | 63 |
*/ |
... | ... | |
64 | 67 |
URI source = dataSourcePage.getUri(); |
65 | 68 |
configurator.setSource(source); |
66 | 69 |
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE); |
67 |
|
|
68 |
CdmStore.getImportManager().run(configurator); |
|
69 |
|
|
70 |
|
|
71 |
if(CdmStore.getCurrentSessionManager().isRemoting()) { |
|
72 |
Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI); |
|
73 |
CdmStore.getImportManager().run(job); |
|
74 |
} else { |
|
75 |
CdmStore.getImportManager().run(configurator); |
|
76 |
} |
|
77 |
|
|
70 | 78 |
return true; |
71 | 79 |
} |
72 | 80 |
|
... | ... | |
74 | 82 |
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) |
75 | 83 |
*/ |
76 | 84 |
/** {@inheritDoc} */ |
77 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
|
85 |
@Override |
|
86 |
public void init(IWorkbench workbench, IStructuredSelection selection) { |
|
78 | 87 |
super.init(workbench, selection); |
79 | 88 |
configurator = CdmStore.getImportManager().SddConfigurator(); |
80 | 89 |
} |
Also available in: Unified diff
#5130 Extend import wizards to import data via remoting and Add tests for the same