- added classification chooser to ABCD import wizard
authorPatric Plitzner <p.plitzner@bgbm.org>
Fri, 16 Jan 2015 10:04:13 +0000 (10:04 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Fri, 16 Jan 2015 10:04:13 +0000 (10:04 +0000)
.gitattributes
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbcdImportWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ClassificationChooserWizardPage.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/NomenclaturalCodeWizardPage.java

index 2a80b2c0296cdb6e4b07eb3cbcec2625ca9a3c64..9380ea51fff478f41bfb3be23f04740e832e2595 100644 (file)
@@ -1257,6 +1257,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/AbstractExcelImportWizard.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbstractExportWizard.java -text
 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/ClassificationChooserWizardPage.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/CsvExportWizard.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
index c2975144f35b7012631f9300aacc0a7890a0ac6b..275c39d3d7164c6759db1be286d543471b6ab26f 100644 (file)
@@ -36,6 +36,7 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
 
        private Abcd206ImportConfigurator configurator;
        private ImportFromFileDataSourceWizardPage dataSourcePage;
+       private ClassificationChooserWizardPage classificationChooserWizardPage;
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.io.wizard.AbstractImportWizard#getConfigurator()
@@ -61,6 +62,10 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
         }
                configurator.setDbSchemaValidation(DbSchemaValidation.CREATE);
 
+               if(classificationChooserWizardPage.getClassification()!=null){
+                   configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
+               }
+
                CdmStore.getImportManager().run(configurator);
                return true;
 
@@ -84,7 +89,9 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
        public void addPages() {
                super.addPages();
 
+               classificationChooserWizardPage = ClassificationChooserWizardPage.createPage();
                dataSourcePage = ImportFromFileDataSourceWizardPage.XML();
+               addPage(classificationChooserWizardPage);
                addPage(dataSourcePage);
        }
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ClassificationChooserWizardPage.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ClassificationChooserWizardPage.java
new file mode 100644 (file)
index 0000000..85d1d03
--- /dev/null
@@ -0,0 +1,125 @@
+// $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 org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+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 org.eclipse.wb.swt.ResourceManager;
+
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
+
+/**
+ * <p>ImportFromFileDataSourceWizardPage class.</p>
+ *
+ * @author n.hoffmann
+ * @created 04.08.2009
+ * @version 1.0
+ */
+public class ClassificationChooserWizardPage extends WizardPage implements Listener{
+
+       public static final String PAGE_NAME = "ClassificationChooserWizardPage";
+
+    private Text textClassification;
+    private Classification classification;
+    private Button btnBrowseClassification;
+
+    private Button btnClear;
+
+       /**
+        * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
+        *
+        * @param title a {@link java.lang.String} object.
+        * @param description a {@link java.lang.String} object.
+        * @param extensions an array of {@link java.lang.String} objects.
+        */
+       protected ClassificationChooserWizardPage(String title, String description) {
+               super(PAGE_NAME);
+
+               setTitle(title);
+
+               setDescription(description);
+
+       }
+
+       /**
+        * <p>XML</p>
+        *
+        * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
+        */
+       protected static ClassificationChooserWizardPage createPage(){
+               return new ClassificationChooserWizardPage("Choose Classification", "Selecting no classification will create a default one.");
+       }
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       /** {@inheritDoc} */
+       @Override
+    public void createControl(Composite parent) {
+               final Composite composite = new Composite(parent, SWT.NULL);
+
+               setPageComplete(false);
+
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 4;
+               composite.setLayout(gridLayout);
+
+               Label label = new Label(composite, SWT.NONE);
+               label.setText("Classification");
+               textClassification = new Text(composite, SWT.NONE);
+               textClassification.setEnabled(false);
+               textClassification.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               btnBrowseClassification = new Button(composite, SWT.NONE);
+               btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
+               btnBrowseClassification.addListener(SWT.Selection, this);
+               btnClear = new Button(composite, SWT.NONE);
+               btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
+               btnClear.addListener(SWT.Selection, this);
+
+               setControl(composite);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+        */
+       @Override
+       public void handleEvent(Event event) {
+           if(event.widget==btnBrowseClassification){
+               classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class, getShell(), null, null);
+               if(classification!=null){
+                   textClassification.setText(classification.getTitleCache());
+               }
+           }
+           else if(event.widget==btnClear){
+               classification = null;
+               textClassification.setText("");
+           }
+       }
+
+
+    /**
+     * @return the classification
+     */
+    public Classification getClassification() {
+        return classification;
+    }
+}
index 361fcaf63392554d60bfd09c452964bd0d4812d1..af287cab18238f968d32a0a9cba03a6c98b44cea 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -34,17 +34,19 @@ import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
  * @version 1.0
  */
 public class NomenclaturalCodeWizardPage extends WizardPage {
-       
-       private IImportConfigurator configurator;
+
+    private static final Logger logger = Logger.getLogger(NomenclaturalCodeWizardPage.class);
+
+    private IImportConfigurator configurator;
 
        /**
         * <p>Constructor for NomenclaturalCodeWizardPage.</p>
         */
        public NomenclaturalCodeWizardPage() {
                super("Choose nomenclatural code");
-               
+
                this.setTitle("Choose nomenclatural code");
-               
+
                this.setDescription("Choose which code to use for imported names.");
        }
 
@@ -58,37 +60,40 @@ public class NomenclaturalCodeWizardPage extends WizardPage {
                this.configurator = configurator;
        }
 
-       private static final Logger logger = Logger
-                       .getLogger(NomenclaturalCodeWizardPage.class);
 
        /* (non-Javadoc)
         * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
         */
        /** {@inheritDoc} */
-       public void createControl(Composite parent) {
+       @Override
+    public void createControl(Composite parent) {
                Composite container = new Composite(parent, SWT.NULL);
                container.setLayout(new FillLayout());
-                               
+
                final Group group = new Group(container, SWT.NONE);
                group.setLayout(new GridLayout());
-               
+
                NomenclaturalCode preferredCode = PreferencesUtil.getPreferredNomenclaturalCode();
-               
+
                // set preferred code as default
                configurator.setNomenclaturalCode(preferredCode);
-               
+
                for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
                        Button button = new Button(group, SWT.RADIO);
                        button.setText(NomenclaturalCodeHelper.getDescription(code));
                        button.setData(code);
                        button.setSelection(preferredCode.equals(code));
                        button.addSelectionListener(new SelectionAdapter() {
-                               public void widgetSelected(SelectionEvent e) {
+                               @Override
+                public void widgetSelected(SelectionEvent e) {
                                        configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
                                }
                        });
-               }               
-               
+               }
+
+
                setControl(container);
        }
+
+
 }