X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/c6476daa5094f992b235fd7c4d10c17b90dc0e8b..e62fc863269c21f4768909f104fb76c8a854a7de:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java index e5c389f66..9d5783130 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java @@ -1,22 +1,23 @@ -// $Id$ /** * 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 + * The content 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.wizard; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; -import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; +import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -27,377 +28,632 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; +import eu.etaxonomy.cdm.api.application.CdmApplicationState; import eu.etaxonomy.cdm.api.service.IClassificationService; +import eu.etaxonomy.cdm.filter.LogicFilter; +import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator; +import eu.etaxonomy.cdm.io.coldp.ColDpExportConfigurator; +import eu.etaxonomy.cdm.io.common.ExportConfiguratorBase; +import eu.etaxonomy.cdm.io.csv.caryophyllales.out.CsvNameExportConfigurator; +import eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator; +import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator; +import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator; +import eu.etaxonomy.cdm.io.sdd.out.SDDExportConfigurator; +import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator; +import eu.etaxonomy.cdm.io.wfo.out.WfoBackboneExportConfigurator; +import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; +import eu.etaxonomy.cdm.model.name.Rank; import eu.etaxonomy.cdm.model.taxon.Classification; -import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository; -import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException; +import eu.etaxonomy.cdm.model.taxon.TaxonNode; +import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByNameComparator; +import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoByRankAndNameComparator; +import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDtoNaturalComparator; +import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum; +import eu.etaxonomy.taxeditor.preference.PreferencesUtil; +import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource; import eu.etaxonomy.taxeditor.store.CdmStore; /** - *
* ExportToFileDestinationWizardPage class. - *
* * @author n.hoffmann * @created 15.06.2009 - * @version 1.0 */ public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener { - /** ConstantDATE_FORMAT_NOW="yyyyMMddHHmm"
*/
- public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
+ /** Constant DATE_FORMAT_NOW="yyyyMMddHHmm"
*/
+ public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
- /** Constant JAXB_EXPORT="JAXB_EXPORT"
*/
- public static final String JAXB_EXPORT = "JAXB_EXPORT";
+ /** Constant JAXB_EXPORT="JAXB_EXPORT"
*/
+ public static final String JAXB_EXPORT = "JAXB_EXPORT";
- /** Constant TCS_EXPORT="TCS_EXPORT"
*/
- public static final String TCS_EXPORT = "TCS_EXPORT";
+ /** Constant TCS_EXPORT="TCS_EXPORT"
*/
+ public static final String TCS_EXPORT = "TCS_EXPORT";
- /** Constant SDD_EXPORT="SDD_EXPORT"
*/
- public static final String SDD_EXPORT = "SDD_EXPORT";
+ /** Constant SDD_EXPORT="SDD_EXPORT"
*/
+ public static final String SDD_EXPORT = "SDD_EXPORT";
- public static final String DWCA_EXPORT = "DWCA_EXPORT";
+ public static final String DWCA_EXPORT = "DWCA_EXPORT";
+ public static final String WFO_BACKBONE_EXPORT = "WFO_BACKBONE_EXPORT";
+ public static final String CDM_LIGHT_EXPORT = "CDM_LIGHT(CSV)";
+ public static final String COL_DP_EXPORT = "COL DP";
+ public static final String CSV_EXPORT = "CSV_EXPORT";
+ public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
+ private static final String CSV_PRINT_EXPORT = "CSV_PRINT_EXPORT";
+ private static final String EXPORT_FOLDER = "EXPORT_FOLDER";
+ public static final String XML = "xml";
- public static final String CSV_EXPORT = "CSV_EXPORT";
- public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
+ public static final String CSV = "csv";
- public static final String XML = "xml";
+ public static final String ZIP = "zip";
- public static final String CSV = "csv";
-
-
+ private boolean csvExport = false;
- public static final String ZIP = "zip";
+ private boolean csvNameExport = false;
- private static boolean csvExport = false;
-
- private static boolean csvNameExport = false;
+ private boolean csvPrintExport = false;
- private static String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT";
+ private boolean cdmLightExport = false;
- private static boolean csvPrintExport = false;
+ private boolean colDPExport = false;
+ private boolean dwcaExport = false;
+ private boolean wfoBackboneExport = false;
- private DirectoryDialog folderDialog;
- private Text text_exportFileName;
+ private DirectoryDialog folderDialog;
+ private Text text_exportFileName;
- private Text text_folder;
+ private Text text_folder;
- private final String type;
+ private final String type;
- private final String extension;
+ private final String extension;
private Combo classificationSelectionCombo;
-
+
private List- * Jaxb - *
- * - * @return a - * {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} - * object. - */ - public static ExportToFileDestinationWizardPage Jaxb() { - return new ExportToFileDestinationWizardPage( - JAXB_EXPORT, - "jaxb", - "JAXB Export", - "Exports the contents of the currently selected database into the cdm jaxb format.", - XML); - } - - /** - *- * Tcs - *
- * - * @return a - * {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} - * object. - */ - public static ExportToFileDestinationWizardPage Tcs() { - return new ExportToFileDestinationWizardPage( - TCS_EXPORT, - "tcs", - "Tcs Export", - "Export the contents of the currently selected database into TCS format.", - XML); - } - - /** - *- * Sdd - *
- * - * @return a - * {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} - * object. - */ - public static ExportToFileDestinationWizardPage Sdd() { - return new ExportToFileDestinationWizardPage( - SDD_EXPORT, - "sdd", - "Sdd Export", - "Export the contents of the currently selected database into SDD format.", - XML); - } - - /** - * @return - */ - public static ExportToFileDestinationWizardPage Dwca() { - return new ExportToFileDestinationWizardPage( - DWCA_EXPORT, - "dwca", - "DwC-Archive Export", - "Export the contents of the currently selected database into Darwin Core Archive format.", - ZIP); - } + private ExportConfiguratorBase, ?, ?> configurator; + private Button checkUseSelectedTaxonNode; + + private Button checkUseSelectedClassification; + private Button checkUseAllClassification; + + private Button checkExportUnpublished; + private Button checkExportFactualData; + private Button checkExportUnpublishedFactualData; + + private Combo orderSelectionCombo; + + private Text text_familyString; + + protected ExportToFileDestinationWizardPage(String pageName, String type, String title, String description, + String extension, ExportConfiguratorBase, ?, ?> configurator) { + super(pageName); + this.configurator = configurator; + this.type = type; + switch (type) { + case CSV_EXPORT: + csvExport = true; + break; + case CSV_NAME_EXPORT: + csvNameExport = true; + break; + case CDM_LIGHT_EXPORT: + cdmLightExport = true; + break; + case COL_DP_EXPORT: + colDPExport = true; + break; + case CSV_PRINT_EXPORT: + csvPrintExport = true; + break; + case DWCA_EXPORT: + dwcaExport = true; + break; + case WFO_BACKBONE_EXPORT: + wfoBackboneExport = true; + break; + default: + throw new RuntimeException("Export type not yet handeled: " + type); + } + this.extension = extension; + this.setTitle(title); + this.setDescription(description); + } + public static ExportToFileDestinationWizardPage Jaxb(JaxbExportConfigurator configurator) { + return new ExportToFileDestinationWizardPage(JAXB_EXPORT, "jaxb", "JAXB Export", + "Exports the content of the currently selected database into the cdm jaxb format.", XML, configurator); + } + public static ExportToFileDestinationWizardPage Tcs(TcsXmlExportConfigurator config) { + return new ExportToFileDestinationWizardPage(TCS_EXPORT, "tcs", "Tcs Export", + "Export the content of the currently selected database into TCS format.", XML, config); + } + + public static ExportToFileDestinationWizardPage Sdd(SDDExportConfigurator config) { + return new ExportToFileDestinationWizardPage(SDD_EXPORT, "sdd", "Sdd Export", + "Export the content of the currently selected database into SDD format.", XML, config); + } + + public static ExportToFileDestinationWizardPage Dwca(DwcaTaxExportConfigurator config) { + return new ExportToFileDestinationWizardPage(DWCA_EXPORT, DWCA_EXPORT, "DwC-Archive Export", + "Export the content of the currently selected database into Darwin Core Archive format.", ZIP, config); + } + public static ExportToFileDestinationWizardPage WFO(WfoBackboneExportConfigurator config) { + return new ExportToFileDestinationWizardPage(WFO_BACKBONE_EXPORT, WFO_BACKBONE_EXPORT, "WFO Backbone Export", + "Export the content of the currently selected database into WFO Backbone format." + , ZIP, config); + } + + public static ExportToFileDestinationWizardPage CdmLight(CdmLightExportConfigurator config) { + + return new ExportToFileDestinationWizardPage(CDM_LIGHT_EXPORT, CDM_LIGHT_EXPORT, "CDM Light Export (csv)", + "Export the content of the currently selected database into the CDM light (csv) format.", CSV, config); + } + + public static ExportToFileDestinationWizardPage ColDp(ColDpExportConfigurator config) { + + return new ExportToFileDestinationWizardPage(COL_DP_EXPORT, COL_DP_EXPORT, "Col DP Export (zip)", + "Export the content of the currently selected database into the Catalogue of Life Data Package (Col DP) format.", ZIP, config); + } + + public static ExportToFileDestinationWizardPage Csv(CsvDemoExportConfigurator config) { + + return new ExportToFileDestinationWizardPage(CSV_EXPORT, CSV_EXPORT, "CSV Export", + "Export the content of the currently selected database into Comma Separated Value format.", CSV, + config); + } + + public static ExportToFileDestinationWizardPage CsvNames(CsvNameExportConfigurator config) { + + return new ExportToFileDestinationWizardPage(CSV_NAME_EXPORT, CSV_NAME_EXPORT, "CSV Name Export", + "Export the names of the currently selected database into Semicolon Separated Value format.", CSV, + config); + } + + public static ExportToFileDestinationWizardPage CsvPrint(CsvNameExportConfigurator config) { + + return new ExportToFileDestinationWizardPage(CSV_PRINT_EXPORT, CSV_NAME_EXPORT, "CSV Print Export", + "Export the content of the currently selected database into Semicolon Separated Value format.", CSV, + config); + } + + /** {@inheritDoc} */ + @Override + public void createControl(Composite parent) { + + setPageComplete(false); + + Composite composite = new Composite(parent, SWT.NONE); + GridLayout gridLayout = new GridLayout(); + + gridLayout.numColumns = 2; + TaxonNode node = null; + + composite.setLayout(gridLayout); + if (cdmLightExport || dwcaExport || colDPExport) { + checkExportUnpublished = new Button(composite, SWT.CHECK); + checkExportUnpublished.setText("Export unpublished taxa"); + Label emptyLabel = new Label(composite, SWT.NONE); + checkExportFactualData = new Button(composite, SWT.CHECK); + checkExportFactualData.setText("Export factual data"); + checkExportFactualData.setSelection(true); + checkExportFactualData.addListener(SWT.Selection, e -> { + Button b = (Button) e.widget; + GridData data = (GridData) checkExportUnpublishedFactualData.getLayoutData(); + data.exclude = b.getSelection(); + checkExportUnpublishedFactualData.setEnabled(data.exclude); + }); + if (cdmLightExport || colDPExport) { + emptyLabel = new Label(composite, SWT.NONE); + + checkExportUnpublishedFactualData = new Button(composite, SWT.CHECK); + checkExportUnpublishedFactualData.setText("Export unpublished factual data"); + checkExportUnpublishedFactualData.setSelection(false); + GridData gridData = new GridData(); + gridData.horizontalIndent = 20; + checkExportUnpublishedFactualData.setLayoutData(gridData); + } + + @SuppressWarnings("unused") + Label nope = new Label(composite, SWT.NONE); + + Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); + GridData gridDataSep = new GridData(GridData.FILL_HORIZONTAL); + gridDataSep.horizontalSpan = 2; + separator.setLayoutData(gridDataSep); + } + if (classifications == null && !wfoBackboneExport) { + classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null); + Collections.sort(classifications, (o1, o2) -> { + if (o1.equals(o2)) { + return 0; + } + int result = o1.getTitleCache().compareTo(o2.getTitleCache()); + if (result == 0) { + return o1.getUuid().compareTo(o2.getUuid()); + } + return result; + }); + if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()) { + selectedClassification = CdmStore.getService(IClassificationService.class) + .load(configurator.getTaxonNodeFilter().getClassificationFilter().get(0).getUuid()); + } else { + + selectedClassification = classifications.iterator().next(); + } + } + + if (csvExport || csvPrintExport || cdmLightExport || csvNameExport || dwcaExport || colDPExport || wfoBackboneExport) { + + // Label comboBoxLabel = new Label(composite, SWT.NONE); + // comboBoxLabel.setText("Classification"); + Composite selectNodeOrClassification = new Composite(composite, SWT.NONE); + GridLayout grid = new GridLayout(); + grid.numColumns = 1; + selectNodeOrClassification.setLayout(grid); + if ((cdmLightExport || dwcaExport || colDPExport || wfoBackboneExport) && !configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()) { + if (!wfoBackboneExport) { + checkUseSelectedTaxonNode = new Button(selectNodeOrClassification, SWT.RADIO); + } + String taxonStr = ""; + int count = configurator.getTaxonNodeFilter().getSubtreeFilter().size(); + List- * getExportFileName - *
- * - * @return the exportFileName - */ - public String getExportFileName() { - return text_exportFileName.getText(); - } - - /** - *- * getFolderText - *
- * - * @return the folderText - */ - public String getFolderText() { - return text_folder.getText(); - } - - private Control createClassificationSelectionCombo(Composite parent){ -// classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null); - - Composite classificationSelection = new Composite(parent, SWT.NULL); - classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); - - GridLayout layout = new GridLayout(); - classificationSelection.setLayout(layout); - - Label label = new Label(classificationSelection, SWT.NULL); - // TODO not working is not really true but leave it here to remind everyone that this is under construction - label.setText("Select Classification"); - classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY); - classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true)); - - for(Classification tree : classifications){ - classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree)); - - } - - classificationSelectionCombo.select(classifications.indexOf(selectedClassification)); - - // TODO remember last selection - classificationSelectionCombo.addSelectionListener(this); - - - - return classificationSelection; - } - - public Combo getCombo(){ - return classificationSelectionCombo; - } - - @Override - public void widgetSelected(SelectionEvent e) { - selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex()); - - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - //not needed here - - } - - public UUID getSelectedClassificationUUID() { - - return selectedClassification.getUuid(); - } + public boolean isExportFactualData() { + return checkExportFactualData.getSelection(); + } + + public boolean isExportUnpublishedFactualData() { + return checkExportUnpublishedFactualData.getSelection(); + } + + private void createClassificationSelectionCombo(Composite parent) { + + GridData gridData = new GridData(); + gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); + gridData.horizontalIndent = 5; + + classificationSelectionCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY); + classificationSelectionCombo.setLayoutData(gridData); + for (Classification tree : classifications) { + classificationSelectionCombo.add(tree.getTitleCache(), classifications.indexOf(tree)); + } + classificationSelectionCombo.select(classifications.indexOf(selectedClassification)); + + // TODO remember last selection + classificationSelectionCombo.addSelectionListener(this); + + } + + public Combo getCombo() { + return classificationSelectionCombo; + } + + @Override + public void widgetSelected(SelectionEvent e) { + selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex()); + } + + public Classification getSelectedClassification() { + return selectedClassification; + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + // not needed here + } + + public UUID getSelectedClassificationUUID() { + return selectedClassification.getUuid(); + } + + public boolean getCheckUseSelectedTaxonNode() { + if (checkUseSelectedTaxonNode == null) { + return false; + } + return checkUseSelectedTaxonNode.getSelection(); + } + + public boolean getCheckUseAllClassifications() { + if (checkUseAllClassification == null) { + return false; + } + return checkUseAllClassification.getSelection(); + } + + public Set