3 * Copyright (C) 2019 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
.view
.search
.facet
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
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
.Composite
;
18 import org
.eclipse
.swt
.widgets
.Text
;
20 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
27 public class SearchComposite
extends Composite
{
28 private Text txtSearch
;
29 private ScrolledComposite filterScrolledComposite
;
30 private Composite filterListComposite
;
31 private Composite searchResultComposite
;
32 private ScrolledComposite resultScrolledComposite
;
33 private Composite composite
;
34 private Button btnSearchButton
;
37 * Create the composite.
41 public SearchComposite(Composite parent
, int style
) {
43 setLayout(new GridLayout(2, false));
45 Composite filterComposite
= new Composite(this, SWT
.NONE
);
46 filterComposite
.setLayout(new GridLayout(1, false));
47 GridData gd_filterComposite
= new GridData(SWT
.FILL
, SWT
.FILL
, false, false, 1, 1);
48 gd_filterComposite
.widthHint
= 170;
49 filterComposite
.setLayoutData(gd_filterComposite
);
51 composite
= new Composite(filterComposite
, SWT
.NONE
);
52 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, false, false, 1, 1));
53 composite
.setLayout(new GridLayout(2, false));
55 txtSearch
= new Text(composite
, SWT
.BORDER
);
56 txtSearch
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1));
58 btnSearchButton
= new Button(composite
, SWT
.NONE
);
59 btnSearchButton
.setImage(ImageResources
.getImage(ImageResources
.SEARCH_ICON
));
61 filterScrolledComposite
= new ScrolledComposite(filterComposite
, SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
);
62 filterScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 1));
63 filterScrolledComposite
.setExpandHorizontal(true);
64 filterScrolledComposite
.setExpandVertical(true);
68 Composite composite_1
= new Composite(this, SWT
.NONE
);
69 composite_1
.setLayout(new GridLayout(1, false));
70 composite_1
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 1));
72 resultScrolledComposite
= new ScrolledComposite(composite_1
, SWT
.BORDER
| SWT
.H_SCROLL
| SWT
.V_SCROLL
);
73 resultScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 1, 1));
74 resultScrolledComposite
.setExpandHorizontal(true);
75 resultScrolledComposite
.setExpandVertical(true);
77 initSearchResultList();
81 private void initSearchResultList() {
82 searchResultComposite
= new Composite(resultScrolledComposite
, SWT
.NONE
);
83 searchResultComposite
.setLayout(new GridLayout(1, false));
84 resultScrolledComposite
.setContent(searchResultComposite
);
85 resultScrolledComposite
.setMinSize(searchResultComposite
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
88 private void initFilterList() {
89 filterListComposite
= new Composite(filterScrolledComposite
, SWT
.NONE
);
90 GridLayout gl_filterListComposite
= new GridLayout(1, false);
91 gl_filterListComposite
.marginHeight
= 0;
92 gl_filterListComposite
.verticalSpacing
= 0;
93 filterListComposite
.setLayout(gl_filterListComposite
);
94 filterScrolledComposite
.setContent(filterListComposite
);
95 filterScrolledComposite
.setMinSize(filterListComposite
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
99 protected void checkSubclass() {
100 // Disable the check that prevents subclassing of SWT components
102 public Text
getTxtSearch() {
106 public Composite
getFilterListComposite() {
107 return filterListComposite
;
111 filterListComposite
.dispose();
117 public void clearResults() {
118 searchResultComposite
.dispose();
119 initSearchResultList();
122 public void refresh(){
123 filterScrolledComposite
.layout(true, true);
124 filterScrolledComposite
.setMinSize(filterListComposite
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
125 resultScrolledComposite
.layout(true, true);
126 resultScrolledComposite
.setMinSize(searchResultComposite
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
128 public Composite
getSearchResultComposite() {
129 return searchResultComposite
;
131 public Button
getBtnSearchButton() {
132 return btnSearchButton
;