Added DwC-A export wizard. Configuration options are now read from l10n properties...
authorn.hoffmann <n.hoffmann@localhost>
Mon, 2 May 2011 16:23:46 +0000 (16:23 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 2 May 2011 16:23:46 +0000 (16:23 +0000)
.gitattributes
eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java

index 3173a420e71a3dfc1d39f93ccdb2c34be5076036..827757e16d9fd3b9110163b50f45759b7632ca16 100644 (file)
@@ -753,6 +753,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/Abst
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractImportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelExportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/BerlinModelImportWizard.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/EndnoteImportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExcelNormalExplicitTaxaImportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java -text
index 5f09991ead5d7630e987cffe600065bbf9d78a48..6e3ec3cff1aa359f09b3177a8872a440dc8f35f7 100644 (file)
@@ -279,6 +279,7 @@ Export-Package: com.google.api,
    org.jdom,
    eu.etaxonomy.cdm.model.agent,
    eu.etaxonomy.cdm.model.common",
+ eu.etaxonomy.cdm.io.dwca.out,
  eu.etaxonomy.cdm.io.excel.common;
   uses:="eu.etaxonomy.cdm.model.reference,
    eu.etaxonomy.cdm.api.application,
index 35589febe8b3a7be2d0e0c3117999c59c5ec4c70..621049e7ccb791184b17fcf5e8008d28d0e39db6 100644 (file)
             id="eu.etaxonomy.taxeditor.io.export.sdd"
             name="SDD">
       </wizard>
+      <wizard
+            category="eu.etaxonomy.taxeditor.export.category.cdm"
+            class="eu.etaxonomy.taxeditor.io.wizard.DarwinCoreArchiveExportWizard"
+            id="eu.etaxonomy.taxeditor.io.export.dwca"
+            name="DwC-A">
+      </wizard>
    </extension>
    <extension
          point="org.eclipse.ui.newWizards">
index 1c8ae90b2c610557543d9613beca9ed22cb5220d..d6e798f6867c84e286c7bb3dbe8b68d929511408 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPart;
 
 import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
@@ -121,14 +122,20 @@ public class ExportManager extends AbstractIOManager<IExportConfigurator> {
 
                                        @Override
                                        public void run() {
-                                               // terminate any open transactions
-                                               IConversationEnabled activePart = (IConversationEnabled) StoreUtil
-                                                               .getActivePage().getActivePart();
-                                               // restarting transaction and committing it to trigger
-                                               // change listener
-                                               // TODO verify correct behaviour
-                                               activePart.getConversationHolder().startTransaction();
-                                               activePart.getConversationHolder().commit();
+                                               IWorkbenchPart activePart = StoreUtil.getActivePage()
+                                                               .getActivePart();
+                                               if (activePart instanceof IConversationEnabled) {
+                                                       // terminate any open transactions
+                                                       IConversationEnabled conversationEnabled = (IConversationEnabled) activePart;
+                                                       // restarting transaction and committing it to
+                                                       // trigger
+                                                       // change listener
+                                                       // TODO verify correct behaviour
+                                                       conversationEnabled.getConversationHolder()
+                                                                       .startTransaction();
+                                                       conversationEnabled.getConversationHolder()
+                                                                       .commit();
+                                               }
                                        }
                                });
                                monitor.worked(10);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java
new file mode 100644 (file)
index 0000000..a7691d9
--- /dev/null
@@ -0,0 +1,83 @@
+// $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.
+ */
+
+package eu.etaxonomy.taxeditor.io.wizard;
+
+import java.io.File;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.dwca.out.DwcaTaxExportConfigurator;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author n.hoffmann
+ * @created May 2, 2011
+ * @version 1.0
+ */
+public class DarwinCoreArchiveExportWizard extends
+               AbstractExportWizard<DwcaTaxExportConfigurator> {
+
+       private DwcaTaxExportConfigurator configurator;
+       private ExportToFileDestinationWizardPage page;
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+        * org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       @Override
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               configurator = DwcaTaxExportConfigurator.NewInstance(null, null, null);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#getConfigurator()
+        */
+       @Override
+       public DwcaTaxExportConfigurator getConfigurator() {
+               return configurator;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               String urlString = page.getFolderText() + File.separator
+                               + page.getExportFileName();
+
+               configurator.setDestination(new File(urlString));
+
+               CdmStore.getExportManager().run(configurator);
+
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see eu.etaxonomy.taxeditor.io.wizard.AbstractExportWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+
+               page = ExportToFileDestinationWizardPage.Dwca();
+               addPage(page);
+       }
+}
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();
        }
+
 }
index a7caebd64f65d99ce474324e16001db21bd5b6ac..e796f54827ce557af357f7dd4f1cb0ea188ab40e 100644 (file)
@@ -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
-* 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;
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
@@ -28,182 +29,236 @@ import eu.etaxonomy.cdm.io.common.IIoConfigurator;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
- * <p>GenericConfiguratorWizardPage class.</p>
- *
+ * <p>
+ * GenericConfiguratorWizardPage class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created 23.06.2009
  * @version 1.0
  */
 public class GenericConfiguratorWizardPage extends WizardPage {
-       
-       private IIoConfigurator configurator;
+
+       private final IIoConfigurator configurator;
+       private final ResourceBundle resourceBundle;
 
        /**
         * @param pageName
-        * @param configurator 
+        * @param configurator
         */
-       private GenericConfiguratorWizardPage(String pageName, IIoConfigurator configurator, String title, String description) {
+       private GenericConfiguratorWizardPage(String pageName,
+                       IIoConfigurator configurator, String title, String description) {
                super(pageName);
                this.setTitle(title);
-               
+
                this.setDescription(description);
-               
+
                this.configurator = configurator;
+               
+               
+               resourceBundle = getResourceBundle(configurator);
+       }
+
+       private ResourceBundle getResourceBundle(IIoConfigurator configurator){
+               try{
+                       return ResourceBundle.getBundle(configurator.getClass().getName());
+               }catch(MissingResourceException e){
+                       return null;
+               }
        }
        
        /**
-        * <p>Import</p>
-        *
-        * @param pageName a {@link java.lang.String} object.
-        * @param configurator a {@link eu.etaxonomy.cdm.io.common.IIoConfigurator} object.
-        * @return a {@link eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage} object.
+        * <p>
+        * Import
+        * </p>
+        * 
+        * @param pageName
+        *            a {@link java.lang.String} object.
+        * @param configurator
+        *            a {@link eu.etaxonomy.cdm.io.common.IIoConfigurator} object.
+        * @return a
+        *         {@link eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage}
+        *         object.
         */
-       public static GenericConfiguratorWizardPage Import(String pageName, IIoConfigurator configurator){
-               return new GenericConfiguratorWizardPage(pageName, configurator, "Import Configuration", "Configure the import mechanism.");
+       public static GenericConfiguratorWizardPage Import(String pageName,
+                       IIoConfigurator configurator) {
+               return new GenericConfiguratorWizardPage(pageName, configurator,
+                               "Import Configuration", "Configure the import mechanism.");
        }
-       
+
        /**
-        * <p>Export</p>
-        *
-        * @param pageName a {@link java.lang.String} object.
-        * @param configurator a {@link eu.etaxonomy.cdm.io.common.IIoConfigurator} object.
-        * @return a {@link eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage} object.
+        * <p>
+        * Export
+        * </p>
+        * 
+        * @param pageName
+        *            a {@link java.lang.String} object.
+        * @param configurator
+        *            a {@link eu.etaxonomy.cdm.io.common.IIoConfigurator} object.
+        * @return a
+        *         {@link eu.etaxonomy.taxeditor.io.wizard.GenericConfiguratorWizardPage}
+        *         object.
         */
-       public static GenericConfiguratorWizardPage Export(String pageName, IIoConfigurator configurator){
-               return new GenericConfiguratorWizardPage(pageName, configurator, "Export Configuration", "Configure the export mechanism.");
+       public static GenericConfiguratorWizardPage Export(String pageName,
+                       IIoConfigurator configurator) {
+               return new GenericConfiguratorWizardPage(pageName, configurator,
+                               "Export Configuration", "Configure the export mechanism.");
        }
-       
-       
-       /* (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) {
-               
-//             ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL);
-//             scrolledComposite.setLayout(new GridLayout());
-               
+
+               // ScrolledComposite scrolledComposite = new ScrolledComposite(parent,
+               // SWT.H_SCROLL);
+               // scrolledComposite.setLayout(new GridLayout());
+
                // TODO wrap this composite in a scrolled composite
                Composite composite = new Composite(parent, SWT.NULL);
                composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               
+
                GridLayout gridLayout = new GridLayout();
-               gridLayout.numColumns = 2;
                composite.setLayout(gridLayout);
-                               
-               
+
                List<Method> methods = getConfiguratorsBooleanSetMethods(configurator);
-               
-               for(Method method : methods){
+
+               for (Method method : methods) {
                        createCheckbox(composite, method, configurator);
                }
-               
-//             scrolledComposite.setContent(composite);
-               
+
+               // scrolledComposite.setContent(composite);
+
                setControl(composite);
        }
-       
-       private void createCheckbox(Composite parent, Method method, final IIoConfigurator configurator){
-       
-               String methodName = method.getName();
-               
-               final String methodNameValue = methodName.substring(3);
-       
-               CLabel label = new CLabel(parent, SWT.NULL);
-               label.setText(methodNameValue);
-               
+
+       private void createCheckbox(Composite parent, Method method,
+                       final IIoConfigurator configurator) {
+
+               final String methodName = method.getName();
+
                final Button checkBox = new Button(parent, SWT.CHECK);
+               
+               checkBox.setText(getLabel(methodName));
                // retrieve the default values and set the checkbox accordingly
-               boolean defaultSelection = executeBooleanGetMethod(configurator,"is" + methodNameValue);
+               boolean defaultSelection = executeBooleanGetMethod(configurator, "is"
+                               + methodName.substring(3));
                checkBox.setSelection(defaultSelection);
-               checkBox.addSelectionListener(new SelectionAdapter(){
+               checkBox.addSelectionListener(new SelectionAdapter() {
 
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                       /*
+                        * (non-Javadoc)
+                        * 
+                        * @see
+                        * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+                        * .swt.events.SelectionEvent)
                         */
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-                               executeBooleanSetMethod(configurator, "set" + methodNameValue, checkBox.getSelection());
+                               executeBooleanSetMethod(configurator, methodName,
+                                               checkBox.getSelection());
                        }
-                       
+
                });
-               
+
        }
        
-       
-       private boolean executeBooleanGetMethod(IIoConfigurator configurator, String methodName){
+       private String getLabel(String methodName){
                
-               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
+               if(resourceBundle == null){
+                       return methodName;
+               }
                
+               try{
+                       return resourceBundle.getString(methodName);
+               }catch(MissingResourceException e){
+                       return methodName;
+               }
+       }
+
+       private boolean executeBooleanGetMethod(IIoConfigurator configurator,
+                       String methodName) {
+
+               Class<? extends IIoConfigurator> configuratorClass = configurator
+                               .getClass();
+
                boolean result = false;
-               
+
                Method[] methods = configuratorClass.getMethods();
-               
-               for(Method method : methods){
-                       if(!method.getName().equals(methodName)){
+
+               for (Method method : methods) {
+                       if (!method.getName().equals(methodName)) {
                                continue;
                        }
-                       
+
                        try {
                                Object returnType = method.invoke(configurator, null);
-                               if(returnType.getClass().equals(Boolean.class)){
+                               if (returnType.getClass().equals(Boolean.class)) {
                                        result = ((Boolean) returnType).booleanValue();
                                }
-                                       
+
                                break;
                        } catch (Exception e) {
                                StoreUtil.warn(this.getClass(), "Could not invoke method");
-                       } 
+                       }
                }
-               
-               
+
                return result;
        }
-       
-       private void executeBooleanSetMethod(IIoConfigurator configurator, String methodName, boolean selected){
-               
-               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
-               
-               
+
+       private void executeBooleanSetMethod(IIoConfigurator configurator,
+                       String methodName, boolean selected) {
+
+               Class<? extends IIoConfigurator> configuratorClass = configurator
+                               .getClass();
+
                Method[] methods = configuratorClass.getMethods();
-               
-               for(Method method : methods){
-                       if(!method.getName().equals(methodName)){
+
+               for (Method method : methods) {
+                       if (!method.getName().equals(methodName)) {
                                continue;
                        }
-                       
+
                        try {
                                method.invoke(configurator, selected);
-                                       
+
                                break;
                        } catch (Exception e) {
                                StoreUtil.warn(this.getClass(), "Could not invoke method");
-                       } 
+                       }
                }
        }
-       
-       private List<Method> getConfiguratorsBooleanSetMethods(IIoConfigurator configurator){
+
+       private List<Method> getConfiguratorsBooleanSetMethods(
+                       IIoConfigurator configurator) {
                List<Method> booleanMethods = new ArrayList<Method>();
-               
-               Class<? extends IIoConfigurator> configuratorClass = configurator.getClass();
-               
+
+               Class<? extends IIoConfigurator> configuratorClass = configurator
+                               .getClass();
+
                Method[] allMethods = configuratorClass.getMethods();
-               
-               for(Method method : allMethods){
-                       if(method.getName().startsWith("set")){
-                               
+
+               for (Method method : allMethods) {
+                       if (method.getName().startsWith("set")) {
+
                                Class<?>[] typeList = method.getParameterTypes();
-                               
-                               if(typeList.length > 1){
-                                       new IllegalStateException("Found a setter with parameter count > 1");
+
+                               if (typeList.length > 1) {
+                                       new IllegalStateException(
+                                                       "Found a setter with parameter count > 1");
                                }
-                               
-                               if(typeList[0].getName().equals("boolean")){
+
+                               if (typeList[0].getName().equals("boolean")) {
                                        booleanMethods.add(method);
                                }
                        }
                }
-               
+
                return booleanMethods;
        }
 }
index cf98bce39b572b2e32e93953b8f4212344cec145..89042f9b79f77e5d7dd79cddc54b12954eca4a6a 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;
 
@@ -19,41 +19,51 @@ import eu.etaxonomy.cdm.io.tcsxml.out.TcsXmlExportConfigurator;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
- * <p>TcsExportWizard class.</p>
- *
+ * <p>
+ * TcsExportWizard class.
+ * </p>
+ * 
  * @author n.hoffmann
  * @created 15.06.2009
  * @version 1.0
  */
-public class TcsExportWizard extends AbstractExportWizard<TcsXmlExportConfigurator> {
-       private static final String TCS_EXPORT = "TCS_EXPORT";
+public class TcsExportWizard extends
+               AbstractExportWizard<TcsXmlExportConfigurator> {
        private TcsXmlExportConfigurator configurator;
        private ExportToFileDestinationWizardPage page;
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see org.eclipse.jface.wizard.Wizard#performFinish()
         */
        /** {@inheritDoc} */
        @Override
        public boolean performFinish() {
-               String urlString = page.getFolderText() + File.separator + page.getExportFileName();
-               
+               String urlString = page.getFolderText() + File.separator
+                               + page.getExportFileName();
+
                configurator.setDestination(new File(urlString));
-               
+
                CdmStore.getExportManager().run(configurator);
-               
+
                return true;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+       /*
+        * (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) {
                configurator = TcsXmlExportConfigurator.NewInstance(null, null);
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#getConfigurator()
         */
        /** {@inheritDoc} */
@@ -62,17 +72,18 @@ public class TcsExportWizard extends AbstractExportWizard<TcsXmlExportConfigurat
                return configurator;
        }
 
-       /* (non-Javadoc)
+       /*
+        * (non-Javadoc)
+        * 
         * @see eu.etaxonomy.taxeditor.io.AbstractExportWizard#addPages()
         */
        /** {@inheritDoc} */
        @Override
        public void addPages() {
                super.addPages();
-               
+
                page = ExportToFileDestinationWizardPage.Tcs();
                addPage(page);
        }
-       
-       
+
 }