Project

General

Profile

Download (4.21 KB) Statistics
| Branch: | Tag: | Revision:
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.GridData;
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
    private boolean allowOverrideAreas;
35
    private boolean allowOverrideStatus;
36
    private CdmPreference prefAreas = null;
37
    private CdmPreference prefStatus = null;
38

    
39
    @Override
40
    protected Control createContents(Composite parent) {
41
        isAdminPreference = true;
42
        Composite composite = createComposite(parent);
43
        GridData labelGridData = new GridData();
44
        labelGridData.horizontalSpan = 2;
45
        labelGridData.verticalSpan = 4;
46

    
47
        prefAreas = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
48
        allowOverrideAreas = prefAreas != null?prefAreas.isAllowOverride():true;
49

    
50
        final CLabel label = new CLabel(composite, SWT.NULL);
51
        label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
52
        label.setLayoutData(labelGridData);
53
        final CommandHandlerButton button_openWizard = new CommandHandlerButton(composite, SWT.PUSH,
54
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler"); //$NON-NLS-1$
55

    
56
        button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
57
        final Button allowOverrideAreasCheckButton = new Button(composite, SWT.CHECK);
58
        allowOverrideAreasCheckButton.setText(Messages.GeneralPreference_allowOverride);
59
        allowOverrideAreasCheckButton.setSelection(allowOverrideAreas);
60
        allowOverrideAreasCheckButton.addSelectionListener(new SelectionAdapter(){
61
            @Override
62
            public void widgetSelected(SelectionEvent e) {
63
                setApply(true);
64
                allowOverrideAreas = allowOverrideAreasCheckButton.getSelection();
65

    
66
            }
67
        });
68

    
69

    
70
        prefStatus = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionStatus);
71

    
72
        allowOverrideStatus = prefStatus != null?prefStatus.isAllowOverride():true;
73

    
74
        final CLabel labelStatus = new CLabel(composite, SWT.NULL);
75
        labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
76
        GridData labelStatusGridData = new GridData();
77
        labelStatusGridData.horizontalSpan = 2;
78
        labelStatusGridData.verticalSpan = 2;
79
        labelStatus.setLayoutData(labelStatusGridData);
80
        final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(composite, SWT.PUSH,
81
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler"); //$NON-NLS-1$
82

    
83
        button_openStatusWizard.setText(Messages.Distribution_status_selection);
84
        final Button allowOverrideStatusCheckButton = new Button(composite, SWT.CHECK);
85
        allowOverrideStatusCheckButton.setText(Messages.GeneralPreference_allowOverride);
86
        allowOverrideStatusCheckButton.setSelection(allowOverrideStatus);
87
        allowOverrideStatusCheckButton.addSelectionListener(new SelectionAdapter(){
88
            @Override
89
            public void widgetSelected(SelectionEvent e) {
90
                setApply(true);
91
                allowOverrideStatus = allowOverrideStatusCheckButton.getSelection();
92

    
93
            }
94
        });
95

    
96
        return composite;
97
    }
98

    
99

    
100
}
(4-4/13)