platform independent file URL
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / EndnoteImportWizard.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.apache.log4j.Logger;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.ui.IImportWizard;
19 import org.eclipse.ui.IWorkbench;
20
21 import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23
24 /**
25 * @author n.hoffmann
26 * @created Sep 18, 2009
27 * @version 1.0
28 */
29 public class EndnoteImportWizard extends AbstractImportWizard<EndnoteImportConfigurator> implements IImportWizard {
30 private static final Logger logger = Logger
31 .getLogger(EndnoteImportWizard.class);
32
33 private EndnoteImportConfigurator configurator;
34
35 private ImportFromFileDataSourceWizardPage dataSourcePage;
36
37 /* (non-Javadoc)
38 * @see org.eclipse.jface.wizard.Wizard#performFinish()
39 */
40 @Override
41 public boolean performFinish() {
42
43 String platformDependendFile = dataSourcePage.getFile();
44
45
46 // TcsXmlImport expects a string that can be used to instantiate a URL instance
47 // TODO consolidate import and exports regarding what may be passed in as source
48 // will construct a url string for now
49
50 File file = new File(platformDependendFile);
51 URI fileUri = file.toURI();
52 configurator.setSource(fileUri.toString());
53
54 CdmStore.getImportHandler().run(configurator);
55
56 return true;
57 }
58
59 /* (non-Javadoc)
60 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#addPages()
61 */
62 @Override
63 public void addPages() {
64 super.addPages();
65
66 dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
67 addPage(dataSourcePage);
68 }
69
70 /* (non-Javadoc)
71 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
72 */
73 public void init(IWorkbench workbench, IStructuredSelection selection) {
74 configurator = CdmStore.getImportHandler().EndnoteConfigurator();
75 }
76
77 /* (non-Javadoc)
78 * @see eu.etaxonomy.taxeditor.io.AbstractImportWizard#getConfigurator()
79 */
80 @Override
81 public EndnoteImportConfigurator getConfigurator() {
82 return configurator;
83 }
84 }