Project

General

Profile

Download (5.55 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.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.taxeditor.preference.menu.CdmPreferencePage;
21
import eu.etaxonomy.taxeditor.store.CdmStore;
22
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
23

    
24
/**
25
 * @author a.oppermann
26
 * @date 21.07.2014
27
 *
28
 */
29
public class ChecklistEditorGeneralPreference extends CdmPreferencePage {
30

    
31
    boolean isEditorActivated;
32
    boolean isShowRank;
33
    boolean isSortByVocabularyOrder;
34
    boolean isShowSymbol;
35
    boolean isShowIdInVocabulary;
36
    Composite child ;
37

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

    
41
        Composite composite = new Composite(parent, SWT.NULL);
42
        composite.setLayout(new GridLayout());
43
        isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
44
        final Button activateCheckButton = new Button(composite, SWT.CHECK);
45
        activateCheckButton.setText("Enable Distribution Editor");
46
        activateCheckButton.setSelection(isEditorActivated);
47
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
48
            @Override
49
            public void widgetSelected(SelectionEvent e) {
50
                isEditorActivated = activateCheckButton.getSelection();
51

    
52
                if(isEditorActivated){
53
                    child.setVisible(true);
54
                    child.setEnabled(true);
55
                }else{
56
                    child.setVisible(false);
57
                    child.setEnabled(false);
58
                }
59

    
60
            }
61
        });
62

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

    
71
        button_openFeatureTree.setText("Open Distribution Selection Wizard");
72
        final Button showIdInVocabulary = new Button(child, SWT.CHECK);
73
        isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
74
        showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
75
        showIdInVocabulary.setSelection(isShowIdInVocabulary);
76
        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
77
            @Override
78
            public void widgetSelected(SelectionEvent e) {
79
                isShowIdInVocabulary = showIdInVocabulary.getSelection();
80

    
81
             }
82
        });
83

    
84
        final Button showSymbol = new Button(child, SWT.CHECK);
85
        isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
86
        showSymbol.setText("Show Symbol of the Status, if existing");
87
        showSymbol.setSelection(isShowSymbol);
88
        showSymbol.addSelectionListener(new SelectionAdapter(){
89
            @Override
90
            public void widgetSelected(SelectionEvent e) {
91
                isShowSymbol = showSymbol.getSelection();
92
             }
93
        });
94
        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
95
        isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
96
        final Button activateRankButton = new Button(child, SWT.CHECK);
97
        activateRankButton.setText("Show Rank in Distribution Editor");
98
        activateRankButton.setSelection(isShowRank);
99
        activateRankButton.addSelectionListener(new SelectionAdapter(){
100
            @Override
101
            public void widgetSelected(SelectionEvent e) {
102
                isShowRank = activateRankButton.getSelection();
103
            }
104
        });
105
        final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
106
        isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
107
        sortNamedAreaByVocabularyOrder.setText("Sort Areas by Order in Vocabulary");
108
        sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
109
        sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
110
            @Override
111
            public void widgetSelected(SelectionEvent e) {
112
                isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
113
             }
114
        });
115

    
116
        if(isEditorActivated){
117
            child.setEnabled(true);
118
        }else{
119
            child.setEnabled(false);
120
        }
121

    
122
        return composite;
123
    }
124

    
125
    @Override
126
    public boolean performOk() {
127
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
128
        PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
129
        PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
130
        PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
131
        PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
132
        return true;
133
    }
134

    
135
}
(3-3/24)