2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.databaseAdmin
.preferencePage
;
11 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
12 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
13 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
14 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
15 import eu
.etaxonomy
.taxeditor
.preference
.SearchDialogPreferences
;
16 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 public class SearchDialogAdminPreferences
extends SearchDialogPreferences
implements IE4AdminPreferencePage
{
28 public void getValues(){
30 if(showIdInSelectionDialogPref
!= null){
31 showIdInSelectionDialog
= Boolean
.parseBoolean(showIdInSelectionDialogPref
.getValue());
33 showIdInSelectionDialog
= null;
34 showIdInSelectionDialogPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, null);
36 if (searchForIdentifierAsDefaultPref
!= null){
37 searchForIdentifierAsDefault
= Boolean
.parseBoolean(searchForIdentifierAsDefaultPref
.getValue());
39 searchForIdentifierAsDefault
= null;
40 searchForIdentifierAsDefaultPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, null);
42 if (searchForIdentifierAndTitleCachePref
!= null){
43 searchForIdentifierAndTitleCache
= Boolean
.parseBoolean(searchForIdentifierAndTitleCachePref
.getValue());
45 searchForIdentifierAndTitleCache
= null;
46 searchForIdentifierAndTitleCachePref
=CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, null);
48 if (sortTaxaByRankAndNamePref
!= null){
49 sortTaxaByRankAndName
= Boolean
.parseBoolean(sortTaxaByRankAndNamePref
.getValue());
51 sortTaxaByRankAndName
= null;
52 sortTaxaByRankAndNamePref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, null);
54 if (filterCommonNameReferencesPref
!= null){
55 filterCommonNameReferences
= Boolean
.parseBoolean(filterCommonNameReferencesPref
.getValue());
57 filterCommonNameReferences
= null;
58 filterCommonNameReferencesPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, null);
63 public boolean performOk(){
67 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
68 if (controller
!= null){
69 IPreferenceService service
= controller
.getPreferenceService();
71 if (showIdInSelectionDialog
!= null || !showIdInSelectionDialogPref
.isAllowOverride()) {
72 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, showIdInSelectionDialog
!= null? showIdInSelectionDialog
.toString():null);
73 pref
.setAllowOverride(showIdInSelectionDialogPref
.isAllowOverride());
76 service
.remove(showIdInSelectionDialogPref
.getKey());
80 if(searchForIdentifierAsDefault
!= null || !searchForIdentifierAsDefaultPref
.isAllowOverride()){
81 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, searchForIdentifierAsDefault
!= null? searchForIdentifierAsDefault
.toString():null);
82 pref
.setAllowOverride(searchForIdentifierAsDefaultPref
.isAllowOverride());
85 service
.remove(searchForIdentifierAsDefaultPref
.getKey());
89 if(searchForIdentifierAndTitleCache
!= null){
90 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, searchForIdentifierAndTitleCache
!= null? searchForIdentifierAndTitleCache
.toString():null);
91 pref
.setAllowOverride(searchForIdentifierAndTitleCachePref
.isAllowOverride());
94 service
.remove(searchForIdentifierAndTitleCachePref
.getKey());
97 if(sortTaxaByRankAndName
!= null){
99 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, sortTaxaByRankAndName
!= null? sortTaxaByRankAndName
.toString():null);
100 pref
.setAllowOverride(sortTaxaByRankAndNamePref
.isAllowOverride());
103 service
.remove(sortTaxaByRankAndNamePref
.getKey());
108 if(filterCommonNameReferences
!= null){
109 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, filterCommonNameReferences
!= null? filterCommonNameReferences
.toString():null);
110 pref
.setAllowOverride(filterCommonNameReferencesPref
.isAllowOverride());
113 service
.remove(filterCommonNameReferencesPref
.getKey());