commit fd907381ca720580c224fb3aa19b8c4d45c24ae7
Author: Patrick Plitzner
Date: Fri Oct 6 15:21:00 2017 +0200
ref #7008 Migrate CSV export
diff --git a/eu.etaxonomy.taxeditor.store/fragment.e4xmi b/eu.etaxonomy.taxeditor.store/fragment.e4xmi
index bdb8dde37..5f028b128 100644
--- a/eu.etaxonomy.taxeditor.store/fragment.e4xmi
+++ b/eu.etaxonomy.taxeditor.store/fragment.e4xmi
@@ -113,6 +113,7 @@
+
@@ -128,6 +129,7 @@
+
@@ -156,5 +158,9 @@
+
+
+
+
diff --git a/eu.etaxonomy.taxeditor.store/plugin.xml b/eu.etaxonomy.taxeditor.store/plugin.xml
index 3bb53262d..c0f7e9ac8 100755
--- a/eu.etaxonomy.taxeditor.store/plugin.xml
+++ b/eu.etaxonomy.taxeditor.store/plugin.xml
@@ -213,12 +213,6 @@
id="eu.etaxonomy.taxeditor.io.export.dwca"
name="%wizard.name.9">
-
-
+ */
+public abstract class AbstractExportWizardE4 extends Wizard {
+
+ protected final String CONFIGURATION_PAGE = "CONFIGURATION_PAGE";
+
+ private GenericConfiguratorWizardPage pageConfiguration;
+
+ /** {@inheritDoc} */
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ pageConfiguration = GenericConfiguratorWizardPage.Export(CONFIGURATION_PAGE, getConfigurator(), null);
+ this.addPage(pageConfiguration);
+ }
+
+ public abstract void init();
+
+ public abstract CONFIG getConfigurator();
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java
new file mode 100644
index 000000000..949db1535
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/AbstractOpenExportWizard.java
@@ -0,0 +1,34 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.io.e4.out;
+
+import org.eclipse.e4.core.contexts.ContextInjectionFactory;
+import org.eclipse.e4.core.contexts.IEclipseContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public abstract class AbstractOpenExportWizard {
+ @Execute
+ public void execute(IEclipseContext ctx, Shell s)
+ {
+ AbstractExportWizardE4 wizard = ContextInjectionFactory.make(getExportWizardClass(), ctx);
+ wizard.init();
+ WizardDialog dialog = new WizardDialog(s, wizard);
+ dialog.open();
+ }
+
+ protected abstract Class extends AbstractExportWizardE4> getExportWizardClass();
+
+}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java
new file mode 100644
index 000000000..c2ad2b2fa
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/CsvExportWizardE4.java
@@ -0,0 +1,102 @@
+/**
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+
+package eu.etaxonomy.taxeditor.io.e4.out.csv;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.ui.progress.IProgressConstants;
+
+import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
+import eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author a.oppermann
+ * @created Nov. 11, 2014
+ * @version 1.0
+ */
+public class CsvExportWizardE4 extends AbstractExportWizardE4 {
+
+ private CsvDemoExportConfigurator configurator;
+ private ExportToFileDestinationWizardPage page;
+
+ private final String description = "Export the contents of the currently selected database into Comma Separated Value format.";
+
+ @Override
+ public void init() {
+ configurator = CsvDemoExportConfigurator.NewInstance(null, null);
+ }
+
+ @Override
+ public CsvDemoExportConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ @Override
+ public boolean performFinish() {
+ String urlString = page.getFolderText() + File.separator
+ + page.getExportFileName();
+
+ final Combo combo = page.getCombo();
+ final List listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
+ if(combo != null){
+ int selectionIndex = combo.getSelectionIndex();
+ HashSet set = new HashSet();
+ if(selectionIndex == -1){
+ for(Classification c:listClassifications){
+ set.add(c.getUuid());
+ }
+ }else{
+ for(Classification c:listClassifications){
+ if(c.getTitleCache().equalsIgnoreCase(combo.getItem(selectionIndex))){
+ set.add(c.getUuid());
+ }
+ }
+ configurator.setClassificationUuids(set);
+ configurator.setDoTaxa(true);
+ configurator.setHasHeaderLines(true);
+ configurator.setClassification(true);
+ configurator.setTaxonName(true);
+ configurator.setAuthor(true);
+ configurator.setRank(true);
+ configurator.setLastChange(true);
+ }
+ }
+
+ // create job
+ Job job = CdmStore.getExportManager().createIOServiceJob(configurator, new File(urlString));
+ // configure the job
+ job.setProperty(IProgressConstants.KEEP_PROPERTY, true);
+ job.setUser(true);
+ // schedule job
+ job.schedule();
+
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ //TODO create page with drop down menu for export for single classification.
+// super.addPages();
+
+
+ //standard page
+ page = ExportToFileDestinationWizardPage.Csv(configurator);
+
+ addPage(page);
+ }
+}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java
new file mode 100644
index 000000000..8287f2bc4
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/csv/OpenCsvExportWizard.java
@@ -0,0 +1,29 @@
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.io.e4.out.csv;
+
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractExportWizardE4;
+import eu.etaxonomy.taxeditor.io.e4.out.AbstractOpenExportWizard;
+
+/**
+ * @author pplitzner
+ * @since Oct 5, 2017
+ *
+ */
+public class OpenCsvExportWizard extends AbstractOpenExportWizard {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Class extends AbstractExportWizardE4> getExportWizardClass() {
+ return CsvExportWizardE4.class;
+ }
+
+}