- extended DerivateSearchView to allow multiple selection
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / derivateSearch / 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.view.derivateSearch;
11
12 import org.eclipse.jface.viewers.TableViewer;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.layout.GridData;
15 import org.eclipse.swt.layout.GridLayout;
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
25 /**
26 * The widgets of the {@link DerivateSearchView}<br>
27 *
28 */
29 public class DerivateSearchComposite extends Composite {
30 private final FormToolkit formToolkit = new FormToolkit(Display.getDefault());
31 private final Text searchField;
32 private final Table table;
33 private final TableViewer resultViewer;
34 private final Combo comboDerivateType;
35 private final Button buttonSearch;
36 private final Button btnFilterUndeterminedSpecimen;
37
38 /**
39 * Create the composite.
40 * @param parent
41 * @param style
42 */
43 public DerivateSearchComposite(Composite parent, int style) {
44 super(parent, style);
45 setLayout(new GridLayout(6, false));
46
47 Label lblDerivateType = new Label(this, SWT.NULL);
48 lblDerivateType.setText("Derivate Filter");
49
50 comboDerivateType = new Combo(this, SWT.READ_ONLY);
51 comboDerivateType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
52 formToolkit.paintBordersFor(comboDerivateType);
53
54 btnFilterUndeterminedSpecimen = new Button(this, SWT.CHECK);
55 btnFilterUndeterminedSpecimen.setText("Only undetermined specimen");
56 btnFilterUndeterminedSpecimen.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
57 new Label(this, SWT.NONE);
58 new Label(this, SWT.NONE);
59 new Label(this, SWT.NONE);
60
61 searchField = formToolkit.createText(this, "New Text", SWT.NONE);
62 searchField.setText("");
63 searchField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
64
65 buttonSearch = new Button(this, SWT.NONE);
66 buttonSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
67 formToolkit.adapt(buttonSearch, true, true);
68 buttonSearch.setText("Search");
69 new Label(this, SWT.NONE);
70 new Label(this, SWT.NONE);
71 new Label(this, SWT.NONE);
72
73 resultViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
74 table = resultViewer.getTable();
75 table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 4));
76
77 }
78
79 @Override
80 protected void checkSubclass() {
81 // Disable the check that prevents subclassing of SWT components
82 }
83 public Text getSearchField() {
84 return searchField;
85 }
86 public TableViewer getResultViewer() {
87 return resultViewer;
88 }
89 public Combo getComboDerivateType() {
90 return comboDerivateType;
91 }
92 public Button getButtonSearch() {
93 return buttonSearch;
94 }
95
96 @Override
97 public void setEnabled(boolean enabled){
98 super.setEnabled(enabled);
99 searchField.setEnabled(enabled);
100 table.setEnabled(enabled);
101 // resultViewer.setEnabled(enabled);
102 comboDerivateType.setEnabled(enabled);
103 buttonSearch.setEnabled(enabled);
104 btnFilterUndeterminedSpecimen.setEnabled(enabled);
105 }
106 public Button getBtnFilterUndeterminedSpecimen() {
107 return btnFilterUndeterminedSpecimen;
108 }
109 }