Improved PrintPublisher Wizard; Integrated SpecimenCdmExcel import
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / SpecimenCdmExcelImportWizard.java
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/SpecimenCdmExcelImportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/SpecimenCdmExcelImportWizard.java
new file mode 100644 (file)
index 0000000..12b7d00
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * 
+ */
+package eu.etaxonomy.taxeditor.io.wizard;
+
+import java.net.URI;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.database.DbSchemaValidation;
+import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ *
+ */
+public class SpecimenCdmExcelImportWizard extends AbstractImportWizard<SpecimenCdmExcelImportConfigurator> {
+
+       private SpecimenCdmExcelImportConfigurator configurator;
+       
+       private ImportFromFileDataSourceWizardPage dataSourcePage;
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
+        */
+       @Override
+       public SpecimenCdmExcelImportConfigurator getConfigurator() {
+               return configurator;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       /** {@inheritDoc} */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               super.init(workbench, selection);
+               configurator =  CdmStore.getImportManager().SpecimenCdmExcelImportConfigurator();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               URI source = dataSourcePage.getUri();
+               configurator.setSource(source);
+               configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
+               
+               CdmStore.getImportManager().run(configurator);
+               
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#addPages()
+        */
+       /** {@inheritDoc} */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               dataSourcePage = new ImportFromFileDataSourceWizardPage("Choose Specimen CDM Excel", 
+                               "Please choose an xls file in the SpecimenCdmExcel format.", new String[]{"*.xls"});
+               addPage(dataSourcePage);
+       }
+
+}