- moved actual query execution from the wizard to the editor
authorPatric Plitzner <p.plitzner@bgbm.org>
Wed, 25 Sep 2013 11:39:51 +0000 (11:39 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Wed, 25 Sep 2013 11:39:51 +0000 (11:39 +0000)
.gitattributes
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/AnnotatedLineDocumentProvider.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditor.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java [deleted file]
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java

index 84b6c5f46fcc7dd2349b16abc9cfbe01342b75c9..90d7d73317ec2d4a7e1a4c1649def73f1f84afdc 100644 (file)
@@ -117,7 +117,7 @@ eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkedito
 eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java -text
 eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditor.java -text
 eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportEditorLineDisplayStrategy.java -text
-eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java -text
+eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java -text
 eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizard.java -text
 eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/wizard/SpecimenSearchWizardPage.java -text
 eu.etaxonomy.taxeditor.bulkeditor/src/test/java/eu/etaxonomy/taxeditor/bulkeditor/Application.java -text
index 5261d35d7ec83f5a681224b2ced9d55549645d30..64df8cf93ea32ff427ddd024c36c4fcf91428a7b 100644 (file)
@@ -26,7 +26,7 @@ import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.texteditor.AbstractDocumentProvider;
 
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
-import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput;
+import eu.etaxonomy.taxeditor.dataimport.DataImportSpecimenEditorInput;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 
 
@@ -219,8 +219,8 @@ public class AnnotatedLineDocumentProvider extends AbstractDocumentProvider {
                if (element instanceof AbstractBulkEditorInput) {
                        return ((AbstractBulkEditorInput)element).getModel();
                }
-               else if(element instanceof SpecimenEditorInput){
-                   return ((SpecimenEditorInput) element).getResults();
+               else if(element instanceof DataImportSpecimenEditorInput){
+                   return ((DataImportSpecimenEditorInput) element).getResults();
                }
                return null;
        }
index 5ca06d921e16126c75c72d8097ca2235bceff9dd..1f905593d5be8fd851f9171b13a283dd504a769d 100644 (file)
@@ -9,6 +9,9 @@
 */
 package eu.etaxonomy.taxeditor.dataimport;
 
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IEditorInput;
+
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor;
 
@@ -36,10 +39,17 @@ public class DataImportEditor extends AnnotatedLineEditor {
     @Override
     protected void initializeEditor() {
         super.initializeEditor();
-        String editorTitle = "Data Import Editor";
-        setPartName(editorTitle);
-        setTitleToolTip(editorTitle);
         setLineDisplayStrategy(new DataImportEditorLineDisplayStrategy());
     }
 
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.annotatedlineeditor.AnnotatedLineEditor#doSetInput(org.eclipse.ui.IEditorInput)
+     */
+    @Override
+    protected void doSetInput(IEditorInput input) throws CoreException {
+        super.doSetInput(input);
+        setPartName(input.getName());
+        setTitleToolTip(input.getName());
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/DataImportSpecimenEditorInput.java
new file mode 100644 (file)
index 0000000..cc64abc
--- /dev/null
@@ -0,0 +1,153 @@
+// $Id$
+/**
+* Copyright (C) 2013 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.dataimport;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.apache.http.client.ClientProtocolException;
+import org.apache.log4j.Logger;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
+import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+
+/**
+ * @author pplitzner
+ * @date 20.09.2013
+ *
+ */
+public class DataImportSpecimenEditorInput implements IEditorInput {
+
+    private static Logger logger = Logger.getLogger(DataImportSpecimenEditorInput.class);
+
+    private List<SpecimenOrObservationBase> results;
+    private BioCaseQuery query;
+
+    /**
+     * @param results
+     */
+    public DataImportSpecimenEditorInput(BioCaseQuery query) {
+        this.query = query;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    @Override
+    public Object getAdapter(Class adapter) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#exists()
+     */
+    @Override
+    public boolean exists() {
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+     */
+    @Override
+    public ImageDescriptor getImageDescriptor() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getName()
+     */
+    @Override
+    public String getName() {
+        return query.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getPersistable()
+     */
+    @Override
+    public IPersistableElement getPersistable() {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IEditorInput#getToolTipText()
+     */
+    @Override
+    public String getToolTipText() {
+        return query.toString();
+    }
+
+    /**
+     * @return the results
+     */
+    public List<SpecimenOrObservationBase> getResults() {
+        String errorMessage = "Could not execute query " + query;
+        try {
+            return new BioCaseQueryServiceWrapper().query(query);
+        } catch (ClientProtocolException e) {
+            logger.error(errorMessage, e);
+        } catch (IOException e) {
+            logger.error(errorMessage, e);
+        } catch (URISyntaxException e) {
+            logger.error(errorMessage, e);
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((query == null) ? 0 : query.hashCode());
+        return result;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        DataImportSpecimenEditorInput other = (DataImportSpecimenEditorInput) obj;
+        if (query == null) {
+            if (other.query != null) {
+                return false;
+            }
+        } else if (!query.equals(other.query)) {
+            return false;
+        }
+        if (results == null) {
+            if (other.results != null) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/dataimport/SpecimenEditorInput.java
deleted file mode 100644 (file)
index 0674bf4..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// $Id$
-/**
-* Copyright (C) 2013 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.dataimport;
-
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
-
-/**
- * @author pplitzner
- * @date 20.09.2013
- *
- */
-public class SpecimenEditorInput implements IEditorInput {
-
-    private List<SpecimenOrObservationBase> results;
-
-    /**
-     * @param results
-     */
-    public SpecimenEditorInput(List<SpecimenOrObservationBase> results) {
-        this.results = results;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
-     */
-    @Override
-    public Object getAdapter(Class adapter) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#exists()
-     */
-    @Override
-    public boolean exists() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
-     */
-    @Override
-    public ImageDescriptor getImageDescriptor() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getName()
-     */
-    @Override
-    public String getName() {
-        return "inputName";
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getPersistable()
-     */
-    @Override
-    public IPersistableElement getPersistable() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IEditorInput#getToolTipText()
-     */
-    @Override
-    public String getToolTipText() {
-        return "tooltip";
-    }
-
-    /**
-     * @return the results
-     */
-    public List<SpecimenOrObservationBase> getResults() {
-        return results;
-    }
-
-}
index 59cffbd4c95ccf4cdf68fd73273b00c02932c02a..b5f346234e9705a4b377ecbb06eca877f1d8b7c8 100644 (file)
@@ -9,11 +9,6 @@
 */
 package eu.etaxonomy.taxeditor.dataimport.wizard;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.List;
-
-import org.apache.http.client.ClientProtocolException;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
@@ -24,10 +19,8 @@ import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.PlatformUI;
 
 import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
-import eu.etaxonomy.cdm.ext.biocase.BioCaseQueryServiceWrapper;
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.dataimport.DataImportEditor;
-import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput;
+import eu.etaxonomy.taxeditor.dataimport.DataImportSpecimenEditorInput;
 
 /**
  * @author pplitzner
@@ -35,19 +28,16 @@ import eu.etaxonomy.taxeditor.dataimport.SpecimenEditorInput;
  *
  */
 public class SpecimenSearchWizard extends Wizard implements IImportWizard {
+    @SuppressWarnings("unused")
     private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);
 
-    private BioCaseQueryServiceWrapper bioCaseQueryServiceWrapper;
     private BioCaseQuery query;
-    private List<SpecimenOrObservationBase> results;
 
     /**
-     *
+     * Creates a new SpecimenSearchWizard
      */
     public SpecimenSearchWizard() {
-        query = new BioCaseQuery();
-        bioCaseQueryServiceWrapper = new BioCaseQueryServiceWrapper();
-        this.results = getResults();
+        //default constructor needed for RCP extension points
     }
 
 
@@ -59,7 +49,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
         IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
 
         try {
-            SpecimenEditorInput input = new SpecimenEditorInput(results);
+            DataImportSpecimenEditorInput input = new DataImportSpecimenEditorInput(query);
             input.getToolTipText();
             page.openEditor(input, DataImportEditor.ID, true);
         } catch ( PartInitException e ) {
@@ -73,23 +63,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
      */
     @Override
     public void addPages() {
-        addPage(new SpecimenSearchWizardPage("Specimen Search", results));
-    }
-
-    public List<SpecimenOrObservationBase> getResults(){
-        try {
-            return bioCaseQueryServiceWrapper.query(query);
-        } catch (ClientProtocolException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (URISyntaxException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return null;
+        addPage(new SpecimenSearchWizardPage("Specimen Search"));
     }
 
     /* (non-Javadoc)
@@ -97,6 +71,7 @@ public class SpecimenSearchWizard extends Wizard implements IImportWizard {
      */
     @Override
     public void init(IWorkbench workbench, IStructuredSelection selection) {
+        query = new BioCaseQuery();
     }
 
     /**
index eeb3614b9636912bdc7ed163a6acddcf3009a3a4..ca40c8836eeaa6066ed12ed98a1d89ab597d49ff 100644 (file)
@@ -9,12 +9,9 @@
 */
 package eu.etaxonomy.taxeditor.dataimport.wizard;
 
-import java.util.List;
-
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.widgets.Composite;
 
-import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchController;
 
 /**
@@ -24,14 +21,11 @@ import eu.etaxonomy.taxeditor.ui.campanula.specimenSearch.SpecimenSearchControll
  */
 public class SpecimenSearchWizardPage extends WizardPage{
 
-    private List<SpecimenOrObservationBase> results;
-
     /**
      * @param pageName
      */
-    protected SpecimenSearchWizardPage(String pageName, List<SpecimenOrObservationBase> results) {
+    protected SpecimenSearchWizardPage(String pageName) {
         super(pageName);
-        this.results = results;
     }
 
     /* (non-Javadoc)
@@ -42,14 +36,4 @@ public class SpecimenSearchWizardPage extends WizardPage{
         setControl(new SpecimenSearchController(parent).getComposite());
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
-     */
-    @Override
-    public void setVisible(boolean visible) {
-        super.setVisible(visible);
-        if(visible==false){
-            ((SpecimenSearchWizard) getWizard()).getResults();
-        }
-    }
 }