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
.IWorkbenchPage
;
23 import org
.eclipse
.ui
.PartInitException
;
24 import org
.eclipse
.ui
.PlatformUI
;
26 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
27 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 * Wizard for querying specimen provider.
36 public class SpecimenSearchWizard
extends Wizard
implements IImportWizard
{
37 @SuppressWarnings("unused")
38 private static final Logger logger
= Logger
.getLogger(SpecimenSearchWizard
.class);
40 private OccurenceQuery query
= null;
41 private SpecimenProviderSelectionWizardPage providerSelectionPage
;
42 private SpecimenSearchWizardPage searchPage
;
45 * Creates a new SpecimenSearchWizard
47 public SpecimenSearchWizard() {
48 //default constructor needed for RCP extension points
50 //check if connected to a data source. If not this will open an error dialog
51 CdmStore
.getCurrentApplicationConfiguration();
52 this.setWindowTitle("Search Specimens");
57 * @see org.eclipse.jface.wizard.Wizard#performFinish()
60 public boolean performFinish() {
61 final IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
62 DataImportEditorInput
<?
> input
= null;
63 String editorId
= null;
64 query
= searchPage
.getQuery();
65 switch (providerSelectionPage
.getQueryType()) {
67 input
= new BioCaseEditorInput(query
, null);
68 editorId
= SpecimenImportEditor
.ID
;
71 input
= new GbifImportEditorInput(query
);
72 editorId
= GbifImportEditor
.ID
;
76 EditorUtil
.open(input
);
77 } catch ( PartInitException e
) {
78 //Put your exception handler here if you wish to
80 Job queryJob
= new QueryJob("Query specimen provider", input
);
86 * @see org.eclipse.jface.wizard.Wizard#addPages()
89 public void addPages() {
90 addPage(providerSelectionPage
);
95 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
98 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
99 providerSelectionPage
= new SpecimenProviderSelectionWizardPage("Select specimen provider");
100 searchPage
= new SpecimenSearchWizardPage("Specimen Search");
103 private class QueryJob
extends Job
{
105 private final DataImportEditorInput
<?
> input
;
110 public QueryJob(String name
, DataImportEditorInput
<?
> input
) {
116 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
119 protected IStatus
run(IProgressMonitor monitor
) {
121 Display
.getDefault().asyncExec(new Runnable() {
125 CdmStore
.getContextManager().notifyContextRefresh();
128 return Status
.OK_STATUS
;