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
|
|
10
|
package eu.etaxonomy.taxeditor.io.wizard;
|
11
|
|
12
|
import java.net.URI;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
|
16
|
import org.apache.commons.lang.StringUtils;
|
17
|
import org.eclipse.jface.layout.GridDataFactory;
|
18
|
import org.eclipse.swt.SWT;
|
19
|
import org.eclipse.swt.events.SelectionAdapter;
|
20
|
import org.eclipse.swt.events.SelectionEvent;
|
21
|
import org.eclipse.swt.events.SelectionListener;
|
22
|
import org.eclipse.swt.layout.GridData;
|
23
|
import org.eclipse.swt.layout.GridLayout;
|
24
|
import org.eclipse.swt.widgets.Button;
|
25
|
import org.eclipse.swt.widgets.Combo;
|
26
|
import org.eclipse.swt.widgets.Composite;
|
27
|
import org.eclipse.swt.widgets.Label;
|
28
|
|
29
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
30
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
31
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
32
|
import eu.etaxonomy.taxeditor.databaseAdmin.wizard.AbstractPreferenceWizard;
|
33
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
34
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
35
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
36
|
|
37
|
/**
|
38
|
*
|
39
|
* @author pplitzner
|
40
|
*
|
41
|
*/
|
42
|
public class AbcdImportConfiguratorWizardPage extends AbstractPreferenceWizard implements SelectionListener {
|
43
|
|
44
|
public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
|
45
|
|
46
|
private static final String ACCESSION_NUMBER = "Accession number";
|
47
|
|
48
|
private static final String BARCODE = "Barcode";
|
49
|
|
50
|
private static final String CATALOGUE_NUMBER = "Catalogue number";
|
51
|
|
52
|
private Abcd206ImportConfigurator abcdImportConfigurator;
|
53
|
|
54
|
private List<URI> biocaseProvider = new ArrayList<>();
|
55
|
|
56
|
private boolean isFileImport = false;
|
57
|
private boolean isPreferencePage = false;
|
58
|
|
59
|
private Combo nomenclaturalCodeSelectionCombo;
|
60
|
private Combo checkBoxMapUnitId;
|
61
|
private Combo textDNAProviderString;
|
62
|
|
63
|
protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator) {
|
64
|
this(title, description, configurator, false, false);
|
65
|
}
|
66
|
|
67
|
protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator, boolean isPreferencePage, boolean isFileImport) {
|
68
|
super(PAGE_NAME);
|
69
|
this.abcdImportConfigurator = configurator;
|
70
|
setTitle(title);
|
71
|
setDescription(description);
|
72
|
this.isPreferencePage = isPreferencePage;
|
73
|
this.isFileImport = isFileImport;
|
74
|
}
|
75
|
|
76
|
public static AbcdImportConfiguratorWizardPage createPage(Abcd206ImportConfigurator configurator){
|
77
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
78
|
"Tooltips will explain parameters in more detail", configurator);
|
79
|
}
|
80
|
public static AbcdImportConfiguratorWizardPage createFileImportPage(Abcd206ImportConfigurator configurator){
|
81
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
82
|
"Tooltips will explain parameters in more detail", configurator, false, true);
|
83
|
}
|
84
|
|
85
|
public static AbcdImportConfiguratorWizardPage createPreferencePage(Abcd206ImportConfigurator configurator){
|
86
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
87
|
"Tooltips will explain parameters in more detail", configurator, true, false);
|
88
|
}
|
89
|
|
90
|
|
91
|
|
92
|
/** {@inheritDoc} */
|
93
|
@Override
|
94
|
public void createControl(Composite parent) {
|
95
|
final Composite composite = new Composite(parent, SWT.NULL);
|
96
|
|
97
|
GridLayout gridLayout = new GridLayout();
|
98
|
gridLayout.numColumns=2;
|
99
|
//gridLayout.makeColumnsEqualWidth=true;
|
100
|
composite.setLayout(gridLayout);
|
101
|
|
102
|
|
103
|
GridData gridData = new GridData();
|
104
|
gridData.horizontalAlignment = GridData.FILL;
|
105
|
gridData.grabExcessHorizontalSpace=true;
|
106
|
gridData.horizontalSpan = 2;
|
107
|
|
108
|
Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
|
109
|
|
110
|
checkBoxMediaSpecimen.setSelection(abcdImportConfigurator.isAddMediaAsMediaSpecimen());
|
111
|
checkBoxMediaSpecimen.setText("Import media as media specimen");
|
112
|
checkBoxMediaSpecimen
|
113
|
.setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
|
114
|
checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
|
115
|
@Override
|
116
|
public void widgetSelected(SelectionEvent e) {
|
117
|
abcdImportConfigurator.setAddMediaAsMediaSpecimen(!abcdImportConfigurator.isAddMediaAsMediaSpecimen());
|
118
|
}
|
119
|
});
|
120
|
checkBoxMediaSpecimen.setLayoutData(gridData);
|
121
|
GridDataFactory.fillDefaults();
|
122
|
|
123
|
Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
|
124
|
gridData = new GridData();
|
125
|
gridData.horizontalAlignment = GridData.FILL;
|
126
|
gridData.grabExcessHorizontalSpace=true;
|
127
|
gridData.horizontalSpan = 2;
|
128
|
|
129
|
checkBoxIgnoreExisting.setSelection(abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
|
130
|
checkBoxIgnoreExisting.setText("Do not import existing specimens");
|
131
|
checkBoxIgnoreExisting
|
132
|
.setToolTipText("Specimens that have previously been imported will be ignored in this import");
|
133
|
checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
|
134
|
@Override
|
135
|
public void widgetSelected(SelectionEvent e) {
|
136
|
abcdImportConfigurator.setIgnoreImportOfExistingSpecimen(!abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
|
137
|
}
|
138
|
});
|
139
|
|
140
|
checkBoxIgnoreExisting.setLayoutData(gridData);
|
141
|
GridDataFactory.fillDefaults();
|
142
|
|
143
|
Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
|
144
|
gridData = new GridData();
|
145
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
146
|
gridData.horizontalSpan = 2;
|
147
|
checkBoxIgnoreAuthorship.setLayoutData(gridData);
|
148
|
GridDataFactory.fillDefaults();
|
149
|
checkBoxIgnoreAuthorship.setSelection(abcdImportConfigurator.isIgnoreAuthorship());
|
150
|
checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
|
151
|
checkBoxIgnoreAuthorship
|
152
|
.setToolTipText("Name matching with existing names will be done without "
|
153
|
+ "the authorship part of the name");
|
154
|
checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
|
155
|
@Override
|
156
|
public void widgetSelected(SelectionEvent e) {
|
157
|
abcdImportConfigurator.setIgnoreAuthorship(!abcdImportConfigurator.isIgnoreAuthorship());
|
158
|
}
|
159
|
});
|
160
|
|
161
|
|
162
|
Label unitIdLabel = new Label(composite, SWT.NONE);
|
163
|
unitIdLabel.setText(Messages.AbcdImportPreference_map_unit_nr_catalog_number);
|
164
|
|
165
|
GridData gridDataUnitId = new GridData();
|
166
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
167
|
unitIdLabel.setLayoutData(gridDataUnitId);
|
168
|
GridDataFactory.fillDefaults();
|
169
|
|
170
|
checkBoxMapUnitId = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
171
|
gridDataUnitId = new GridData();
|
172
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
173
|
checkBoxMapUnitId.setLayoutData(gridDataUnitId);
|
174
|
GridDataFactory.fillDefaults();
|
175
|
|
176
|
checkBoxMapUnitId.add(ACCESSION_NUMBER);
|
177
|
checkBoxMapUnitId.add(BARCODE);
|
178
|
checkBoxMapUnitId.add(CATALOGUE_NUMBER);
|
179
|
checkBoxMapUnitId
|
180
|
.setToolTipText(Messages.AbcdImportPreference_map_unit_number_catalog_number_tooltip);
|
181
|
checkBoxMapUnitId.addSelectionListener(this);
|
182
|
|
183
|
if (abcdImportConfigurator.isMapUnitIdToAccessionNumber()){
|
184
|
checkBoxMapUnitId.select(0);
|
185
|
}else if (abcdImportConfigurator.isMapUnitIdToBarcode()){
|
186
|
checkBoxMapUnitId.select(1);
|
187
|
}else {
|
188
|
checkBoxMapUnitId.select(2);
|
189
|
}
|
190
|
|
191
|
|
192
|
Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
|
193
|
gridData = new GridData();
|
194
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
195
|
gridData.horizontalSpan = 2;
|
196
|
checkBoxRemoveCountry.setLayoutData(gridData);
|
197
|
GridDataFactory.fillDefaults();
|
198
|
checkBoxRemoveCountry.setSelection(abcdImportConfigurator.isRemoveCountryFromLocalityText());
|
199
|
checkBoxRemoveCountry.setText("Remove country from locality text");
|
200
|
checkBoxRemoveCountry
|
201
|
.setToolTipText("If the locality text contains information about the "
|
202
|
+ "country which is additionally stored in other ABCD "
|
203
|
+ "elements then it is removed from the locality text");
|
204
|
checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
|
205
|
@Override
|
206
|
public void widgetSelected(SelectionEvent e) {
|
207
|
abcdImportConfigurator.setRemoveCountryFromLocalityText(!abcdImportConfigurator.isRemoveCountryFromLocalityText());
|
208
|
}
|
209
|
});
|
210
|
|
211
|
Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
|
212
|
gridData = new GridData();
|
213
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
214
|
gridData.horizontalSpan = 2;
|
215
|
checkBoxMoveToDefaultClassification.setLayoutData(gridData);
|
216
|
GridDataFactory.fillDefaults();
|
217
|
checkBoxMoveToDefaultClassification.setSelection(abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
|
218
|
checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
|
219
|
checkBoxMoveToDefaultClassification
|
220
|
.setToolTipText("For taxa that do not exist in the data base "
|
221
|
+ "a new classification will be created");
|
222
|
checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
|
223
|
@Override
|
224
|
public void widgetSelected(SelectionEvent e) {
|
225
|
abcdImportConfigurator.setMoveNewTaxaToDefaultClassification(!abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
|
226
|
}
|
227
|
});
|
228
|
|
229
|
Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
|
230
|
gridData = new GridData();
|
231
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
232
|
gridData.horizontalSpan = 2;
|
233
|
checkBoxImportSiblings.setLayoutData(gridData);
|
234
|
GridDataFactory.fillDefaults();
|
235
|
checkBoxImportSiblings.setSelection(abcdImportConfigurator.isGetSiblings());
|
236
|
checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
|
237
|
checkBoxImportSiblings
|
238
|
.setToolTipText("For a tissue sample or culture all children will be searched and imported");
|
239
|
checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
|
240
|
@Override
|
241
|
public void widgetSelected(SelectionEvent e) {
|
242
|
abcdImportConfigurator.setGetSiblings(checkBoxImportSiblings.getSelection());
|
243
|
}
|
244
|
});
|
245
|
|
246
|
Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
|
247
|
gridData = new GridData();
|
248
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
249
|
gridData.horizontalSpan = 2;
|
250
|
checkBoxAddIndividualsAssociations.setLayoutData(gridData);
|
251
|
GridDataFactory.fillDefaults();
|
252
|
checkBoxAddIndividualsAssociations.setSelection(abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
253
|
checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
|
254
|
checkBoxAddIndividualsAssociations
|
255
|
.setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
|
256
|
checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
|
257
|
@Override
|
258
|
public void widgetSelected(SelectionEvent e) {
|
259
|
abcdImportConfigurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
260
|
}
|
261
|
});
|
262
|
|
263
|
Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
|
264
|
gridData = new GridData();
|
265
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
266
|
gridData.horizontalSpan = 2;
|
267
|
checkBoxReuseDescriptiveGroups.setLayoutData(gridData);
|
268
|
GridDataFactory.fillDefaults();
|
269
|
checkBoxReuseDescriptiveGroups.setSelection(abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
270
|
checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
|
271
|
checkBoxReuseDescriptiveGroups
|
272
|
.setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
|
273
|
checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
|
274
|
@Override
|
275
|
public void widgetSelected(SelectionEvent e) {
|
276
|
abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
277
|
}
|
278
|
});
|
279
|
|
280
|
Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
|
281
|
gridData = new GridData();
|
282
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
283
|
gridData.horizontalSpan = 2;
|
284
|
checkBoxReuseExistingTaxa.setLayoutData(gridData);
|
285
|
GridDataFactory.fillDefaults();
|
286
|
checkBoxReuseExistingTaxa.setSelection(abcdImportConfigurator.isReuseExistingTaxaWhenPossible());
|
287
|
checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
|
288
|
checkBoxReuseExistingTaxa
|
289
|
.setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
|
290
|
checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
|
291
|
@Override
|
292
|
public void widgetSelected(SelectionEvent e) {
|
293
|
abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
294
|
}
|
295
|
});
|
296
|
|
297
|
|
298
|
if (!isFileImport){
|
299
|
|
300
|
Label labelRef = new Label(composite, SWT.NONE);
|
301
|
gridDataUnitId = new GridData();
|
302
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
303
|
labelRef.setLayoutData(gridDataUnitId);
|
304
|
labelRef.setText("Biocase provider for associated DNA");
|
305
|
GridDataFactory.fillDefaults();
|
306
|
|
307
|
textDNAProviderString = new Combo(composite, SWT.BORDER);
|
308
|
textDNAProviderString.setLayoutData(gridDataUnitId);
|
309
|
GridDataFactory.fillDefaults();
|
310
|
|
311
|
|
312
|
String allProviderString = PreferencesUtil.getStringValue(PreferencePredicate.BioCaseProvider.getKey(), false);
|
313
|
if (StringUtils.isNotBlank(allProviderString)){
|
314
|
String[] providerArray = allProviderString.split(";"); //$NON-NLS-1$
|
315
|
for (String providerString : providerArray){
|
316
|
if (!StringUtils.isBlank(providerString)){
|
317
|
textDNAProviderString.add(providerString);
|
318
|
|
319
|
}
|
320
|
}
|
321
|
}
|
322
|
textDNAProviderString.setEnabled(true);
|
323
|
textDNAProviderString.add("Do not search for DNA");
|
324
|
textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
|
325
|
if (abcdImportConfigurator.getDnaSoure() != null){
|
326
|
textDNAProviderString.select(0);
|
327
|
}else{
|
328
|
textDNAProviderString.select(textDNAProviderString.getItemCount());
|
329
|
}
|
330
|
textDNAProviderString.addSelectionListener(this);
|
331
|
}else{
|
332
|
abcdImportConfigurator.setDnaSoure(null);
|
333
|
}
|
334
|
|
335
|
|
336
|
Label labelCode = new Label(composite, SWT.NONE);
|
337
|
labelCode.setText("Nomenclatural Code");
|
338
|
gridData = new GridData();
|
339
|
gridData.horizontalAlignment=SWT.BEGINNING;
|
340
|
|
341
|
labelCode.setLayoutData(gridData);
|
342
|
GridDataFactory.fillDefaults();
|
343
|
nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
344
|
gridData = new GridData();
|
345
|
gridData.horizontalAlignment=SWT.BEGINNING;
|
346
|
nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
|
347
|
GridDataFactory.fillDefaults();
|
348
|
for(NomenclaturalCode code: NomenclaturalCode.values()){
|
349
|
nomenclaturalCodeSelectionCombo.add(code.getKey());
|
350
|
}
|
351
|
|
352
|
nomenclaturalCodeSelectionCombo.addSelectionListener(this);
|
353
|
int index = 0;
|
354
|
if (abcdImportConfigurator.getNomenclaturalCode() != null){
|
355
|
for (String label : nomenclaturalCodeSelectionCombo.getItems()){
|
356
|
if (label.equals(abcdImportConfigurator.getNomenclaturalCode().getKey())){
|
357
|
nomenclaturalCodeSelectionCombo.select(index);
|
358
|
}
|
359
|
index++;
|
360
|
}
|
361
|
}
|
362
|
|
363
|
setControl(composite);
|
364
|
}
|
365
|
|
366
|
@Override
|
367
|
public void widgetSelected(SelectionEvent e) {
|
368
|
if (e.getSource().equals(nomenclaturalCodeSelectionCombo)){
|
369
|
this.abcdImportConfigurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
|
370
|
}
|
371
|
if (e.getSource().equals(checkBoxMapUnitId)){
|
372
|
String text = checkBoxMapUnitId.getText();
|
373
|
if (text.equals(ACCESSION_NUMBER)){
|
374
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(true);
|
375
|
abcdImportConfigurator.setMapUnitIdToBarcode(false);
|
376
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(false);
|
377
|
}else if (text.equals(BARCODE)){
|
378
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(false);
|
379
|
abcdImportConfigurator.setMapUnitIdToBarcode(true);
|
380
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(false);
|
381
|
}else{
|
382
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(false);
|
383
|
abcdImportConfigurator.setMapUnitIdToBarcode(false);
|
384
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(true);
|
385
|
}
|
386
|
}
|
387
|
if (e.getSource().equals(textDNAProviderString)){
|
388
|
String text = textDNAProviderString.getText();
|
389
|
try{
|
390
|
abcdImportConfigurator.setDnaSoure(URI.create(text));
|
391
|
}catch(IllegalArgumentException illegalArgument){
|
392
|
abcdImportConfigurator.setDnaSoure(null);
|
393
|
}
|
394
|
}
|
395
|
|
396
|
|
397
|
}
|
398
|
|
399
|
public void saveConfigToPrefernceStore() {
|
400
|
try{
|
401
|
abcdImportConfigurator.setDnaSoure(URI.create(textDNAProviderString.getText()));
|
402
|
}catch(IllegalArgumentException e){
|
403
|
//TODO: check prior or message
|
404
|
abcdImportConfigurator.setDnaSoure(null);
|
405
|
}
|
406
|
PreferencesUtil.setStringValue(IPreferenceKeys.LAST_USED_ABCD_CONFIG, abcdImportConfigurator.toString());
|
407
|
|
408
|
|
409
|
}
|
410
|
|
411
|
public String createConfigString(){
|
412
|
return abcdImportConfigurator.toString();
|
413
|
|
414
|
}
|
415
|
|
416
|
|
417
|
|
418
|
/* (non-Javadoc)
|
419
|
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
420
|
*/
|
421
|
@Override
|
422
|
public void widgetDefaultSelected(SelectionEvent e) {
|
423
|
// TODO Auto-generated method stub
|
424
|
|
425
|
}
|
426
|
|
427
|
public void createAbcdImportConfig() {
|
428
|
this.abcdImportConfigurator = PreferencesUtil.getLocalAbcdImportConfigurator(false);
|
429
|
|
430
|
}
|
431
|
}
|