Project

General

Profile

Download (5.06 KB) Statistics
| Branch: | Tag: | Revision:
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.derivate.searchFilter;
11

    
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.layout.GridData;
14
import org.eclipse.swt.layout.GridLayout;
15
import org.eclipse.swt.widgets.Button;
16
import org.eclipse.swt.widgets.Combo;
17
import org.eclipse.swt.widgets.Composite;
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.wb.swt.ResourceManager;
23

    
24
/**
25
 * The widgets of the {@link DerivateSearchView}<br>
26
 *
27
 */
28
public class DerivateSearchComposite extends Composite {
29

    
30
    public static final int ALL_SPECIMENS = 0;
31
    public static final int ASSIGNED_SPECIMENS = 1;
32
    public static final int UNASSIGNED_SPECIMENS = 2;
33

    
34
    private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
35
    private final Text searchField;
36
    private final Combo comboDerivateType;
37
    private final Button buttonSearch;
38
    private final Text textTaxonName;
39
    private final Button btnBrowseTaxa;
40
    private final Label lblTaxon;
41
    private final Label lblDerivateType;
42
    private final Button btnClearTaxon;
43
    private Label lblNewLabel;
44
    private Combo comboTaxonAssignment;
45

    
46
    /**
47
     * Create the composite.
48
     *
49
     * @param parent
50
     * @param style
51
     */
52
    public DerivateSearchComposite(Composite parent, int style) {
53
        super(parent, style);
54
        setLayout(new GridLayout(7, false));
55

    
56
        lblTaxon = new Label(this, SWT.NONE);
57
        lblTaxon.setText("Taxon");
58

    
59
        textTaxonName = formToolkit.createText(this, "New Text", SWT.NONE);
60
        textTaxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
61
        textTaxonName.setEnabled(false);
62
        textTaxonName.setText("");
63

    
64
        btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE);
65
        btnBrowseTaxa.setAlignment(SWT.RIGHT);
66
        btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
67

    
68
        btnClearTaxon = formToolkit.createButton(this, "", SWT.NONE);
69
        btnClearTaxon.setAlignment(SWT.RIGHT);
70
        btnClearTaxon.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
71
        btnClearTaxon.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
72

    
73
        lblNewLabel = new Label(this, SWT.NONE);
74
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
75
        formToolkit.adapt(lblNewLabel, true, true);
76
        lblNewLabel.setText("Taxon assignment");
77

    
78
        comboTaxonAssignment = new Combo(this, SWT.NONE);
79
        comboTaxonAssignment.setItems(new String[] { "Yes", "No", "All" });
80
        comboTaxonAssignment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
81
        formToolkit.adapt(comboTaxonAssignment);
82
        formToolkit.paintBordersFor(comboTaxonAssignment);
83
        comboTaxonAssignment.select(ALL_SPECIMENS);
84
        new Label(this, SWT.NONE);
85

    
86
        searchField = formToolkit.createText(this, "New Text", SWT.NONE);
87
        searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
88
        searchField.setText("");
89
        new Label(this, SWT.NONE);
90
        new Label(this, SWT.NONE);
91

    
92
        lblDerivateType = new Label(this, SWT.NULL);
93
        lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
94
        lblDerivateType.setText("Derivative Type");
95

    
96
        comboDerivateType = new Combo(this, SWT.READ_ONLY);
97
        comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
98
        formToolkit.paintBordersFor(comboDerivateType);
99

    
100
        buttonSearch = new Button(this, SWT.NONE);
101
        formToolkit.adapt(buttonSearch, true, true);
102
        buttonSearch.setText("Search");
103

    
104
    }
105

    
106
    @Override
107
    protected void checkSubclass() {
108
        // Disable the check that prevents subclassing of SWT components
109
    }
110

    
111
    public Text getSearchField() {
112
        return searchField;
113
    }
114

    
115
    public Combo getComboDerivateType() {
116
        return comboDerivateType;
117
    }
118

    
119
    public Button getButtonSearch() {
120
        return buttonSearch;
121
    }
122

    
123
    @Override
124
    public void setEnabled(boolean enabled) {
125
        super.setEnabled(enabled);
126
        searchField.setEnabled(enabled);
127
        comboDerivateType.setEnabled(enabled);
128
        buttonSearch.setEnabled(enabled);
129
        btnBrowseTaxa.setEnabled(enabled);
130
        lblTaxon.setEnabled(enabled);
131
        lblDerivateType.setEnabled(enabled);
132
    }
133

    
134

    
135
    public Button getBtnBrowseTaxa() {
136
        return btnBrowseTaxa;
137
    }
138

    
139
    public Text getTextTaxonName() {
140
        return textTaxonName;
141
    }
142

    
143
    public Button getBtnClearTaxon() {
144
        return btnClearTaxon;
145
    }
146
    public Combo getComboTaxonAssignment() {
147
        return comboTaxonAssignment;
148
    }
149
}
(1-1/2)