Project

General

Profile

Download (5.18 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2014 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;
10

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

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

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

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

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

    
64
            }
65
        });
66

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

    
75
        button_openFeatureTree.setText("Open Distribution Selection Wizard");
76
        final Button showIdInVocabulary = new Button(child, SWT.CHECK);
77
        boolean isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
78
        showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
79
        showIdInVocabulary.setSelection(isShowIdInVocabulary);
80
        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
81
            @Override
82
            public void widgetSelected(SelectionEvent e) {
83
                boolean isShowIdInVocabulary = showIdInVocabulary.getSelection();
84
                PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
85
             }
86
        });
87
        
88
        final Button showSymbol = new Button(child, SWT.CHECK);
89
        boolean isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
90
        showSymbol.setText("Show Symbol of the areas");
91
        showSymbol.setSelection(isShowSymbol);
92
        showSymbol.addSelectionListener(new SelectionAdapter(){
93
            @Override
94
            public void widgetSelected(SelectionEvent e) {
95
                boolean isShowSymbol = showSymbol.getSelection();
96
                PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
97
             }
98
        });
99
        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
100
        boolean isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
101
        final Button activateRankButton = new Button(child, SWT.CHECK);
102
        activateRankButton.setText("Show Rank in Distribution Editor");
103
        activateRankButton.setSelection(isShowRank);
104
        activateRankButton.addSelectionListener(new SelectionAdapter(){
105
            @Override
106
            public void widgetSelected(SelectionEvent e) {
107
                boolean isShowRank = activateRankButton.getSelection();
108
                PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
109
            }
110
        });
111

    
112

    
113
        if(isEditorActivated){
114
            child.setEnabled(true);
115
        }else{
116
            child.setEnabled(false);
117
        }
118

    
119
        return composite;
120
    }
121

    
122
    /*
123
     * (non-Javadoc)
124
     *
125
     * @see
126
     * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
127
     */
128
    @Override
129
    public void init(IWorkbench workbench) {
130
    }
131

    
132
}
(5-5/25)