From 1531d4fddbaa6ec0958cccc19de67554e904c4b1 Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Mon, 2 May 2011 16:23:46 +0000 Subject: [PATCH] Added DwC-A export wizard. Configuration options are now read from l10n properties file in cdmlib --- .gitattributes | 1 + .../META-INF/MANIFEST.MF | 1 + eu.etaxonomy.taxeditor.store/plugin.xml | 6 + .../etaxonomy/taxeditor/io/ExportManager.java | 23 +- .../wizard/DarwinCoreArchiveExportWizard.java | 83 ++++++ .../ExportToFileDestinationWizardPage.java | 208 +++++++++----- .../wizard/GenericConfiguratorWizardPage.java | 265 +++++++++++------- .../taxeditor/io/wizard/TcsExportWizard.java | 57 ++-- 8 files changed, 434 insertions(+), 210 deletions(-) create mode 100644 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java diff --git a/.gitattributes b/.gitattributes index 3173a420e..827757e16 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF index 5f09991ea..6e3ec3cff 100644 --- a/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF +++ b/eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF @@ -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, diff --git a/eu.etaxonomy.taxeditor.store/plugin.xml b/eu.etaxonomy.taxeditor.store/plugin.xml index 35589febe..621049e7c 100644 --- a/eu.etaxonomy.taxeditor.store/plugin.xml +++ b/eu.etaxonomy.taxeditor.store/plugin.xml @@ -480,6 +480,12 @@ id="eu.etaxonomy.taxeditor.io.export.sdd" name="SDD"> + + diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java index 1c8ae90b2..d6e798f68 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ExportManager.java @@ -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 { @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 index 000000000..a7691d92f --- /dev/null +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/DarwinCoreArchiveExportWizard.java @@ -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 { + + 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); + } +} 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 07286e912..4628b2c14 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,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; /** - *

ExportToFileDestinationWizardPage class.

- * + *

+ * ExportToFileDestinationWizardPage class. + *

+ * * @author n.hoffmann * @created 15.06.2009 * @version 1.0 */ -public class ExportToFileDestinationWizardPage extends WizardPage{ +public class ExportToFileDestinationWizardPage extends WizardPage { /** 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 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"; - + 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); } - + /** - *

Jaxb

- * - * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ExportToFileDestinationWizardPage} object. + *

+ * 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."); + 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. + *

+ * 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."); + 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. + *

+ * 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."); + 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(); } - /** - *

getExportFileName

- * + *

+ * getExportFileName + *

+ * * @return the exportFileName */ public String getExportFileName() { return text_exportFileName.getText(); } - /** - *

getFolderText

- * + *

+ * getFolderText + *

+ * * @return the folderText */ public String getFolderText() { return text_folder.getText(); } + } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java index a7caebd64..e796f5482 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.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 -* 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; /** - *

GenericConfiguratorWizardPage class.

- * + *

+ * GenericConfiguratorWizardPage class. + *

+ * * @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; + } } /** - *

Import

- * - * @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. + *

+ * Import + *

+ * + * @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."); } - + /** - *

Export

- * - * @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. + *

+ * Export + *

+ * + * @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 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 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 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 configuratorClass = configurator.getClass(); - - + + private void executeBooleanSetMethod(IIoConfigurator configurator, + String methodName, boolean selected) { + + Class 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 getConfiguratorsBooleanSetMethods(IIoConfigurator configurator){ + + private List getConfiguratorsBooleanSetMethods( + IIoConfigurator configurator) { List booleanMethods = new ArrayList(); - - Class configuratorClass = configurator.getClass(); - + + Class 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; } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java index cf98bce39..89042f9b7 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/TcsExportWizard.java @@ -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; /** - *

TcsExportWizard class.

- * + *

+ * TcsExportWizard class. + *

+ * * @author n.hoffmann * @created 15.06.2009 * @version 1.0 */ -public class TcsExportWizard extends AbstractExportWizard { - private static final String TCS_EXPORT = "TCS_EXPORT"; +public class TcsExportWizard extends + AbstractExportWizard { 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