Project

General

Profile

Download (2.36 KB) Statistics
| Branch: | Tag: | Revision:
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.wizard;
11

    
12
import java.io.File;
13
import java.net.URI;
14

    
15
import org.eclipse.core.runtime.jobs.Job;
16
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.ui.IWorkbench;
18

    
19
import eu.etaxonomy.cdm.database.DbSchemaValidation;
20
import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
21
import eu.etaxonomy.cdm.io.sdd.in.SDDImportConfigurator;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * <p>SddImportWizard class.</p>
26
 *
27
 * @author n.hoffmann
28
 * @created Jun 16, 2010
29
 * @version 1.0
30
 */
31
public class SddImportWizard extends AbstractImportWizard<SDDImportConfigurator> {
32

    
33
	private SDDImportConfigurator configurator;
34

    
35
	private ImportFromFileDataSourceWizardPage dataSourcePage;
36

    
37
	/* (non-Javadoc)
38
	 * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
39
	 */
40
	/** {@inheritDoc} */
41
	@Override
42
	public SDDImportConfigurator getConfigurator() {
43
		return configurator;
44
	}
45

    
46
	/*
47
	 * (non-Javadoc)
48
	 * @see org.eclipse.jface.wizard.Wizard#addPage(org.eclipse.jface.wizard.IWizardPage)
49
	 */
50
	/** {@inheritDoc} */
51
	@Override
52
	public void addPages() {
53
		super.addPages();
54

    
55
		dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose File",
56
				"Please choose an XML file in the SDD format.", new String[]{"*.xml", "*.sdd"});
57
		addPage(dataSourcePage);
58
	}
59

    
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
62
	 */
63
	/** {@inheritDoc} */
64
	@Override
65
	public boolean performFinish() {
66
		URI source = dataSourcePage.getUri();
67
		configurator.setSource(source);
68
		configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
69
		Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.URI);
70
		CdmStore.getImportManager().run(job);
71
		
72
		return true;
73
	}
74

    
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
77
	 */
78
	/** {@inheritDoc} */
79
	@Override
80
    public void init(IWorkbench workbench, IStructuredSelection selection) {
81
		super.init(workbench, selection);
82
		configurator =  CdmStore.getImportManager().SddConfigurator();
83
	}
84
}
(23-23/26)