Project

General

Profile

Download (5.89 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.editor.view.derivate.searchFilter;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.layout.GridData;
13
import org.eclipse.swt.layout.GridLayout;
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.Display;
18
import org.eclipse.swt.widgets.Label;
19
import org.eclipse.swt.widgets.Text;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.wb.swt.ResourceManager;
22

    
23
import eu.etaxonomy.taxeditor.editor.Messages;
24

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

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

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

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

    
58
        lblTaxon = new Label(this, SWT.NONE);
59
        lblTaxon.setText(Messages.DerivateSearchComposite_TAXON);
60

    
61
        textTaxonName = formToolkit.createText(this, Messages.DerivateSearchComposite_NEW_TEXT, SWT.BORDER);
62
        textTaxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
63
        textTaxonName.setEnabled(false);
64
        textTaxonName.setText(""); //$NON-NLS-1$
65

    
66
        btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE); //$NON-NLS-1$
67
        btnBrowseTaxa.setAlignment(SWT.RIGHT);
68
        btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif")); //$NON-NLS-1$ //$NON-NLS-2$
69

    
70
        btnClearTaxon = formToolkit.createButton(this, "", SWT.NONE); //$NON-NLS-1$
71
        btnClearTaxon.setAlignment(SWT.RIGHT);
72
        btnClearTaxon.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
73
        btnClearTaxon.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif")); //$NON-NLS-1$ //$NON-NLS-2$
74

    
75
        lbltaxonAssignment = new Label(this, SWT.NONE);
76
        lbltaxonAssignment.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
77
        lbltaxonAssignment.setText(Messages.DerivateSearchComposite_TAXON_ASSIGNMENT);
78

    
79
        comboTaxonAssignment = new Combo(this, SWT.NONE);
80
        comboTaxonAssignment.setItems(new String[] { Messages.DerivateSearchComposite_ALL, Messages.DerivateSearchComposite_YES, Messages.DerivateSearchComposite_NO });
81
        comboTaxonAssignment.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
82
        formToolkit.adapt(comboTaxonAssignment);
83
        formToolkit.paintBordersFor(comboTaxonAssignment);
84
        comboTaxonAssignment.select(ALL_SPECIMENS);
85
        new Label(this, SWT.NONE);
86

    
87
        lblTitleCache = new Label(this, SWT.NONE);
88
        lblTitleCache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
89
        lblTitleCache.setText(Messages.DerivateSearchComposite_TITLE_CACHE);
90

    
91
        searchField = formToolkit.createText(this, "New Text", SWT.BORDER); //$NON-NLS-1$
92
        searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
93
        searchField.setText(""); //$NON-NLS-1$
94

    
95
        lblDerivateType = new Label(this, SWT.NULL);
96
        lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
97
        lblDerivateType.setText(Messages.DerivateSearchComposite_DERIVATE_TYPE);
98

    
99
        comboDerivateType = new Combo(this, SWT.READ_ONLY);
100
        comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
101
        formToolkit.paintBordersFor(comboDerivateType);
102

    
103
        buttonSearch = new Button(this, SWT.NONE);
104
        formToolkit.adapt(buttonSearch, true, true);
105
        buttonSearch.setText(Messages.DerivateSearchComposite_SEARCH);
106

    
107
    }
108

    
109
    @Override
110
    protected void checkSubclass() {
111
        // Disable the check that prevents subclassing of SWT components
112
    }
113

    
114
    public Text getSearchField() {
115
        return searchField;
116
    }
117

    
118
    public Combo getComboDerivateType() {
119
        return comboDerivateType;
120
    }
121

    
122
    public Button getButtonSearch() {
123
        return buttonSearch;
124
    }
125

    
126
    @Override
127
    public void setEnabled(boolean enabled) {
128
        super.setEnabled(enabled);
129
        searchField.setEnabled(enabled);
130
        comboDerivateType.setEnabled(enabled);
131
        comboTaxonAssignment.setEnabled(enabled);
132
        buttonSearch.setEnabled(enabled);
133
        btnBrowseTaxa.setEnabled(enabled);
134
        btnClearTaxon.setEnabled(enabled);
135
        lblTaxon.setEnabled(enabled);
136
        lblTitleCache.setEnabled(enabled);
137
        lbltaxonAssignment.setEnabled(enabled);
138
        lblDerivateType.setEnabled(enabled);
139
    }
140

    
141

    
142
    public Button getBtnBrowseTaxa() {
143
        return btnBrowseTaxa;
144
    }
145

    
146
    public Text getTextTaxonName() {
147
        return textTaxonName;
148
    }
149

    
150
    public Button getBtnClearTaxon() {
151
        return btnClearTaxon;
152
    }
153
    public Combo getComboTaxonAssignment() {
154
        return comboTaxonAssignment;
155
    }
156

    
157
    public Label getLbltaxonAssignment() {
158
        return lbltaxonAssignment;
159
    }
160
}
(1-1/2)