ref #10448: add base url text field
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / ExportToFileDestinationWizardPage.java
index a35e64490f9a9f6d3c6879b9d90a08572fc013a8..e1c63773d41c724e703d868747783d2e3814627d 100644 (file)
-// $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.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;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 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.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;
 
 /**
- * <p>
  * ExportToFileDestinationWizardPage class.
- * </p>
  *
  * @author n.hoffmann
  * @created 15.06.2009
- * @version 1.0
  */
-public class ExportToFileDestinationWizardPage extends WizardPage {
-
-       /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
-       public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
-
-       /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
-       public static final String JAXB_EXPORT = "JAXB_EXPORT";
-
-       /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
-       public static final String TCS_EXPORT = "TCS_EXPORT";
-
-       /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
-       public static final String SDD_EXPORT = "SDD_EXPORT";
-
-       public static final String DWCA_EXPORT = "DWCA_EXPORT";
-
-       public static final String CSV_EXPORT = "CSV_EXPORT";
-       public static final String CSV_NAME_EXPORT = "CSV_NAME_EXPORT";
-
-       public static final String XML = "xml";
-
-       public static final String CSV = "csv";
-       
-       
-
-       public static final String ZIP = "zip";
-
-    private static boolean csvExport = false;
-    
-    private static boolean csvNameExport = false;
-
-       private static String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT";
-
-       private static boolean csvPrintExport = false;
-
-       private DirectoryDialog folderDialog;
-       private Text text_exportFileName;
-
-       private Text text_folder;
-
-       private final String type;
-
-       private final String extension;
-
-    private Combo comboBox;
-
-       /**
-        * @param pageName
-        * @param selection
-        */
-       protected ExportToFileDestinationWizardPage(String pageName, String type,
-                       String title, String description, String extension) {
-               super(pageName);
-
-               this.type = type;
-               this.extension = extension;
-               this.setTitle(title);
-               this.setDescription(description);
-       }
-
-       /**
-        * <p>
-        * Jaxb
-        * </p>
-        *
-        * @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);
-       }
-
-       /**
-        * <p>
-        * Tcs
-        * </p>
-        *
-        * @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);
-       }
-
-       /**
-        * <p>
-        * Sdd
-        * </p>
-        *
-        * @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);
-       }
+public class ExportToFileDestinationWizardPage extends WizardPage implements SelectionListener {
 
+    /** Constant <code>DATE_FORMAT_NOW="yyyyMMddHHmm"</code> */
+    public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm";
 
+    /** Constant <code>JAXB_EXPORT="JAXB_EXPORT"</code> */
+    public static final String JAXB_EXPORT = "JAXB_EXPORT";
+
+    /** Constant <code>TCS_EXPORT="TCS_EXPORT"</code> */
+    public static final String TCS_EXPORT = "TCS_EXPORT";
+
+    /** Constant <code>SDD_EXPORT="SDD_EXPORT"</code> */
+    public static final String SDD_EXPORT = "SDD_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 = "csv";
+
+    public static final String ZIP = "zip";
+
+    private boolean csvExport = false;
+
+    private boolean csvNameExport = false;
+
+    private boolean csvPrintExport = false;
+
+    private boolean cdmLightExport = false;
+
+    private boolean colDPExport = false;
+    private boolean dwcaExport = false;
+    private boolean wfoBackboneExport = false;
+
+    private DirectoryDialog folderDialog;
+    private Text text_exportFileName;
+
+    private Text text_folder;
+
+    private final String type;
+
+    private final String extension;
+
+    private Combo classificationSelectionCombo;
+
+    private List<Classification> classifications;
+
+    private Classification selectedClassification;
+
+    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;
+
+    private Text text_baseUrl;
+
+    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<TaxonNode> selectedNodes = new ArrayList<>();
+                for (LogicFilter<TaxonNode> filter : configurator.getTaxonNodeFilter().getSubtreeFilter()) {
+                    node = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(filter.getUuid());
+                    selectedNodes.add(node);
+                    count--;
+                    if (node.hasTaxon()) {
+                        taxonStr += node.getTaxon().getName().getTitleCache();
+                        if (count > 0) {
+                            taxonStr += ", ";
+                        }
+                    }
+                }
+                if (!wfoBackboneExport) {
+                    checkUseSelectedTaxonNode.setText("Export all selected subtree(s) (" + taxonStr + ")");
+                    checkUseSelectedTaxonNode.addListener(SWT.Selection, e -> {
+                        Button b = (Button) e.widget;
+                        GridData data = (GridData) classificationSelectionCombo.getLayoutData();
+                        data.exclude = b.getSelection();
+                        if (classificationSelectionCombo != null) {
+                            classificationSelectionCombo.setEnabled(!data.exclude);
+                        }
+                    });
+                    checkUseSelectedTaxonNode.setSelection(true);
+                }else {
+                    Composite wfoComp = new Composite(selectNodeOrClassification, SWT.NONE);
+                    grid = new GridLayout();
+                    grid.numColumns = 2;
+                    wfoComp.setLayout(grid);
+
+                    Label label = new Label(wfoComp, SWT.NONE);
+                    label.setText("Export all selected subtree(s) (" + taxonStr + ")");
+                    GridData gridData = new GridData();
+                    gridData.horizontalSpan = 2;
+                    gridData.grabExcessHorizontalSpace = true;
+                    label.setLayoutData(gridData);
+
+                    Label familyString = new Label(wfoComp, SWT.NONE);
+                    familyString.setText("Family");
+                    text_familyString = new Text(wfoComp, SWT.BORDER);
+                    text_familyString.setText(generateFamilyName(selectedNodes));
+                    text_familyString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+                    Label baseUrlString = new Label(wfoComp, SWT.NONE);
+                    baseUrlString.setText("Base url");
+                    text_baseUrl = new Text(wfoComp, SWT.BORDER);
+                    text_baseUrl.setText("");
+                    text_baseUrl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+                    text_baseUrl.setToolTipText("The base url without /cdm_dataportal/taxon/{uuid}  e.g. https://portal.cybertaxonomy.org/salvador");
+
+
+
+                }
+            }else if (wfoBackboneExport) {
+
+                Label label = new Label(composite, SWT.NONE);
+                label.setText("WFO Backbone export is only available for subtrees, not for classifications");
+                GridData gridData = new GridData();
+                gridData.horizontalSpan = 2;
+                gridData.grabExcessHorizontalSpace = true;
+                label.setLayoutData(gridData);
+                label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+            }
+
+            if (cdmLightExport || dwcaExport || colDPExport ) {
+                if (dwcaExport) {
+                    checkUseAllClassification = new Button(selectNodeOrClassification, SWT.RADIO);
+                    checkUseAllClassification.setText("Export all classifications");
+                    checkUseAllClassification.addListener(SWT.Selection, new Listener() {
+                        @Override
+                        public void handleEvent(Event e) {
+                            Button b = (Button) e.widget;
+                            GridData data = (GridData) classificationSelectionCombo.getLayoutData();
+                            data.exclude = b.getSelection();
+                            classificationSelectionCombo.setEnabled(!data.exclude);
+
+                        }
+                    });
+                }
+                checkUseSelectedClassification = new Button(selectNodeOrClassification, SWT.RADIO);
+                checkUseSelectedClassification.setText("Export selected classification");
+                checkUseSelectedClassification.addListener(SWT.Selection, e -> {
+                    Button b = (Button) e.widget;
+                    GridData data = (GridData) classificationSelectionCombo.getLayoutData();
+                    data.exclude = b.getSelection();
+                    classificationSelectionCombo.setEnabled(data.exclude);
+                });
+            }
+
+            if (node != null && !wfoBackboneExport) {
+                selectedClassification = node.getClassification();
+            }
+            if (!wfoBackboneExport) {
+                createClassificationSelectionCombo(selectNodeOrClassification);
+            }
+            if (cdmLightExport) {
+                Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+                GridData gridDataSep = new GridData();
+                gridDataSep = new GridData(GridData.BEGINNING, GridData.CENTER, true, true);
+                gridDataSep.horizontalSpan = 2;
+                separator.setLayoutData(gridDataSep);
+
+                Composite comp = new Composite(composite, SWT.NONE);
+
+                GridData gridData = new GridData();
+                gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
+                gridData.horizontalSpan = 2;
+                comp.setLayoutData(gridData);
+
+                Label label = new Label(comp, SWT.NONE);
+                label.setText("Sorting of taxa");
+
+                orderSelectionCombo = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
+
+                GridLayoutFactory.fillDefaults().applyTo(comp);
+                for (NavigatorOrderEnum display : NavigatorOrderEnum.values()) {
+                    orderSelectionCombo.add(display.getLabel());
+                }
+
+                int index = 0;
+                if (PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()) != null) {
+                    NavigatorOrderEnum orderInNavigator = NavigatorOrderEnum
+                            .valueOf(PreferencesUtil.getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
+
+                    for (String itemLabel : orderSelectionCombo.getItems()) {
+                        if (itemLabel.equalsIgnoreCase(orderInNavigator.getLabel())) {
+                            orderSelectionCombo.select(index);
+                            setComparatorToConfig();
+                            break;
+                        }
+                        index++;
+                    }
+                }
+
+                orderSelectionCombo.addSelectionListener(new SelectionListener() {
+
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        setComparatorToConfig();
+                    }
+
+                    @Override
+                    public void widgetDefaultSelected(SelectionEvent e) {
+                        // TODO Auto-generated method stub
+                    }
+                });
+            }
+
+            if (classificationSelectionCombo != null) {
+                if (checkUseSelectedTaxonNode != null) {
+                    if (checkUseSelectedTaxonNode.getSelection()) {
+                        classificationSelectionCombo.setEnabled(false);
+                    }
+                } else {
+                    classificationSelectionCombo.setEnabled(true);
+                    classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+                }
+            }
+            Label separator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+            GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+            gridData.horizontalSpan = 2;
+            separator.setLayoutData(gridData);
+
+        }
+
+        Label folderLabel = new Label(composite, SWT.NONE);
+        folderLabel.setText("Select Folder for exported files");
+        folderLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+        folderDialog = new DirectoryDialog(parent.getShell());
+        String exportFolder = PreferencesUtil.getStringValue(EXPORT_FOLDER, true);
+        folderDialog.setFilterPath(exportFolder);
+
+        text_folder = new Text(composite, SWT.BORDER);
+        text_folder.setEditable(false);
+        text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        if (exportFolder != null) {
+            text_folder.setText(exportFolder);
+            setPageComplete(true);
+        }
+
+        Button button = new Button(composite, SWT.PUSH);
+        button.setText("Browse...");
+
+        button.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                super.widgetSelected(e);
+
+                String path = folderDialog.open();
+                if (path != null) { // a folder was selected
+                    text_folder.setText(path);
+                    PreferencesUtil.setStringValue(EXPORT_FOLDER, path);
+                    setPageComplete(true);
+                }
+            }
+        });
+        if (!cdmLightExport) {
+
+            Label fileLabel = new Label(composite, SWT.NONE);
+            fileLabel.setText("Filename");
+            text_exportFileName = new Text(composite, SWT.BORDER);
+            text_exportFileName.setText(generateFilename());
+            text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+        }
+
+        // make the composite the wizard pages control
+        setControl(composite);
+    }
 
     /**
      * @return
      */
-    public static ExportToFileDestinationWizardPage Csv() {
-        csvExport = true;
-        return new ExportToFileDestinationWizardPage(
-                CSV_EXPORT,
-                "csv",
-                "CSV Export",
-                "Export the contents of the currently selected database into Comma Separated Value format.",
-                CSV);
-    }
-    
-    /**
-     * @return
-     */
-    public static ExportToFileDestinationWizardPage CsvNames() {
-       csvNameExport = true;
-        return new ExportToFileDestinationWizardPage(
-                CSV_NAME_EXPORT,
-                "csvNames",
-                "CSV Name Export",
-                "Export the names of the currently selected database into Semicolon Separated Value format.",
-                CSV);
-    }
-    
-    /**
-     * @return
-     */
-    public static ExportToFileDestinationWizardPage CsvPrint() {
-       csvPrintExport  = true;
-        return new ExportToFileDestinationWizardPage(
-                CSV_PRINT_EXPORT,
-                "csvPrint",
-                "CSV Print Export",
-                "Export the content of the currently selected database into Semicolon Separated Value format.",
-                CSV);
-    }
-
-       /*
-        * (non-Javadoc)
-        *
-        * @see
-        * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
-        * .Composite)
-        */
-       /** {@inheritDoc} */
-       @Override
-    public void createControl(Composite parent) {
+    private String generateFamilyName(List<TaxonNode> nodes) {
+        if (nodes.size() == 1){
+            TaxonNode node = nodes.get(0);
+            if (node.getTaxon() != null) {
+                if(node.getTaxon().getName().getRank().getOrderIndex() >= Rank.FAMILY().getOrderIndex()) {
+                    TaxonNode familyNode = node.getAncestorOfRank(Rank.FAMILY());
+                    if (familyNode != null && familyNode.getTaxon() != null) {
+                        return familyNode.getTaxon().getName().getNameCache();
+                    }
+
+                }
+            }
+
+        }
+        return "";
+    }
+
+    protected void setComparatorToConfig() {
+        if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.NaturalOrder.getLabel())) {
+            ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoNaturalComparator());
+        } else if (orderSelectionCombo.getText().equals(NavigatorOrderEnum.AlphabeticalOrder.getLabel())) {
+            ((CdmLightExportConfigurator) configurator).setTaxonNodeComparator(new TaxonNodeDtoByNameComparator());
+        } else {
+            ((CdmLightExportConfigurator) configurator)
+                    .setTaxonNodeComparator(new TaxonNodeDtoByRankAndNameComparator());
+        }
+    }
+
+    protected String generateFilename() {
+        StringBuffer buffer = new StringBuffer();
+
+        Calendar cal = Calendar.getInstance();
+        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
+        buffer.append(sdf.format(cal.getTime()));
+
+        buffer.append("-");
+        buffer.append(type + "_");
+
+        String source = ((ICdmRemoteSource) CdmStore.getActiveCdmSource()).toString();
+        source = source.substring(source.indexOf("/") + 1);
+        buffer.append(source);
+
+        buffer.append(".");
+        buffer.append(extension);
 
-               setPageComplete(false);
-
-               Composite composite = new Composite(parent, SWT.NONE);
-               GridLayout gridLayout = new GridLayout();
-               gridLayout.numColumns = 3;
-               composite.setLayout(gridLayout);
-
-
-               if(csvExport){
-                   Label comboBoxLabel = new Label(composite, SWT.NONE);
-                   comboBoxLabel.setText("Classification");
-                   Combo comboBox = addComboBox(composite);
-                   comboBox.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
-                               true, false, 2, 1));
-               }
-               
-               
-
-
-               Label fileLabel = new Label(composite, SWT.NONE);
-               fileLabel.setText("File");
-
-               text_exportFileName = new Text(composite, SWT.BORDER);
-               text_exportFileName.setText(generateFilename());
-               text_exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
-                               true, false, 2, 1));
-
-               Label folderLabel = new Label(composite, SWT.NONE);
-               folderLabel.setText("Folder");
-
-               folderDialog = new DirectoryDialog(parent.getShell());
-
-               text_folder = new Text(composite, SWT.BORDER);
-               text_folder.setEditable(false);
-               text_folder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
-                               false));
-
-               Button button = new Button(composite, SWT.PUSH);
-               button.setText("Browse...");
-
-               button.addSelectionListener(new SelectionAdapter() {
-                       /*
-                        * (non-Javadoc)
-                        *
-                        * @see
-                        * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
-                        * .swt.events.SelectionEvent)
-                        */
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                               super.widgetSelected(e);
-                               String path = folderDialog.open();
-                               if (path != null) { // a folder was selected
-                                       text_folder.setText(path);
-                                       setPageComplete(true);
-                               }
-                       }
-               });
-
-               // make the composite the wizard pages control
-               setControl(composite);
-       }
-
-       protected String generateFilename() {
-               StringBuffer buffer = new StringBuffer();
-
-               Calendar cal = Calendar.getInstance();
-               SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
-               buffer.append(sdf.format(cal.getTime()));
-
-               buffer.append("-");
-
-               buffer.append(type + "_export-");
-               try {
-                       buffer.append(CdmDataSourceRepository.getCurrentCdmSource());
-               } catch (CdmRemoteSourceException e) {
-                       buffer.append("Unknown");
-               }
-
-               buffer.append(".");
-               buffer.append(extension);
-
-               return buffer.toString();
-       }
-
-       /**
-        * <p>
-        * getExportFileName
-        * </p>
-        *
-        * @return the exportFileName
-        */
-       public String getExportFileName() {
-               return text_exportFileName.getText();
-       }
-
-       /**
-        * <p>
-        * getFolderText
-        * </p>
-        *
-        * @return the folderText
-        */
-       public String getFolderText() {
-               return text_folder.getText();
-       }
-
-       private Combo addComboBox(Composite composite){
-
-           comboBox = new Combo(composite, SWT.DROP_DOWN);
-           comboBox.setText("Choose Classification");
-
-           final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null);
-
-           for(Classification c : listClassifications){
-               comboBox.add(c.getTitleCache());
-           }
-
-           return comboBox;
-       }
-
-       public Combo getCombo(){
-           return comboBox;
-       }
+        return buffer.toString();
+    }
+
+    public String getExportFileName() {
+        return text_exportFileName.getText();
+    }
+
+    public String getFamilyString() {
+        return text_familyString.getText();
+    }
+
+    public String getFolderText() {
+        return text_folder.getText();
+    }
 
+    public String get_baseUrl() {
+        return text_baseUrl.getText();
+    }
+
+    public Text getFolderComposite() {
+        return text_folder;
+    }
+
+    public boolean isExportUnpublishedData() {
+        return checkExportUnpublished.getSelection();
+    }
+
+    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<UUID> getAllClassificationUuids() {
+        Set<UUID> allClassificationUuids = new HashSet<>();
+        for (Classification classification : this.classifications) {
+            allClassificationUuids.add(classification.getUuid());
+        }
+        return allClassificationUuids;
+    }
+
+    @Override
+    public boolean canFlipToNextPage() {
+        return getFolderText() != null && !(wfoBackboneExport && configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty());
+    }
 }