2 * Copyright (C) 2013 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.searchFilter
;
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
;
23 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
26 * The widgets of the {@link DerivateSearchView}<br>
29 public class DerivateSearchComposite
extends Composite
{
31 public static final int ALL_SPECIMENS
= 0;
32 public static final int ASSIGNED_SPECIMENS
= 1;
33 public static final int UNASSIGNED_SPECIMENS
= 2;
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
;
49 * Create the composite.
54 public DerivateSearchComposite(Composite parent
, int style
) {
56 setLayout(new GridLayout(7, false));
58 lblTaxon
= new Label(this, SWT
.NONE
);
59 lblTaxon
.setText(Messages
.DerivateSearchComposite_TAXON
);
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$
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$
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$
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
);
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
);
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
);
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$
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
);
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
);
103 buttonSearch
= new Button(this, SWT
.NONE
);
104 formToolkit
.adapt(buttonSearch
, true, true);
105 buttonSearch
.setText(Messages
.DerivateSearchComposite_SEARCH
);
110 protected void checkSubclass() {
111 // Disable the check that prevents subclassing of SWT components
114 public Text
getSearchField() {
118 public Combo
getComboDerivateType() {
119 return comboDerivateType
;
122 public Button
getButtonSearch() {
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
);
142 public Button
getBtnBrowseTaxa() {
143 return btnBrowseTaxa
;
146 public Text
getTextTaxonName() {
147 return textTaxonName
;
150 public Button
getBtnClearTaxon() {
151 return btnClearTaxon
;
153 public Combo
getComboTaxonAssignment() {
154 return comboTaxonAssignment
;
157 public Label
getLbltaxonAssignment() {
158 return lbltaxonAssignment
;