02f3e5d051038f21156117d35f045b057f7155de
[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 private Button buttonToggleLink;
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("Taxon");
60
61 textTaxonName = formToolkit.createText(this, "New Text", SWT.BORDER);
62 textTaxonName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
63 textTaxonName.setEnabled(false);
64 textTaxonName.setText("");
65
66 btnBrowseTaxa = formToolkit.createButton(this, "", SWT.NONE);
67 btnBrowseTaxa.setAlignment(SWT.RIGHT);
68 btnBrowseTaxa.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
69
70 btnClearTaxon = formToolkit.createButton(this, "", SWT.NONE);
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"));
74
75 lbltaxonAssignment = new Label(this, SWT.NONE);
76 lbltaxonAssignment.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
77 lbltaxonAssignment.setText("Taxon assignment");
78
79 comboTaxonAssignment = new Combo(this, SWT.NONE);
80 comboTaxonAssignment.setItems(new String[] { "All", "Yes", "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
86 buttonToggleLink = new Button(this, SWT.NONE);
87 buttonToggleLink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
88 buttonToggleLink.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.editor", "icons/synced.gif"));
89 formToolkit.adapt(buttonToggleLink, true, true);
90
91 lblTitleCache = new Label(this, SWT.NONE);
92 lblTitleCache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
93 lblTitleCache.setText("Title Cache");
94
95 searchField = formToolkit.createText(this, "New Text", SWT.BORDER);
96 searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
97 searchField.setText("");
98
99 lblDerivateType = new Label(this, SWT.NULL);
100 lblDerivateType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
101 lblDerivateType.setText("Derivative Type");
102
103 comboDerivateType = new Combo(this, SWT.READ_ONLY);
104 comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
105 formToolkit.paintBordersFor(comboDerivateType);
106
107 buttonSearch = new Button(this, SWT.NONE);
108 formToolkit.adapt(buttonSearch, true, true);
109 buttonSearch.setText("Search");
110
111 }
112
113 @Override
114 protected void checkSubclass() {
115 // Disable the check that prevents subclassing of SWT components
116 }
117
118 public Text getSearchField() {
119 return searchField;
120 }
121
122 public Combo getComboDerivateType() {
123 return comboDerivateType;
124 }
125
126 public Button getButtonSearch() {
127 return buttonSearch;
128 }
129
130 @Override
131 public void setEnabled(boolean enabled) {
132 super.setEnabled(enabled);
133 searchField.setEnabled(enabled);
134 comboDerivateType.setEnabled(enabled);
135 comboTaxonAssignment.setEnabled(enabled);
136 buttonSearch.setEnabled(enabled);
137 btnBrowseTaxa.setEnabled(enabled);
138 btnClearTaxon.setEnabled(enabled);
139 lblTaxon.setEnabled(enabled);
140 lblTitleCache.setEnabled(enabled);
141 lbltaxonAssignment.setEnabled(enabled);
142 lblDerivateType.setEnabled(enabled);
143 }
144
145
146 public Button getBtnBrowseTaxa() {
147 return btnBrowseTaxa;
148 }
149
150 public Text getTextTaxonName() {
151 return textTaxonName;
152 }
153
154 public Button getBtnClearTaxon() {
155 return btnClearTaxon;
156 }
157 public Combo getComboTaxonAssignment() {
158 return comboTaxonAssignment;
159 }
160
161 public Label getLbltaxonAssignment() {
162 return lbltaxonAssignment;
163 }
164 public Button getButtonToggleLink() {
165 return buttonToggleLink;
166 }
167 }