3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.searchFilter
;
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
;
25 * The widgets of the {@link DerivateSearchView}<br>
28 public class DerivateSearchComposite
extends Composite
{
30 public static final int ALL_SPECIMENS
= 0;
31 public static final int ASSIGNED_SPECIMENS
= 1;
32 public static final int UNASSIGNED_SPECIMENS
= 2;
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 lbltaxonAssignment
;
44 private Combo comboTaxonAssignment
;
45 private Label lblTitleCache
;
48 * Create the composite.
53 public DerivateSearchComposite(Composite parent
, int style
) {
55 setLayout(new GridLayout(7, false));
57 lblTaxon
= new Label(this, SWT
.NONE
);
58 lblTaxon
.setText("Taxon");
60 textTaxonName
= formToolkit
.createText(this, "New Text", SWT
.BORDER
);
61 textTaxonName
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 1, 1));
62 textTaxonName
.setEnabled(false);
63 textTaxonName
.setText("");
65 btnBrowseTaxa
= formToolkit
.createButton(this, "", SWT
.NONE
);
66 btnBrowseTaxa
.setAlignment(SWT
.RIGHT
);
67 btnBrowseTaxa
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/prj_obj.gif"));
69 btnClearTaxon
= formToolkit
.createButton(this, "", SWT
.NONE
);
70 btnClearTaxon
.setAlignment(SWT
.RIGHT
);
71 btnClearTaxon
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.TOP
, false, false, 1, 1));
72 btnClearTaxon
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
74 lbltaxonAssignment
= new Label(this, SWT
.NONE
);
75 lbltaxonAssignment
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
76 lbltaxonAssignment
.setText("Taxon assignment");
78 comboTaxonAssignment
= new Combo(this, SWT
.NONE
);
79 comboTaxonAssignment
.setItems(new String
[] { "All", "Yes", "No" });
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
);
86 lblTitleCache
= new Label(this, SWT
.NONE
);
87 lblTitleCache
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
88 lblTitleCache
.setText("Title Cache");
90 searchField
= formToolkit
.createText(this, "New Text", SWT
.BORDER
);
91 searchField
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 3, 1));
92 searchField
.setText("");
94 lblDerivateType
= new Label(this, SWT
.NULL
);
95 lblDerivateType
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 1, 1));
96 lblDerivateType
.setText("Derivative Type");
98 comboDerivateType
= new Combo(this, SWT
.READ_ONLY
);
99 comboDerivateType
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, false, false, 1, 1));
100 formToolkit
.paintBordersFor(comboDerivateType
);
102 buttonSearch
= new Button(this, SWT
.NONE
);
103 formToolkit
.adapt(buttonSearch
, true, true);
104 buttonSearch
.setText("Search");
109 protected void checkSubclass() {
110 // Disable the check that prevents subclassing of SWT components
113 public Text
getSearchField() {
117 public Combo
getComboDerivateType() {
118 return comboDerivateType
;
121 public Button
getButtonSearch() {
126 public void setEnabled(boolean enabled
) {
127 super.setEnabled(enabled
);
128 searchField
.setEnabled(enabled
);
129 comboDerivateType
.setEnabled(enabled
);
130 comboTaxonAssignment
.setEnabled(enabled
);
131 buttonSearch
.setEnabled(enabled
);
132 btnBrowseTaxa
.setEnabled(enabled
);
133 btnClearTaxon
.setEnabled(enabled
);
134 lblTaxon
.setEnabled(enabled
);
135 lblTitleCache
.setEnabled(enabled
);
136 lbltaxonAssignment
.setEnabled(enabled
);
137 lblDerivateType
.setEnabled(enabled
);
141 public Button
getBtnBrowseTaxa() {
142 return btnBrowseTaxa
;
145 public Text
getTextTaxonName() {
146 return textTaxonName
;
149 public Button
getBtnClearTaxon() {
150 return btnClearTaxon
;
152 public Combo
getComboTaxonAssignment() {
153 return comboTaxonAssignment
;
156 public Label
getLbltaxonAssignment() {
157 return lbltaxonAssignment
;