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.io.wizard;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.apache.commons.lang3.StringUtils;
|
15
|
import org.eclipse.jface.layout.GridDataFactory;
|
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.events.SelectionListener;
|
20
|
import org.eclipse.swt.graphics.Font;
|
21
|
import org.eclipse.swt.graphics.FontData;
|
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.Display;
|
28
|
import org.eclipse.swt.widgets.Label;
|
29
|
import org.eclipse.swt.widgets.Text;
|
30
|
import org.eclipse.wb.swt.ResourceManager;
|
31
|
|
32
|
import eu.etaxonomy.cdm.common.URI;
|
33
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
34
|
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
35
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
36
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
37
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
38
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
39
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
40
|
import eu.etaxonomy.taxeditor.databaseAdmin.wizard.AbstractPreferenceWizard;
|
41
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
42
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
43
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
44
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
45
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
|
46
|
|
47
|
/**
|
48
|
* @author pplitzner
|
49
|
*/
|
50
|
public class AbcdImportConfiguratorWizardPage extends AbstractPreferenceWizard implements SelectionListener {
|
51
|
|
52
|
public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
|
53
|
|
54
|
private static final String ACCESSION_NUMBER = "Accession number";
|
55
|
|
56
|
private static final String BARCODE = "Barcode";
|
57
|
|
58
|
private static final String CATALOGUE_NUMBER = "Catalogue number";
|
59
|
private Text textClassification;
|
60
|
private Button btnBrowseClassification;
|
61
|
private Button btnClear;
|
62
|
|
63
|
private Text textSource;
|
64
|
private Button btnBrowseSource;
|
65
|
private Button btnClearSource;
|
66
|
|
67
|
private Abcd206ImportConfigurator abcdImportConfigurator;
|
68
|
|
69
|
private List<URI> biocaseProvider = new ArrayList<>();
|
70
|
|
71
|
private boolean isFileImport = false;
|
72
|
private boolean isPreferencePage = false;
|
73
|
|
74
|
private Combo nomenclaturalCodeSelectionCombo;
|
75
|
private Combo checkBoxMapUnitId;
|
76
|
private Combo textDNAProviderString;
|
77
|
|
78
|
protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator) {
|
79
|
this(title, description, configurator, false, false);
|
80
|
}
|
81
|
|
82
|
protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator, boolean isPreferencePage, boolean isFileImport) {
|
83
|
super(PAGE_NAME);
|
84
|
this.abcdImportConfigurator = configurator;
|
85
|
setTitle(title);
|
86
|
setDescription(description);
|
87
|
this.isPreferencePage = isPreferencePage;
|
88
|
this.isFileImport = isFileImport;
|
89
|
}
|
90
|
|
91
|
public static AbcdImportConfiguratorWizardPage createPage(Abcd206ImportConfigurator configurator){
|
92
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
93
|
"Tooltips will explain parameters in more detail", configurator);
|
94
|
}
|
95
|
public static AbcdImportConfiguratorWizardPage createFileImportPage(Abcd206ImportConfigurator configurator){
|
96
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
97
|
"Tooltips will explain parameters in more detail", configurator, false, true);
|
98
|
}
|
99
|
|
100
|
public static AbcdImportConfiguratorWizardPage createPreferencePage(Abcd206ImportConfigurator configurator){
|
101
|
return new AbcdImportConfiguratorWizardPage("Configure import parameters",
|
102
|
"Tooltips will explain parameters in more detail", configurator, true, false);
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
public void createControl(Composite parent) {
|
107
|
Composite composite = new Composite(parent, SWT.NULL);
|
108
|
GridLayout gridLayout = new GridLayout();
|
109
|
gridLayout.numColumns=2;
|
110
|
Label labelnewlyCreatedTaxa = new Label(composite, SWT.NONE);
|
111
|
labelnewlyCreatedTaxa.setText("Newly Created Taxa");
|
112
|
Display display = Display.getDefault();
|
113
|
FontData data = display .getSystemFont().getFontData()[0];
|
114
|
Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
|
115
|
labelnewlyCreatedTaxa.setFont(font);
|
116
|
GridData gridData = new GridData();
|
117
|
gridData.horizontalAlignment = GridData.FILL;
|
118
|
gridData.grabExcessHorizontalSpace=true;
|
119
|
gridData.horizontalSpan = 2;
|
120
|
labelnewlyCreatedTaxa.setLayoutData(gridData);
|
121
|
|
122
|
//gridLayout.makeColumnsEqualWidth=true;
|
123
|
composite.setLayout(gridLayout);
|
124
|
|
125
|
Composite classificationAndSourceComp = new Composite(composite, SWT.NULL);
|
126
|
classificationAndSourceComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
|
127
|
classificationAndSourceComp.setLayout(new GridLayout(4, false));
|
128
|
|
129
|
Label labelClassification = new Label(classificationAndSourceComp, SWT.TOP);
|
130
|
labelClassification.setText("Classification");
|
131
|
// labelClassification.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
|
132
|
textClassification = new Text(classificationAndSourceComp, SWT.BORDER);
|
133
|
textClassification.setEnabled(false);
|
134
|
textClassification.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
135
|
if (abcdImportConfigurator.getClassificationUuid() != null){
|
136
|
if (abcdImportConfigurator.getClassificationName() != null){
|
137
|
textClassification.setText(abcdImportConfigurator.getClassificationName());
|
138
|
}else{
|
139
|
Classification classification = CdmStore.getService(IClassificationService.class).load(abcdImportConfigurator.getClassificationUuid());
|
140
|
textClassification.setText(classification.getTitleCache());
|
141
|
}
|
142
|
}
|
143
|
btnBrowseClassification = new Button(classificationAndSourceComp, SWT.NONE);
|
144
|
btnBrowseClassification.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
|
145
|
btnBrowseClassification.addSelectionListener(new SelectionAdapter() {
|
146
|
@Override
|
147
|
public void widgetSelected(SelectionEvent e) {
|
148
|
Classification classification = SelectionDialogFactory.getSelectionFromDialog(Classification.class,parent.getShell(), null, null);
|
149
|
if(classification!=null){
|
150
|
textClassification.setText(classification.getTitleCache());
|
151
|
abcdImportConfigurator.setClassificationUuid(classification.getUuid());
|
152
|
abcdImportConfigurator.setClassificationName(classification.getTitleCache());
|
153
|
}
|
154
|
}
|
155
|
});
|
156
|
btnClear = new Button(classificationAndSourceComp, SWT.NONE);
|
157
|
btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
|
158
|
btnClear.addSelectionListener(new SelectionAdapter() {
|
159
|
@Override
|
160
|
public void widgetSelected(SelectionEvent e) {
|
161
|
abcdImportConfigurator.setClassificationUuid(null);
|
162
|
textClassification.setText("");
|
163
|
}
|
164
|
});
|
165
|
|
166
|
Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
|
167
|
gridData = new GridData();
|
168
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
169
|
gridData.horizontalSpan = 2;
|
170
|
checkBoxMoveToDefaultClassification.setLayoutData(gridData);
|
171
|
GridDataFactory.fillDefaults();
|
172
|
checkBoxMoveToDefaultClassification.setSelection(abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
|
173
|
checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
|
174
|
checkBoxMoveToDefaultClassification
|
175
|
.setToolTipText("For taxa that do not exist in the data base "
|
176
|
+ "a new classification will be created");
|
177
|
checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
|
178
|
@Override
|
179
|
public void widgetSelected(SelectionEvent e) {
|
180
|
abcdImportConfigurator.setMoveNewTaxaToDefaultClassification(!abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
|
181
|
}
|
182
|
});
|
183
|
|
184
|
Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
|
185
|
gridData = new GridData();
|
186
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
187
|
gridData.horizontalSpan = 2;
|
188
|
checkBoxReuseExistingTaxa.setLayoutData(gridData);
|
189
|
GridDataFactory.fillDefaults();
|
190
|
checkBoxReuseExistingTaxa.setSelection(abcdImportConfigurator.isReuseExistingTaxaWhenPossible());
|
191
|
checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
|
192
|
checkBoxReuseExistingTaxa
|
193
|
.setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
|
194
|
checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
|
195
|
@Override
|
196
|
public void widgetSelected(SelectionEvent e) {
|
197
|
abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
198
|
}
|
199
|
});
|
200
|
|
201
|
Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
|
202
|
gridData = new GridData();
|
203
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
204
|
gridData.horizontalSpan = 2;
|
205
|
checkBoxIgnoreAuthorship.setLayoutData(gridData);
|
206
|
GridDataFactory.fillDefaults();
|
207
|
checkBoxIgnoreAuthorship.setSelection(abcdImportConfigurator.isIgnoreAuthorship());
|
208
|
checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
|
209
|
checkBoxIgnoreAuthorship
|
210
|
.setToolTipText("Name matching with existing names will be done without "
|
211
|
+ "the authorship part of the name");
|
212
|
checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
|
213
|
@Override
|
214
|
public void widgetSelected(SelectionEvent e) {
|
215
|
abcdImportConfigurator.setIgnoreAuthorship(!abcdImportConfigurator.isIgnoreAuthorship());
|
216
|
}
|
217
|
});
|
218
|
|
219
|
Label labelCode = new Label(composite, SWT.NONE);
|
220
|
labelCode.setText("Nomenclatural Code");
|
221
|
gridData = new GridData();
|
222
|
gridData.horizontalAlignment=SWT.BEGINNING;
|
223
|
|
224
|
labelCode.setLayoutData(gridData);
|
225
|
GridDataFactory.fillDefaults();
|
226
|
nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
227
|
gridData = new GridData();
|
228
|
gridData.horizontalAlignment=SWT.BEGINNING;
|
229
|
nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
|
230
|
GridDataFactory.fillDefaults();
|
231
|
for(NomenclaturalCode code: NomenclaturalCode.values()){
|
232
|
nomenclaturalCodeSelectionCombo.add(code.getKey());
|
233
|
}
|
234
|
|
235
|
nomenclaturalCodeSelectionCombo.addSelectionListener(this);
|
236
|
int index = 0;
|
237
|
if (abcdImportConfigurator.getNomenclaturalCode() != null){
|
238
|
for (String label : nomenclaturalCodeSelectionCombo.getItems()){
|
239
|
if (label.equals(abcdImportConfigurator.getNomenclaturalCode().getKey())){
|
240
|
nomenclaturalCodeSelectionCombo.select(index);
|
241
|
}
|
242
|
index++;
|
243
|
}
|
244
|
}
|
245
|
|
246
|
Label labelLinkToTaxon = new Label(composite, SWT.NONE);
|
247
|
labelLinkToTaxon.setText("Link to Taxon");
|
248
|
labelLinkToTaxon.setFont(font);
|
249
|
|
250
|
Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
|
251
|
gridData = new GridData();
|
252
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
253
|
gridData.horizontalSpan = 2;
|
254
|
checkBoxAddIndividualsAssociations.setLayoutData(gridData);
|
255
|
GridDataFactory.fillDefaults();
|
256
|
checkBoxAddIndividualsAssociations.setSelection(abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
257
|
checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
|
258
|
checkBoxAddIndividualsAssociations
|
259
|
.setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
|
260
|
checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
|
261
|
@Override
|
262
|
public void widgetSelected(SelectionEvent e) {
|
263
|
abcdImportConfigurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
|
264
|
}
|
265
|
});
|
266
|
|
267
|
Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
|
268
|
gridData = new GridData();
|
269
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
270
|
gridData.horizontalSpan = 2;
|
271
|
checkBoxReuseDescriptiveGroups.setLayoutData(gridData);
|
272
|
GridDataFactory.fillDefaults();
|
273
|
checkBoxReuseDescriptiveGroups.setSelection(abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
274
|
checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
|
275
|
checkBoxReuseDescriptiveGroups
|
276
|
.setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
|
277
|
checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
|
278
|
@Override
|
279
|
public void widgetSelected(SelectionEvent e) {
|
280
|
abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
|
281
|
}
|
282
|
});
|
283
|
|
284
|
|
285
|
Label labelSpecimen = new Label(composite, SWT.NONE);
|
286
|
labelSpecimen.setText("Specimen");
|
287
|
labelSpecimen.setFont(font);
|
288
|
gridData = new GridData();
|
289
|
gridData.horizontalAlignment = GridData.FILL;
|
290
|
gridData.grabExcessHorizontalSpace=true;
|
291
|
gridData.horizontalSpan = 2;
|
292
|
labelSpecimen.setLayoutData(gridData);
|
293
|
GridDataFactory.fillDefaults();
|
294
|
Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
|
295
|
gridData = new GridData();
|
296
|
gridData.horizontalAlignment = GridData.FILL;
|
297
|
gridData.grabExcessHorizontalSpace=true;
|
298
|
gridData.horizontalSpan = 2;
|
299
|
|
300
|
checkBoxIgnoreExisting.setSelection(abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
|
301
|
checkBoxIgnoreExisting.setText("Do not import existing specimens");
|
302
|
checkBoxIgnoreExisting
|
303
|
.setToolTipText("Specimens that have previously been imported will be ignored in this import");
|
304
|
checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
|
305
|
@Override
|
306
|
public void widgetSelected(SelectionEvent e) {
|
307
|
abcdImportConfigurator.setIgnoreImportOfExistingSpecimen(!abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
|
308
|
}
|
309
|
});
|
310
|
|
311
|
checkBoxIgnoreExisting.setLayoutData(gridData);
|
312
|
GridDataFactory.fillDefaults();
|
313
|
|
314
|
Label unitIdLabel = new Label(composite, SWT.NONE);
|
315
|
unitIdLabel.setText(Messages.AbcdImportPreference_map_unit_nr_catalog_number);
|
316
|
|
317
|
GridData gridDataUnitId = new GridData();
|
318
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
319
|
unitIdLabel.setLayoutData(gridDataUnitId);
|
320
|
GridDataFactory.fillDefaults();
|
321
|
|
322
|
checkBoxMapUnitId = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
|
323
|
gridDataUnitId = new GridData();
|
324
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
325
|
checkBoxMapUnitId.setLayoutData(gridDataUnitId);
|
326
|
GridDataFactory.fillDefaults();
|
327
|
|
328
|
checkBoxMapUnitId.add(ACCESSION_NUMBER);
|
329
|
checkBoxMapUnitId.add(BARCODE);
|
330
|
checkBoxMapUnitId.add(CATALOGUE_NUMBER);
|
331
|
checkBoxMapUnitId
|
332
|
.setToolTipText(Messages.AbcdImportPreference_map_unit_number_catalog_number_tooltip);
|
333
|
checkBoxMapUnitId.addSelectionListener(this);
|
334
|
|
335
|
if (abcdImportConfigurator.isMapUnitIdToAccessionNumber()){
|
336
|
checkBoxMapUnitId.select(0);
|
337
|
}else if (abcdImportConfigurator.isMapUnitIdToBarcode()){
|
338
|
checkBoxMapUnitId.select(1);
|
339
|
}else {
|
340
|
checkBoxMapUnitId.select(2);
|
341
|
}
|
342
|
|
343
|
|
344
|
Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
|
345
|
gridData = new GridData();
|
346
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
347
|
gridData.horizontalSpan = 2;
|
348
|
checkBoxRemoveCountry.setLayoutData(gridData);
|
349
|
GridDataFactory.fillDefaults();
|
350
|
checkBoxRemoveCountry.setSelection(abcdImportConfigurator.isRemoveCountryFromLocalityText());
|
351
|
checkBoxRemoveCountry.setText("Remove country from locality text");
|
352
|
checkBoxRemoveCountry
|
353
|
.setToolTipText("If the locality text contains information about the "
|
354
|
+ "country which is additionally stored in other ABCD "
|
355
|
+ "elements then it is removed from the locality text");
|
356
|
checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
|
357
|
@Override
|
358
|
public void widgetSelected(SelectionEvent e) {
|
359
|
abcdImportConfigurator.setRemoveCountryFromLocalityText(!abcdImportConfigurator.isRemoveCountryFromLocalityText());
|
360
|
}
|
361
|
});
|
362
|
|
363
|
|
364
|
|
365
|
Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
|
366
|
gridData = new GridData();
|
367
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
368
|
gridData.horizontalSpan = 2;
|
369
|
checkBoxImportSiblings.setLayoutData(gridData);
|
370
|
GridDataFactory.fillDefaults();
|
371
|
checkBoxImportSiblings.setSelection(abcdImportConfigurator.isGetSiblings());
|
372
|
checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
|
373
|
checkBoxImportSiblings
|
374
|
.setToolTipText("For a tissue sample or culture all children will be searched and imported");
|
375
|
checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
|
376
|
@Override
|
377
|
public void widgetSelected(SelectionEvent e) {
|
378
|
abcdImportConfigurator.setGetSiblings(checkBoxImportSiblings.getSelection());
|
379
|
}
|
380
|
});
|
381
|
|
382
|
|
383
|
|
384
|
|
385
|
|
386
|
if (!isFileImport){
|
387
|
|
388
|
Label labelRef = new Label(composite, SWT.NONE);
|
389
|
gridDataUnitId = new GridData();
|
390
|
gridDataUnitId.horizontalAlignment=SWT.BEGINNING;
|
391
|
labelRef.setLayoutData(gridDataUnitId);
|
392
|
labelRef.setText("Biocase provider for associated DNA");
|
393
|
GridDataFactory.fillDefaults();
|
394
|
|
395
|
textDNAProviderString = new Combo(composite, SWT.BORDER);
|
396
|
textDNAProviderString.setLayoutData(gridDataUnitId);
|
397
|
GridDataFactory.fillDefaults();
|
398
|
|
399
|
|
400
|
String allProviderString = PreferencesUtil.getStringValue(PreferencePredicate.BioCaseProvider.getKey(), false);
|
401
|
if (StringUtils.isNotBlank(allProviderString)){
|
402
|
String[] providerArray = allProviderString.split(";"); //$NON-NLS-1$
|
403
|
for (String providerString : providerArray){
|
404
|
if (!StringUtils.isBlank(providerString)){
|
405
|
textDNAProviderString.add(providerString);
|
406
|
|
407
|
}
|
408
|
}
|
409
|
}
|
410
|
textDNAProviderString.setEnabled(true);
|
411
|
textDNAProviderString.add("Do not search for DNA");
|
412
|
textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
|
413
|
if (abcdImportConfigurator.getDnaSoure() != null){
|
414
|
textDNAProviderString.select(0);
|
415
|
}else{
|
416
|
textDNAProviderString.select(textDNAProviderString.getItemCount());
|
417
|
}
|
418
|
textDNAProviderString.addSelectionListener(this);
|
419
|
}else{
|
420
|
abcdImportConfigurator.setDnaSoure(null);
|
421
|
}
|
422
|
|
423
|
Label labelMedia = new Label(composite, SWT.NONE);
|
424
|
labelMedia.setText("Media");
|
425
|
labelMedia.setFont(font);
|
426
|
gridData = new GridData();
|
427
|
gridData.horizontalAlignment = GridData.FILL;
|
428
|
gridData.grabExcessHorizontalSpace=true;
|
429
|
gridData.horizontalSpan = 2;
|
430
|
labelMedia.setLayoutData(gridData);
|
431
|
|
432
|
|
433
|
Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
|
434
|
|
435
|
checkBoxMediaSpecimen.setSelection(abcdImportConfigurator.isAddMediaAsMediaSpecimen());
|
436
|
checkBoxMediaSpecimen.setText("Import media as media specimen");
|
437
|
checkBoxMediaSpecimen
|
438
|
.setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
|
439
|
checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
|
440
|
@Override
|
441
|
public void widgetSelected(SelectionEvent e) {
|
442
|
abcdImportConfigurator.setAddMediaAsMediaSpecimen(!abcdImportConfigurator.isAddMediaAsMediaSpecimen());
|
443
|
}
|
444
|
});
|
445
|
gridData = new GridData();
|
446
|
gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
|
447
|
gridData.horizontalSpan = 2;
|
448
|
checkBoxMediaSpecimen.setLayoutData(gridData);
|
449
|
GridDataFactory.fillDefaults();
|
450
|
|
451
|
Label labelSource = new Label(composite, SWT.NONE);
|
452
|
labelSource.setText("Source");
|
453
|
labelSource.setFont(font);
|
454
|
gridData = new GridData();
|
455
|
gridData.horizontalAlignment = GridData.FILL;
|
456
|
gridData.grabExcessHorizontalSpace=true;
|
457
|
gridData.horizontalSpan = 2;
|
458
|
labelSource.setLayoutData(gridData);
|
459
|
|
460
|
Composite sourceComp = new Composite(composite, SWT.NULL);
|
461
|
sourceComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
|
462
|
sourceComp.setLayout(new GridLayout(4, false));
|
463
|
Label labelSourceRef = new Label(sourceComp, SWT.TOP);
|
464
|
labelSourceRef.setText("Source");
|
465
|
// labelClassification.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
|
466
|
textSource = new Text(sourceComp, SWT.BORDER);
|
467
|
textSource.setEnabled(false);
|
468
|
textSource.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
|
469
|
if (abcdImportConfigurator.getSourceRefUuid() != null){
|
470
|
if (abcdImportConfigurator.getSourceReferenceTitle() != null){
|
471
|
textSource.setText(abcdImportConfigurator.getSourceReferenceTitle());
|
472
|
}else{
|
473
|
Reference sourceRef = CdmStore.getService(IReferenceService.class).load(abcdImportConfigurator.getSourceRefUuid());
|
474
|
textClassification.setText(sourceRef.getTitleCache());
|
475
|
}
|
476
|
}
|
477
|
btnBrowseSource = new Button(sourceComp, SWT.NONE);
|
478
|
btnBrowseSource.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
|
479
|
btnBrowseSource.addSelectionListener(new SelectionAdapter() {
|
480
|
@Override
|
481
|
public void widgetSelected(SelectionEvent e) {
|
482
|
Reference sourceRef = SelectionDialogFactory.getSelectionFromDialog(Reference.class,parent.getShell(), null, null);
|
483
|
if(sourceRef!=null){
|
484
|
textSource.setText(sourceRef.getTitleCache());
|
485
|
abcdImportConfigurator.setSourceRefUuid(sourceRef.getUuid());
|
486
|
abcdImportConfigurator.setSourceReferenceTitle(sourceRef.getTitleCache());
|
487
|
}
|
488
|
}
|
489
|
});
|
490
|
btnClear = new Button(sourceComp, SWT.NONE);
|
491
|
btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
|
492
|
btnClear.addSelectionListener(new SelectionAdapter() {
|
493
|
@Override
|
494
|
public void widgetSelected(SelectionEvent e) {
|
495
|
abcdImportConfigurator.setClassificationUuid(null);
|
496
|
textClassification.setText("");
|
497
|
}
|
498
|
});
|
499
|
|
500
|
setControl(composite);
|
501
|
}
|
502
|
|
503
|
@Override
|
504
|
public void widgetSelected(SelectionEvent e) {
|
505
|
if (e.getSource().equals(nomenclaturalCodeSelectionCombo)){
|
506
|
this.abcdImportConfigurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
|
507
|
}
|
508
|
if (e.getSource().equals(checkBoxMapUnitId)){
|
509
|
String text = checkBoxMapUnitId.getText();
|
510
|
if (text.equals(ACCESSION_NUMBER)){
|
511
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(true);
|
512
|
abcdImportConfigurator.setMapUnitIdToBarcode(false);
|
513
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(false);
|
514
|
}else if (text.equals(BARCODE)){
|
515
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(false);
|
516
|
abcdImportConfigurator.setMapUnitIdToBarcode(true);
|
517
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(false);
|
518
|
}else{
|
519
|
abcdImportConfigurator.setMapUnitIdToAccessionNumber(false);
|
520
|
abcdImportConfigurator.setMapUnitIdToBarcode(false);
|
521
|
abcdImportConfigurator.setMapUnitIdToCatalogNumber(true);
|
522
|
}
|
523
|
}
|
524
|
if (e.getSource().equals(textDNAProviderString)){
|
525
|
String text = textDNAProviderString.getText();
|
526
|
try{
|
527
|
abcdImportConfigurator.setDnaSoure(URI.create(text));
|
528
|
}catch(IllegalArgumentException illegalArgument){
|
529
|
abcdImportConfigurator.setDnaSoure(null);
|
530
|
}
|
531
|
}
|
532
|
}
|
533
|
|
534
|
public void saveConfigToPrefernceStore() {
|
535
|
try{
|
536
|
abcdImportConfigurator.setDnaSoure(URI.create(textDNAProviderString.getText()));
|
537
|
}catch(IllegalArgumentException e){
|
538
|
//TODO: check prior or message
|
539
|
abcdImportConfigurator.setDnaSoure(null);
|
540
|
}
|
541
|
|
542
|
PreferencesUtil.setStringValue(IPreferenceKeys.LAST_USED_ABCD_CONFIG, abcdImportConfigurator.toString());
|
543
|
}
|
544
|
|
545
|
public String createConfigString(){
|
546
|
return abcdImportConfigurator.toString();
|
547
|
|
548
|
}
|
549
|
|
550
|
@Override
|
551
|
public void widgetDefaultSelected(SelectionEvent e) {
|
552
|
// TODO Auto-generated method stub
|
553
|
}
|
554
|
|
555
|
public void createAbcdImportConfig() {
|
556
|
this.abcdImportConfigurator = PreferencesUtil.getLocalAbcdImportConfigurator(false);
|
557
|
}
|
558
|
}
|