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
|
}
|
48
|
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
52
|
*/
|
53
|
@Override
|
54
|
public boolean performFinish() {
|
55
|
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
56
|
|
57
|
try {
|
58
|
query = searchPage.getQuery();
|
59
|
DerivedUnitEditorInput input = new DerivedUnitEditorInput(query);
|
60
|
page.openEditor(input, DataImportEditor.ID, true);
|
61
|
} catch ( PartInitException e ) {
|
62
|
//Put your exception handler here if you wish to
|
63
|
}
|
64
|
return true;
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see org.eclipse.jface.wizard.Wizard#addPages()
|
69
|
*/
|
70
|
@Override
|
71
|
public void addPages() {
|
72
|
addPage(searchPage);
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
|
77
|
*/
|
78
|
@Override
|
79
|
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
80
|
query = new BioCaseQuery();
|
81
|
searchPage = new SpecimenSearchWizardPage("Specimen Search");
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* Return a {@link BioCaseQuery} with the parameters entered in the wizard
|
86
|
* @return the query
|
87
|
*/
|
88
|
public BioCaseQuery getQuery() {
|
89
|
return query;
|
90
|
}
|
91
|
|
92
|
}
|