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.editor.view.dataimport;
|
11
|
|
12
|
import java.net.MalformedURLException;
|
13
|
import java.net.URI;
|
14
|
import java.net.URISyntaxException;
|
15
|
import java.net.URL;
|
16
|
|
17
|
import org.eclipse.jface.wizard.WizardPage;
|
18
|
import org.eclipse.swt.widgets.Composite;
|
19
|
|
20
|
import eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenProviderSelectionController;
|
21
|
|
22
|
|
23
|
/**
|
24
|
* Wizard page for selecting the specimen provider
|
25
|
* @author pplitzner
|
26
|
* @date 12.09.2013
|
27
|
*
|
28
|
*/
|
29
|
public class SpecimenProviderSelectionWizardPage extends WizardPage{
|
30
|
|
31
|
private SpecimenProviderSelectionController specimenProviderSelectionController;
|
32
|
private URI endPoint;
|
33
|
|
34
|
protected SpecimenProviderSelectionWizardPage(String pageName) {
|
35
|
super(pageName);
|
36
|
setTitle("Select Specimen Provider");
|
37
|
setDescription("Select the provider to query for specimens.\nTo query a BioCASE " +
|
38
|
"provider the access point URL must be entered.");
|
39
|
}
|
40
|
|
41
|
/* (non-Javadoc)
|
42
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
43
|
*/
|
44
|
@Override
|
45
|
public void createControl(Composite parent) {
|
46
|
specimenProviderSelectionController = SpecimenProviderSelectionController.getInstance(parent, getWizard());
|
47
|
setControl(specimenProviderSelectionController.getComposite());
|
48
|
}
|
49
|
|
50
|
public QueryType getQueryType(){
|
51
|
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
|
52
|
return QueryType.BIOCASE;
|
53
|
}
|
54
|
else {// if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
|
55
|
return QueryType.GBIF;
|
56
|
}
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* @return
|
61
|
* @throws URISyntaxException
|
62
|
*/
|
63
|
public URI getEndPoint() {
|
64
|
return endPoint;
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
|
69
|
*/
|
70
|
@Override
|
71
|
public boolean isPageComplete() {
|
72
|
if(specimenProviderSelectionController.getComposite().getBtnBioCaseProvider().getSelection()){
|
73
|
endPoint = null;
|
74
|
try {
|
75
|
endPoint = new URL(specimenProviderSelectionController.getComposite().getTxtAccessPoint().getText()).toURI();
|
76
|
this.setErrorMessage(null);
|
77
|
return true;
|
78
|
} catch (MalformedURLException e) {
|
79
|
setErrorMessage("A valid URL has to be entered.");
|
80
|
return false;
|
81
|
} catch (URISyntaxException e) {
|
82
|
setErrorMessage("A valid URL has to be entered.");
|
83
|
return false;
|
84
|
}
|
85
|
}
|
86
|
else if(specimenProviderSelectionController.getComposite().getBtnGbif().getSelection()){
|
87
|
this.setErrorMessage(null);
|
88
|
return true;
|
89
|
}
|
90
|
return false;
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* @return
|
95
|
*/
|
96
|
public SpecimenProviderSelectionController getController() {
|
97
|
return specimenProviderSelectionController;
|
98
|
}
|
99
|
|
100
|
|
101
|
}
|