Project

General

Profile

Download (16.9 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.preference;
2

    
3

    
4
import org.eclipse.jface.preference.PreferencePage;
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.events.SelectionAdapter;
7
import org.eclipse.swt.events.SelectionEvent;
8
import org.eclipse.swt.layout.GridLayout;
9
import org.eclipse.swt.widgets.Button;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.swt.widgets.Control;
12
import org.eclipse.swt.widgets.Label;
13
import org.eclipse.ui.IWorkbench;
14
import org.eclipse.ui.IWorkbenchPreferencePage;
15

    
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
17
import eu.etaxonomy.taxeditor.l10n.Messages;
18

    
19

    
20
public class NameDetailsViewConfiguration extends PreferencePage implements IWorkbenchPreferencePage {
21
	boolean isSimpleDetailsViewActivated;
22
	boolean isUseLocalSettings;
23
    Composite child ;
24
    Composite localSettings ;
25
	@Override
26
	public void init(IWorkbench workbench) {
27

    
28
	}
29

    
30
	/*
31
     * (non-Javadoc)
32
     *
33
     * @see
34
     * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
35
     * ()
36
     */
37
    @Override
38
    protected Control createContents(Composite parent) {
39

    
40
    	Composite composite = new Composite(parent, SWT.NULL);
41
        composite.setLayout(new GridLayout());
42

    
43
        boolean isAllowOverride = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView).isAllowOverride();
44

    
45

    
46
        if (isAllowOverride){
47

    
48
            final Button activateLocalButton = new Button(composite, SWT.CHECK);
49
            activateLocalButton.setText(Messages.NameDetailsViewConfiguration_useLocalSettings);
50
            isUseLocalSettings =PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.OVERRIDE_NAME_DETAILS);
51
            activateLocalButton.setSelection(isUseLocalSettings);
52
            activateLocalButton.addSelectionListener(new SelectionAdapter(){
53
            @Override
54
            public void widgetSelected(SelectionEvent e) {
55
                isUseLocalSettings = activateLocalButton.getSelection();
56
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isUseLocalSettings);
57
                if(isUseLocalSettings ){
58
                    child.setVisible(true);
59
                    child.setEnabled(true);
60
                }else{
61
                    child.setVisible(false);
62
                    child.setEnabled(false);
63
                }
64
             }
65
             });
66

    
67
            child  = new Composite(composite, SWT.NONE);
68
            child.setLayout(new GridLayout());
69
            child.setVisible(isUseLocalSettings);
70

    
71
            isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
72

    
73

    
74

    
75
            final Button activateCheckButton = new Button(child, SWT.CHECK);
76
            activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
77
            activateCheckButton.setSelection(isSimpleDetailsViewActivated);
78
            activateCheckButton.addSelectionListener(new SelectionAdapter(){
79
            @Override
80
            public void widgetSelected(SelectionEvent e) {
81
            	isSimpleDetailsViewActivated = activateCheckButton.getSelection();
82
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
83
                if(isSimpleDetailsViewActivated && isUseLocalSettings){
84
                    localSettings.setVisible(true);
85
                    localSettings.setEnabled(true);
86
                }else{
87
                    localSettings.setVisible(false);
88
                    localSettings.setEnabled(false);
89
                }
90
             }
91
             });
92
            localSettings  = new Composite(child, SWT.NONE);
93
            localSettings.setLayout(new GridLayout());
94
            localSettings.setVisible(isSimpleDetailsViewActivated);
95

    
96

    
97
            final Button showTaxon = new Button(localSettings, SWT.CHECK);
98
            boolean isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
99
            showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
100
            showTaxon.setSelection(isShowTaxon);
101
            showTaxon.addSelectionListener(new SelectionAdapter(){
102
                 @Override
103
                 public void widgetSelected(SelectionEvent e) {
104
                     boolean isShowTaxon = showTaxon.getSelection();
105
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
106
                  }
107
             });
108

    
109
            final Button showLsid = new Button(localSettings, SWT.CHECK);
110
            boolean isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
111
            showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
112
            showLsid.setSelection(isShowLSID);
113
            showLsid.addSelectionListener(new SelectionAdapter(){
114
                 @Override
115
                 public void widgetSelected(SelectionEvent e) {
116
                     boolean isShowLSID = showLsid.getSelection();
117
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
118
                  }
119
             });
120

    
121
            final Button showNomenclaturalCode = new Button(localSettings, SWT.CHECK);
122
            boolean isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
123
            showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
124
            showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
125
            showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
126
                 @Override
127
                 public void widgetSelected(SelectionEvent e) {
128
                     boolean isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
129
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
130
                  }
131
             });
132

    
133
            final Button showNameCache = new Button(localSettings, SWT.CHECK);
134
            boolean isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
135
            showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
136
            showNameCache.setSelection(isShowNomenclaturalCode);
137
            showNameCache.addSelectionListener(new SelectionAdapter(){
138
                 @Override
139
                 public void widgetSelected(SelectionEvent e) {
140
                     boolean isShowNameCache = showNameCache.getSelection();
141
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
142
                  }
143
             });
144
            final Button showAppendedPhrase = new Button(localSettings, SWT.CHECK);
145
            boolean isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
146
            showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
147
            showAppendedPhrase.setSelection(isShowAppendedPhrase);
148
            showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
149
                 @Override
150
                 public void widgetSelected(SelectionEvent e) {
151
                     boolean isShowAppendedPhrase = showAppendedPhrase.getSelection();
152
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
153
                  }
154
             });
155

    
156
            final Button showRank = new Button(localSettings, SWT.CHECK);
157
            boolean isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
158
            showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
159
            showRank.setSelection(isShowRank);
160
            showRank.addSelectionListener(new SelectionAdapter(){
161
                 @Override
162
                 public void widgetSelected(SelectionEvent e) {
163
                     boolean isShowRank = showRank.getSelection();
164
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
165
                  }
166
             });
167
            final Button showEpithets = new Button(localSettings, SWT.CHECK);
168
            boolean isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
169
            showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
170
            showEpithets.setSelection(isShowEpithets);
171
            showEpithets.addSelectionListener(new SelectionAdapter(){
172
                 @Override
173
                 public void widgetSelected(SelectionEvent e) {
174
                     boolean isShowEpithets = showEpithets.getSelection();
175
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
176
                  }
177
             });
178

    
179
            final Button showAuthorCache = new Button(localSettings, SWT.CHECK);
180
            boolean isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
181
            showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
182
            showAuthorCache.setSelection(isShowAuthorCache);
183
            showAuthorCache.addSelectionListener(new SelectionAdapter(){
184
                 @Override
185
                 public void widgetSelected(SelectionEvent e) {
186
                     boolean isShowAuthorCache = showAuthorCache.getSelection();
187
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
188
                  }
189
             });
190

    
191
            final Button showAuthorship = new Button(localSettings, SWT.CHECK);
192
            boolean isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
193
            showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
194
            showAuthorship.setSelection(isShowAuthorship);
195
            showAuthorship.addSelectionListener(new SelectionAdapter(){
196
                 @Override
197
                 public void widgetSelected(SelectionEvent e) {
198
                     boolean isShowAuthorship = showAuthorship.getSelection();
199
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
200
                  }
201
             });
202

    
203
            final Button showNomenclaturalRef = new Button(localSettings, SWT.CHECK);
204
            boolean isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
205
            showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
206
            showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
207
            showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
208
                 @Override
209
                 public void widgetSelected(SelectionEvent e) {
210
                     boolean isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
211
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
212
                  }
213
             });
214

    
215
            final Button showNomenclaturalStatus = new Button(localSettings, SWT.CHECK);
216
            boolean isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
217
            showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
218
            showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
219
            showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
220
                 @Override
221
                 public void widgetSelected(SelectionEvent e) {
222
                     boolean isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
223
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
224
                  }
225
             });
226

    
227
            final Button showProtologue = new Button(localSettings, SWT.CHECK);
228
            boolean isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
229
            showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
230
            showProtologue.setSelection(isShowProtologue);
231
            showProtologue.addSelectionListener(new SelectionAdapter(){
232
                 @Override
233
                 public void widgetSelected(SelectionEvent e) {
234
                     boolean isShowProtologue = showProtologue.getSelection();
235
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
236
                  }
237
             });
238

    
239
            final Button showTypeDesignation = new Button(localSettings, SWT.CHECK);
240
            boolean isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
241
            showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
242
            showTypeDesignation.setSelection(isShowTypeDesignation);
243
            showTypeDesignation.addSelectionListener(new SelectionAdapter(){
244
                 @Override
245
                 public void widgetSelected(SelectionEvent e) {
246
                     boolean isShowTypeDesignation = showTypeDesignation.getSelection();
247
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
248
                  }
249
             });
250

    
251

    
252
            final Button showNameRelationship = new Button(localSettings, SWT.CHECK);
253
            boolean isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
254
            showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
255
            showNameRelationship.setSelection(isShowNameRelationship);
256
            showNameRelationship.addSelectionListener(new SelectionAdapter(){
257
                 @Override
258
                 public void widgetSelected(SelectionEvent e) {
259
                     boolean isShowNameRelationship = showNameRelationship.getSelection();
260
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
261
                  }
262
             });
263

    
264
            final Button showHybrid = new Button(localSettings, SWT.CHECK);
265
            boolean isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
266
            showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
267
            showHybrid.setSelection(isShowHybrid);
268
            showHybrid.addSelectionListener(new SelectionAdapter(){
269
                 @Override
270
                 public void widgetSelected(SelectionEvent e) {
271
                     boolean isShowHybrid = showHybrid.getSelection();
272
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
273
                  }
274
             });
275
            final Button showNameApprobiation = new Button(localSettings, SWT.CHECK);
276
            boolean isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
277
            showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
278
            showNameApprobiation.setSelection(isShowNameApprobiation);
279
            showNameApprobiation.addSelectionListener(new SelectionAdapter(){
280
                 @Override
281
                 public void widgetSelected(SelectionEvent e) {
282
                     boolean isShowNameApprobiation = showNameApprobiation.getSelection();
283
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
284
                  }
285
             });
286

    
287

    
288
            if(isSimpleDetailsViewActivated){
289
                localSettings.setEnabled(true);
290
            }else{
291
                localSettings.setEnabled(false);
292
            }
293
        }else{
294
            Label label = new Label(composite, SWT.NONE);
295
            label.setText("The CDM settings don't allow to set the preferences for the display of name details locally. If you need to make local settings, please ask an administrator.");
296
        }
297
        return composite;
298

    
299

    
300

    
301
	}
302

    
303
}
(16-16/25)