public static final String SHOW_MEDIA = "eu.etaxonomy.taxeditor.view.showMedia";
public static final String SHOW_CHECKLIST_PERSPECTIVE = "eu.etaxonomy.taxeditor.perspective.showChecklist";
public static final String SHOW_TAXONNODE_WIZARD = "eu.etaxonomy.taxeditor.menu.showTaxonNodeWizard";
-
+ public static final String IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT = "eu.etaxonomy.taxeditor.search.reference.defaultIdentifier";
+ public static final String SEARCH_FOR_IDENTIFIER_AND_TITLECACHE = "eu.etaxonomy.taxeditor.search.reference.identifierAndTitleCache";
--- /dev/null
+/**
+* Copyright (C) 2018 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.preference;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+
+import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
+
+/**
+ * @author k.luther
+ * @since 16.10.2018
+ *
+ */
+public class SearchPreferences extends FieldEditorPreferencePageE4 {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void createFieldEditors() {
+
+ addField(new BooleanFieldEditor(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT,
+ "Set search for Identifier as default.",
+ getFieldEditorParent()));
+ addField(new BooleanFieldEditor(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE,
+ "Search for identifier and titleCache, if identifier search is enabled",
+ getFieldEditorParent()));
+
+
+
+ }
+
+}
}
}else{
- if (isUseIdentifier()){
+ if (isUseIdentifier() && PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE)){
+ List<IdentifiedEntityDTO<Reference>> list = CdmStore.getService(IReferenceService.class).listByIdentifierAndTitleCacheAbbrev(pattern, null, MatchMode.BEGINNING, limitOfInitialElements);
+ if (model!= null){
+ model.clear();
+ }
+ identifierMap = new HashMap();
+ for (IdentifiedEntityDTO dto: list){
+ if (dto.getIdentifier() != null){
+ identifierMap.put(dto.getCdmEntity().getUuid(), dto.getIdentifier());
+ }
+ model.add(dto.getCdmEntity());
+
+ }
+ }else if (isUseIdentifier() ){
List<IdentifiedEntityDTO<Reference>> list = CdmStore.getService(IReferenceService.class).listByIdentifierAbbrev(pattern, null, MatchMode.BEGINNING, limitOfInitialElements);
if (model!= null){
model.clear();
model.add(dto.getCdmEntity());
}
- }else{
+ }else {
model = CdmStore.getService(IReferenceService.class).getUuidAndTitleCache(limitOfInitialElements,pattern);
}
protected void addIdentifierCheckButton(Composite searchAndFilter) {
Button btnCheckButton = new Button(searchAndFilter, SWT.CHECK);
btnCheckButton.setText("Use Identifier");
+ if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT)){
+ btnCheckButton.setSelection(true);
+ useIdentifier = true;
+ }
btnCheckButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
titleCache += " ["+uuidAndTitleCache.getId()+"]";
}
if (isUseIdentifier()){
- AlternativeIdentifier identifier = identifierMap.get(uuidAndTitleCache.getUuid());
- titleCache += " (" + identifier.getTypeLabel() +": " + identifier.getIdentifier() + ")";
+ if (identifierMap != null){
+ AlternativeIdentifier identifier = identifierMap.get(uuidAndTitleCache.getUuid());
+ if (identifier != null){
+ titleCache += " (" + identifier.getTypeLabel() +": " + identifier.getIdentifier() + ")";
+ }else{
+ titleCache += " (-)";
+ }
+ }
+
}
return titleCache;