1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2019 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.search.facet;
|
11
|
|
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.Composite;
|
17
|
import org.eclipse.swt.widgets.Text;
|
18
|
|
19
|
/**
|
20
|
* @author pplitzner
|
21
|
* @date 22.01.2019
|
22
|
*
|
23
|
*/
|
24
|
public class SearchComposite extends Composite {
|
25
|
private Text txtSearch;
|
26
|
private ScrolledComposite filterScrolledComposite;
|
27
|
private Composite filterListComposite;
|
28
|
private Composite searchResultComposite;
|
29
|
private ScrolledComposite resultScrolledComposite;
|
30
|
|
31
|
/**
|
32
|
* Create the composite.
|
33
|
* @param parent
|
34
|
* @param style
|
35
|
*/
|
36
|
public SearchComposite(Composite parent, int style) {
|
37
|
super(parent, style);
|
38
|
setLayout(new GridLayout(2, false));
|
39
|
|
40
|
Composite filterComposite = new Composite(this, SWT.NONE);
|
41
|
filterComposite.setLayout(new GridLayout(1, false));
|
42
|
GridData gd_filterComposite = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
|
43
|
gd_filterComposite.widthHint = 170;
|
44
|
filterComposite.setLayoutData(gd_filterComposite);
|
45
|
|
46
|
txtSearch = new Text(filterComposite, SWT.BORDER);
|
47
|
txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
|
48
|
|
49
|
filterScrolledComposite = new ScrolledComposite(filterComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
50
|
filterScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
51
|
filterScrolledComposite.setExpandHorizontal(true);
|
52
|
filterScrolledComposite.setExpandVertical(true);
|
53
|
|
54
|
initFilterList();
|
55
|
|
56
|
Composite composite_1 = new Composite(this, SWT.NONE);
|
57
|
composite_1.setLayout(new GridLayout(1, false));
|
58
|
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
59
|
|
60
|
resultScrolledComposite = new ScrolledComposite(composite_1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
61
|
resultScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
62
|
resultScrolledComposite.setExpandHorizontal(true);
|
63
|
resultScrolledComposite.setExpandVertical(true);
|
64
|
|
65
|
initSearchResultList();
|
66
|
|
67
|
}
|
68
|
|
69
|
private void initSearchResultList() {
|
70
|
searchResultComposite = new Composite(resultScrolledComposite, SWT.NONE);
|
71
|
searchResultComposite.setLayout(new GridLayout(1, false));
|
72
|
resultScrolledComposite.setContent(searchResultComposite);
|
73
|
resultScrolledComposite.setMinSize(searchResultComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
74
|
}
|
75
|
|
76
|
private void initFilterList() {
|
77
|
filterListComposite = new Composite(filterScrolledComposite, SWT.NONE);
|
78
|
GridLayout gl_filterListComposite = new GridLayout(1, false);
|
79
|
gl_filterListComposite.marginHeight = 0;
|
80
|
gl_filterListComposite.verticalSpacing = 0;
|
81
|
filterListComposite.setLayout(gl_filterListComposite);
|
82
|
filterScrolledComposite.setContent(filterListComposite);
|
83
|
filterScrolledComposite.setMinSize(filterListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
84
|
}
|
85
|
|
86
|
@Override
|
87
|
protected void checkSubclass() {
|
88
|
// Disable the check that prevents subclassing of SWT components
|
89
|
}
|
90
|
public Text getTxtSearch() {
|
91
|
return txtSearch;
|
92
|
}
|
93
|
|
94
|
public Composite getFilterListComposite() {
|
95
|
return filterListComposite;
|
96
|
}
|
97
|
|
98
|
public void clear(){
|
99
|
filterListComposite.dispose();
|
100
|
initFilterList();
|
101
|
|
102
|
clearResults();
|
103
|
}
|
104
|
|
105
|
public void clearResults() {
|
106
|
searchResultComposite.dispose();
|
107
|
initSearchResultList();
|
108
|
}
|
109
|
|
110
|
public void refresh(){
|
111
|
filterScrolledComposite.layout(true, true);
|
112
|
filterScrolledComposite.setMinSize(filterListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
113
|
resultScrolledComposite.layout(true, true);
|
114
|
resultScrolledComposite.setMinSize(searchResultComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
115
|
}
|
116
|
public Composite getSearchResultComposite() {
|
117
|
return searchResultComposite;
|
118
|
}
|
119
|
}
|