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 isAdminPreference
= true;
31 if(showIdInSelectionDialogPref
!= null){
32 showIdInSelectionDialog
= showIdInSelectionDialogPref
.getValue() != null? Boolean
.parseBoolean(showIdInSelectionDialogPref
.getValue()): null;
34 showIdInSelectionDialog
= null;
35 showIdInSelectionDialogPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, null);
37 if (searchForIdentifierAsDefaultPref
!= null){
38 searchForIdentifierAsDefault
= searchForIdentifierAsDefaultPref
.getValue() != null? Boolean
.parseBoolean(searchForIdentifierAsDefaultPref
.getValue()): null;
40 searchForIdentifierAsDefault
= null;
41 searchForIdentifierAsDefaultPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, null);
43 if (searchForIdentifierAndTitleCachePref
!= null){
44 searchForIdentifierAndTitleCache
= searchForIdentifierAndTitleCachePref
.getValue() != null? Boolean
.parseBoolean(searchForIdentifierAndTitleCachePref
.getValue()): null;
46 searchForIdentifierAndTitleCache
= null;
47 searchForIdentifierAndTitleCachePref
=CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, null);
49 if (sortTaxaByRankAndNamePref
!= null){
50 sortTaxaByRankAndName
= sortTaxaByRankAndNamePref
.getValue() != null? Boolean
.parseBoolean(sortTaxaByRankAndNamePref
.getValue()): null;
52 sortTaxaByRankAndName
= null;
53 sortTaxaByRankAndNamePref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, null);
55 if (filterCommonNameReferencesPref
!= null){
56 filterCommonNameReferences
= filterCommonNameReferencesPref
.getValue() != null? Boolean
.parseBoolean(filterCommonNameReferencesPref
.getValue()): null;
58 filterCommonNameReferences
= null;
59 filterCommonNameReferencesPref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, null);
64 public boolean performOk(){
68 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
69 if (controller
!= null){
70 IPreferenceService service
= controller
.getPreferenceService();
72 if (showIdInSelectionDialog
!= null || !showIdInSelectionDialogPref
.isAllowOverride()) {
73 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.ShowIdInSelectionDialog
, showIdInSelectionDialog
!= null? showIdInSelectionDialog
.toString():null);
74 pref
.setAllowOverride(showIdInSelectionDialogPref
.isAllowOverride());
77 service
.remove(showIdInSelectionDialogPref
.getKey());
81 if(searchForIdentifierAsDefault
!= null || !searchForIdentifierAsDefaultPref
.isAllowOverride()){
82 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAsDefault
, searchForIdentifierAsDefault
!= null? searchForIdentifierAsDefault
.toString():null);
83 pref
.setAllowOverride(searchForIdentifierAsDefaultPref
.isAllowOverride());
86 service
.remove(searchForIdentifierAsDefaultPref
.getKey());
90 if(searchForIdentifierAndTitleCache
!= null || !searchForIdentifierAndTitleCachePref
.isAllowOverride()){
91 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SearchForIdentifierAndTitleCache
, searchForIdentifierAndTitleCache
!= null? searchForIdentifierAndTitleCache
.toString():null);
92 pref
.setAllowOverride(searchForIdentifierAndTitleCachePref
.isAllowOverride());
95 service
.remove(searchForIdentifierAndTitleCachePref
.getKey());
98 if(sortTaxaByRankAndName
!= null || !sortTaxaByRankAndNamePref
.isAllowOverride()){
100 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.SortTaxaByRankAndName
, sortTaxaByRankAndName
!= null? sortTaxaByRankAndName
.toString():null);
101 pref
.setAllowOverride(sortTaxaByRankAndNamePref
.isAllowOverride());
104 service
.remove(sortTaxaByRankAndNamePref
.getKey());
109 if(filterCommonNameReferences
!= null || !filterCommonNameReferencesPref
.isAllowOverride()){
110 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameReferencesWithMarker
, filterCommonNameReferences
!= null? filterCommonNameReferences
.toString():null);
111 pref
.setAllowOverride(filterCommonNameReferencesPref
.isAllowOverride());
114 service
.remove(filterCommonNameReferencesPref
.getKey());