1
|
/**
|
2
|
* Copyright (C) 2013 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.view.search.specimen;
|
10
|
|
11
|
import java.util.List;
|
12
|
|
13
|
import org.eclipse.swt.SWT;
|
14
|
import org.eclipse.swt.widgets.Button;
|
15
|
import org.eclipse.swt.widgets.Combo;
|
16
|
import org.eclipse.swt.widgets.Composite;
|
17
|
import org.eclipse.swt.widgets.DateTime;
|
18
|
import org.eclipse.swt.widgets.Display;
|
19
|
import org.eclipse.swt.widgets.Label;
|
20
|
import org.eclipse.swt.widgets.Text;
|
21
|
import org.eclipse.ui.forms.widgets.FormToolkit;
|
22
|
import org.eclipse.ui.forms.widgets.TableWrapData;
|
23
|
import org.eclipse.ui.forms.widgets.TableWrapLayout;
|
24
|
|
25
|
import eu.etaxonomy.cdm.model.location.Country;
|
26
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
27
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
28
|
|
29
|
/**
|
30
|
* @author pplitzner
|
31
|
* @date 03.09.2013
|
32
|
*
|
33
|
*/
|
34
|
public class SpecimenSearchComposite extends Composite {
|
35
|
private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
|
36
|
private final Text textTaxonName;
|
37
|
private final Text textHigherTaxon;
|
38
|
private final Text textCollector;
|
39
|
private final Text textCollectorNumber;
|
40
|
private final Text textAccessionNumber;
|
41
|
private final Text textLocality;
|
42
|
private final Text textHerbarium;
|
43
|
private final Combo textCountry;
|
44
|
private final DateTime dateFrom;
|
45
|
private final DateTime dateTo;
|
46
|
private final Button btnShowDate;
|
47
|
|
48
|
/**
|
49
|
* Create the composite.
|
50
|
* @param parent
|
51
|
* @setBackgroundMode(SWT.INHERIT_DEFAULT);
|
52
|
param style
|
53
|
*/
|
54
|
public SpecimenSearchComposite(Composite parent, int style) {
|
55
|
super(parent, style);
|
56
|
{
|
57
|
TableWrapLayout tableWrapLayout = new TableWrapLayout();
|
58
|
tableWrapLayout.numColumns = 2;
|
59
|
setLayout(tableWrapLayout);
|
60
|
}
|
61
|
CdmFormFactory formFactory = new CdmFormFactory(parent.getDisplay());
|
62
|
Label lblTaxonName = new Label(this, SWT.NONE);
|
63
|
lblTaxonName.setText("Taxon Name");
|
64
|
|
65
|
textTaxonName = new Text(this, SWT.NONE);
|
66
|
textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
67
|
|
68
|
Label lblHigherTaxon = new Label(this, SWT.NONE);
|
69
|
lblHigherTaxon.setText("Higher Taxon");
|
70
|
|
71
|
textHigherTaxon = new Text(this, SWT.NONE);
|
72
|
textHigherTaxon.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
73
|
|
74
|
Label lblCollectors = new Label(this, SWT.NONE);
|
75
|
lblCollectors.setText("Collector(s)");
|
76
|
|
77
|
textCollector = new Text(this, SWT.NONE);
|
78
|
textCollector.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
79
|
formToolkit.adapt(textCollector, true, true);
|
80
|
|
81
|
Label lblCollectorsNumber = new Label(this, SWT.NONE);
|
82
|
lblCollectorsNumber.setText("Collector(s) Number");
|
83
|
|
84
|
textCollectorNumber = new Text(this, SWT.NONE);
|
85
|
textCollectorNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
86
|
formToolkit.adapt(textCollectorNumber, true, true);
|
87
|
|
88
|
Label lblAccessionNumber = new Label(this, SWT.NONE);
|
89
|
lblAccessionNumber.setText("Accession Number");
|
90
|
|
91
|
textAccessionNumber = new Text(this, SWT.NONE);
|
92
|
textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
93
|
formToolkit.adapt(textAccessionNumber, true, true);
|
94
|
|
95
|
Label lblHerbarium = new Label(this, SWT.NONE);
|
96
|
lblHerbarium.setText("Collection");
|
97
|
|
98
|
textHerbarium = new Text(this, SWT.NONE);
|
99
|
textHerbarium.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
100
|
|
101
|
Label lblCountry = new Label(this, SWT.NONE);
|
102
|
lblCountry.setText("Country");
|
103
|
|
104
|
textCountry = new Combo(this, SWT.NONE);
|
105
|
textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
106
|
List<Country> items = CdmStore.getTermManager().getPreferredTerms(Country.class);
|
107
|
String[] itemsArray = new String[items.size()];
|
108
|
int i = 0;
|
109
|
for (Country country: items){
|
110
|
itemsArray[i]= country.getIso3166_A2() + " - " + country.getLabel();
|
111
|
i++;
|
112
|
}
|
113
|
|
114
|
textCountry.setItems(itemsArray);
|
115
|
|
116
|
|
117
|
|
118
|
Label lblLocality = new Label(this, SWT.NONE);
|
119
|
lblLocality.setText("Locality");
|
120
|
|
121
|
textLocality = new Text(this, SWT.NONE);
|
122
|
textLocality.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
|
123
|
formToolkit.adapt(textLocality, true, true);
|
124
|
|
125
|
Label lblCollectionDate = new Label(this, SWT.NONE);
|
126
|
lblCollectionDate.setText("Collection Date");
|
127
|
|
128
|
btnShowDate = new Button(this, SWT.CHECK);
|
129
|
|
130
|
Label lblFrom = new Label(this, SWT.NONE);
|
131
|
lblFrom.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
|
132
|
lblFrom.setText("from");
|
133
|
|
134
|
dateFrom = new DateTime(this, SWT.SHORT);
|
135
|
dateFrom.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1));
|
136
|
formToolkit.paintBordersFor(dateFrom);
|
137
|
|
138
|
Label lblTo = new Label(this, SWT.NONE);
|
139
|
lblTo.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
|
140
|
lblTo.setText("to");
|
141
|
|
142
|
dateTo = new DateTime(this, SWT.SHORT);
|
143
|
dateTo.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1));
|
144
|
formToolkit.paintBordersFor(dateTo);
|
145
|
|
146
|
}
|
147
|
|
148
|
@Override
|
149
|
protected void checkSubclass() {
|
150
|
// Disable the check that prevents subclassing of SWT components
|
151
|
}
|
152
|
|
153
|
public Text getTextTaxonName() {
|
154
|
return textTaxonName;
|
155
|
}
|
156
|
|
157
|
public Text getTextHigherTaxon() {
|
158
|
return textHigherTaxon;
|
159
|
}
|
160
|
public Text getTextCollector() {
|
161
|
return textCollector;
|
162
|
}
|
163
|
public Text getTextCollectorNumber() {
|
164
|
return textCollectorNumber;
|
165
|
}
|
166
|
public Text getTextAccessionNumber() {
|
167
|
return textAccessionNumber;
|
168
|
}
|
169
|
public Text getTextHerbarium() {
|
170
|
return textHerbarium;
|
171
|
}
|
172
|
public Combo getTextCountry() {
|
173
|
return textCountry;
|
174
|
}
|
175
|
public Text getTextLocality() {
|
176
|
return textLocality;
|
177
|
}
|
178
|
public DateTime getDateFrom() {
|
179
|
return dateFrom;
|
180
|
}
|
181
|
public DateTime getDateTo() {
|
182
|
return dateTo;
|
183
|
}
|
184
|
public Button getBtnShowDate() {
|
185
|
return btnShowDate;
|
186
|
}
|
187
|
}
|