Project

General

Profile

Download (2.28 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.preference.wizard;
10

    
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.events.SelectionAdapter;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.widgets.Button;
15
import org.eclipse.swt.widgets.Composite;
16

    
17
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
18
import eu.etaxonomy.cdm.model.term.TermType;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20

    
21

    
22
/**
23
 * @author k.luther
24
 * @since 22.11.2018
25
 *
26
 */
27
public abstract class AbstractAdminTermSelectionWizardPage extends AbstractTermSelectionWizardPage
28
        {
29

    
30
    /**
31
     * @param pageName
32
     * @param type
33
     */
34
    protected AbstractAdminTermSelectionWizardPage(String pageName, TermType type, CdmPreference pref) {
35
        super(pageName, type);
36
        this.pref = pref;
37
        if (localPref){
38
            this.override = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(pref.getPredicate()));
39
        }else{
40
            this.override = pref != null? this.pref.isAllowOverride(): true;
41
        }
42

    
43
    }
44

    
45
    CdmPreference pref;
46
    boolean override;
47

    
48
    /**
49
     * {@inheritDoc}
50
     */
51

    
52
    protected void createAllowOverrideButton(Composite parent) {
53
        final Button activateCheckButton = new Button(parent, SWT.CHECK);
54
       if (localPref){
55
           activateCheckButton.setText("Override");
56
           activateCheckButton.setSelection(override);
57
       }else{
58
           activateCheckButton.setText("Allow Override");
59
           activateCheckButton.setSelection(pref.isAllowOverride());
60
       }
61

    
62

    
63

    
64
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
65
                @Override
66
                public void widgetSelected(SelectionEvent e) {
67
                    pref.setAllowOverride(activateCheckButton.getSelection());
68
                    override = activateCheckButton.getSelection();
69

    
70
                }
71
            });
72
    }
73

    
74
    public CdmPreference getPreference(){
75
        return pref;
76
    }
77

    
78
    public void setPreference(CdmPreference pref){
79
        this.pref = pref;
80
    }
81

    
82
}
(1-1/16)