2 * Copyright (C) 2014 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 org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Control
;
14 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IPreferenceService
;
16 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
17 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
18 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
19 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
20 import eu
.etaxonomy
.taxeditor
.preference
.ChecklistEditorGeneralPreference
;
21 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 public class ChecklistEditorGeneralAdminPreference
extends ChecklistEditorGeneralPreference
implements IE4AdminPreferencePage
{
35 protected Control
createContents(Composite parent
) {
37 return super.createContents(parent
);
42 public boolean performOk() {
46 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
47 if (controller
== null){
50 IPreferenceService service
= controller
.getPreferenceService();
52 if (isEditorActivated
== null){
53 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DistributionEditorActivated
));
55 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.DistributionEditorActivated
, Boolean
.toString(isEditorActivated
));
56 pref
.setAllowOverride(allowOverrideActivatedButton
.getSelection());
59 if(displayArea
.equals(Messages
.Preference_Use_Default
)){
60 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DisplayOfAreasInDistributionEditor
));
62 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.DisplayOfAreasInDistributionEditor
, this.displayArea
);
63 pref
.setAllowOverride(allowOverrideAreaDisplayButton
.getSelection());
67 if (displayStatus
.equals(Messages
.Preference_Use_Default
)){
68 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.DisplayOfStatus
));
70 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.DisplayOfStatus
, this.displayStatus
);
71 pref
.setAllowOverride(allowOverrideStatusDisplayButton
.getSelection());
75 if (isShowRank
== null){
76 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.ShowRankInDistributionEditor
));
78 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.ShowRankInDistributionEditor
, Boolean
.toString(isShowRank
));
79 pref
.setAllowOverride(allowOverrideRankButton
.getSelection());
82 if (orderAreas
.equals(Messages
.Preference_Use_Default
)){
83 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.AreasSortedInDistributionEditor
));
85 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.AreasSortedInDistributionEditor
, this.orderAreas
);
86 pref
.setAllowOverride(allowOverrideOrderAreasButton
.getSelection());
90 if (ownDescriptionForDistributionEditor
== null){
91 service
.remove(CdmPreference
.NewKey(PreferenceSubject
.NewTaxEditorInstance(), PreferencePredicate
.OwnDescriptionForDistributionEditor
));
93 pref
= CdmPreference
.NewTaxEditorInstance( PreferencePredicate
.OwnDescriptionForDistributionEditor
, Boolean
.toString(ownDescriptionForDistributionEditor
));
94 pref
.setAllowOverride(prefOwnDescription
.isAllowOverride());
97 // if (statusPref != null){
98 // service.set(statusPref);
100 // if (areaVocPref != null){
101 // service.set(areaVocPref);
103 PreferencesUtil
.updateDBPreferences();
109 public void getValues() {
111 //distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
112 if (distributionEditorPref
!= null){
113 isEditorActivated
= Boolean
.valueOf(distributionEditorPref
.getValue());
117 isAdminPreference
= true;
119 if (prefAreaDisplay
!= null){
120 this.displayArea
= prefAreaDisplay
.getValue();
122 this.displayArea
= Messages
.Preference_Use_Default
;
126 if (prefStatusDisplay
!= null){
127 this.displayStatus
= prefStatusDisplay
.getValue();
129 this.displayStatus
= Messages
.Preference_Use_Default
;
132 if (prefAreaSort
!= null){
133 if (prefAreaSort
.getValue() != null){
134 this.orderAreas
= prefAreaSort
.getValue().toString();
136 this.orderAreas
= Messages
.Preference_Use_Default
;
140 this.orderAreas
= Messages
.Preference_Use_Default
;
145 if (prefRank
!= null){
146 this.isShowRank
= Boolean
.valueOf(prefRank
.getValue().toString());
149 this.isShowRank
= null;
153 if (prefOwnDescription
!= null){
154 this.ownDescriptionForDistributionEditor
= Boolean
.valueOf(prefOwnDescription
.getValue().toString());
156 this.ownDescriptionForDistributionEditor
= Boolean
.valueOf(PreferencePredicate
.OwnDescriptionForDistributionEditor
.getDefaultValue().toString());
159 commandHandlerString
= "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
160 commandHandlerStringStatus
= "eu.etaxonomy.taxeditor.store.open.OpenDistributionPerAreaStatusWizardHandler";