class="eu.etaxonomy.taxeditor.preference.TaxonPreferences"
id="eu.etaxonomy.taxeditor.preferences.taxonPreferences"
name="%page.name.52">
+ </page>
+ <page
+ category="eu.etaxonomy.taxeditor.preferences.taxonPreferences"
+ class="eu.etaxonomy.taxeditor.preference.PublishFlagLocalPreference"
+ id="eu.etaxonomy.taxeditor.preferences.publishFlagPreference"
+ name="%page.name.46">
</page>
<page
category="eu.etaxonomy.taxeditor.preferences.general"
*/
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
-import org.eclipse.swt.widgets.Combo;
-
import eu.etaxonomy.cdm.api.application.ICdmRepository;
import eu.etaxonomy.cdm.api.service.IPreferenceService;
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.preference.PublishEnum;
*/
public class PublishFlagPreference extends PublishFlagLocalPreference implements IE4AdminPreferencePage{
- PublishEnum publishBehaviour;
-
- Combo publishFlagBehaviour;
- CdmPreference pref = null;
-
- protected boolean allowOverride;
@Override
public void init() {
+ @Override
+ public void getValues() {
+ isAdminPreference = true;
+ pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
+ if (pref == null){
+ pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DefaultBehaviourForPublishFlag, EditorPreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue().toString());
+ }
+ allowOverride = pref.isAllowOverride();
+ publishBehaviour = PublishEnum.valueOf(pref.getValue().toString());
+ }
+
+
+
}
getValues();
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout());
- if(!isAdminPreference && !Boolean.valueOf(distributionEditorPref.getValue())){
+ if(!isAdminPreference && !Boolean.valueOf(distributionEditorPref.getValue()) && !distributionEditorPref.isAllowOverride()){
Label label = new Label(composite, SWT.NONE);
label.setText("The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
button_openStatusWizard.setButtonEnabled(false);
}
}
+ PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
}
- PreferencesUtil.recursiveSetEnabled(child, isEditorActivated);
+
+
setValid(true);
return composite;
}
*/
public enum PublishEnum {
- Publish("Publish", Messages.PublishEnum_publish), //$NON-NLS-1$
- NotPublish("NotPublish", ""), //$NON-NLS-1$ //$NON-NLS-2$
- InheritFromParent("InheritFromParent", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ Publish("Publish", Messages.PublishEnum_publish),
+ NotPublish("NotPublish", Messages.PublishFlagPreference_do_not_set),
+ InheritFromParent("InheritFromParent", Messages.PublishFlagPreference_inherit);
String label;
*/
public class PublishFlagLocalPreference extends CdmPreferencePage {
- PublishEnum publishBehaviour;
+ protected PublishEnum publishBehaviour;
- Combo publishFlagBehaviour;
- CdmPreference pref = null;
+ protected Combo publishFlagBehaviour;
+ protected CdmPreference pref = null;
protected boolean allowOverride;
+
@Override
public void init() {
super.init();
*/
@Override
protected Control createContents(Composite parent) {
+ getValues();
pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
if (pref == null){
pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DefaultBehaviourForPublishFlag, EditorPreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue().toString());
allowOverride = pref.isAllowOverride();
Composite composite = createComposite(parent);
final CLabel description = new CLabel(composite, SWT.NULL);
- if (!allowOverride){
+ if (!allowOverride && !isAdminPreference){
description.setText(Messages.PublishFlagPreference_description_not_allowed);
description.setLayoutData(createTextGridData());
return composite;
}
- PublishEnum publishFlag;
- try{
- publishFlag = PublishEnum.valueOf(PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), true));
- }catch (IllegalArgumentException e){
- publishFlag = PublishEnum.InheritFromParent;
- }
+
description.setText(Messages.PublishFlagPreference_description);
description.setLayoutData(createTextGridData());
allowOverrideButton.addSelectionListener(new SelectionAdapter(){
@Override
public void widgetSelected(SelectionEvent e) {
- allowOverride = allowOverrideButton.getSelection();
+ allowOverride = !allowOverride;
setApply(true);
}
});
for (String itemLabel : publishFlagBehaviour.getItems()){
- if (itemLabel.equalsIgnoreCase(publishFlag.getLabel())){
+ if (itemLabel.equalsIgnoreCase(publishBehaviour.getLabel())){
publishFlagBehaviour.select(index);
break;
}
return true;
}
+ @Override
+ public void getValues(){
+
+ try{
+ publishBehaviour = PublishEnum.valueOf(PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForPublishFlag.getKey(), true));
+ }catch (IllegalArgumentException e){
+ publishBehaviour = PublishEnum.InheritFromParent;
+ }
+ }
+
}
isShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowSpecimen.getKey());
allowOverrideShowSpecimenRelatedIssues = cache.get(EditorPreferencePredicate.ShowSpecimen.getKey())!= null ? cache.get(EditorPreferencePredicate.ShowSpecimen.getKey()).isAllowOverride():true;
+ overrideShowSpecimenRelatedIssues = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowSpecimen.getKey()));
isShowCollectingAreaInGeneralSection = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey());
allowOverrideShowCollectingAreaInGeneralSection = cache.get(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey())!= null ? cache.get(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()).isAllowOverride():true;
+ overrideShowCollectionAreaInGeneralSection = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()));
isDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey());
allowOverrideDeterminationOnlyForFieldUnits = cache.get(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey())!= null ? cache.get(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey()).isAllowOverride():true;
+ overrideDeterminationOnlyForFieldUnits = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey()));
isShowTaxonAssociation = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowTaxonAssociations.getKey());
allowOverrideShowTaxonAssociation = cache.get(EditorPreferencePredicate.ShowTaxonAssociations.getKey())!= null ? cache.get(EditorPreferencePredicate.ShowTaxonAssociations.getKey()).isAllowOverride():true;
+ overrideShowTaxonAssociation = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowTaxonAssociations.getKey()));
isShowLifeForm = PreferencesUtil.getBooleanValue(EditorPreferencePredicate.ShowLifeForm.getKey());
allowOverrideShowLifeForm = cache.get(EditorPreferencePredicate.ShowLifeForm.getKey())!= null ? cache.get(EditorPreferencePredicate.ShowLifeForm.getKey()).isAllowOverride():true;
+ overrideShowLifeForm = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowLifeForm.getKey()));
}
public boolean performOk() {
if (allowOverrideShowSpecimenRelatedIssues){
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.ShowSpecimen.getKey(), isShowSpecimenRelatedIssues);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowSpecimen.getKey()), overrideShowSpecimenRelatedIssues);
}
if (allowOverrideShowCollectingAreaInGeneralSection){
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey(), isShowCollectingAreaInGeneralSection);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowCollectingAreasInGeneralSection.getKey()), overrideShowCollectionAreaInGeneralSection);
}
if (allowOverrideDeterminationOnlyForFieldUnits){
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey(), isDeterminationOnlyForFieldUnits);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.DeterminationOnlyForFieldUnits.getKey()), overrideDeterminationOnlyForFieldUnits);
}
if (allowOverrideShowTaxonAssociation){
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.ShowTaxonAssociations.getKey(), isShowTaxonAssociation);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowTaxonAssociations.getKey()), overrideShowTaxonAssociation);
}
if (allowOverrideShowLifeForm){
PreferencesUtil.setBooleanValue(EditorPreferencePredicate.ShowLifeForm.getKey(), isShowLifeForm);
+ PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(EditorPreferencePredicate.ShowLifeForm.getKey()), overrideShowLifeForm);
}
return true;
}