c4e8fe32517262df5a4daa69fa66bd2ae1497e21
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / derivate / searchFilter / DerivateSearchComposite.java
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 lbltaxonAssignment;
44 private Combo comboTaxonAssignment;
45 private Label lblTitleCache;
46
47 /**
48 * Create the composite.
49 *
50 * @param parent
51 * @param style
52 */
53 public DerivateSearchComposite(Composite parent, int style) {
54 super(parent, style);
55 setLayout(new GridLayout(7, false));
56
57 lblTaxon = new Label(this, SWT.NONE);
58 lblTaxon.setText("Taxon");
59
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("");
64
65 btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE);
66 btnBrowseTaxa.setAlignment(SWT.RIGHT);
67 btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
68
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"));
73
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");
77
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);
85
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");
89
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("");
93
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");
97
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);
101
102 buttonSearch = new Button(this, SWT.NONE);
103 formToolkit.adapt(buttonSearch, true, true);
104 buttonSearch.setText("Search");
105
106 }
107
108 @Override
109 protected void checkSubclass() {
110 // Disable the check that prevents subclassing of SWT components
111 }
112
113 public Text getSearchField() {
114 return searchField;
115 }
116
117 public Combo getComboDerivateType() {
118 return comboDerivateType;
119 }
120
121 public Button getButtonSearch() {
122 return buttonSearch;
123 }
124
125 @Override
126 public void setEnabled(boolean enabled) {
127 super.setEnabled(enabled);
128 searchField.setEnabled(enabled);
129 comboDerivateType.setEnabled(enabled);
130 buttonSearch.setEnabled(enabled);
131 btnBrowseTaxa.setEnabled(enabled);
132 lblTaxon.setEnabled(enabled);
133 lblDerivateType.setEnabled(enabled);
134 }
135
136
137 public Button getBtnBrowseTaxa() {
138 return btnBrowseTaxa;
139 }
140
141 public Text getTextTaxonName() {
142 return textTaxonName;
143 }
144
145 public Button getBtnClearTaxon() {
146 return btnClearTaxon;
147 }
148 public Combo getComboTaxonAssignment() {
149 return comboTaxonAssignment;
150 }
151 }