Added DwC-A export wizard. Configuration options are now read from l10n properties...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / wizard / ExportToFileDestinationWizardPage.java
index 07286e9124a29f742e3d5e581c1eeb4aac953bc1..4628b2c144508bb802836d284ab9732585783de7 100644 (file)
@@ -1,12 +1,12 @@
 // $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
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * 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.wizard;
 
@@ -28,162 +28,222 @@ import org.eclipse.swt.widgets.Text;
 import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
 
 /**
- * <p>ExportToFileDestinationWizardPage class.</p>
- *
+ * <p>
+ * ExportToFileDestinationWizardPage class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created 15.06.2009
  * @version 1.0
  */
-public class ExportToFileDestinationWizardPage extends WizardPage{
+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 SDD_EXPORT = "SDD_EXPORT";
+
+       public static final String DWCA_EXPORT = "DWCA_EXPORT";
+
+       public static final String XML = "xml";
+
+       public static final String ZIP = "zip";
+
        private DirectoryDialog folderDialog;
        private Text text_exportFileName;
 
        private Text text_folder;
 
-       private String type;
-       
-       
+       private final String type;
+
+       private final String extension;
+
        /**
         * @param pageName
         * @param selection
         */
-       private ExportToFileDestinationWizardPage(String pageName, String type, String title, String description) {
+       private ExportToFileDestinationWizardPage(String pageName, String type,
+                       String title, String description, String extension) {
                super(pageName);
-               
+
                this.type = type;
-               
+               this.extension = extension;
                this.setTitle(title);
-               this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
+               this.setDescription(description);
        }
-       
+
        /**
-        * <p>Jaxb</p>
-        *
-        * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object.
+        * <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.");
+       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.
+        * <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.");
+       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.
+        * <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.");
+       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);
+       }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+        * .Composite)
         */
        /** {@inheritDoc} */
        public void createControl(Composite parent) {
-               
+
                setPageComplete(false);
-               
+
                Composite composite = new Composite(parent, SWT.NONE);
                GridLayout gridLayout = new GridLayout();
                gridLayout.numColumns = 3;
                composite.setLayout(gridLayout);
-               
+
                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));
-               
-               
+               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));
+               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)
+
+               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
+                               if (path != null) { // a folder was selected
                                        text_folder.setText(path);
                                        setPageComplete(true);
                                }
                        }
                });
-               
+
                // make the composite the wizard pages control
                setControl(composite);
        }
-       
-       private String generateFilename(){
+
+       private String generateFilename() {
                StringBuffer buffer = new StringBuffer();
-               
+
                Calendar cal = Calendar.getInstance();
-           SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
+               SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
                buffer.append(sdf.format(cal.getTime()));
-               
+
                buffer.append("-");
-               
+
                buffer.append(type + "_export-");
                buffer.append(CdmDataSourceRepository.getCurrentDataSource());
-                               
-               buffer.append(".xml");
-               
+
+               buffer.append(".");
+               buffer.append(extension);
+
                return buffer.toString();
        }
 
-
        /**
-        * <p>getExportFileName</p>
-        *
+        * <p>
+        * getExportFileName
+        * </p>
+        * 
         * @return the exportFileName
         */
        public String getExportFileName() {
                return text_exportFileName.getText();
        }
 
-
        /**
-        * <p>getFolderText</p>
-        *
+        * <p>
+        * getFolderText
+        * </p>
+        * 
         * @return the folderText
         */
        public String getFolderText() {
                return text_folder.getText();
        }
+
 }