Project

General

Profile

Download (3.37 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2014 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.taxeditor.preference;
11

    
12
import org.eclipse.jface.preference.PreferencePage;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.custom.CLabel;
15
import org.eclipse.swt.events.SelectionAdapter;
16
import org.eclipse.swt.events.SelectionEvent;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.ui.IWorkbench;
22
import org.eclipse.ui.IWorkbenchPreferencePage;
23

    
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
26

    
27
/**
28
 * @author a.oppermann
29
 * @date 21.07.2014
30
 *
31
 */
32
public class ChecklistEditorGeneralPreference extends PreferencePage implements IWorkbenchPreferencePage {
33

    
34
    boolean isEditorActivated;
35
    Composite child ;
36
    /*
37
     * (non-Javadoc)
38
     *
39
     * @see
40
     * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
41
     * ()
42
     */
43
    @Override
44
    protected Control createContents(Composite parent) {
45

    
46
        Composite composite = new Composite(parent, SWT.NULL);
47
        composite.setLayout(new GridLayout());
48
        isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
49
        final Button activateCheckButton = new Button(composite, SWT.CHECK);
50
        activateCheckButton.setText("Enable Checklist Editor");
51
        activateCheckButton.setSelection(isEditorActivated);
52
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
53
            @Override
54
            public void widgetSelected(SelectionEvent e) {
55
                isEditorActivated = activateCheckButton.getSelection();
56
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
57
                if(isEditorActivated){
58
                    child.setVisible(true);
59
                    child.setEnabled(true);
60
                }else{
61
                    child.setVisible(false);
62
                    child.setEnabled(false);
63
                }
64

    
65
            }
66
        });
67

    
68
        child  = new Composite(composite, SWT.NULL);
69
        child.setLayout(new GridLayout());
70
        child.setVisible(isEditorActivated);
71
        final CLabel label = new CLabel(child, SWT.NULL);
72
        label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Checklist Editor");
73
        final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
74
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
75

    
76
        button_openFeatureTree.setText("Open Distribution Selection Wizard");
77
        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
78

    
79
        if(isEditorActivated){
80
            child.setEnabled(true);
81
        }else{
82
            child.setEnabled(false);
83
        }
84

    
85
        return composite;
86
    }
87

    
88
    /*
89
     * (non-Javadoc)
90
     *
91
     * @see
92
     * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
93
     */
94
    @Override
95
    public void init(IWorkbench workbench) {
96
    }
97

    
98
}
(3-3/23)