Revision a1b92e88
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorQuery.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.bulkeditor; |
11 | 11 |
|
12 | 12 |
import java.util.ArrayList; |
13 |
import java.util.Comparator; |
|
14 | 13 |
import java.util.List; |
15 | 14 |
|
16 | 15 |
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; |
... | ... | |
26 | 25 |
public class BulkEditorQuery { |
27 | 26 |
|
28 | 27 |
private final String searchString; |
29 |
private final Comparator<?> comparator; |
|
30 | 28 |
private final IIdentifiableEntityServiceConfigurator searchConfigurator; |
31 | 29 |
|
32 |
public BulkEditorQuery (String searchString, Comparator comparator) {
|
|
30 |
public BulkEditorQuery (String searchString) { |
|
33 | 31 |
this.searchString = searchString; |
34 |
this.comparator = comparator; |
|
35 | 32 |
List<String> propertyPath = new ArrayList<String>(); |
36 | 33 |
propertyPath.add("markers"); |
37 | 34 |
searchConfigurator = IdentifiableServiceConfiguratorFactory.getConfigurator(IdentifiableEntity.class); |
... | ... | |
42 | 39 |
searchConfigurator.setPageSize(20); |
43 | 40 |
} |
44 | 41 |
|
45 |
public Comparator getComparator() { |
|
46 |
return comparator; |
|
47 |
} |
|
48 |
|
|
49 | 42 |
public String getSearchString() { |
50 | 43 |
return searchString; |
51 | 44 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorSortCombo.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2007 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
|
|
10 |
package eu.etaxonomy.taxeditor.bulkeditor; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Comparator; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Set; |
|
16 |
|
|
17 |
import org.eclipse.swt.SWT; |
|
18 |
import org.eclipse.swt.events.SelectionAdapter; |
|
19 |
import org.eclipse.swt.events.SelectionEvent; |
|
20 |
import org.eclipse.swt.widgets.Combo; |
|
21 |
import org.eclipse.swt.widgets.Composite; |
|
22 |
import org.eclipse.swt.widgets.Label; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author n.hoffmann |
|
26 |
* @created Dec 14, 2010 |
|
27 |
* @version 1.0 |
|
28 |
*/ |
|
29 |
public class BulkEditorSortCombo { |
|
30 |
|
|
31 |
private Label label; |
|
32 |
|
|
33 |
private Combo combo; |
|
34 |
|
|
35 |
private List<IBulkEditorSortProvider> sortProviders; |
|
36 |
|
|
37 |
private List<Comparator> comparators = new ArrayList<Comparator>(); |
|
38 |
|
|
39 |
private int selectedIndex = 0; |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
public BulkEditorSortCombo(Composite parent, List<IBulkEditorSortProvider> sortProviders) { |
|
45 |
this.sortProviders = sortProviders; |
|
46 |
if(! sortProviders.isEmpty()){ |
|
47 |
label = new Label(parent, SWT.NONE); |
|
48 |
label.setText("Sort by"); |
|
49 |
|
|
50 |
combo = new Combo(parent, SWT.DROP_DOWN); |
|
51 |
|
|
52 |
fillCombo(); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* |
|
58 |
*/ |
|
59 |
private void fillCombo() { |
|
60 |
for(IBulkEditorSortProvider sortProvider : sortProviders){ |
|
61 |
Set<String> names = sortProvider.getComparatorNames(); |
|
62 |
for(String name : names){ |
|
63 |
combo.add(name); |
|
64 |
comparators.add(sortProvider.getComparatorByName(name)); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
combo.addSelectionListener(new SelectionListener()); |
|
69 |
combo.select(selectedIndex); |
|
70 |
} |
|
71 |
|
|
72 |
private class SelectionListener extends SelectionAdapter{ |
|
73 |
/* (non-Javadoc) |
|
74 |
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public void widgetSelected(SelectionEvent e) { |
|
78 |
selectedIndex = combo.getSelectionIndex(); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* |
|
84 |
*/ |
|
85 |
public Comparator getSelection() { |
|
86 |
return comparators.get(selectedIndex); |
|
87 |
} |
|
88 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
158 | 158 |
thisPart.setLabel(input.getEditorName()); |
159 | 159 |
|
160 | 160 |
if(input.getEntityUuid()!=null){ |
161 |
performSearch(new BulkEditorQuery(input.getEntityUuid().toString(), null));
|
|
161 |
performSearch(new BulkEditorQuery(input.getEntityUuid().toString())); |
|
162 | 162 |
} |
163 | 163 |
|
164 | 164 |
createTable(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorSearchE4.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.bulkeditor.e4; |
11 | 11 |
|
12 |
import java.util.Comparator; |
|
13 |
|
|
14 | 12 |
import org.eclipse.swt.SWT; |
15 | 13 |
import org.eclipse.swt.events.FocusEvent; |
16 | 14 |
import org.eclipse.swt.events.FocusListener; |
... | ... | |
29 | 27 |
|
30 | 28 |
import eu.etaxonomy.cdm.common.CdmUtils; |
31 | 29 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery; |
32 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorSortCombo; |
|
33 | 30 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
34 | 31 |
import eu.etaxonomy.taxeditor.model.ColorResources; |
35 | 32 |
import eu.etaxonomy.taxeditor.preference.Resources; |
... | ... | |
51 | 48 |
private final BulkEditorE4 editor; |
52 | 49 |
|
53 | 50 |
private Text text; |
54 |
private BulkEditorSortCombo sortCombo; |
|
55 | 51 |
|
56 | 52 |
private Button button; |
57 | 53 |
|
... | ... | |
76 | 72 |
|
77 | 73 |
createSearchTextField(container, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); |
78 | 74 |
|
79 |
createSortCombo(container, style); |
|
80 |
|
|
81 | 75 |
button = new Button(container, SWT.PUSH); |
82 | 76 |
button.setText(SEARCH); |
83 | 77 |
button.addSelectionListener(new SelectionAdapter() { |
... | ... | |
90 | 84 |
registerAtFocusService(); |
91 | 85 |
} |
92 | 86 |
|
93 |
private void createSortCombo(Composite parent, int style) { |
|
94 |
sortCombo = new BulkEditorSortCombo(parent, editor.getEditorInput().getSortProviders()); |
|
95 |
|
|
96 |
} |
|
97 |
|
|
98 | 87 |
/** |
99 | 88 |
* Handles focus changes for the textfield. |
100 | 89 |
*/ |
... | ... | |
162 | 151 |
return; |
163 | 152 |
} |
164 | 153 |
|
165 |
BulkEditorQuery query = new BulkEditorQuery(searchString, getComparator());
|
|
154 |
BulkEditorQuery query = new BulkEditorQuery(searchString); |
|
166 | 155 |
editor.performSearch(query); |
167 | 156 |
} |
168 | 157 |
|
... | ... | |
174 | 163 |
return text.getText().trim(); |
175 | 164 |
} |
176 | 165 |
|
177 |
public Comparator getComparator() { |
|
178 |
return sortCombo.getSelection(); |
|
179 |
} |
|
180 |
|
|
181 | 166 |
public void setFocus() { |
182 | 167 |
if(text != null && ! text.isDisposed()){ |
183 | 168 |
text.setFocus(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.input; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.Comparator; |
|
13 | 12 |
import java.util.HashMap; |
14 | 13 |
import java.util.HashSet; |
15 | 14 |
import java.util.List; |
... | ... | |
37 | 36 |
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery; |
38 | 37 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; |
39 | 38 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider; |
40 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator; |
|
41 | 39 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
42 | 40 |
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput; |
43 | 41 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
... | ... | |
162 | 160 |
else if(bulkEditorQuery != null){ |
163 | 161 |
|
164 | 162 |
IIdentifiableEntityServiceConfigurator configurator = bulkEditorQuery.getSearchConfigurator(); |
165 |
Comparator queryComparator = (bulkEditorQuery.getComparator() != null) ? bulkEditorQuery.getComparator() : new TitleCacheComparator(); |
|
166 |
|
|
167 | 163 |
|
168 | 164 |
int pageSize = configurator.getPageSize()!=null?configurator.getPageSize():getPageSize(); |
169 | 165 |
long count = countEntities(configurator); |
Also available in: Unified diff
ref #7439 Remove sort type combo box