Project

General

Profile

Download (6.08 KB) Statistics
| Branch: | Tag: | Revision:
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.specimenSearch;
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 textCollector;
38
    private final Text textCollectorNumber;
39
    private final Text textAccessionNumber;
40
    private final Text textLocality;
41
    private final Text textHerbarium;
42
    private final Combo textCountry;
43
    private final DateTime dateFrom;
44
    private final DateTime dateTo;
45
    private final Button btnShowDate;
46

    
47
    /**
48
     * Create the composite.
49
     * @param parent
50
     * @setBackgroundMode(SWT.INHERIT_DEFAULT);
51
        param style
52
     */
53
    public SpecimenSearchComposite(Composite parent, int style) {
54
        super(parent, style);
55
        {
56
            TableWrapLayout tableWrapLayout = new TableWrapLayout();
57
            tableWrapLayout.numColumns = 2;
58
            setLayout(tableWrapLayout);
59
        }
60
        CdmFormFactory formFactory = new CdmFormFactory(parent.getDisplay());
61
        Label lblTaxonName = new Label(this, SWT.NONE);
62
        lblTaxonName.setText("Taxon Name");
63

    
64
        textTaxonName = new Text(this, SWT.NONE);
65
        textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
66

    
67
        Label lblCollectors = new Label(this, SWT.NONE);
68
        lblCollectors.setText("Collector(s)");
69

    
70
        textCollector = new Text(this, SWT.NONE);
71
        textCollector.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
72
        formToolkit.adapt(textCollector, true, true);
73

    
74
        Label lblCollectorsNumber = new Label(this, SWT.NONE);
75
        lblCollectorsNumber.setText("Collector(s) Number");
76

    
77
        textCollectorNumber = new Text(this, SWT.NONE);
78
        textCollectorNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
79
        formToolkit.adapt(textCollectorNumber, true, true);
80

    
81
        Label lblAccessionNumber = new Label(this, SWT.NONE);
82
        lblAccessionNumber.setText("Accession Number");
83

    
84
        textAccessionNumber = new Text(this, SWT.NONE);
85
        textAccessionNumber.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
86
        formToolkit.adapt(textAccessionNumber, true, true);
87

    
88
        Label lblHerbarium = new Label(this, SWT.NONE);
89
        lblHerbarium.setText("Collection");
90

    
91
        textHerbarium = new Text(this, SWT.NONE);
92
        textHerbarium.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
93

    
94
        Label lblCountry = new Label(this, SWT.NONE);
95
        lblCountry.setText("Country");
96

    
97
        textCountry = new Combo(this, SWT.NONE);
98
        textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
99
        List<Country> items = CdmStore.getTermManager().getPreferredTerms(Country.class);
100
        String[] itemsArray = new String[items.size()];
101
        int i = 0;
102
        for (Country country: items){
103
            itemsArray[i]= country.getIso3166_A2() + " - " + country.getLabel();
104
            i++;
105
        }
106

    
107
        textCountry.setItems(itemsArray);
108

    
109

    
110

    
111
        Label lblLocality = new Label(this, SWT.NONE);
112
        lblLocality.setText("Locality");
113

    
114
        textLocality = new Text(this, SWT.NONE);
115
        textLocality.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
116
        formToolkit.adapt(textLocality, true, true);
117

    
118
        Label lblCollectionDate = new Label(this, SWT.NONE);
119
        lblCollectionDate.setText("Collection Date");
120

    
121
        btnShowDate = new Button(this, SWT.CHECK);
122

    
123
        Label lblFrom = new Label(this, SWT.NONE);
124
        lblFrom.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
125
        lblFrom.setText("from");
126

    
127
        dateFrom = new DateTime(this, SWT.SHORT);
128
        dateFrom.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1));
129
        formToolkit.paintBordersFor(dateFrom);
130

    
131
        Label lblTo = new Label(this, SWT.NONE);
132
        lblTo.setLayoutData(new TableWrapData(TableWrapData.RIGHT, TableWrapData.TOP, 1, 1));
133
        lblTo.setText("to");
134

    
135
        dateTo = new DateTime(this, SWT.SHORT);
136
        dateTo.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP, 1, 1));
137
        formToolkit.paintBordersFor(dateTo);
138

    
139
    }
140

    
141
    @Override
142
    protected void checkSubclass() {
143
        // Disable the check that prevents subclassing of SWT components
144
    }
145

    
146
    public Text getTextTaxonName() {
147
        return textTaxonName;
148
    }
149
    public Text getTextCollector() {
150
        return textCollector;
151
    }
152
    public Text getTextCollectorNumber() {
153
        return textCollectorNumber;
154
    }
155
    public Text getTextAccessionNumber() {
156
        return textAccessionNumber;
157
    }
158
    public Text getTextHerbarium() {
159
        return textHerbarium;
160
    }
161
    public Combo getTextCountry() {
162
        return textCountry;
163
    }
164
    public Text getTextLocality() {
165
        return textLocality;
166
    }
167
    public DateTime getDateFrom() {
168
        return dateFrom;
169
    }
170
    public DateTime getDateTo() {
171
        return dateTo;
172
    }
173
    public Button getBtnShowDate() {
174
        return btnShowDate;
175
    }
176
}
(3-3/4)