Project

General

Profile

Download (5.49 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.view.derivateSearch;
11

    
12
import org.eclipse.jface.viewers.TableViewer;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.SelectionAdapter;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Combo;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.swt.widgets.Label;
21
import org.eclipse.swt.widgets.Table;
22
import org.eclipse.swt.widgets.Text;
23
import org.eclipse.ui.forms.widgets.FormToolkit;
24
import org.eclipse.ui.forms.widgets.TableWrapData;
25
import org.eclipse.ui.forms.widgets.TableWrapLayout;
26
import org.eclipse.wb.swt.ResourceManager;
27

    
28
/**
29
 * The widgets of the {@link DerivateSearchView}<br>
30
 *
31
 */
32
public class DerivateSearchComposite extends Composite {
33
    private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
34
    private final Text searchField;
35
    private final Table table;
36
    private final TableViewer resultViewer;
37
    private final Combo comboDerivateType;
38
    private final Button buttonSearch;
39
    private final Button btnFilterUndeterminedSpecimen;
40
    private final Text textTaxonName;
41
    private final Button btnBrowseTaxa;
42
    private final Label lblTaxon;
43
    private final Label lblDerivateType;
44

    
45
    /**
46
     * Create the composite.
47
     * @param parent
48
     * @param style
49
     */
50
    public DerivateSearchComposite(Composite parent, int style) {
51
        super(parent, style);
52
        {
53
            TableWrapLayout tableWrapLayout = new TableWrapLayout();
54
            tableWrapLayout.numColumns = 3;
55
            setLayout(tableWrapLayout);
56
        }
57

    
58
        lblTaxon = new Label(this, SWT.NONE);
59
        lblTaxon.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
60
        lblTaxon.setText("Taxon");
61

    
62
        textTaxonName = formToolkit.createText(this, "New Text", SWT.NONE);
63
        textTaxonName.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE, 1, 1));
64
        textTaxonName.setEnabled(false);
65
        textTaxonName.setText("");
66

    
67
        btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE);
68
        btnBrowseTaxa.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
69
        btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
70

    
71
        lblDerivateType = new Label(this, SWT.NULL);
72
        lblDerivateType.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
73
        lblDerivateType.setText("Derivate Type");
74

    
75
        comboDerivateType = new Combo(this, SWT.READ_ONLY);
76
        comboDerivateType.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE, 1, 1));
77
        formToolkit.paintBordersFor(comboDerivateType);
78

    
79
        btnFilterUndeterminedSpecimen = new Button(this, SWT.CHECK);
80
        btnFilterUndeterminedSpecimen.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
81
        btnFilterUndeterminedSpecimen.addSelectionListener(new SelectionAdapter() {
82
            @Override
83
            public void widgetSelected(SelectionEvent e) {
84
            }
85
        });
86
        btnFilterUndeterminedSpecimen.setText("Determined");
87

    
88
        buttonSearch = new Button(this, SWT.NONE);
89
        buttonSearch.setLayoutData(new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE, 1, 1));
90
        formToolkit.adapt(buttonSearch, true, true);
91
        buttonSearch.setText("Search");
92

    
93
        searchField = formToolkit.createText(this, "New Text", SWT.NONE);
94
        TableWrapData twd_searchField = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE, 1, 1);
95
        twd_searchField.align = TableWrapData.CENTER;
96
        searchField.setLayoutData(twd_searchField);
97
        searchField.setText("");
98
        new Label(this, SWT.NONE);
99

    
100
        resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
101
        table = resultViewer.getTable();
102
        table.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 2));
103
        new Label(this, SWT.NONE);
104

    
105
    }
106

    
107
    @Override
108
    protected void checkSubclass() {
109
        // Disable the check that prevents subclassing of SWT components
110
    }
111
    public Text getSearchField() {
112
        return searchField;
113
    }
114
    public TableViewer getResultViewer() {
115
        return resultViewer;
116
    }
117
    public Combo getComboDerivateType() {
118
        return comboDerivateType;
119
    }
120
    public Button getButtonSearch() {
121
        return buttonSearch;
122
    }
123

    
124
    @Override
125
    public void setEnabled(boolean enabled){
126
        super.setEnabled(enabled);
127
        searchField.setEnabled(enabled);
128
        table.setEnabled(enabled);
129
        //        resultViewer.setEnabled(enabled);
130
        comboDerivateType.setEnabled(enabled);
131
        buttonSearch.setEnabled(enabled);
132
        btnFilterUndeterminedSpecimen.setEnabled(enabled);
133
        btnBrowseTaxa.setEnabled(enabled);
134
        lblTaxon.setEnabled(enabled);
135
        lblDerivateType.setEnabled(enabled);
136
    }
137
    public Button getBtnFilterUndeterminedSpecimen() {
138
        return btnFilterUndeterminedSpecimen;
139
    }
140
    public Button getBtnBrowseTaxa() {
141
        return btnBrowseTaxa;
142
    }
143
    public Text getTextTaxonName() {
144
        return textTaxonName;
145
    }
146
}
(2-2/4)