Project

General

Profile

Download (5.72 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.databaseAdmin.preferencePage;
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.IPreferenceKeys;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
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 CdmPreferencePage implements IE4AdminPreferencePage {
32

    
33
    boolean isEditorActivated;
34
    boolean isShowRank;
35
    boolean isSortByVocabularyOrder;
36
    boolean isShowSymbol;
37
    boolean isShowIdInVocabulary;
38
    Composite child ;
39

    
40
    @Override
41
    protected Control createContents(Composite parent) {
42

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

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

    
62
            }
63
        });
64

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

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

    
83
             }
84
        });
85

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

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

    
124
        return composite;
125
    }
126

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

    
137
}
(2-2/5)