Project

General

Profile

« Previous | Next » 

Revision f665e780

Added by Katja Luther about 6 years ago

ref #6429: adapt admin preferences to other preferences

View differences:

eu.etaxonomy.taxeditor.store/schema/eu.etaxonomy.taxeditor.store.adminPreferencePage.exsd
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="eu.etaxonomy.taxeditor.store" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="eu.etaxonomy.taxeditor.store" id="eu.etaxonomy.taxeditor.store.adminPreferencePage" name="AdminPreference Page"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12

  
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence minOccurs="0" maxOccurs="unbounded">
21
            <element ref="page"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49

  
50
   <element name="page">
51
      <annotation>
52
         <appInfo>
53
            <meta.element labelAttribute="name"/>
54
         </appInfo>
55
      </annotation>
56
      <complexType>
57
         <attribute name="id" type="string" use="required">
58
            <annotation>
59
               <documentation>
60
                  a unique name that will be used to identify this page.
61
               </documentation>
62
            </annotation>
63
         </attribute>
64
         <attribute name="name" type="string" use="required">
65
            <annotation>
66
               <documentation>
67
                  a translatable name that will be used in the UI for this page.
68
               </documentation>
69
               <appInfo>
70
                  <meta.attribute translatable="true"/>
71
               </appInfo>
72
            </annotation>
73
         </attribute>
74
         <attribute name="class" type="string" use="required">
75
            <annotation>
76
               <documentation>
77
                  a name of the fully qualified class that implements 
78
&lt;samp&gt;eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.IE4AdminPreferencePage&lt;/samp&gt;.
79
               </documentation>
80
               <appInfo>
81
                  <meta.attribute kind="java" basedOn=":eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.IE4AdminPreferencePage"/>
82
               </appInfo>
83
            </annotation>
84
         </attribute>
85
         <attribute name="category" type="string">
86
            <annotation>
87
               <documentation>
88
                  a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence
89
     of IDs separated by &apos;/&apos;, representing the full path from the root node.
90
               </documentation>
91
               <appInfo>
92
                  <meta.attribute kind="identifier" basedOn="eu.etaxonomy.taxeditor.store.adminPreferencePage/page/@id"/>
93
               </appInfo>
94
            </annotation>
95
         </attribute>
96
      </complexType>
97
   </element>
98

  
99
   <annotation>
100
      <appInfo>
101
         <meta.section type="since"/>
102
      </appInfo>
103
      <documentation>
104
         [Enter the first release in which this extension point appears.]
105
      </documentation>
106
   </annotation>
107

  
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="examples"/>
111
      </appInfo>
112
      <documentation>
113
         [Enter extension point usage example here.]
114
      </documentation>
115
   </annotation>
116

  
117
   <annotation>
118
      <appInfo>
119
         <meta.section type="apiinfo"/>
120
      </appInfo>
121
      <documentation>
122
         [Enter API information here.]
123
      </documentation>
124
   </annotation>
125

  
126
   <annotation>
127
      <appInfo>
128
         <meta.section type="implementation"/>
129
      </appInfo>
130
      <documentation>
131
         [Enter information about supplied implementation of this extension point.]
132
      </documentation>
133
   </annotation>
134

  
135

  
136
</schema>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/AbcdImportPreference.java
1
/**
2
* Copyright (C) 2018 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.preferencePage;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.events.SelectionAdapter;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.events.SelectionListener;
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.Combo;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21

  
22
import eu.etaxonomy.cdm.api.application.ICdmRepository;
23
import eu.etaxonomy.cdm.api.service.IPreferenceService;
24
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
25
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
26
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
27
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
28
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
29
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
30
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
31
import eu.etaxonomy.taxeditor.store.CdmStore;
32

  
33
/**
34
 * @author k.luther
35
 * @since 23.03.2018
36
 *
37
 */
38
public class AbcdImportPreference extends CdmPreferencePage implements IE4AdminPreferencePage, SelectionListener {
39

  
40
    private Abcd206ImportConfigurator configurator;
41

  
42
    private Combo nomenclaturalCodeSelectionCombo;
43

  
44
    /**
45
     * {@inheritDoc}
46
     */
47
    @Override
48
    protected Control createContents(Composite parent) {
49
        final Composite composite = new Composite(parent, SWT.NULL);
50

  
51
        GridLayout gridLayout = new GridLayout();
52
        composite.setLayout(gridLayout);
53

  
54
        configurator = PreferencesUtil.getAbcdImportConfigurationPreference(false);
55

  
56
        Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
57
        checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
58
        checkBoxMediaSpecimen.setText("Import media as media specimen");
59
        checkBoxMediaSpecimen
60
                .setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
61
        checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
62
            @Override
63
            public void widgetSelected(SelectionEvent e) {
64
                configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
65
            }
66
        });
67

  
68
        Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
69
        checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
70
        checkBoxIgnoreExisting.setText("Do not import existing specimens");
71
        checkBoxIgnoreExisting
72
        .setToolTipText("Specimens that have previously been imported will be ignored in this import");
73
        checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
74
            @Override
75
            public void widgetSelected(SelectionEvent e) {
76
                configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
77
            }
78
        });
79

  
80
        Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
81
        checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
82
        checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
83
        checkBoxIgnoreAuthorship
84
        .setToolTipText("Name matching with existing names will be done without "
85
                + "the authorship part of the name");
86
        checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
87
            @Override
88
            public void widgetSelected(SelectionEvent e) {
89
                configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
90
            }
91
        });
92

  
93
        Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
94
        checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
95
        checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
96
        checkBoxMapUnitIdToCatalogNumber
97
        .setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
98
                + "of the specimen");
99
        checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
100
            @Override
101
            public void widgetSelected(SelectionEvent e) {
102
                configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
103
            }
104
        });
105
//TODO: only one of the mappings can be checked!
106
        Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
107
        checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
108
        checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
109
        checkBoxMapUnitIdToAccessionNumber
110
        .setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
111
                + "of the specimen");
112
        checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
113
            @Override
114
            public void widgetSelected(SelectionEvent e) {
115
                configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber());
116
            }
117
        });
118

  
119
        Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
120
        checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode());
121
        checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
122
        checkBoxMapUnitIdToBarcode
123
        .setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
124
                + "of the specimen");
125
        checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
126
            @Override
127
            public void widgetSelected(SelectionEvent e) {
128
                configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
129
            }
130
        });
131

  
132
        Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
133
        checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
134
        checkBoxRemoveCountry.setText("Remove country from locality text");
135
        checkBoxRemoveCountry
136
        .setToolTipText("If the locality text contains information about the "
137
                + "country which is additionally stored in other ABCD "
138
                + "elements then it is removed from the locality text");
139
        checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
140
            @Override
141
            public void widgetSelected(SelectionEvent e) {
142
                configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
143
            }
144
        });
145

  
146
        Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
147
        checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
148
        checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
149
        checkBoxMoveToDefaultClassification
150
        .setToolTipText("For taxa that do not exist in the data base "
151
                + "a new classification will be created");
152
        checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
153
            @Override
154
            public void widgetSelected(SelectionEvent e) {
155
                configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
156
            }
157
        });
158

  
159
        Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
160
        checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
161
        checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
162
        checkBoxImportSiblings
163
            .setToolTipText("For a tissue sample or culture all children will be searched and imported");
164
        checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
165
            @Override
166
            public void widgetSelected(SelectionEvent e) {
167
                configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
168
            }
169
        });
170

  
171
        Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
172
        checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
173
        checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
174
        checkBoxAddIndividualsAssociations
175
            .setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
176
        checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
177
            @Override
178
            public void widgetSelected(SelectionEvent e) {
179
                configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
180
            }
181
        });
182

  
183
        Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
184
        checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
185
        checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
186
        checkBoxReuseDescriptiveGroups
187
            .setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
188
        checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
189
            @Override
190
            public void widgetSelected(SelectionEvent e) {
191
                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
192
            }
193
        });
194

  
195
        Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
196
        checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
197
        checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
198
        checkBoxReuseExistingTaxa
199
            .setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
200
        checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
201
            @Override
202
            public void widgetSelected(SelectionEvent e) {
203
                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
204
            }
205
        });
206

  
207
        GridData gridData = new GridData();
208
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
209
        gridData.horizontalIndent = 5;
210
//      classificationSelection.setLayoutData(gridData);
211

  
212
        nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
213
        nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
214
        for(NomenclaturalCode code: NomenclaturalCode.values()){
215
            nomenclaturalCodeSelectionCombo.add(code.getKey());
216
        }
217

  
218

  
219

  
220
        // TODO remember last selection
221
        nomenclaturalCodeSelectionCombo.addSelectionListener(this);
222
        return composite;
223
    }
224

  
225
    @Override
226
    public void widgetSelected(SelectionEvent e) {
227
        this.configurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
228

  
229
    }
230

  
231
    @Override
232
    public boolean performOk() {
233
        if (configurator != null){
234
            String configString = configurator.toString();
235

  
236
            CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
237
            pref.setAllowOverride(true);
238

  
239
            ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
240
            if (controller == null){
241
                return false;
242
            }
243
            IPreferenceService service = controller.getPreferenceService();
244
            service.set(pref);
245
        }
246
        return true;
247
    }
248

  
249
    /**
250
     * {@inheritDoc}
251
     */
252
    @Override
253
    public void widgetDefaultSelected(SelectionEvent e) {
254
        // TODO Auto-generated method stub
255

  
256
    }
257

  
258
    public void createAbcdImportConfig() {
259
        this.configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
260
        this.configurator.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
261
        this.configurator.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
262
        //this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
263
        this.configurator.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
264
        this.configurator.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
265
       // this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
266
        this.configurator.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
267
        this.configurator.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
268
        this.configurator.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
269
        this.configurator.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
270
        this.configurator.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
271
        this.configurator.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
272
        this.configurator.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
273
        this.configurator.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
274
        this.configurator.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
275

  
276
    }
277

  
278
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java
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.databaseAdmin.preferencePage;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19

  
20
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
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 CdmPreferencePage implements IE4AdminPreferencePage {
32

  
33
    boolean isEditorActivated;
34
    boolean isShowRank;
35
    boolean isSortByVocabularyOrder;
36
    boolean isShowSymbol;
37
    boolean isShowIdInVocabulary;
38
    Composite child ;
39

  
40
    @Override
41
    protected Control createContents(Composite parent) {
42

  
43
        Composite composite = new Composite(parent, SWT.NULL);
44
        composite.setLayout(new GridLayout());
45
        isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
46
        final Button activateCheckButton = new Button(composite, SWT.CHECK);
47
        activateCheckButton.setText("Enable Distribution Editor");
48
        activateCheckButton.setSelection(isEditorActivated);
49
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
50
            @Override
51
            public void widgetSelected(SelectionEvent e) {
52
                isEditorActivated = activateCheckButton.getSelection();
53

  
54
                if(isEditorActivated){
55
                    child.setVisible(true);
56
                    child.setEnabled(true);
57
                }else{
58
                    child.setVisible(false);
59
                    child.setEnabled(false);
60
                }
61

  
62
            }
63
        });
64

  
65
        child  = new Composite(composite, SWT.NULL);
66
        child.setLayout(new GridLayout());
67
        child.setVisible(isEditorActivated);
68
        final CLabel label = new CLabel(child, SWT.NULL);
69
        label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Distribution Editor");
70
        final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
71
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
72

  
73
        button_openFeatureTree.setText("Open Distribution Selection Wizard");
74
        final Button showIdInVocabulary = new Button(child, SWT.CHECK);
75
        isShowIdInVocabulary = PreferencesUtil.isShowIdInVocabularyInChecklistEditor();
76
        showIdInVocabulary.setText("Show Id in Vocabulary instead of full title of the areas");
77
        showIdInVocabulary.setSelection(isShowIdInVocabulary);
78
        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
79
            @Override
80
            public void widgetSelected(SelectionEvent e) {
81
                isShowIdInVocabulary = showIdInVocabulary.getSelection();
82

  
83
             }
84
        });
85

  
86
        final Button showSymbol = new Button(child, SWT.CHECK);
87
        isShowSymbol = PreferencesUtil.isShowSymbolInChecklistEditor();
88
        showSymbol.setText("Show Symbol of the Status, if existing");
89
        showSymbol.setSelection(isShowSymbol);
90
        showSymbol.addSelectionListener(new SelectionAdapter(){
91
            @Override
92
            public void widgetSelected(SelectionEvent e) {
93
                isShowSymbol = showSymbol.getSelection();
94
             }
95
        });
96
        PreferencesUtil.recursiveSetEnabled(button_openFeatureTree, CdmStore.isActive());
97
        isShowRank = PreferencesUtil.isShowRankInChecklistEditor();
98
        final Button activateRankButton = new Button(child, SWT.CHECK);
99
        activateRankButton.setText("Show Rank in Distribution Editor");
100
        activateRankButton.setSelection(isShowRank);
101
        activateRankButton.addSelectionListener(new SelectionAdapter(){
102
            @Override
103
            public void widgetSelected(SelectionEvent e) {
104
                isShowRank = activateRankButton.getSelection();
105
            }
106
        });
107
        final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
108
        isSortByVocabularyOrder = PreferencesUtil.isSortNamedAreaByOrderInVocabulary();
109
        sortNamedAreaByVocabularyOrder.setText("Sort Areas by Order in Vocabulary");
110
        sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
111
        sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
112
            @Override
113
            public void widgetSelected(SelectionEvent e) {
114
                isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
115
             }
116
        });
117

  
118
        if(isEditorActivated){
119
            child.setEnabled(true);
120
        }else{
121
            child.setEnabled(false);
122
        }
123

  
124
        return composite;
125
    }
126

  
127
    @Override
128
    public boolean performOk() {
129
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
130
        PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
131
        PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
132
        PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
133
        PreferencesUtil.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary);
134
        return true;
135
    }
136

  
137
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/IE4AdminPreferencePage.java
1
/**
2
* Copyright (C) 2018 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.preferencePage;
10

  
11
/**
12
 * @author k.luther
13
 * @since 22.03.2018
14
 *
15
 */
16
public interface IE4AdminPreferencePage {
17

  
18
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NameDetailsViewConfiguration.java
1
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
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.GridData;
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

  
14
import eu.etaxonomy.cdm.api.application.ICdmRepository;
15
import eu.etaxonomy.cdm.api.service.IPreferenceService;
16
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
17
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
18
import eu.etaxonomy.taxeditor.l10n.Messages;
19
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
20
import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

  
25

  
26
public class NameDetailsViewConfiguration extends CdmPreferencePage implements IE4AdminPreferencePage{
27

  
28
    boolean isSimpleDetailsViewActivated;
29

  
30
    Composite dbSettings ;
31
    boolean isAllowOverride;
32
    boolean isShowTaxon;
33
    boolean isShowLSID;
34
    boolean isShowNomenclaturalCode;
35
    boolean isShowNameCache;
36
    boolean isShowAppendedPhrase;
37
    boolean isShowRank;
38
    boolean isShowEpithets;
39
    boolean isShowAuthorCache;
40
    boolean isShowAuthorship;
41
    boolean isShowNomenclaturalRef;
42
    boolean isShowNomenclaturalStatus;
43
    boolean isShowProtologue;
44
    boolean isShowTypeDesignation;
45
    boolean isShowNameRelationship;
46
    boolean isShowHybrid;
47
    boolean isShowNameApprobiation;
48

  
49

  
50
    @Override
51
    protected Control createContents(Composite parent) {
52

  
53
        CdmPreference nameDetailsPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NameDetailsView);
54
        isAllowOverride = false;
55
        if (nameDetailsPref != null){
56
            //TODO: create checkbox
57

  
58
            isAllowOverride = nameDetailsPref.isAllowOverride();
59
        }
60

  
61

  
62

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

  
65
        final Button activateCheckButton = new Button(parent, SWT.CHECK);
66
        activateCheckButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
67
        activateCheckButton.setText(Messages.NameDetailsViewConfiguration_activateSimpleDetailsView);
68
        activateCheckButton.setSelection(isSimpleDetailsViewActivated);
69
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
70
        @Override
71
        public void widgetSelected(SelectionEvent e) {
72
            isSimpleDetailsViewActivated = activateCheckButton.getSelection();
73
           //
74
            if(isSimpleDetailsViewActivated){
75
                dbSettings.setVisible(true);
76
                dbSettings.setEnabled(true);
77
            }else{
78
                dbSettings.setVisible(false);
79
                dbSettings.setEnabled(false);
80
            }
81
         }
82
         });
83

  
84

  
85

  
86
        dbSettings  = new Composite(parent, SWT.NONE);
87
        dbSettings.setLayout(new GridLayout());
88
        dbSettings.setVisible(isSimpleDetailsViewActivated);
89
//       Table table = new Table(dbSettings,SWT.BORDER | SWT.CHECK);
90
//       TableColumn tableColumnValue = new TableColumn(table, SWT.CENTER);
91
//
92
//       TableColumn tableColumnAllowOverride = new TableColumn(table, SWT.CENTER);
93

  
94

  
95

  
96
        final Button allowLocalPreference = new Button(dbSettings, SWT.CHECK);
97
//      boolean isUseLocalPreference = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
98
      allowLocalPreference.setText(Messages.DatabasePreferencesPage_UseLocalPreferences);
99
      allowLocalPreference.setSelection(isAllowOverride);
100
      allowLocalPreference.addSelectionListener(new SelectionAdapter(){
101
           @Override
102
           public void widgetSelected(SelectionEvent e) {
103
               isAllowOverride = allowLocalPreference.getSelection();
104

  
105
            }
106
       });
107
        Label separator= new Label(dbSettings, SWT.HORIZONTAL | SWT.SEPARATOR);
108
        separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
109
        final Button showTaxon = new Button(dbSettings, SWT.CHECK);
110
        isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
111
        showTaxon.setText(Messages.NameDetailsViewComposite_Show_Taxon);
112
        showTaxon.setSelection(isShowTaxon);
113
        showTaxon.addSelectionListener(new SelectionAdapter(){
114
             @Override
115
             public void widgetSelected(SelectionEvent e) {
116
                 isShowTaxon = showTaxon.getSelection();
117

  
118
              }
119
         });
120

  
121
        final Button showLsid = new Button(dbSettings, SWT.CHECK);
122
        isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
123
        showLsid.setText(Messages.NameDetailsViewComposite_Show_LSID);
124
        showLsid.setSelection(isShowLSID);
125
        showLsid.addSelectionListener(new SelectionAdapter(){
126
             @Override
127
             public void widgetSelected(SelectionEvent e) {
128
                 isShowLSID = showLsid.getSelection();
129

  
130
              }
131
         });
132

  
133
        final Button showNomenclaturalCode = new Button(dbSettings, SWT.CHECK);
134
        isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
135
        showNomenclaturalCode.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalCode);
136
        showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
137
        showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
138
             @Override
139
             public void widgetSelected(SelectionEvent e) {
140
                 isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
141

  
142
              }
143
         });
144

  
145
        final Button showNameCache = new Button(dbSettings, SWT.CHECK);
146
        isShowNameCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
147
        showNameCache.setText(Messages.NameDetailsViewComposite_Show_NameCache);
148
        showNameCache.setSelection(isShowNameCache);
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(dbSettings, SWT.CHECK);
157
        isShowAppendedPhrase= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
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(dbSettings, SWT.CHECK);
169
        isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
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
         });
179
        final Button showEpithets = new Button(dbSettings, SWT.CHECK);
180
        isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
181
        showEpithets.setText(Messages.NameDetailsViewComposite_Show_AtomisedEpithets);
182
        showEpithets.setSelection(isShowEpithets);
183
        showEpithets.addSelectionListener(new SelectionAdapter(){
184
             @Override
185
             public void widgetSelected(SelectionEvent e) {
186
                 isShowEpithets = showEpithets.getSelection();
187

  
188
              }
189
         });
190

  
191
        final Button showAuthorCache = new Button(dbSettings, SWT.CHECK);
192
        isShowAuthorCache = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
193
        showAuthorCache.setText(Messages.NameDetailsViewComposite_Show_AuthorCache);
194
        showAuthorCache.setSelection(isShowAuthorCache);
195
        showAuthorCache.addSelectionListener(new SelectionAdapter(){
196
             @Override
197
             public void widgetSelected(SelectionEvent e) {
198
                 isShowAuthorCache = showAuthorCache.getSelection();
199

  
200
              }
201
         });
202

  
203
        final Button showAuthorship = new Button(dbSettings, SWT.CHECK);
204
        isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
205
        showAuthorship.setText(Messages.NameDetailsViewComposite_Show_Author);
206
        showAuthorship.setSelection(isShowAuthorship);
207
        showAuthorship.addSelectionListener(new SelectionAdapter(){
208
             @Override
209
             public void widgetSelected(SelectionEvent e) {
210
                 isShowAuthorship = showAuthorship.getSelection();
211

  
212
              }
213
         });
214

  
215
        final Button showNomenclaturalRef = new Button(dbSettings, SWT.CHECK);
216
        isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
217
        showNomenclaturalRef.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalReference);
218
        showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
219
        showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
220
             @Override
221
             public void widgetSelected(SelectionEvent e) {
222
                 isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
223

  
224
              }
225
         });
226

  
227
        final Button showNomenclaturalStatus = new Button(dbSettings, SWT.CHECK);
228
        isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
229
        showNomenclaturalStatus.setText(Messages.NameDetailsViewComposite_Show_NomenclaturalStatus);
230
        showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
231
        showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
232
             @Override
233
             public void widgetSelected(SelectionEvent e) {
234
                 isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
235

  
236
              }
237
         });
238

  
239
        final Button showProtologue = new Button(dbSettings, SWT.CHECK);
240
        isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
241
        showProtologue.setText(Messages.NameDetailsViewComposite_Show_Protologue);
242
        showProtologue.setSelection(isShowProtologue);
243
        showProtologue.addSelectionListener(new SelectionAdapter(){
244
             @Override
245
             public void widgetSelected(SelectionEvent e) {
246
                 isShowProtologue = showProtologue.getSelection();
247

  
248
              }
249
         });
250

  
251
        final Button showTypeDesignation = new Button(dbSettings, SWT.CHECK);
252
        isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
253
        showTypeDesignation.setText(Messages.NameDetailsViewComposite_Show_TypeDesignation);
254
        showTypeDesignation.setSelection(isShowTypeDesignation);
255
        showTypeDesignation.addSelectionListener(new SelectionAdapter(){
256
             @Override
257
             public void widgetSelected(SelectionEvent e) {
258
                 isShowTypeDesignation = showTypeDesignation.getSelection();
259

  
260
              }
261
         });
262

  
263

  
264
        final Button showNameRelationship = new Button(dbSettings, SWT.CHECK);
265
        isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
266
        showNameRelationship.setText(Messages.NameDetailsViewComposite_Show_Namerelationships);
267
        showNameRelationship.setSelection(isShowNameRelationship);
268
        showNameRelationship.addSelectionListener(new SelectionAdapter(){
269
             @Override
270
             public void widgetSelected(SelectionEvent e) {
271
                 isShowNameRelationship = showNameRelationship.getSelection();
272

  
273
              }
274
         });
275

  
276
        final Button showHybrid = new Button(dbSettings, SWT.CHECK);
277
        isShowHybrid = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID);
278
        showHybrid.setText(Messages.NameDetailsViewComposite_Show_Hybrid);
279
        showHybrid.setSelection(isShowHybrid);
280
        showHybrid.addSelectionListener(new SelectionAdapter(){
281
             @Override
282
             public void widgetSelected(SelectionEvent e) {
283
                 isShowHybrid = showHybrid.getSelection();
284

  
285
              }
286
         });
287
        final Button showNameApprobiation = new Button(dbSettings, SWT.CHECK);
288
        isShowNameApprobiation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION);
289
        showNameApprobiation.setText(Messages.NameDetailsViewComposite_Show_NameApprobiation);
290
        showNameApprobiation.setSelection(isShowNameApprobiation);
291
        showNameApprobiation.addSelectionListener(new SelectionAdapter(){
292
             @Override
293
             public void widgetSelected(SelectionEvent e) {
294
                 isShowNameApprobiation = showNameApprobiation.getSelection();
295
                 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION, isShowNameApprobiation);
296
              }
297
         });
298

  
299

  
300

  
301

  
302
        return dbSettings;
303
	}
304

  
305
    /**
306
    *
307
    */
308
   protected NameDetailsConfigurator createNameDetailsViewConfig() {
309
       NameDetailsConfigurator config = new NameDetailsConfigurator(isSimpleDetailsViewActivated);
310

  
311
      config.setAppendedPhraseActivated(isShowAppendedPhrase);
312
      config.setAtomisedEpithetsActivated(isShowEpithets);
313
      config.setAuthorshipSectionActivated(isShowAuthorship);
314
      config.setAuthorCacheActivated(isShowAuthorCache);
315
      config.setLSIDActivated(isShowLSID);
316
      config.setNameApprobiationActivated(isShowNameApprobiation);
317
      config.setNameCacheActivated(isShowNameCache);
318
      config.setNameRelationsSectionActivated(isShowNameRelationship);
319
      config.setNomenclaturalCodeActived(isShowNomenclaturalCode);
320
      config.setNomenclaturalStatusSectionActivated(isShowNomenclaturalStatus);
321
      config.setNomenclaturalReferenceSectionActivated(isShowNomenclaturalRef);
322
      config.setProtologueActivated(isShowProtologue);
323
      config.setRankActivated(isShowRank);
324
      config.setTaxonSectionActivated(isShowTaxon);
325
      config.setTypeDesignationSectionActivated(isShowTypeDesignation);
326
      config.setHybridActivated(isShowHybrid);
327

  
328

  
329
      return config;
330
   }
331

  
332

  
333
    @Override
334
    public boolean performOk() {
335
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
336
        if (controller == null){
337
            return false;
338
        }
339
        IPreferenceService service = controller.getPreferenceService();
340
        NameDetailsConfigurator config = createNameDetailsViewConfig();
341
        String value = config.toString();
342
//        boolean allowOverride = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS);
343

  
344
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NameDetailsView, value);
345
        pref.setAllowOverride(isAllowOverride);
346
        service.set(pref);
347
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
348
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
349
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, isShowNomenclaturalCode);
350
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE, isShowNameCache);
351
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE, isShowAppendedPhrase);
352
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
353
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, isShowEpithets);
354
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, isShowAuthorship);
355
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, isShowAuthorCache);
356
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, isShowNomenclaturalRef);
357
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, isShowNomenclaturalStatus);
358
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, isShowProtologue);
359
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, isShowTypeDesignation);
360
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, isShowNameRelationship);
361
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID, isShowHybrid);
362
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ALLOW_OVERRIDE_NAME_DETAILS, isAllowOverride);
363
        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION, isSimpleDetailsViewActivated);
364
        return true;
365
    }
366

  
367
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/NomenclaturalCodePreferences.java
1
/**
2
 * Copyright (C) 2007 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.preferencePage;
10

  
11
import java.util.HashMap;
12
import java.util.List;
13
import java.util.Map;
14
import java.util.Map.Entry;
15

  
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Combo;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23

  
24
import eu.etaxonomy.cdm.api.application.ICdmRepository;
25
import eu.etaxonomy.cdm.api.service.IPreferenceService;
26
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
27
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
28
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
29
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
30
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
31
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
32
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
33
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
34
import eu.etaxonomy.taxeditor.store.CdmStore;
35

  
36
/**
37
 * <p>
38
 * NomenclaturalCodePreferences class.
39
 * </p>
40
 *
41
 * @author k.luther
42
 * @created 14.09.2018
43
 */
44
public class NomenclaturalCodePreferences extends CdmPreferencePage implements IE4AdminPreferencePage{
45

  
46
    String actualCode;
47
    Map<String, String>  labelAndValues;
48
    Map<String, Integer> keyAndIndex;
49
    Combo nomenclaturalCode;
50

  
51

  
52
	@Override
53
	protected Control createContents(Composite parent) {
54
//	    PreferencesUtil.setPreferredNomenclaturalCode(null, false);
55

  
56
	    Composite composite = new Composite(parent, SWT.NULL);
57
        composite.setLayout(new GridLayout());
58

  
59
        nomenclaturalCode= new Combo(composite, SWT.READ_ONLY);
60
        nomenclaturalCode.setText("Available Codes");
61

  
62

  
63

  
64
        nomenclaturalCode.setFont(parent.getFont());
65
        getLabelAndValues();
66
        keyAndIndex = new HashMap<>();
67
        Integer index = 0;
68
        for (String key: labelAndValues.keySet()) {
69
            nomenclaturalCode.add(labelAndValues.get(key));
70
            keyAndIndex.put(key, index);
71
            index++;
72
        }
73
        index = keyAndIndex.get(actualCode);
74
        nomenclaturalCode.select(index);
75

  
76
        nomenclaturalCode.addSelectionListener(new SelectionAdapter() {
77
            @Override
78
            public void widgetSelected(SelectionEvent evt) {
79
                String name = nomenclaturalCode.getText();
80
                for (Entry<String, String> label:labelAndValues.entrySet()){
81
                    if (label.getValue().equals(name)){
82
                        actualCode = label.getKey();
83
                    }
84
                }
85
//                actualCode = labelAndValues.get(name);;
86

  
87

  
88
            }
89
        });
90

  
91
        return composite;
92

  
93
	}
94

  
95
	/**
96
	 * @return
97
	 */
98
	private Map<String, String> getLabelAndValues() {
99
		List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
100
				.getSupportedCodes();
101
		labelAndValues = new HashMap<>();
102
		for (int i = 0; i < supportedCodes.size(); i++) {
103
			labelAndValues.put(PreferencesUtil.getPreferenceKey(supportedCodes.get(i)), NomenclaturalCodeHelper
104
                    .getDescription(supportedCodes.get(i))) ;
105

  
106
		}
107
		return labelAndValues;
108
	}
109

  
110
	/**
111
	 * {@inheritDoc}
112
	 *
113
	 * Initialize the preference page
114
	 */
115
    @Override
116
    public void init() {
117
        super.init();
118
        if(!CdmStore.isActive()){
119
            return;
120
        }
121
	      ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
122
          if (controller != null){
123
              IPreferenceService service = controller.getPreferenceService();
124
              PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
125
              CdmPreference pref = service.find(key);
126
              if (pref != null){
127
                  actualCode = pref.getValue();
128

  
129
              }
130
          }
131

  
132

  
133
	}
134

  
135
	@Override
136
	 public boolean performOk() {
137

  
138
		boolean result = super.performOk();
139
		if (labelAndValues != null){
140
		    String key = labelAndValues.get(actualCode);
141
    		NomenclaturalCode preferredCode = NomenclaturalCode.getByKey(actualCode);
142
    		PreferencesUtil.setPreferredNomenclaturalCode(actualCode, false);
143
		}
144
        return result;
145
    }
146

  
147
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/InitNomenclaturalCodePrefDialog.java
129 129
    public boolean close() {
130 130

  
131 131
		// Save preferred nomenclatural code before closing
132
		PreferencesUtil.setPreferredNomenclaturalCode(preferredCode, true);
132
		PreferencesUtil.setPreferredNomenclaturalCode(PreferencesUtil.getPreferenceKey(preferredCode), true);
133 133

  
134 134
		return super.close();
135 135
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
110 110
	 *            object.
111 111
	 */
112 112
	public static CdmPreference setPreferredNomenclaturalCode(
113
			NomenclaturalCode preferredCode, boolean local) {
113
			String preferenceKey, boolean local) {
114 114
	    if (local){
115 115
	        getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
116
                    getPreferenceKey(preferredCode));
116
	                preferenceKey);
117 117
	    }
118 118
	    else{
119 119
    		ICdmRepository controller;
......
128 128
    		if (controller == null){
129 129
    			return null;
130 130
    		}
131
    		if (preferredCode == null){
131
    		if (preferenceKey == null){
132 132
    			preference = controller.getPreferenceService().find(key);
133 133
    			if (preference == null){
134 134
    				return null;
135 135
    			} else{
136
    				int index = StringUtils.lastIndexOf(preference.getValue(), ".");
137
    				UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
138
    				preferredCode = NomenclaturalCode.getByUuid(uuid);
136
//    				int index = StringUtils.lastIndexOf(preference.getValue(), ".");
137
//    				UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
138
//    				preferredCode = NomenclaturalCode.getByUuid(uuid);
139 139

  
140 140
    				getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
141
    	                    getPreferenceKey(preferredCode));
141
    				        preferenceKey);
142 142
    				getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
143 143
    				return preference;
144 144
    			}
145 145
    		} else{
146
    			preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferredCode.getKey());
146
    			preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceKey);
147 147
    			controller.getPreferenceService().set(preference);
148 148

  
149 149
    		}
......
477 477
				"name", "name.$", "relationsFromThisTaxon.$"));
478 478

  
479 479
		configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
480
				"name", "name.$", "synonymRelations.relatedTo.*"));
480
				"name", "name.$", "synonyms.relatedTo.*"));
481 481

  
482 482
		// DEFAULT VALUES
483 483
		// match mode is a simple like, actually all other match modes are kind
......
572 572

  
573 573

  
574 574
		if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
575
			PreferencesUtil.setPreferredNomenclaturalCode(NomenclaturalCode.ICNAFP, true);
575
			PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
576 576
		}
577 577

  
578 578

  
......
1223 1223
                     config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
1224 1224
                 }else if (keyString.equals("overwriteExistingSpecimens")){
1225 1225
                     config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
1226
                 }else if (keyString.equals(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)){
1227
                         config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
1226 1228
                 }else{
1227 1229
                     logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
1228 1230
                 }
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java
19 19
import eu.etaxonomy.cdm.api.service.ITaxonService;
20 20
import eu.etaxonomy.cdm.model.common.CdmBase;
21 21
import eu.etaxonomy.cdm.model.name.TaxonName;
22
import eu.etaxonomy.cdm.model.taxon.Synonym;
23 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
24 23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
25 24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
......
43 42
        // load taxon Crepis from cichorieae
44 43
        UUID taxonBaseUuid = UUID.fromString("d0ae2121-1c32-4737-8c49-f871d429fd90");
45 44
        List<String> taxonBasePropertyPaths = Arrays.asList(new String[] {
46
                "synonymRelations.synonym.name.status.type",
47
                "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.relatedFrom.name.status"
45
                "synonym.synonym.name.status.type",
46
                "name.homotypicalGroup.typifiedNames.taxonBases.synonyms.relatedFrom.name.status"
48 47
        });
49 48
        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths);
50 49
        Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
111 111
    <elements xsi:type="commands:Handler" xmi:id="_WLNcQSQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.OpenExternalAboutPlatformHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenExternalAboutPlatformHandler" command="_UZ2zYCQsEeeq76l4saMAFQ"/>
112 112
    <elements xsi:type="commands:Handler" xmi:id="_WLNcQiQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.OpenExternalParserHelpHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenExternalParserHelpHandler" command="_UZ_WQCQsEeeq76l4saMAFQ"/>
113 113
    <elements xsi:type="commands:Handler" xmi:id="_WLNcQyQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler" command="_Va29YCQsEeeq76l4saMAFQ"/>
114
    <elements xsi:type="commands:Handler" xmi:id="_WLNcRCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler" command="_VawPsCQsEeeq76l4saMAFQ"/>
114
    <elements xsi:type="commands:Handler" xmi:id="_WLNcRCQsEeeq76l4saMAFQ" elementId="eu.etaxonomy.taxeditor.handler.OpenAdminPreferencesHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.handler.OpenAdminPreferencesHandler" command="_VawPsCQsEeeq76l4saMAFQ"/>
115 115
    <elements xsi:type="commands:Handler" xmi:id="_S6Rf4CRAEeeKsvEah5BAoQ" elementId="eu.etaxonomy.taxeditor.update.InstallNewSoftwareHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.update.InstallNewSoftwareHandler" command="_koenACRAEeeKsvEah5BAoQ"/>
116 116
    <elements xsi:type="commands:Handler" xmi:id="_nSIiECUKEeeHw5lTgGMs1Q" elementId="eu.etaxonomy.taxeditor.handler.OpenImportPreferenceHandler" command="_fdEqUCUKEeeHw5lTgGMs1Q"/>
117 117
    <elements xsi:type="commands:Handler" xmi:id="_2fnUYCZ0EeeQLpuomSmVoQ" elementId="eu.etaxonomy.taxeditor.workbench.OpenPartHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.OpenPartHandler" command="_hMjgECZsEeer_rabtodzWA"/>
eu.etaxonomy.taxeditor.workbench/plugin.xml
3 3
<plugin>
4 4
   <extension-point id="e4PreferencePages" name="e4PreferencePages" schema="schema/e4PreferencePages.exsd"/>
5 5
   <extension-point id="e4PreferenceStoreProvider" name="e4PreferenceStoreProvider" schema="schema/e4PreferenceStoreProvider.exsd"/>
6
   <extension-point id="adminPreferencePage" name="adminPreferencePage" schema="schema/adminPreferencePage.exsd"/>
6 7
   <extension
7 8
         id="eu.etaxonomy.taxeditor.workbench.workbench.model"
8 9
         name="Taxonomic Editor Application Model"
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/handler/OpenAdminPreferencesHandler.java
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.workbench.handler;
11
import java.util.ArrayList;
12
import java.util.Collections;
13
import java.util.Comparator;
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.List;
17
import java.util.Map;
18

  
19
import javax.inject.Named;
20

  
21
import org.apache.log4j.Logger;
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.IConfigurationElement;
24
import org.eclipse.core.runtime.IExtensionRegistry;
25
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.e4.core.di.annotations.CanExecute;
27
import org.eclipse.e4.core.di.annotations.Execute;
28
import org.eclipse.e4.ui.services.IServiceConstants;
29
import org.eclipse.jface.preference.IPreferencePage;
30
import org.eclipse.jface.preference.PreferenceDialog;
31
import org.eclipse.jface.preference.PreferenceManager;
32
import org.eclipse.jface.preference.PreferenceNode;
33
import org.eclipse.swt.widgets.Shell;
34

  
35

  
36
/**
37
 * Scans all extension for extension point <code>eu.etaxonomy.taxeditor.store.preferencePage</code> and
38
 * creates the tree of preference nodes according to the <code>category</code> attribute of the
39
 * extension point.<br>
40
 * <b>Note:</b> If, for a given category, no parent node can be found then this page will not be
41
 * added to the preferences
42
 * @author pplitzner/k.luther
43
 * @date 14.03.2018
44
 *
45
 */
46
public class OpenAdminPreferencesHandler {
47

  
48
    private static final String ATT_NAME = "name"; //$NON-NLS-1$
49
    private static final String ATT_ID = "id"; //$NON-NLS-1$
50
    private static final String ATT_CATEGORY = "category"; //$NON-NLS-1$
51
    private static final String ATT_CLASS = "class"; //$NON-NLS-1$
52
    private static final String EXTENSION_ELEMENT_PAGE = "page"; //$NON-NLS-1$
53
    private static final String EXTENSION_POINT_ID = "eu.etaxonomy.taxeditor.store.adminPreferencePage"; //$NON-NLS-1$
54
    private Logger logger = Logger.getLogger(OpenAdminPreferencesHandler.class);
55

  
56
    @Execute
57
    public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
58
        List<PageWrapper> pagesYetToBeAdded = new ArrayList<>();
59
        List<PageWrapper> rootPages = new ArrayList<>();
60
        Map<String, PreferenceNode> idToNodeMap = new HashMap<>();
61

  
62
        PreferenceManager manager = new PreferenceManager('/');
63

  
64
        IExtensionRegistry reg = Platform.getExtensionRegistry();
65
        IConfigurationElement[] extensions = reg
66
                .getConfigurationElementsFor(EXTENSION_POINT_ID); //$NON-NLS-1$
67
        for (IConfigurationElement configElement : extensions) {
68
            if(configElement.getName().equals(EXTENSION_ELEMENT_PAGE)){ //$NON-NLS-1$
69
                Object o;
70
                try {
71
                    o = configElement.createExecutableExtension(ATT_CLASS);
72
                    if(o instanceof IPreferencePage){
73
                        IPreferencePage page = (IPreferencePage) o;
74
                        String category = configElement.getAttribute(ATT_CATEGORY);
75
                        String id = configElement.getAttribute(ATT_ID);
76
                        String name = configElement.getAttribute(ATT_NAME);
77

  
78
                        page.setTitle(name);
79
                        //add all root nodes
80
                        if(category==null){
81
                            rootPages.add(new PageWrapper(page, category, id, name));
82
                        }
83
                        //child nodes will be handled later
84
                        else{
85
                            pagesYetToBeAdded.add(new PageWrapper(page, category, id, name));
86
                        }
87
                    }
88
                } catch (CoreException e) {
89
                    logger.error(String.format("Failed to initialize preference page for config element: %s", configElement), e); //$NON-NLS-1$
90
                }
91
            }
92
        }
93

  
94
        //sort root nodes
95
        Collections.sort(rootPages, new PreferenceNodeComparator());
96
        //add root nodes
97
        rootPages.forEach(pageWrapper->{
98
            PreferenceNode node = new PreferenceNode(pageWrapper.id, pageWrapper.page);
99
            manager.addToRoot(node);
100
            idToNodeMap.put(pageWrapper.id, node);
101
        });
102

  
103
        //sort child nodes
104
        Collections.sort(pagesYetToBeAdded, new PreferenceNodeComparator());
105
        //add child nodes
106
        int size = pagesYetToBeAdded.size();
107
        while(!pagesYetToBeAdded.isEmpty()){
108

  
109
            Iterator<PageWrapper> iterator = pagesYetToBeAdded.iterator();
110
            while(iterator.hasNext()){
111
                PageWrapper pageWrapper = iterator.next();
112
                if(addPage(pageWrapper, idToNodeMap)){
113
                    iterator.remove();
114
                }
115
            }
116
            if(size==pagesYetToBeAdded.size()){
117
                //avoid potential endless loop
118
                break;
119
            }
120
            size = pagesYetToBeAdded.size();
121
        }
122
        PreferenceDialog dialog = new PreferenceDialog(shell, manager);
123
        dialog.create();
124
        dialog.getTreeViewer().expandAll();
125
        dialog.open();
126
    }
127

  
128
    @CanExecute
129
    public boolean canExecute()
130
    {
131
        return true;
132
    }
133

  
134

  
135
    private boolean addPage(PageWrapper pageWrapper, Map<String, PreferenceNode> idToNodeMap){
136
        PreferenceNode node = new PreferenceNode(pageWrapper.id, pageWrapper.page);
137
        PreferenceNode parent = idToNodeMap.get(pageWrapper.category);
138
        if(parent!=null){
139
            idToNodeMap.put(pageWrapper.id, node);
140
            parent.add(node);
141
            return true;
142
        }
143
        return false;
144
    }
145

  
146
    private class PreferenceNodeComparator implements Comparator<PageWrapper>{
147
        @Override
148
        public int compare(PageWrapper o1, PageWrapper o2) {
149
            return o1.name.compareTo(o2.name);
150
        }
151
    }
152

  
153
    private class PageWrapper{
154
        IPreferencePage page;
155
        String category;
156
        String id;
157
        String name;
158
        public PageWrapper(IPreferencePage page, String category, String id, String name) {
159
            super();
160
            this.page = page;
161
            this.category = category;
162
            this.id = id;
163
            this.name = name;
164
        }
165
    }
166
}
167

  
168

  

Also available in: Unified diff