2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
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
.layout
.GridData
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.widgets
.Button
;
23 import org
.eclipse
.swt
.widgets
.Combo
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.Label
;
26 import org
.eclipse
.swt
.widgets
.Text
;
28 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
29 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
30 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
31 import eu
.etaxonomy
.taxeditor
.databaseAdmin
.wizard
.AbstractPreferenceWizard
;
32 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
39 public class AbcdImportConfiguratorWizardPage
extends AbstractPreferenceWizard
implements SelectionListener
{
41 public static final String PAGE_NAME
= "AbcdImportConfiguratorWizardPage";
43 private Abcd206ImportConfigurator abcdImportConfigurator
;
45 private List
<URI
> biocaseProvider
= new ArrayList
<>();
47 private boolean isPreferencePage
= false;
49 private Combo nomenclaturalCodeSelectionCombo
;
50 private Text textDNAProviderString
;
52 protected AbcdImportConfiguratorWizardPage(String title
, String description
, Abcd206ImportConfigurator configurator
) {
54 this.abcdImportConfigurator
= configurator
;
56 setDescription(description
);
59 protected AbcdImportConfiguratorWizardPage(String title
, String description
, Abcd206ImportConfigurator configurator
, boolean isPreferencePage
) {
61 this.abcdImportConfigurator
= configurator
;
63 setDescription(description
);
64 this.isPreferencePage
= isPreferencePage
;
67 public static AbcdImportConfiguratorWizardPage
createPage(Abcd206ImportConfigurator configurator
){
68 return new AbcdImportConfiguratorWizardPage("Configure import parameters",
69 "Tooltips will explain parameters in more detail", configurator
);
72 public static AbcdImportConfiguratorWizardPage
createPreferencePage(Abcd206ImportConfigurator configurator
){
73 return new AbcdImportConfiguratorWizardPage("Configure import parameters",
74 "Tooltips will explain parameters in more detail", configurator
, true);
81 public void createControl(Composite parent
) {
82 final Composite composite
= new Composite(parent
, SWT
.NULL
);
83 //composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
84 GridLayout gridLayout
= new GridLayout();
85 composite
.setLayout(gridLayout
);
86 // if (isPreferencePage){
87 // ListComponent list = new ListComponent(composite, composite.getStyle());
90 Button checkBoxMediaSpecimen
= new Button(composite
, SWT
.CHECK
);
91 checkBoxMediaSpecimen
.setSelection(abcdImportConfigurator
.isAddMediaAsMediaSpecimen());
92 checkBoxMediaSpecimen
.setText("Import media as media specimen");
94 .setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
95 checkBoxMediaSpecimen
.addSelectionListener(new SelectionAdapter() {
97 public void widgetSelected(SelectionEvent e
) {
98 abcdImportConfigurator
.setAddMediaAsMediaSpecimen(!abcdImportConfigurator
.isAddMediaAsMediaSpecimen());
102 Button checkBoxIgnoreExisting
= new Button(composite
, SWT
.CHECK
);
103 checkBoxIgnoreExisting
.setSelection(abcdImportConfigurator
.isIgnoreImportOfExistingSpecimen());
104 checkBoxIgnoreExisting
.setText("Do not import existing specimens");
105 checkBoxIgnoreExisting
106 .setToolTipText("Specimens that have previously been imported will be ignored in this import");
107 checkBoxIgnoreExisting
.addSelectionListener(new SelectionAdapter() {
109 public void widgetSelected(SelectionEvent e
) {
110 abcdImportConfigurator
.setIgnoreImportOfExistingSpecimen(!abcdImportConfigurator
.isIgnoreImportOfExistingSpecimen());
114 Button checkBoxIgnoreAuthorship
= new Button(composite
, SWT
.CHECK
);
115 checkBoxIgnoreAuthorship
.setSelection(abcdImportConfigurator
.isIgnoreAuthorship());
116 checkBoxIgnoreAuthorship
.setText("Ignore Authorship for name matching");
117 checkBoxIgnoreAuthorship
118 .setToolTipText("Name matching with existing names will be done without "
119 + "the authorship part of the name");
120 checkBoxIgnoreAuthorship
.addSelectionListener(new SelectionAdapter() {
122 public void widgetSelected(SelectionEvent e
) {
123 abcdImportConfigurator
.setIgnoreAuthorship(!abcdImportConfigurator
.isIgnoreAuthorship());
127 Button checkBoxMapUnitIdToCatalogNumber
= new Button(composite
, SWT
.CHECK
);
128 checkBoxMapUnitIdToCatalogNumber
.setSelection(abcdImportConfigurator
.isMapUnitIdToCatalogNumber());
129 checkBoxMapUnitIdToCatalogNumber
.setText("Map UnitID to catalog number");
130 checkBoxMapUnitIdToCatalogNumber
131 .setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
132 + "of the specimen");
133 checkBoxMapUnitIdToCatalogNumber
.addSelectionListener(new SelectionAdapter() {
135 public void widgetSelected(SelectionEvent e
) {
136 abcdImportConfigurator
.setMapUnitIdToCatalogNumber(!abcdImportConfigurator
.isMapUnitIdToCatalogNumber());
139 //TODO: only one of the mappings can be checked!
140 Button checkBoxMapUnitIdToAccessionNumber
= new Button(composite
, SWT
.CHECK
);
141 checkBoxMapUnitIdToAccessionNumber
.setSelection(abcdImportConfigurator
.isMapUnitIdToAccessionNumber());
142 checkBoxMapUnitIdToAccessionNumber
.setText("Map UnitID to accession number");
143 checkBoxMapUnitIdToAccessionNumber
144 .setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
145 + "of the specimen");
146 checkBoxMapUnitIdToAccessionNumber
.addSelectionListener(new SelectionAdapter() {
148 public void widgetSelected(SelectionEvent e
) {
149 abcdImportConfigurator
.setMapUnitIdToAccessionNumber(!abcdImportConfigurator
.isMapUnitIdToAccessionNumber());
153 Button checkBoxMapUnitIdToBarcode
= new Button(composite
, SWT
.CHECK
);
154 checkBoxMapUnitIdToBarcode
.setSelection(abcdImportConfigurator
.isMapUnitIdToBarcode());
155 checkBoxMapUnitIdToBarcode
.setText("Map UnitID to barcode");
156 checkBoxMapUnitIdToBarcode
157 .setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
158 + "of the specimen");
159 checkBoxMapUnitIdToBarcode
.addSelectionListener(new SelectionAdapter() {
161 public void widgetSelected(SelectionEvent e
) {
162 abcdImportConfigurator
.setMapUnitIdToBarcode(!abcdImportConfigurator
.isMapUnitIdToBarcode());
166 Button checkBoxRemoveCountry
= new Button(composite
, SWT
.CHECK
);
167 checkBoxRemoveCountry
.setSelection(abcdImportConfigurator
.isRemoveCountryFromLocalityText());
168 checkBoxRemoveCountry
.setText("Remove country from locality text");
169 checkBoxRemoveCountry
170 .setToolTipText("If the locality text contains information about the "
171 + "country which is additionally stored in other ABCD "
172 + "elements then it is removed from the locality text");
173 checkBoxRemoveCountry
.addSelectionListener(new SelectionAdapter() {
175 public void widgetSelected(SelectionEvent e
) {
176 abcdImportConfigurator
.setRemoveCountryFromLocalityText(!abcdImportConfigurator
.isRemoveCountryFromLocalityText());
180 Button checkBoxMoveToDefaultClassification
= new Button(composite
, SWT
.CHECK
);
181 checkBoxMoveToDefaultClassification
.setSelection(abcdImportConfigurator
.isMoveNewTaxaToDefaultClassification());
182 checkBoxMoveToDefaultClassification
.setText("Create new classification for new taxa");
183 checkBoxMoveToDefaultClassification
184 .setToolTipText("For taxa that do not exist in the data base "
185 + "a new classification will be created");
186 checkBoxMoveToDefaultClassification
.addSelectionListener(new SelectionAdapter() {
188 public void widgetSelected(SelectionEvent e
) {
189 abcdImportConfigurator
.setMoveNewTaxaToDefaultClassification(!abcdImportConfigurator
.isMoveNewTaxaToDefaultClassification());
193 Button checkBoxImportSiblings
= new Button(composite
, SWT
.CHECK
);
194 checkBoxImportSiblings
.setSelection(abcdImportConfigurator
.isGetSiblings());
195 checkBoxImportSiblings
.setText("Import all children of cultures or tissue samples");
196 checkBoxImportSiblings
197 .setToolTipText("For a tissue sample or culture all children will be searched and imported");
198 checkBoxImportSiblings
.addSelectionListener(new SelectionAdapter() {
200 public void widgetSelected(SelectionEvent e
) {
201 abcdImportConfigurator
.setGetSiblings(checkBoxImportSiblings
.getSelection());
205 Button checkBoxAddIndividualsAssociations
= new Button(composite
, SWT
.CHECK
);
206 checkBoxAddIndividualsAssociations
.setSelection(abcdImportConfigurator
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
207 checkBoxAddIndividualsAssociations
.setText("Create an Individual Association for each Specimen");
208 checkBoxAddIndividualsAssociations
209 .setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
210 checkBoxAddIndividualsAssociations
.addSelectionListener(new SelectionAdapter() {
212 public void widgetSelected(SelectionEvent e
) {
213 abcdImportConfigurator
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!abcdImportConfigurator
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
217 Button checkBoxReuseDescriptiveGroups
= new Button(composite
, SWT
.CHECK
);
218 checkBoxReuseDescriptiveGroups
.setSelection(abcdImportConfigurator
.isReuseExistingDescriptiveGroups());
219 checkBoxReuseDescriptiveGroups
.setText("Reuse existing descriptive group");
220 checkBoxReuseDescriptiveGroups
221 .setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
222 checkBoxReuseDescriptiveGroups
.addSelectionListener(new SelectionAdapter() {
224 public void widgetSelected(SelectionEvent e
) {
225 abcdImportConfigurator
.setReuseExistingDescriptiveGroups(!abcdImportConfigurator
.isReuseExistingDescriptiveGroups());
229 Button checkBoxReuseExistingTaxa
= new Button(composite
, SWT
.CHECK
);
230 checkBoxReuseExistingTaxa
.setSelection(abcdImportConfigurator
.isReuseExistingTaxaWhenPossible());
231 checkBoxReuseExistingTaxa
.setText("Reuse existing taxa when possible");
232 checkBoxReuseExistingTaxa
233 .setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
234 checkBoxReuseExistingTaxa
.addSelectionListener(new SelectionAdapter() {
236 public void widgetSelected(SelectionEvent e
) {
237 abcdImportConfigurator
.setReuseExistingDescriptiveGroups(!abcdImportConfigurator
.isReuseExistingDescriptiveGroups());
241 Label labelRef
= new Label(composite
, SWT
.NONE
);
242 labelRef
.setText("Biocase provider for associated DNA");
243 new Label(composite
, SWT
.NONE
);
244 textDNAProviderString
= new Text(composite
, SWT
.NONE
);
245 textDNAProviderString
.setEnabled(true);
246 textDNAProviderString
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, true, 1, 1));
247 if (abcdImportConfigurator
.getDnaSoure() != null){
248 textDNAProviderString
.setText(abcdImportConfigurator
.getDnaSoure().toString());
251 GridData gridData
= new GridData();
252 gridData
= new GridData(GridData
.BEGINNING
, GridData
.CENTER
, true, false);
253 gridData
.horizontalIndent
= 5;
254 // classificationSelection.setLayoutData(gridData);
256 nomenclaturalCodeSelectionCombo
= new Combo(composite
, SWT
.BORDER
| SWT
.READ_ONLY
);
257 nomenclaturalCodeSelectionCombo
.setLayoutData(gridData
);
258 for(NomenclaturalCode code
: NomenclaturalCode
.values()){
259 nomenclaturalCodeSelectionCombo
.add(code
.getKey());
264 // TODO remember last selection
265 nomenclaturalCodeSelectionCombo
.addSelectionListener(this);
267 if (abcdImportConfigurator
.getNomenclaturalCode() != null){
268 for (String label
: nomenclaturalCodeSelectionCombo
.getItems()){
269 if (label
.equals(abcdImportConfigurator
.getNomenclaturalCode().getKey())){
270 nomenclaturalCodeSelectionCombo
.select(index
);
276 setControl(composite
);
280 public void widgetSelected(SelectionEvent e
) {
281 this.abcdImportConfigurator
.setNomenclaturalCode(NomenclaturalCode
.getByKey(nomenclaturalCodeSelectionCombo
.getText()));
285 public void saveConfigToPrefernceStore() {
286 PreferencesUtil
.setStringValue(PreferencePredicate
.AbcdImportConfig
.getKey(), abcdImportConfigurator
.toString());
291 public String
createConfigString(){
292 return abcdImportConfigurator
.toString();
299 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
302 public void widgetDefaultSelected(SelectionEvent e
) {
303 // TODO Auto-generated method stub
307 public void createAbcdImportConfig() {
308 this.abcdImportConfigurator
= PreferencesUtil
.getLocalAbcdImportConfigurator();