3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.dataimport
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.core
.runtime
.Status
;
16 import org
.eclipse
.core
.runtime
.jobs
.Job
;
17 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
18 import org
.eclipse
.jface
.wizard
.Wizard
;
19 import org
.eclipse
.swt
.widgets
.Display
;
20 import org
.eclipse
.ui
.IImportWizard
;
21 import org
.eclipse
.ui
.IWorkbench
;
22 import org
.eclipse
.ui
.PartInitException
;
24 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
25 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 * Wizard for querying specimen provider.
34 public class SpecimenSearchWizard
extends Wizard
implements IImportWizard
{
35 @SuppressWarnings("unused")
36 private static final Logger logger
= Logger
.getLogger(SpecimenSearchWizard
.class);
38 private OccurenceQuery query
= null;
39 private SpecimenProviderSelectionWizardPage providerSelectionPage
;
40 private SpecimenSearchWizardPage searchPage
;
43 * Creates a new SpecimenSearchWizard
45 public SpecimenSearchWizard() {
46 //default constructor needed for RCP extension points
48 //check if connected to a data source. If not this will open an error dialog
49 CdmStore
.getCurrentApplicationConfiguration();
50 this.setWindowTitle("Search Specimens");
55 * @see org.eclipse.jface.wizard.Wizard#performFinish()
58 public boolean performFinish() {
59 searchPage
.getController().saveLastSate();
61 DataImportEditorInput
<?
> input
= null;
62 query
= searchPage
.getQuery();
63 switch (providerSelectionPage
.getQueryType()) {
65 input
= new BioCaseEditorInput(query
, null);
68 input
= new GbifImportEditorInput(query
);
72 EditorUtil
.open(input
);
73 } catch ( PartInitException e
) {
74 //Put your exception handler here if you wish to
76 Job queryJob
= new QueryJob("Query specimen provider", input
);
82 * @see org.eclipse.jface.wizard.Wizard#addPages()
85 public void addPages() {
86 addPage(providerSelectionPage
);
91 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
94 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
95 providerSelectionPage
= new SpecimenProviderSelectionWizardPage("Select specimen provider");
96 searchPage
= new SpecimenSearchWizardPage("Specimen Search");
99 private class QueryJob
extends Job
{
101 private final DataImportEditorInput
<?
> input
;
106 public QueryJob(String name
, DataImportEditorInput
<?
> input
) {
112 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
115 protected IStatus
run(IProgressMonitor monitor
) {
117 Display
.getDefault().asyncExec(new Runnable() {
121 CdmStore
.getContextManager().notifyContextRefresh();
124 return Status
.OK_STATUS
;