Project

General

Profile

Download (2.83 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2013 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.dataimport.wizard;
11

    
12
import org.apache.log4j.Logger;
13
import org.eclipse.jface.viewers.IStructuredSelection;
14
import org.eclipse.jface.wizard.Wizard;
15
import org.eclipse.ui.IImportWizard;
16
import org.eclipse.ui.IWorkbench;
17
import org.eclipse.ui.IWorkbenchPage;
18
import org.eclipse.ui.PartInitException;
19
import org.eclipse.ui.PlatformUI;
20

    
21
import eu.etaxonomy.cdm.ext.biocase.BioCaseQuery;
22
import eu.etaxonomy.taxeditor.dataimport.DataImportEditor;
23
import eu.etaxonomy.taxeditor.dataimport.DerivedUnitEditorInput;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 * Wizard for querying BioCASe provider.
28
 * @author pplitzner
29
 * @date 11.09.2013
30
 *
31
 */
32
public class SpecimenSearchWizard extends Wizard implements IImportWizard {
33
    @SuppressWarnings("unused")
34
    private static final Logger logger = Logger.getLogger(SpecimenSearchWizard.class);
35

    
36
    private BioCaseQuery query;
37
    private SpecimenSearchWizardPage searchPage;
38

    
39
    /**
40
     * Creates a new SpecimenSearchWizard
41
     */
42
    public SpecimenSearchWizard() {
43
        //default constructor needed for RCP extension points
44

    
45
        //check if connected to a data source. If not this will open an error dialog
46
        CdmStore.getCurrentApplicationConfiguration();
47
        this.setWindowTitle("Search Specimens");
48
    }
49

    
50

    
51
    /* (non-Javadoc)
52
     * @see org.eclipse.jface.wizard.Wizard#performFinish()
53
     */
54
    @Override
55
    public boolean performFinish() {
56
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
57

    
58
        try {
59
            query = searchPage.getQuery();
60
            DerivedUnitEditorInput input = new DerivedUnitEditorInput(query);
61
            input.query();
62
            page.openEditor(input, DataImportEditor.ID, true);
63
        } catch ( PartInitException e ) {
64
            //Put your exception handler here if you wish to
65
        }
66
        return true;
67
    }
68

    
69
    /* (non-Javadoc)
70
     * @see org.eclipse.jface.wizard.Wizard#addPages()
71
     */
72
    @Override
73
    public void addPages() {
74
        addPage(searchPage);
75
    }
76

    
77
    /* (non-Javadoc)
78
     * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
79
     */
80
    @Override
81
    public void init(IWorkbench workbench, IStructuredSelection selection) {
82
        query = new BioCaseQuery();
83
        searchPage = new SpecimenSearchWizardPage("Specimen Search");
84
    }
85

    
86
    /**
87
     * Return a {@link BioCaseQuery} with the parameters entered in the wizard
88
     * @return the query
89
     */
90
    public BioCaseQuery getQuery() {
91
        return query;
92
    }
93

    
94
}
(1-1/2)