Revision 219d7e87
Added by Patrick Plitzner about 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/search/facet/SearchController.java | ||
---|---|---|
11 | 11 |
import java.util.ArrayList; |
12 | 12 |
import java.util.Collections; |
13 | 13 |
import java.util.Comparator; |
14 |
import java.util.HashMap; |
|
14 | 15 |
import java.util.HashSet; |
15 | 16 |
import java.util.List; |
17 |
import java.util.Map; |
|
18 |
import java.util.Map.Entry; |
|
16 | 19 |
import java.util.Set; |
17 | 20 |
|
21 |
import org.eclipse.jface.layout.GridDataFactory; |
|
18 | 22 |
import org.eclipse.swt.SWT; |
19 | 23 |
import org.eclipse.swt.events.KeyEvent; |
20 | 24 |
import org.eclipse.swt.events.KeyListener; |
21 | 25 |
import org.eclipse.swt.events.SelectionEvent; |
22 | 26 |
import org.eclipse.swt.events.SelectionListener; |
27 |
import org.eclipse.swt.layout.GridLayout; |
|
23 | 28 |
import org.eclipse.swt.widgets.Composite; |
29 |
import org.eclipse.swt.widgets.Group; |
|
24 | 30 |
|
25 | 31 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
26 | 32 |
|
... | ... | |
70 | 76 |
} |
71 | 77 |
|
72 | 78 |
private void createFilterButtons(Set<Facet> facets) { |
79 |
Map<String, List<Facet>> categoryToFacetsMap = new HashMap<>(); |
|
73 | 80 |
for (Facet facet : facets) { |
74 |
if(facet.getFacet()!=null){
|
|
75 |
FilterComposite filterComposite = new FilterComposite(facet, this, composite.getFilterListComposite(), SWT.NONE);
|
|
76 |
appliedFacets.add(facet);
|
|
81 |
List<Facet> categoryFacets = categoryToFacetsMap.get(facet.getCategory());
|
|
82 |
if(categoryFacets==null){
|
|
83 |
categoryFacets = new ArrayList<>();
|
|
77 | 84 |
} |
85 |
categoryFacets.add(facet); |
|
86 |
categoryToFacetsMap.put(facet.getCategory(), categoryFacets); |
|
78 | 87 |
} |
88 |
for (Entry<String, List<Facet>> entry: categoryToFacetsMap.entrySet()) { |
|
89 |
String category = entry.getKey(); |
|
90 |
// create group |
|
91 |
Group group = new Group(composite.getFilterListComposite(), SWT.NONE); |
|
92 |
group.setLayout(new GridLayout()); |
|
93 |
GridDataFactory.fillDefaults().applyTo(group); |
|
94 |
group.setText(category!=null?category:"None"); |
|
95 |
// fill group with facet filters |
|
96 |
List<Facet> categoryFacets = entry.getValue(); |
|
97 |
for (Facet facet : categoryFacets) { |
|
98 |
if(facet.getFacet()!=null){ |
|
99 |
FilterComposite filterComposite = new FilterComposite(facet, this, group, SWT.NONE); |
|
100 |
appliedFacets.add(facet); |
|
101 |
} |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
79 | 105 |
} |
80 | 106 |
|
81 | 107 |
private Set<Facet> createResults(List<S> results) { |
Also available in: Unified diff
ref #8011 Use termType as facet category