Project

General

Profile

Download (4.63 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 Distribution 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 Distribution 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
        final Button showIdInVocabulary = new Button(child, SWT.CHECK);
78
        boolean isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
79
        showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
80
        showIdInVocabulary.setSelection(isShowIdInVocabulary);
81
        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
82
            @Override
83
            public void widgetSelected(SelectionEvent e) {
84
                boolean isShowIdInVocabulary = showIdInVocabulary.getSelection();
85
                PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
86
             }
87
        });
88
        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
89
        boolean isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
90
        final Button activateRankButton = new Button(child, SWT.CHECK);
91
        activateRankButton.setText("Show Rank in Distribution Editor");
92
        activateRankButton.setSelection(isShowRank);
93
        activateRankButton.addSelectionListener(new SelectionAdapter(){
94
            @Override
95
            public void widgetSelected(SelectionEvent e) {
96
                boolean isShowRank = activateRankButton.getSelection();
97
                PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
98
            }
99
        });
100

    
101

    
102
        if(isEditorActivated){
103
            child.setEnabled(true);
104
        }else{
105
            child.setEnabled(false);
106
        }
107

    
108
        return composite;
109
    }
110

    
111
    /*
112
     * (non-Javadoc)
113
     *
114
     * @see
115
     * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
116
     */
117
    @Override
118
    public void init(IWorkbench workbench) {
119
    }
120

    
121
}
(5-5/27)