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.net.URI;
|
13
|
|
14
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
15
|
import org.eclipse.ui.IWorkbench;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
|
19
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
20
|
|
21
|
/**
|
22
|
* <p>JaxbImportWizard class.</p>
|
23
|
*
|
24
|
* @author n.hoffmann
|
25
|
* @created 15.06.2009
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class JaxbImportWizard extends AbstractImportWizard<JaxbImportConfigurator> {
|
29
|
|
30
|
private JaxbImportConfigurator configurator;
|
31
|
|
32
|
private ImportFromFileDataSourceWizardPage dataSourcePage;
|
33
|
|
34
|
/* (non-Javadoc)
|
35
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
|
36
|
*/
|
37
|
/** {@inheritDoc} */
|
38
|
@Override
|
39
|
public JaxbImportConfigurator getConfigurator() {
|
40
|
return configurator;
|
41
|
}
|
42
|
|
43
|
/* (non-Javadoc)
|
44
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
45
|
*/
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
public boolean performFinish() {
|
49
|
URI source = dataSourcePage.getUri();
|
50
|
configurator.setSource(source);
|
51
|
configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
|
52
|
|
53
|
CdmStore.getImportManager().run(configurator);
|
54
|
|
55
|
return true;
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
60
|
*/
|
61
|
/** {@inheritDoc} */
|
62
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
63
|
super.init(workbench, selection);
|
64
|
configurator = CdmStore.getImportManager().JaxbConfigurator();
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
|
69
|
*/
|
70
|
/** {@inheritDoc} */
|
71
|
@Override
|
72
|
public void addPages() {
|
73
|
super.addPages();
|
74
|
|
75
|
dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose File",
|
76
|
"Please choose an XML file in the cdm JAXB format.", new String[]{"*.xml"});
|
77
|
addPage(dataSourcePage);
|
78
|
}
|
79
|
}
|