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.NameDetailsConfigurator;
22
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23

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

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

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

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

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

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

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

    
81

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

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

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

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

    
116
             }
117
        });
118

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

    
128
             }
129
        });
130

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

    
140
             }
141
        });
142

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

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

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

    
164
             }
165
        });
166

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

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

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

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

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

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

    
253

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

    
265
       final Button showHybrid = new Button(child, SWT.CHECK);
266
       isShowHybrid = config.isHybridActivated();
267
       showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
268
       showHybrid.setSelection(isShowHybrid);
269
       showHybrid.addSelectionListener(new SelectionAdapter(){
270
            @Override
271
            public void widgetSelected(SelectionEvent e) {
272
                isShowHybrid = showHybrid.getSelection();
273
             }
274
        });
275
       final Button showNameApprobiation = new Button(child, SWT.CHECK);
276
       isShowNameApprobiation = config.isNameApprobiationActivated();
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
            	isShowNameApprobiation = showNameApprobiation.getSelection();
283
             }
284
        });
285

    
286
       this.redraw();
287

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

    
294
    }
295

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

    
301

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

    
320

    
321
      return config;
322
   }
323

    
324

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

    
329
}
(6-6/9)