Project

General

Profile

Download (2.75 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.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 05.10.2018
30
 *
31
 */
32
public class VokabularyAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
33

    
34
    boolean allowOverride;
35
    CdmPreference pref = null;
36

    
37

    
38
    @Override
39
    protected Control createContents(Composite parent) {
40

    
41
        Composite composite = new Composite(parent, SWT.NULL);
42
        composite.setLayout(new GridLayout());
43

    
44
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
45

    
46
        if (pref != null){
47
            allowOverride = pref.isAllowOverride();
48
        }
49

    
50
        final CLabel commonNameAreaLabel = new CLabel(composite, SWT.NULL);
51
        commonNameAreaLabel.setText("Select the area vocabularies which should be available for common names.");
52

    
53
        final CommandHandlerButton button_opencommonNameAreaWizard = new CommandHandlerButton(composite, SWT.PUSH,
54
                "eu.etaxonomy.taxeditor.store.open.OpenCommonNameAreaWizardAdminHandler");
55

    
56
        button_opencommonNameAreaWizard.setText(Messages.GeneralPreference_open_common_name_area_selection);
57
        final Button allowOverrideCommonNameAreaCheckButton = new Button(composite, SWT.CHECK);
58
        allowOverrideCommonNameAreaCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
59
        allowOverrideCommonNameAreaCheckButton.setSelection(allowOverride);
60
        allowOverrideCommonNameAreaCheckButton.addSelectionListener(new SelectionAdapter(){
61
            @Override
62
            public void widgetSelected(SelectionEvent e) {
63
                allowOverride = allowOverrideCommonNameAreaCheckButton.getSelection();
64

    
65
            }
66
        });
67

    
68
        return composite;
69
    }
70

    
71
    @Override
72
    public boolean performOk() {
73
        PreferencesUtil.updateDBPreferences();
74
        return true;
75

    
76
    }
77

    
78

    
79
}
(12-12/12)