Revision 305c1b35
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java | ||
---|---|---|
250 | 250 |
public static final String SHOW_MEDIA = "eu.etaxonomy.taxeditor.view.showMedia"; |
251 | 251 |
public static final String SHOW_CHECKLIST_PERSPECTIVE = "eu.etaxonomy.taxeditor.perspective.showChecklist"; |
252 | 252 |
public static final String SHOW_TAXONNODE_WIZARD = "eu.etaxonomy.taxeditor.menu.showTaxonNodeWizard"; |
253 |
|
|
253 |
public static final String IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT = "eu.etaxonomy.taxeditor.search.reference.defaultIdentifier"; |
|
254 |
public static final String SEARCH_FOR_IDENTIFIER_AND_TITLECACHE = "eu.etaxonomy.taxeditor.search.reference.identifierAndTitleCache"; |
|
254 | 255 |
|
255 | 256 |
|
256 | 257 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchPreferences.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 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 |
package eu.etaxonomy.taxeditor.preference; |
|
10 |
|
|
11 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
12 |
|
|
13 |
import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author k.luther |
|
17 |
* @since 16.10.2018 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class SearchPreferences extends FieldEditorPreferencePageE4 { |
|
21 |
|
|
22 |
/** |
|
23 |
* {@inheritDoc} |
|
24 |
*/ |
|
25 |
@Override |
|
26 |
protected void createFieldEditors() { |
|
27 |
|
|
28 |
addField(new BooleanFieldEditor(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT, |
|
29 |
"Set search for Identifier as default.", |
|
30 |
getFieldEditorParent())); |
|
31 |
addField(new BooleanFieldEditor(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE, |
|
32 |
"Search for identifier and titleCache, if identifier search is enabled", |
|
33 |
getFieldEditorParent())); |
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java | ||
---|---|---|
179 | 179 |
} |
180 | 180 |
|
181 | 181 |
}else{ |
182 |
if (isUseIdentifier()){ |
|
182 |
if (isUseIdentifier() && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE)){ |
|
183 |
List<IdentifiedEntityDTO<Reference>> list = CdmStore.getService(IReferenceService.class).listByIdentifierAndTitleCacheAbbrev(pattern, null, MatchMode.BEGINNING, limitOfInitialElements); |
|
184 |
if (model!= null){ |
|
185 |
model.clear(); |
|
186 |
} |
|
187 |
identifierMap = new HashMap(); |
|
188 |
for (IdentifiedEntityDTO dto: list){ |
|
189 |
if (dto.getIdentifier() != null){ |
|
190 |
identifierMap.put(dto.getCdmEntity().getUuid(), dto.getIdentifier()); |
|
191 |
} |
|
192 |
model.add(dto.getCdmEntity()); |
|
193 |
|
|
194 |
} |
|
195 |
}else if (isUseIdentifier() ){ |
|
183 | 196 |
List<IdentifiedEntityDTO<Reference>> list = CdmStore.getService(IReferenceService.class).listByIdentifierAbbrev(pattern, null, MatchMode.BEGINNING, limitOfInitialElements); |
184 | 197 |
if (model!= null){ |
185 | 198 |
model.clear(); |
... | ... | |
190 | 203 |
model.add(dto.getCdmEntity()); |
191 | 204 |
|
192 | 205 |
} |
193 |
}else{ |
|
206 |
}else {
|
|
194 | 207 |
model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern); |
195 | 208 |
} |
196 | 209 |
|
... | ... | |
202 | 215 |
protected void addIdentifierCheckButton(Composite searchAndFilter) { |
203 | 216 |
Button btnCheckButton = new Button(searchAndFilter, SWT.CHECK); |
204 | 217 |
btnCheckButton.setText("Use Identifier"); |
218 |
if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT)){ |
|
219 |
btnCheckButton.setSelection(true); |
|
220 |
useIdentifier = true; |
|
221 |
} |
|
205 | 222 |
btnCheckButton.addSelectionListener(new SelectionAdapter() { |
206 | 223 |
@Override |
207 | 224 |
public void widgetSelected(SelectionEvent e) { |
... | ... | |
263 | 280 |
titleCache += " ["+uuidAndTitleCache.getId()+"]"; |
264 | 281 |
} |
265 | 282 |
if (isUseIdentifier()){ |
266 |
AlternativeIdentifier identifier = identifierMap.get(uuidAndTitleCache.getUuid()); |
|
267 |
titleCache += " (" + identifier.getTypeLabel() +": " + identifier.getIdentifier() + ")"; |
|
283 |
if (identifierMap != null){ |
|
284 |
AlternativeIdentifier identifier = identifierMap.get(uuidAndTitleCache.getUuid()); |
|
285 |
if (identifier != null){ |
|
286 |
titleCache += " (" + identifier.getTypeLabel() +": " + identifier.getIdentifier() + ")"; |
|
287 |
}else{ |
|
288 |
titleCache += " (-)"; |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
268 | 292 |
} |
269 | 293 |
|
270 | 294 |
return titleCache; |
Also available in: Unified diff
ref # #7283: add preference to configure search for identifier