Project

General

Profile

Download (13.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.wizard;
10

    
11
import org.eclipse.jface.preference.IPreferenceStore;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Composite;
19

    
20
import eu.etaxonomy.taxeditor.l10n.Messages;
21
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
22
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
24

    
25
/**
26
 * @author k.luther
27
 * @date 22.02.2017
28
 *
29
 */
30
public class NameDetailsViewComposite extends Composite {
31

    
32
    NameDetailsConfigurator config;
33
    boolean isSimpleDetailsViewActivated;
34
    boolean isShowTaxon;
35
    boolean isShowLSID;
36
    boolean isShowNomenclaturalCode;
37
    boolean isShowNameCache;
38
    boolean isShowAppendedPhrase;
39
    boolean isShowRank;
40
    boolean isShowEpithets;
41
    boolean isShowAuthorshipCache;
42
    boolean isShowAuthorship;
43
    boolean isShowNomenclaturalRef;
44
    boolean isShowNomenclaturalStatus;
45
    boolean isShowProtologue;
46
    boolean isShowTypeDesignation;
47
    boolean isShowNameRelationship;
48
    boolean isShowHybrid;
49
    Composite child;
50
	private boolean isShowNameApprobiation;
51

    
52
    public NameDetailsViewComposite(Composite parent, int style, NameDetailsConfigurator config){
53

    
54
        super(parent, SWT.NONE);
55
//        TabItem tbtmNameDetailsConfiguration = new TabItem(tabFolder, SWT.NONE);
56
//        Composite c2 = new Composite(tabFolder, SWT.BORDER);
57
//        c2.setLayout(new GridLayout(1, true));
58
//        tbtmNameDetailsConfiguration.setControl(c2);
59
       // composite.setLayout(new GridLayout(1, true));
60
       this.config = config;
61

    
62
      // Composite composite = new Composite(parent, SWT.NULL);
63

    
64
       this.setLayout(new GridLayout());
65
       GridData data = new GridData(GridData.FILL_BOTH);
66
       this.setData(data);
67
//       CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
68
//       NameDetailsConfigurator config = PreferencesUtil.setPreferredNameDetailsConfiguration(local)
69

    
70
       final Button allowLocalPreference = new Button(this, SWT.CHECK);
71
       boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
72
       allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
73
       allowLocalPreference.setSelection(isUseLocalPreference);
74
       allowLocalPreference.addSelectionListener(new SelectionAdapter(){
75
            @Override
76
            public void widgetSelected(SelectionEvent e) {
77
                boolean isUseLocalPreference = allowLocalPreference.getSelection();
78
                PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS, isUseLocalPreference);
79
             }
80
        });
81

    
82

    
83
       isSimpleDetailsViewActivated= config.isSimpleDetailsViewActivated();
84
       final Button activateCheckButton = new Button(this, SWT.CHECK);
85
       activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
86
       activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
87
       activateCheckButton.setSelection(isSimpleDetailsViewActivated);
88
       activateCheckButton.addSelectionListener(new SelectionAdapter(){
89
       @Override
90
       public void widgetSelected(SelectionEvent e) {
91
           isSimpleDetailsViewActivated = activateCheckButton.getSelection();
92
          //
93
           if(isSimpleDetailsViewActivated){
94
               child.setVisible(true);
95
               child.setEnabled(true);
96
           }else{
97
               child.setVisible(false);
98
               child.setEnabled(false);
99
           }
100
        }
101
        });
102

    
103
       child = new Composite(this, SWT.NULL);
104

    
105
       child.setLayout(new GridLayout());
106
       child.setVisible(isSimpleDetailsViewActivated);
107

    
108
       final Button showTaxon = new Button(child, SWT.CHECK);
109
       isShowTaxon = config.isTaxonSectionActivated();
110
       showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
111
       showTaxon.setSelection(isShowTaxon);
112
       showTaxon.addSelectionListener(new SelectionAdapter(){
113
            @Override
114
            public void widgetSelected(SelectionEvent e) {
115
               isShowTaxon = showTaxon.getSelection();
116

    
117
             }
118
        });
119

    
120
       final Button showLsid = new Button(child, SWT.CHECK);
121
       isShowLSID = config.isLSIDActivated();
122
       showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
123
       showLsid.setSelection(isShowLSID);
124
       showLsid.addSelectionListener(new SelectionAdapter(){
125
            @Override
126
            public void widgetSelected(SelectionEvent e) {
127
                isShowLSID = showLsid.getSelection();
128

    
129
             }
130
        });
131

    
132
       final Button showNomenclaturalCode = new Button(child, SWT.CHECK);
133
       isShowNomenclaturalCode = config.isNomenclaturalCodeActived();
134
       showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
135
       showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
136
       showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
137
            @Override
138
            public void widgetSelected(SelectionEvent e) {
139
                isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
140

    
141
             }
142
        });
143

    
144
       final Button showNameCache = new Button(child, SWT.CHECK);
145
       isShowNameCache= config.isNameCacheActivated();
146

    
147
       showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
148
       showNameCache.setSelection(isShowNomenclaturalCode);
149
       showNameCache.addSelectionListener(new SelectionAdapter(){
150
            @Override
151
            public void widgetSelected(SelectionEvent e) {
152
                isShowNameCache = showNameCache.getSelection();
153

    
154
             }
155
        });
156
       final Button showAppendedPhrase = new Button(child, SWT.CHECK);
157
       isShowAppendedPhrase= config.isAppendedPhraseActivated();
158
       showAppendedPhrase.setText(Messages.NameDetailsViewComposite_Show_AppendedPhrase);
159
       showAppendedPhrase.setSelection(isShowAppendedPhrase);
160
       showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
161
            @Override
162
            public void widgetSelected(SelectionEvent e) {
163
                isShowAppendedPhrase = showAppendedPhrase.getSelection();
164

    
165
             }
166
        });
167

    
168
       final Button showRank = new Button(child, SWT.CHECK);
169
       isShowRank = config.isRankActivated();
170
       showRank.setText(Messages.NameDetailsViewComposite_Show_Rank);
171
       showRank.setSelection(isShowRank);
172
       showRank.addSelectionListener(new SelectionAdapter(){
173
            @Override
174
            public void widgetSelected(SelectionEvent e) {
175
                isShowRank = showRank.getSelection();
176
             }
177
        });
178
       final Button showEpithets = new Button(child, SWT.CHECK);
179
       isShowEpithets = config.isAtomisedEpithetsActivated();
180
       showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
181
       showEpithets.setSelection(isShowEpithets);
182
       showEpithets.addSelectionListener(new SelectionAdapter(){
183
            @Override
184
            public void widgetSelected(SelectionEvent e) {
185
                isShowEpithets = showEpithets.getSelection();
186
             }
187
        });
188
       final Button showAuthorshipCache = new Button(child, SWT.CHECK);
189
       isShowAuthorshipCache= config.isAuthorCacheActivated();
190
       showAuthorshipCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
191
       showAuthorshipCache.setSelection(isShowAuthorshipCache);
192
       showAuthorshipCache.addSelectionListener(new SelectionAdapter(){
193
            @Override
194
            public void widgetSelected(SelectionEvent e) {
195
                isShowAuthorshipCache = showAuthorshipCache.getSelection();
196
             }
197
        });
198

    
199
       final Button showAuthorship = new Button(child, SWT.CHECK);
200
       isShowAuthorship =config.isAuthorshipSectionActivated();
201
       showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
202
       showAuthorship.setSelection(isShowAuthorship);
203
       showAuthorship.addSelectionListener(new SelectionAdapter(){
204
            @Override
205
            public void widgetSelected(SelectionEvent e) {
206
                isShowAuthorship = showAuthorship.getSelection();
207
             }
208
        });
209

    
210
       final Button showNomenclaturalRef = new Button(child, SWT.CHECK);
211
       isShowNomenclaturalRef = config.isNomenclaturalReferenceSectionActivated();
212
       showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
213
       showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
214
       showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
215
            @Override
216
            public void widgetSelected(SelectionEvent e) {
217
                isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
218
             }
219
        });
220

    
221
       final Button showNomenclaturalStatus = new Button(child, SWT.CHECK);
222
       isShowNomenclaturalStatus = config.isNomenclaturalStatusSectionActivated();
223
       showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
224
       showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
225
       showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
226
            @Override
227
            public void widgetSelected(SelectionEvent e) {
228
                isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
229
             }
230
        });
231

    
232
       final Button showProtologue = new Button(child, SWT.CHECK);
233
       isShowProtologue  = config.isProtologueActivated();
234
       showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
235
       showProtologue.setSelection(isShowProtologue);
236
       showProtologue.addSelectionListener(new SelectionAdapter(){
237
            @Override
238
            public void widgetSelected(SelectionEvent e) {
239
                isShowProtologue = showProtologue.getSelection();
240
             }
241
        });
242

    
243
       final Button showTypeDesignation = new Button(child, SWT.CHECK);
244
       isShowTypeDesignation = config.isTypeDesignationSectionActivated();
245
       showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
246
       showTypeDesignation.setSelection(isShowTypeDesignation);
247
       showTypeDesignation.addSelectionListener(new SelectionAdapter(){
248
            @Override
249
            public void widgetSelected(SelectionEvent e) {
250
                isShowTypeDesignation = showTypeDesignation.getSelection();
251
             }
252
        });
253

    
254

    
255
       final Button showNameRelationship = new Button(child, SWT.CHECK);
256
       isShowNameRelationship = config.isNameRelationsSectionActivated();
257
       showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
258
       showNameRelationship.setSelection(isShowNameRelationship);
259
       showNameRelationship.addSelectionListener(new SelectionAdapter(){
260
            @Override
261
            public void widgetSelected(SelectionEvent e) {
262
                isShowNameRelationship = showNameRelationship.getSelection();
263
             }
264
        });
265

    
266
       final Button showHybrid = new Button(child, SWT.CHECK);
267
       isShowHybrid = config.isHybridActivated();
268
       showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
269
       showHybrid.setSelection(isShowHybrid);
270
       showHybrid.addSelectionListener(new SelectionAdapter(){
271
            @Override
272
            public void widgetSelected(SelectionEvent e) {
273
                isShowHybrid = showHybrid.getSelection();
274
             }
275
        });
276
       final Button showNameApprobiation = new Button(child, SWT.CHECK);
277
       isShowNameApprobiation = config.isNameApprobiationActivated();
278
       showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
279
       showNameApprobiation.setSelection(isShowNameApprobiation);
280
       showNameApprobiation.addSelectionListener(new SelectionAdapter(){
281
            @Override
282
            public void widgetSelected(SelectionEvent e) {
283
            	isShowNameApprobiation = showNameApprobiation.getSelection();
284
             }
285
        });
286

    
287
       this.redraw();
288

    
289
       if(isSimpleDetailsViewActivated){
290
           child.setEnabled(true);
291
       }else{
292
           child.setEnabled(false);
293
       }
294

    
295
    }
296

    
297
    /**
298
    *
299
    */
300
   protected NameDetailsConfigurator createNameDetailsViewConfig() {
301

    
302

    
303
      config.setSimpleDetailsViewActivated(isSimpleDetailsViewActivated);
304
      config.setAppendedPhraseActivated(isShowAppendedPhrase);
305
      config.setAtomisedEpithetsActivated(isShowEpithets);
306
      config.setAuthorshipSectionActivated(isShowAuthorship);
307
      config.setAuthorCacheActivated(isShowAuthorshipCache);
308
      config.setLSIDActivated(isShowLSID);
309
      config.setNameApprobiationActivated(isShowNameApprobiation);
310
      config.setNameCacheActivated(isShowNameCache);
311
      config.setNameRelationsSectionActivated(isShowNameRelationship);
312
      config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
313
      config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
314
      config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
315
      config.setProtologueActivated(isShowProtologue);
316
      config.setRankActivated(isShowRank);
317
      config.setTaxonSectionActivated(isShowTaxon);
318
      config.setTypeDesignationSectionActivated(isShowTypeDesignation);
319
      config.setHybridActivated(isShowHybrid);
320

    
321

    
322
      return config;
323
   }
324

    
325

    
326
    protected IPreferenceStore doGetPreferenceStore() {
327
        return PreferencesUtil.getPreferenceStore();
328
    }
329

    
330
}
(8-8/11)