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.custom.CLabel;
|
13
|
import org.eclipse.swt.events.SelectionAdapter;
|
14
|
import org.eclipse.swt.events.SelectionEvent;
|
15
|
import org.eclipse.swt.events.SelectionListener;
|
16
|
import org.eclipse.swt.layout.GridData;
|
17
|
import org.eclipse.swt.layout.GridLayout;
|
18
|
import org.eclipse.swt.widgets.Button;
|
19
|
import org.eclipse.swt.widgets.Combo;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Control;
|
22
|
|
23
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
24
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
25
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
26
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
27
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
28
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
29
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
30
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
31
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
32
|
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
33
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
34
|
|
35
|
/**
|
36
|
* @author k.luther
|
37
|
* @since 23.03.2018
|
38
|
*
|
39
|
*/
|
40
|
public class AbcdImportPreference extends CdmPreferencePage implements IE4AdminPreferencePage, SelectionListener {
|
41
|
|
42
|
private Abcd206ImportConfigurator configurator;
|
43
|
|
44
|
private Combo nomenclaturalCodeSelectionCombo;
|
45
|
|
46
|
/**
|
47
|
* {@inheritDoc}
|
48
|
*/
|
49
|
@Override
|
50
|
protected Control createContents(Composite parent) {
|
51
|
final Composite composite = new Composite(parent, SWT.NULL);
|
52
|
|
53
|
GridLayout gridLayout = new GridLayout();
|
54
|
composite.setLayout(gridLayout);
|
55
|
|
56
|
configurator = PreferencesUtil.getAbcdImportConfigurationPreference(false);
|
57
|
final CLabel description = new CLabel(composite, SWT.NULL);
|
58
|
description.setText(Messages.AbcdImportPreference_description);
|
59
|
Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
|
60
|
checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen());
|
61
|
checkBoxMediaSpecimen.setText(Messages.AbcdImportPreference_media_as_mediaSpecimen);
|
62
|
checkBoxMediaSpecimen
|
63
|
.setToolTipText(Messages.AbcdImportPreference_media_as_subUnit);
|
64
|
checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
|
65
|
@Override
|
66
|
public void widgetSelected(SelectionEvent e) {
|
67
|
configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen());
|
68
|
}
|
69
|
});
|
70
|
|
71
|
Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
|
72
|
checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen());
|
73
|
checkBoxIgnoreExisting.setText(Messages.AbcdImportPreference_not_import_existing_specimen);
|
74
|
checkBoxIgnoreExisting
|
75
|
.setToolTipText(Messages.AbcdImportPreference_not_import_existing_specimen_tooltip);
|
76
|
checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
|
77
|
@Override
|
78
|
public void widgetSelected(SelectionEvent e) {
|
79
|
configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen());
|
80
|
}
|
81
|
});
|
82
|
|
83
|
Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
|
84
|
checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship());
|
85
|
checkBoxIgnoreAuthorship.setText(Messages.AbcdImportPreference_ignore_author);
|
86
|
checkBoxIgnoreAuthorship
|
87
|
.setToolTipText(Messages.AbcdImportPreference_ignore_author_tooltip);
|
88
|
checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
|
89
|
@Override
|
90
|
public void widgetSelected(SelectionEvent e) {
|
91
|
configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship());
|
92
|
}
|
93
|
});
|
94
|
|
95
|
Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
|
96
|
checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber());
|
97
|
checkBoxMapUnitIdToCatalogNumber.setText(Messages.AbcdImportPreference_map_unit_nr_catalog_number);
|
98
|
checkBoxMapUnitIdToCatalogNumber
|
99
|
.setToolTipText(Messages.AbcdImportPreference_map_unit_number_catalog_number_tooltip);
|
100
|
checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
|
101
|
@Override
|
102
|
public void widgetSelected(SelectionEvent e) {
|
103
|
configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber());
|
104
|
}
|
105
|
});
|
106
|
//TODO: only one of the mappings can be checked!
|
107
|
Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
|
108
|
checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber());
|
109
|
checkBoxMapUnitIdToAccessionNumber.setText(Messages.AbcdImportPreference_map_unit_number_to_accession_number);
|
110
|
checkBoxMapUnitIdToAccessionNumber
|
111
|
.setToolTipText(Messages.AbcdImportPreference_map_unit_number_accession_number_tooltip);
|
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(Messages.AbcdImportPreference_map_unit_number_barcode);
|
122
|
checkBoxMapUnitIdToBarcode
|
123
|
.setToolTipText(Messages.AbcdImportPreference_map_unit_number_barcode_tooltip);
|
124
|
checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
|
125
|
@Override
|
126
|
public void widgetSelected(SelectionEvent e) {
|
127
|
configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode());
|
128
|
}
|
129
|
});
|
130
|
|
131
|
Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
|
132
|
checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText());
|
133
|
checkBoxRemoveCountry.setText(Messages.AbcdImportPreference_remove_country_from_locality);
|
134
|
checkBoxRemoveCountry
|
135
|
.setToolTipText(Messages.AbcdImportPreference_remove_country_from_locality_tooltip);
|
136
|
checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
|
137
|
@Override
|
138
|
public void widgetSelected(SelectionEvent e) {
|
139
|
configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText());
|
140
|
}
|
141
|
});
|
142
|
|
143
|
Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
|
144
|
checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification());
|
145
|
checkBoxMoveToDefaultClassification.setText(Messages.AbcdImportPreference_create_new_classification_new_taxa);
|
146
|
checkBoxMoveToDefaultClassification
|
147
|
.setToolTipText(Messages.AbcdImportPreference_create_new_classification_new_taxa_tooltip);
|
148
|
checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
|
149
|
@Override
|
150
|
public void widgetSelected(SelectionEvent e) {
|
151
|
configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification());
|
152
|
}
|
153
|
});
|
154
|
|
155
|
Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
|
156
|
checkBoxImportSiblings.setSelection(configurator.isGetSiblings());
|
157
|
checkBoxImportSiblings.setText(Messages.AbcdImportPreference_import_all_children_for_cultures_or_tissues);
|
158
|
checkBoxImportSiblings
|
159
|
.setToolTipText(Messages.AbcdImportPreference_import_all_children_for_cultures_or_tissues_tooltip);
|
160
|
checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
|
161
|
@Override
|
162
|
public void widgetSelected(SelectionEvent e) {
|
163
|
configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
|
164
|
}
|
165
|
});
|
166
|
|
167
|
Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
|
168
|
checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
169
|
checkBoxAddIndividualsAssociations.setText(Messages.AbcdImportPreference_create_Individual_Association);
|
170
|
checkBoxAddIndividualsAssociations
|
171
|
.setToolTipText(Messages.AbcdImportPreference_create_Individual_Association_tooltip);
|
172
|
checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
|
173
|
@Override
|
174
|
public void widgetSelected(SelectionEvent e) {
|
175
|
configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
176
|
}
|
177
|
});
|
178
|
|
179
|
Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
|
180
|
checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups());
|
181
|
checkBoxReuseDescriptiveGroups.setText(Messages.AbcdImportPreference_reuse_descriptive_group);
|
182
|
checkBoxReuseDescriptiveGroups
|
183
|
.setToolTipText(Messages.AbcdImportPreference_reuse_descriptive_group_tooltip);
|
184
|
checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
|
185
|
@Override
|
186
|
public void widgetSelected(SelectionEvent e) {
|
187
|
configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
|
188
|
}
|
189
|
});
|
190
|
|
191
|
Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
|
192
|
checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible());
|
193
|
checkBoxReuseExistingTaxa.setText(Messages.AbcdImportPreference_reuse_existing_taxa);
|
194
|
checkBoxReuseExistingTaxa
|
195
|
.setToolTipText(Messages.AbcdImportPreference_reuse_existing_taxa_tooltip);
|
196
|
checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
|
197
|
@Override
|
198
|
public void widgetSelected(SelectionEvent e) {
|
199
|
configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
|
200
|
}
|
201
|
});
|
202
|
|
203
|
GridData gridData = new GridData();
|
204
|
gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
|
205
|
gridData.horizontalIndent = 5;
|
206
|
// classificationSelection.setLayoutData(gridData);
|
207
|
|
208
|
nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
209
|
nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
|
210
|
for(NomenclaturalCode code: NomenclaturalCode.values()){
|
211
|
nomenclaturalCodeSelectionCombo.add(code.getKey());
|
212
|
}
|
213
|
int index = 0;
|
214
|
if (configurator.getNomenclaturalCode() != null){
|
215
|
for (String label : nomenclaturalCodeSelectionCombo.getItems()){
|
216
|
if (label.equals(configurator.getNomenclaturalCode().getKey())){
|
217
|
nomenclaturalCodeSelectionCombo.select(index);
|
218
|
}
|
219
|
index++;
|
220
|
}
|
221
|
}
|
222
|
|
223
|
// TODO remember last selection
|
224
|
nomenclaturalCodeSelectionCombo.addSelectionListener(this);
|
225
|
return composite;
|
226
|
}
|
227
|
|
228
|
@Override
|
229
|
public void widgetSelected(SelectionEvent e) {
|
230
|
this.configurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
|
231
|
|
232
|
}
|
233
|
|
234
|
@Override
|
235
|
public boolean performOk() {
|
236
|
if (configurator != null){
|
237
|
String configString = configurator.toString();
|
238
|
|
239
|
CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
|
240
|
pref.setAllowOverride(true);
|
241
|
|
242
|
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
|
243
|
if (controller == null){
|
244
|
return false;
|
245
|
}
|
246
|
IPreferenceService service = controller.getPreferenceService();
|
247
|
service.set(pref);
|
248
|
}
|
249
|
return true;
|
250
|
}
|
251
|
|
252
|
/**
|
253
|
* {@inheritDoc}
|
254
|
*/
|
255
|
@Override
|
256
|
public void widgetDefaultSelected(SelectionEvent e) {
|
257
|
// TODO Auto-generated method stub
|
258
|
|
259
|
}
|
260
|
|
261
|
public void createAbcdImportConfig() {
|
262
|
this.configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
|
263
|
this.configurator.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
|
264
|
this.configurator.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
|
265
|
//this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
|
266
|
this.configurator.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
|
267
|
this.configurator.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
|
268
|
// this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
|
269
|
this.configurator.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
|
270
|
this.configurator.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
|
271
|
this.configurator.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
|
272
|
this.configurator.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
|
273
|
this.configurator.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
|
274
|
this.configurator.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
|
275
|
this.configurator.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
|
276
|
this.configurator.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
|
277
|
this.configurator.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
|
278
|
this.configurator.setNomenclaturalCode(PreferencesUtil.getPreferredNomenclaturalCode(doGetPreferenceStore().getString(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
|
279
|
|
280
|
}
|
281
|
|
282
|
}
|