do not save cdm preference which are not changed
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / databaseAdmin / preferencePage / DistributionAdminPreferences.java
1 /**
2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9 package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
10
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.custom.CLabel;
13 import org.eclipse.swt.events.SelectionAdapter;
14 import org.eclipse.swt.events.SelectionEvent;
15 import org.eclipse.swt.layout.GridLayout;
16 import org.eclipse.swt.widgets.Button;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19
20 import eu.etaxonomy.cdm.model.metadata.CdmPreference;
21 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
22 import eu.etaxonomy.taxeditor.l10n.Messages;
23 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
24 import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
25 import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
26
27 /**
28 * @author k.luther
29 * @since 08.10.2018
30 *
31 */
32 public class DistributionAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
33
34 boolean allowOverride;
35 CdmPreference pref = null;
36
37 @Override
38 protected Control createContents(Composite parent) {
39 Composite composite = new Composite(parent, SWT.NULL);
40 composite.setLayout(new GridLayout());
41
42
43 pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
44 if (pref != null){
45 allowOverride = pref.isAllowOverride();
46 }
47
48
49
50 final CLabel label = new CLabel(composite, SWT.NULL);
51 label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
52
53 final CommandHandlerButton button_openWizard = new CommandHandlerButton(composite, SWT.PUSH,
54 "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler");
55
56 button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
57 final Button allowOverrideCheckButton = new Button(composite, SWT.CHECK);
58 allowOverrideCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
59 allowOverrideCheckButton.setSelection(allowOverride);
60 allowOverrideCheckButton.addSelectionListener(new SelectionAdapter(){
61 @Override
62 public void widgetSelected(SelectionEvent e) {
63 allowOverride = allowOverrideCheckButton.getSelection();
64
65 }
66 });
67
68
69 pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
70
71 if (pref != null){
72 allowOverride = pref.isAllowOverride();
73 }
74
75 final CLabel labelStatus = new CLabel(composite, SWT.NULL);
76 labelStatus.setText("Select the status which should be available for distribution data.");
77
78 final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(composite, SWT.PUSH,
79 "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler");
80
81 button_openStatusWizard.setText(Messages.Distribution_status_selection);
82 final Button allowOverrideStatusCheckButton = new Button(composite, SWT.CHECK);
83 allowOverrideStatusCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
84 allowOverrideStatusCheckButton.setSelection(allowOverride);
85 allowOverrideStatusCheckButton.addSelectionListener(new SelectionAdapter(){
86 @Override
87 public void widgetSelected(SelectionEvent e) {
88 allowOverride = allowOverrideStatusCheckButton.getSelection();
89
90 }
91 });
92
93 return composite;
94 }
95
96
97 }