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.SashForm;
|
14
|
import org.eclipse.swt.custom.ScrolledComposite;
|
15
|
import org.eclipse.swt.layout.GridData;
|
16
|
import org.eclipse.swt.layout.GridLayout;
|
17
|
import org.eclipse.swt.widgets.Button;
|
18
|
import org.eclipse.swt.widgets.Composite;
|
19
|
import org.eclipse.swt.widgets.Text;
|
20
|
|
21
|
import eu.etaxonomy.taxeditor.model.ImageResources;
|
22
|
|
23
|
/**
|
24
|
* @author pplitzner
|
25
|
* @date 22.01.2019
|
26
|
*
|
27
|
*/
|
28
|
public class SearchComposite extends SashForm {
|
29
|
private Text txtSearch;
|
30
|
private ScrolledComposite filterScrolledComposite;
|
31
|
private Composite filterListComposite;
|
32
|
private Composite searchResultComposite;
|
33
|
private ScrolledComposite resultScrolledComposite;
|
34
|
private Button btnSearchButton;
|
35
|
|
36
|
/**
|
37
|
* Create the composite.
|
38
|
* @param parent
|
39
|
* @param style
|
40
|
*/
|
41
|
public SearchComposite(Composite parent, int style) {
|
42
|
super(parent, style);
|
43
|
setLayout(new GridLayout(2, false));
|
44
|
|
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
|
filterComposite.setLayoutData(gd_filterComposite);
|
49
|
|
50
|
Composite composite = new Composite(filterComposite, SWT.NONE);
|
51
|
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
|
52
|
composite.setLayout(new GridLayout(2, false));
|
53
|
|
54
|
txtSearch = new Text(composite, SWT.BORDER);
|
55
|
txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
|
56
|
|
57
|
btnSearchButton = new Button(composite, SWT.NONE);
|
58
|
btnSearchButton.setImage(ImageResources.getImage(ImageResources.SEARCH_ICON));
|
59
|
|
60
|
filterScrolledComposite = new ScrolledComposite(filterComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
61
|
filterScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
62
|
filterScrolledComposite.setExpandHorizontal(true);
|
63
|
filterScrolledComposite.setExpandVertical(true);
|
64
|
|
65
|
initFilterList();
|
66
|
|
67
|
Composite composite_1 = new Composite(this, SWT.NONE);
|
68
|
composite_1.setLayout(new GridLayout(1, false));
|
69
|
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
70
|
|
71
|
resultScrolledComposite = new ScrolledComposite(composite_1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
72
|
resultScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
73
|
resultScrolledComposite.setExpandHorizontal(true);
|
74
|
resultScrolledComposite.setExpandVertical(true);
|
75
|
setWeights(new int[] {40, 60});
|
76
|
|
77
|
initSearchResultList();
|
78
|
|
79
|
|
80
|
}
|
81
|
|
82
|
private void initSearchResultList() {
|
83
|
searchResultComposite = new Composite(resultScrolledComposite, SWT.NONE);
|
84
|
searchResultComposite.setLayout(new GridLayout(1, false));
|
85
|
resultScrolledComposite.setContent(searchResultComposite);
|
86
|
resultScrolledComposite.setMinSize(searchResultComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
87
|
}
|
88
|
|
89
|
private void initFilterList() {
|
90
|
filterListComposite = new Composite(filterScrolledComposite, SWT.NONE);
|
91
|
GridLayout gl_filterListComposite = new GridLayout(1, false);
|
92
|
gl_filterListComposite.marginHeight = 0;
|
93
|
gl_filterListComposite.verticalSpacing = 0;
|
94
|
filterListComposite.setLayout(gl_filterListComposite);
|
95
|
filterScrolledComposite.setContent(filterListComposite);
|
96
|
filterScrolledComposite.setMinSize(filterListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
97
|
}
|
98
|
|
99
|
@Override
|
100
|
protected void checkSubclass() {
|
101
|
// Disable the check that prevents subclassing of SWT components
|
102
|
}
|
103
|
public Text getTxtSearch() {
|
104
|
return txtSearch;
|
105
|
}
|
106
|
|
107
|
public Composite getFilterListComposite() {
|
108
|
return filterListComposite;
|
109
|
}
|
110
|
|
111
|
public void clear(){
|
112
|
filterListComposite.dispose();
|
113
|
initFilterList();
|
114
|
|
115
|
clearResults();
|
116
|
}
|
117
|
|
118
|
public void clearResults() {
|
119
|
searchResultComposite.dispose();
|
120
|
initSearchResultList();
|
121
|
}
|
122
|
|
123
|
public void refresh(){
|
124
|
filterScrolledComposite.layout(true, true);
|
125
|
filterScrolledComposite.setMinSize(filterListComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
126
|
resultScrolledComposite.layout(true, true);
|
127
|
resultScrolledComposite.setMinSize(searchResultComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
128
|
}
|
129
|
public Composite getSearchResultComposite() {
|
130
|
return searchResultComposite;
|
131
|
}
|
132
|
public Button getBtnSearchButton() {
|
133
|
return btnSearchButton;
|
134
|
}
|
135
|
}
|