Project

General

Profile

Download (2.5 KB) Statistics
| Branch: | Tag: | Revision:
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.sdd.in.SDDImportConfigurator;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

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

    
34
	private SDDImportConfigurator configurator;
35

    
36
	private ImportFromFileDataSourceWizardPage dataSourcePage;
37

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

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

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

    
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
63
	 */
64
	/** {@inheritDoc} */
65
	@Override
66
	public boolean performFinish() {
67
		URI source = dataSourcePage.getUri();
68
		configurator.setSource(source);
69
		configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
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

    
78
		return true;
79
	}
80

    
81
	/* (non-Javadoc)
82
	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
83
	 */
84
	/** {@inheritDoc} */
85
	@Override
86
    public void init(IWorkbench workbench, IStructuredSelection selection) {
87
		super.init(workbench, selection);
88
		configurator =  CdmStore.getImportManager().SddConfigurator();
89
	}
90
}
(21-21/24)