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