Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / e4 / in / abcd / AbcdImportConfiguratorWizardPageE4.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
10 package eu.etaxonomy.taxeditor.io.e4.in.abcd;
11
12 import javax.inject.Inject;
13
14 import org.eclipse.jface.wizard.WizardPage;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.events.SelectionAdapter;
17 import org.eclipse.swt.events.SelectionEvent;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.layout.GridLayout;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Label;
23 import org.eclipse.swt.widgets.Text;
24
25 import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
26 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
27 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28
29 /**
30 *
31 * @author pplitzner
32 *
33 */
34 public class AbcdImportConfiguratorWizardPageE4 extends WizardPage {
35
36 public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
37
38 private Abcd206ImportConfigurator configurator;
39 Text textDNAProviderString;
40
41 @Inject
42 public AbcdImportConfiguratorWizardPageE4() {
43 super(PAGE_NAME);
44 setTitle("Configure import parameters");
45 setDescription("Tooltips will explain parameters in more detail");
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public void createControl(Composite parent) {
51 final Composite composite = new Composite(parent, SWT.NULL);
52 //composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
53 GridLayout gridLayout = new GridLayout();
54 composite.setLayout(gridLayout);
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.setReuseExistingTaxaWhenPossible(!configurator.isReuseExistingTaxaWhenPossible());
204 }
205 });
206
207 Label labelRef = new Label(composite, SWT.NONE);
208 labelRef.setText("Biocase provider for associated DNA");
209 new Label(composite, SWT.NONE);
210 textDNAProviderString = new Text(composite, SWT.NONE);
211 textDNAProviderString.setEnabled(true);
212 textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1));
213
214
215
216 setControl(composite);
217 }
218
219 public void saveConfigToPrefernceStore() {
220 PreferencesUtil.setStringValue(PreferencePredicate.AbcdImportConfig.getKey(), configurator.toString());
221
222 }
223
224 public String createConfigString(){
225 return configurator.toString();
226
227 }
228
229 public void setConfigurator(Abcd206ImportConfigurator configurator) {
230 this.configurator = configurator;
231 }
232
233
234 }