Project

General

Profile

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

    
3

    
4
import org.eclipse.swt.SWT;
5
import org.eclipse.swt.events.SelectionAdapter;
6
import org.eclipse.swt.events.SelectionEvent;
7
import org.eclipse.swt.layout.GridLayout;
8
import org.eclipse.swt.widgets.Button;
9
import org.eclipse.swt.widgets.Composite;
10
import org.eclipse.swt.widgets.Control;
11
import org.eclipse.swt.widgets.Label;
12

    
13
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
14
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
15
import eu.etaxonomy.taxeditor.l10n.Messages;
16
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
17

    
18

    
19
public class NameDetailsViewConfiguration extends CdmPreferencePage {
20

    
21
    boolean isSimpleDetailsViewActivated;
22
	boolean isUseLocalSettings;
23
    Composite child ;
24
    Composite localSettings ;
25

    
26
    @Override
27
    protected Control createContents(Composite parent) {
28

    
29
    	Composite composite = new Composite(parent, SWT.NULL);
30
        composite.setLayout(new GridLayout());
31
        CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
32
        boolean isAllowOverride = false;
33
        if (nameDetailsPref != null){
34
            isAllowOverride = nameDetailsPref.isAllowOverride();
35
        }
36

    
37

    
38
        if (isAllowOverride){
39

    
40
            final Button activateLocalButton = new Button(composite, SWT.CHECK);
41
            activateLocalButton.setText(Messages.NameDetailsViewConfiguration_useLocalSettings);
42
            isUseLocalSettings =PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.OVERRIDE_NAME_DETAILS);
43
            activateLocalButton.setSelection(isUseLocalSettings);
44
            activateLocalButton.addSelectionListener(new SelectionAdapter(){
45
            @Override
46
            public void widgetSelected(SelectionEvent e) {
47
                isUseLocalSettings = activateLocalButton.getSelection();
48
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.OVERRIDE_NAME_DETAILS, isUseLocalSettings);
49
                if(isUseLocalSettings ){
50
                    child.setVisible(true);
51
                    child.setEnabled(true);
52
                }else{
53
                    child.setVisible(false);
54
                    child.setEnabled(false);
55
                }
56
             }
57
             });
58

    
59
            child  = new Composite(composite, SWT.NONE);
60
            child.setLayout(new GridLayout());
61
            child.setVisible(isUseLocalSettings);
62

    
63
            isSimpleDetailsViewActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
64

    
65

    
66

    
67
            final Button activateCheckButton = new Button(child, SWT.CHECK);
68
            activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
69
            activateCheckButton.setSelection(isSimpleDetailsViewActivated);
70
            activateCheckButton.addSelectionListener(new SelectionAdapter(){
71
            @Override
72
            public void widgetSelected(SelectionEvent e) {
73
            	isSimpleDetailsViewActivated = activateCheckButton.getSelection();
74
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
75
                if(isSimpleDetailsViewActivated && isUseLocalSettings){
76
                    localSettings.setVisible(true);
77
                    localSettings.setEnabled(true);
78
                }else{
79
                    localSettings.setVisible(false);
80
                    localSettings.setEnabled(false);
81
                }
82
             }
83
             });
84
            localSettings  = new Composite(child, SWT.NONE);
85
            localSettings.setLayout(new GridLayout());
86
            localSettings.setVisible(isSimpleDetailsViewActivated);
87

    
88

    
89
            final Button showTaxon = new Button(localSettings, SWT.CHECK);
90
            boolean isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
91
            showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
92
            showTaxon.setSelection(isShowTaxon);
93
            showTaxon.addSelectionListener(new SelectionAdapter(){
94
                 @Override
95
                 public void widgetSelected(SelectionEvent e) {
96
                     boolean isShowTaxon = showTaxon.getSelection();
97
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
98
                  }
99
             });
100

    
101
            final Button showLsid = new Button(localSettings, SWT.CHECK);
102
            boolean isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
103
            showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
104
            showLsid.setSelection(isShowLSID);
105
            showLsid.addSelectionListener(new SelectionAdapter(){
106
                 @Override
107
                 public void widgetSelected(SelectionEvent e) {
108
                     boolean isShowLSID = showLsid.getSelection();
109
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
110
                  }
111
             });
112

    
113
            final Button showNomenclaturalCode = new Button(localSettings, SWT.CHECK);
114
            boolean isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
115
            showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
116
            showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
117
            showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
118
                 @Override
119
                 public void widgetSelected(SelectionEvent e) {
120
                     boolean isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
121
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
122
                  }
123
             });
124

    
125
            final Button showNameCache = new Button(localSettings, SWT.CHECK);
126
            boolean isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
127
            showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
128
            showNameCache.setSelection(isShowNomenclaturalCode);
129
            showNameCache.addSelectionListener(new SelectionAdapter(){
130
                 @Override
131
                 public void widgetSelected(SelectionEvent e) {
132
                     boolean isShowNameCache = showNameCache.getSelection();
133
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
134
                  }
135
             });
136
            final Button showAppendedPhrase = new Button(localSettings, SWT.CHECK);
137
            boolean isShowAppendedPhrase = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
138
            showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
139
            showAppendedPhrase.setSelection(isShowAppendedPhrase);
140
            showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
141
                 @Override
142
                 public void widgetSelected(SelectionEvent e) {
143
                     boolean isShowAppendedPhrase = showAppendedPhrase.getSelection();
144
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
145
                  }
146
             });
147

    
148
            final Button showRank = new Button(localSettings, SWT.CHECK);
149
            boolean isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
150
            showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
151
            showRank.setSelection(isShowRank);
152
            showRank.addSelectionListener(new SelectionAdapter(){
153
                 @Override
154
                 public void widgetSelected(SelectionEvent e) {
155
                     boolean isShowRank = showRank.getSelection();
156
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
157
                  }
158
             });
159
            final Button showEpithets = new Button(localSettings, SWT.CHECK);
160
            boolean isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
161
            showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
162
            showEpithets.setSelection(isShowEpithets);
163
            showEpithets.addSelectionListener(new SelectionAdapter(){
164
                 @Override
165
                 public void widgetSelected(SelectionEvent e) {
166
                     boolean isShowEpithets = showEpithets.getSelection();
167
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
168
                  }
169
             });
170

    
171
            final Button showAuthorCache = new Button(localSettings, SWT.CHECK);
172
            boolean isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
173
            showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
174
            showAuthorCache.setSelection(isShowAuthorCache);
175
            showAuthorCache.addSelectionListener(new SelectionAdapter(){
176
                 @Override
177
                 public void widgetSelected(SelectionEvent e) {
178
                     boolean isShowAuthorCache = showAuthorCache.getSelection();
179
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
180
                  }
181
             });
182

    
183
            final Button showAuthorship = new Button(localSettings, SWT.CHECK);
184
            boolean isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
185
            showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
186
            showAuthorship.setSelection(isShowAuthorship);
187
            showAuthorship.addSelectionListener(new SelectionAdapter(){
188
                 @Override
189
                 public void widgetSelected(SelectionEvent e) {
190
                     boolean isShowAuthorship = showAuthorship.getSelection();
191
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
192
                  }
193
             });
194

    
195
            final Button showNomenclaturalRef = new Button(localSettings, SWT.CHECK);
196
            boolean isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
197
            showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
198
            showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
199
            showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
200
                 @Override
201
                 public void widgetSelected(SelectionEvent e) {
202
                     boolean isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
203
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
204
                  }
205
             });
206

    
207
            final Button showNomenclaturalStatus = new Button(localSettings, SWT.CHECK);
208
            boolean isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
209
            showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
210
            showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
211
            showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
212
                 @Override
213
                 public void widgetSelected(SelectionEvent e) {
214
                     boolean isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
215
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
216
                  }
217
             });
218

    
219
            final Button showProtologue = new Button(localSettings, SWT.CHECK);
220
            boolean isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
221
            showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
222
            showProtologue.setSelection(isShowProtologue);
223
            showProtologue.addSelectionListener(new SelectionAdapter(){
224
                 @Override
225
                 public void widgetSelected(SelectionEvent e) {
226
                     boolean isShowProtologue = showProtologue.getSelection();
227
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
228
                  }
229
             });
230

    
231
            final Button showTypeDesignation = new Button(localSettings, SWT.CHECK);
232
            boolean isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
233
            showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
234
            showTypeDesignation.setSelection(isShowTypeDesignation);
235
            showTypeDesignation.addSelectionListener(new SelectionAdapter(){
236
                 @Override
237
                 public void widgetSelected(SelectionEvent e) {
238
                     boolean isShowTypeDesignation = showTypeDesignation.getSelection();
239
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
240
                  }
241
             });
242

    
243

    
244
            final Button showNameRelationship = new Button(localSettings, SWT.CHECK);
245
            boolean isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
246
            showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
247
            showNameRelationship.setSelection(isShowNameRelationship);
248
            showNameRelationship.addSelectionListener(new SelectionAdapter(){
249
                 @Override
250
                 public void widgetSelected(SelectionEvent e) {
251
                     boolean isShowNameRelationship = showNameRelationship.getSelection();
252
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
253
                  }
254
             });
255

    
256
            final Button showHybrid = new Button(localSettings, SWT.CHECK);
257
            boolean isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
258
            showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
259
            showHybrid.setSelection(isShowHybrid);
260
            showHybrid.addSelectionListener(new SelectionAdapter(){
261
                 @Override
262
                 public void widgetSelected(SelectionEvent e) {
263
                     boolean isShowHybrid = showHybrid.getSelection();
264
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
265
                  }
266
             });
267
            final Button showNameApprobiation = new Button(localSettings, SWT.CHECK);
268
            boolean isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
269
            showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
270
            showNameApprobiation.setSelection(isShowNameApprobiation);
271
            showNameApprobiation.addSelectionListener(new SelectionAdapter(){
272
                 @Override
273
                 public void widgetSelected(SelectionEvent e) {
274
                     boolean isShowNameApprobiation = showNameApprobiation.getSelection();
275
                     PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
276
                  }
277
             });
278

    
279

    
280
            if(isSimpleDetailsViewActivated){
281
                localSettings.setEnabled(true);
282
            }else{
283
                localSettings.setEnabled(false);
284
            }
285
        }else{
286
            Label label = new Label(composite, SWT.NONE);
287
            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.");
288
        }
289
        return composite;
290
	}
291

    
292
}
(16-16/24)