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
|
import org.eclipse.swt.widgets.Label;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
22
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
23
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
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 CdmPreferencePage {
|
33
|
|
34
|
boolean isEditorActivated;
|
35
|
boolean isUseLocal;
|
36
|
boolean isShowRank;
|
37
|
boolean isSortByVocabularyOrder;
|
38
|
boolean isShowSymbol;
|
39
|
boolean isShowIdInVocabulary;
|
40
|
Composite child ;
|
41
|
boolean isAllowOverride;
|
42
|
|
43
|
@Override
|
44
|
protected Control createContents(Composite parent) {
|
45
|
|
46
|
Composite composite = new Composite(parent, SWT.NULL);
|
47
|
composite.setLayout(new GridLayout());
|
48
|
|
49
|
CdmPreference distributionEditorPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
|
50
|
isAllowOverride = false;
|
51
|
if (distributionEditorPref != null){
|
52
|
isAllowOverride = distributionEditorPref.isAllowOverride();
|
53
|
}
|
54
|
|
55
|
|
56
|
if (isAllowOverride){
|
57
|
isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
|
58
|
final Button activateCheckButton = new Button(composite, SWT.CHECK);
|
59
|
activateCheckButton.setText("Enable Distribution Editor");
|
60
|
activateCheckButton.setSelection(isEditorActivated);
|
61
|
activateCheckButton.addSelectionListener(new SelectionAdapter(){
|
62
|
@Override
|
63
|
public void widgetSelected(SelectionEvent e) {
|
64
|
isEditorActivated = activateCheckButton.getSelection();
|
65
|
|
66
|
if(isEditorActivated){
|
67
|
child.setVisible(true);
|
68
|
child.setEnabled(true);
|
69
|
}else{
|
70
|
child.setVisible(false);
|
71
|
child.setEnabled(false);
|
72
|
}
|
73
|
|
74
|
}
|
75
|
});
|
76
|
|
77
|
child = new Composite(composite, SWT.NULL);
|
78
|
child.setLayout(new GridLayout());
|
79
|
child.setVisible(isEditorActivated);
|
80
|
final CLabel label = new CLabel(child, SWT.NULL);
|
81
|
label.setText("Please open the wizard below, in order to \n" + "choose the area vocabularies for the Distribution Editor");
|
82
|
final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
|
83
|
"eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
|
84
|
|
85
|
button_openFeatureTree.setText("Open Distribution Selection Wizard");
|
86
|
final Button showIdInVocabulary = new Button(child, SWT.CHECK);
|
87
|
isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
|
88
|
showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
|
89
|
showIdInVocabulary.setSelection(isShowIdInVocabulary);
|
90
|
showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
|
91
|
@Override
|
92
|
public void widgetSelected(SelectionEvent e) {
|
93
|
isShowIdInVocabulary = showIdInVocabulary.getSelection();
|
94
|
|
95
|
}
|
96
|
});
|
97
|
|
98
|
final Button showSymbol = new Button(child, SWT.CHECK);
|
99
|
isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
|
100
|
showSymbol.setText("Show Symbol of the Status, if existing");
|
101
|
showSymbol.setSelection(isShowSymbol);
|
102
|
showSymbol.addSelectionListener(new SelectionAdapter(){
|
103
|
@Override
|
104
|
public void widgetSelected(SelectionEvent e) {
|
105
|
isShowSymbol = showSymbol.getSelection();
|
106
|
}
|
107
|
});
|
108
|
PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
|
109
|
isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
110
|
final Button activateRankButton = new Button(child, SWT.CHECK);
|
111
|
activateRankButton.setText("Show Rank in Distribution Editor");
|
112
|
activateRankButton.setSelection(isShowRank);
|
113
|
activateRankButton.addSelectionListener(new SelectionAdapter(){
|
114
|
@Override
|
115
|
public void widgetSelected(SelectionEvent e) {
|
116
|
isShowRank = activateRankButton.getSelection();
|
117
|
}
|
118
|
});
|
119
|
final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
|
120
|
isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
|
121
|
sortNamedAreaByVocabularyOrder.setText("Sort Areas by Order in Vocabulary");
|
122
|
sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
|
123
|
sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
|
124
|
@Override
|
125
|
public void widgetSelected(SelectionEvent e) {
|
126
|
isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
|
127
|
}
|
128
|
});
|
129
|
|
130
|
if(isEditorActivated){
|
131
|
child.setEnabled(true);
|
132
|
}else{
|
133
|
child.setEnabled(false);
|
134
|
}
|
135
|
}else{
|
136
|
Label label = new Label(composite, SWT.NONE);
|
137
|
label.setText("The CDM settings don't allow to set the preferences for using the distribution editor locally. If you need to make local settings, please ask an administrator.");
|
138
|
|
139
|
}
|
140
|
|
141
|
return composite;
|
142
|
}
|
143
|
|
144
|
@Override
|
145
|
public boolean performOk() {
|
146
|
if (isAllowOverride){
|
147
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
|
148
|
PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
|
149
|
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
150
|
PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
|
151
|
PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
|
152
|
}
|
153
|
return true;
|
154
|
}
|
155
|
|
156
|
}
|