import eu.etaxonomy.cdm.api.service.IPreferenceService;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
-import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
-import eu.etaxonomy.cdm.model.metadata.TermOrder;
+import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
+import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
@Override
public boolean performOk() {
- if (distributionEditorPref == null){
+ if (!isApply()){
return true;
}
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
return false;
}
IPreferenceService service = controller.getPreferenceService();
+ CdmPreference pref;
+ if (isEditorActivated == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DistributionEditorActivated));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
+ pref.setAllowOverride(allowOverrideActivatedButton.getSelection());
+ service.set(pref);
+ }
+ if(displayArea.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfAreasInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
+ pref.setAllowOverride(allowOverrideAreaDisplayButton.getSelection());
+ service.set(pref);
+ }
- CdmPreference pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
- pref.setAllowOverride(this.allowOverrideActivated);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
- pref.setAllowOverride(this.allowOverrideAreaDisplay);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
- pref.setAllowOverride(this.allowOverrideStatusDisplay);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
- pref.setAllowOverride(this.allowOverrideRank);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
- pref.setAllowOverride(this.allowOverrideOrderAreas);
- service.set(pref);
-
- pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.OwnDescriptionForDistributionEditor, Boolean.toString(ownDescriptionForDistributionEditor));
- pref.setAllowOverride(this.allowOverrideOwnDescriptionForDistributionEditor);
- service.set(pref);
+ if (displayStatus.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatus));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatus, this.displayStatus);
+ pref.setAllowOverride(allowOverrideStatusDisplayButton.getSelection());
+ service.set(pref);
+ }
- if (statusPref != null){
- service.set(statusPref);
+ if (isShowRank == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.ShowRankInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
+ pref.setAllowOverride(allowOverrideRankButton.getSelection());
+ service.set(pref);
}
- if (areaVocPref != null){
- service.set(areaVocPref);
+ if (orderAreas.equals(Messages.Preference_Use_Default)){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AreasSortedInDistributionEditor));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedInDistributionEditor, this.orderAreas);
+ pref.setAllowOverride(allowOverrideOrderAreasButton.getSelection());
+ service.set(pref);
+ }
+
+ if (displayStatusCombo == null){
+ service.remove(CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.DisplayOfStatusInCombo));
+ }else{
+ pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DisplayOfStatusInCombo, displayStatusCombo);
+ if (prefStatusDisplayInCombo == null){
+ prefStatusDisplayInCombo = pref;
+ }
+ pref.setAllowOverride(prefStatusDisplayInCombo.isAllowOverride());
+ service.set(pref);
}
+
PreferencesUtil.updateDBPreferences();
return true;
@Override
public void getValues() {
-
- distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
- if (distributionEditorPref == null){
- distributionEditorPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, PreferencePredicate.DistributionEditorActivated.getDefaultValue().toString());
+ super.getValues();
+ //distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
+ if (distributionEditorPref != null){
+ isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
}
- isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
- allowOverrideActivated = distributionEditorPref.isAllowOverride();
+
+
isAdminPreference = true;
- CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfAreasInDistributionEditor);
- if (pref != null){
- this.displayArea = pref.getValue();
- this.allowOverrideAreaDisplay = pref.isAllowOverride();
+ if (prefAreaDisplay != null){
+ this.displayArea = prefAreaDisplay.getValue();
+ }else{
+ this.displayArea = Messages.Preference_Use_Default;
+ }
+
+
+ if (prefStatusDisplay != null){
+ this.displayStatus = prefStatusDisplay.getValue();
}else{
- this.displayArea = ((TermDisplayEnum)PreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue()).getKey();
- this.allowOverrideAreaDisplay = true;
+ this.displayStatus = Messages.Preference_Use_Default;
}
- pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DisplayOfStatus);
- if (pref != null){
- this.displayStatus = pref.getValue();
- this.allowOverrideStatusDisplay = pref.isAllowOverride();
+ if (prefStatusDisplayInCombo != null){
+ this.displayStatusCombo = prefStatusDisplayInCombo.getValue();
}else{
- this.displayStatus = ((TermDisplayEnum)PreferencePredicate.DisplayOfStatus.getDefaultValue()).getKey();
- this.allowOverrideStatusDisplay = true;
+ this.displayStatusCombo = Messages.Preference_Use_Default;
}
- pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedInDistributionEditor);
- if (pref != null){
- if (pref.getValue() != null){
- this.orderAreas = pref.getValue().toString();
+
+ if (prefAreaSort != null){
+ if (prefAreaSort.getValue() != null){
+ this.orderAreas = prefAreaSort.getValue().toString();
}else{
- this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
+ this.orderAreas = Messages.Preference_Use_Default;
}
- this.allowOverrideOrderAreas = pref.isAllowOverride();
+
}else{
- this.orderAreas = ((TermOrder)PreferencePredicate.AreasSortedInDistributionEditor.getDefaultValue()).getKey();
- this.allowOverrideOrderAreas = true;
+ this.orderAreas = Messages.Preference_Use_Default;
+
}
- pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
- if (pref != null){
- this.isShowRank = Boolean.valueOf(pref.getValue().toString());
- this.allowOverrideRank = pref.isAllowOverride();
+
+ if (prefRank != null){
+ this.isShowRank = Boolean.valueOf(prefRank.getValue().toString());
+
}else{
- this.isShowRank = Boolean.valueOf(PreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
- this.allowOverrideRank = true;
+ this.isShowRank = null;
}
- pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.OwnDescriptionForDistributionEditor);
- if (pref != null){
- this.ownDescriptionForDistributionEditor = Boolean.valueOf(pref.getValue().toString());
- this.allowOverrideOwnDescriptionForDistributionEditor= pref.isAllowOverride();
+
+ if (prefOwnDescription != null){
+ this.ownDescriptionForDistributionEditor = Boolean.valueOf(prefOwnDescription.getValue().toString());
}else{
this.ownDescriptionForDistributionEditor = Boolean.valueOf(PreferencePredicate.OwnDescriptionForDistributionEditor.getDefaultValue().toString());
- this.allowOverrideOwnDescriptionForDistributionEditor = true;
}
- commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
- commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler";
+
setValid(false);
}