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
|
PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
|
88
|
boolean isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
|
89
|
final Button activateRankButton = new Button(child, SWT.CHECK);
|
90
|
activateRankButton.setText("Show Rank in Distribution Editor");
|
91
|
activateRankButton.setSelection(isShowRank);
|
92
|
activateRankButton.addSelectionListener(new SelectionAdapter(){
|
93
|
@Override
|
94
|
public void widgetSelected(SelectionEvent e) {
|
95
|
boolean isShowRank = activateRankButton.getSelection();
|
96
|
PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
|
97
|
}
|
98
|
});
|
99
|
|
100
|
|
101
|
if(isEditorActivated){
|
102
|
child.setEnabled(true);
|
103
|
}else{
|
104
|
child.setEnabled(false);
|
105
|
}
|
106
|
|
107
|
return composite;
|
108
|
}
|
109
|
|
110
|
/*
|
111
|
* (non-Javadoc)
|
112
|
*
|
113
|
* @see
|
114
|
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
|
115
|
*/
|
116
|
@Override
|
117
|
public void init(IWorkbench workbench) {
|
118
|
}
|
119
|
|
120
|
}
|