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
.store
.CdmStore
;
30 * Wizard for querying specimen provider.
35 public class SpecimenSearchWizard
extends Wizard
implements IImportWizard
{
36 @SuppressWarnings("unused")
37 private static final Logger logger
= Logger
.getLogger(SpecimenSearchWizard
.class);
39 private OccurenceQuery query
= null;
40 private SpecimenProviderSelectionWizardPage providerSelectionPage
;
41 private SpecimenSearchWizardPage searchPage
;
44 * Creates a new SpecimenSearchWizard
46 public SpecimenSearchWizard() {
47 //default constructor needed for RCP extension points
49 //check if connected to a data source. If not this will open an error dialog
50 CdmStore
.getCurrentApplicationConfiguration();
51 this.setWindowTitle("Search Specimens");
56 * @see org.eclipse.jface.wizard.Wizard#performFinish()
59 public boolean performFinish() {
60 final IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
61 DataImportEditorInput
<?
> input
= null;
62 String editorId
= null;
63 query
= searchPage
.getQuery();
64 switch (providerSelectionPage
.getQueryType()) {
66 input
= new BioCaseEditorInput(query
);
67 editorId
= SpecimenImportEditor
.ID
;
70 input
= new GbifImportEditorInput(query
);
71 editorId
= GbifImportEditor
.ID
;
75 page
.openEditor(input
, editorId
, true);
76 } catch ( PartInitException e
) {
77 //Put your exception handler here if you wish to
79 Job queryJob
= new QueryJob("Query specimen provider", input
);
85 * @see org.eclipse.jface.wizard.Wizard#addPages()
88 public void addPages() {
89 addPage(providerSelectionPage
);
94 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
97 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
98 providerSelectionPage
= new SpecimenProviderSelectionWizardPage("Select specimen provider");
99 searchPage
= new SpecimenSearchWizardPage("Specimen Search");
102 private class QueryJob
extends Job
{
104 private final DataImportEditorInput
<?
> input
;
109 public QueryJob(String name
, DataImportEditorInput
<?
> input
) {
115 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
118 protected IStatus
run(IProgressMonitor monitor
) {
120 Display
.getDefault().asyncExec(new Runnable() {
124 CdmStore
.getContextManager().notifyContextRefresh();
127 return Status
.OK_STATUS
;