Project

General

Profile

Download (18.7 KB) Statistics
| Branch: | Tag: | Revision:
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.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.SelectionAdapter;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.events.SelectionListener;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Combo;
25
import org.eclipse.swt.widgets.Composite;
26

    
27
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
28
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
29
import eu.etaxonomy.taxeditor.databaseAdmin.wizard.AbstractPreferenceWizard;
30
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
31
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
32

    
33
/**
34
 *
35
 * @author pplitzner
36
 *
37
 */
38
public class AbcdImportConfiguratorWizardPage extends AbstractPreferenceWizard implements SelectionListener {
39

    
40
	public static final String PAGE_NAME = "AbcdImportConfiguratorWizardPage";
41

    
42
	private Abcd206ImportConfigurator abcdImportConfigurator;
43

    
44
	private List<URI> biocaseProvider = new ArrayList<>();
45

    
46
	private boolean isPreferencePage = false;
47

    
48
    private Combo nomenclaturalCodeSelectionCombo;
49

    
50
	protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator) {
51
        super(PAGE_NAME);
52
        this.abcdImportConfigurator = configurator;
53
        setTitle(title);
54
        setDescription(description);
55
    }
56

    
57
	protected AbcdImportConfiguratorWizardPage(String title, String description, Abcd206ImportConfigurator configurator, boolean isPreferencePage) {
58
		super(PAGE_NAME);
59
		this.abcdImportConfigurator = configurator;
60
		setTitle(title);
61
		setDescription(description);
62
		this.isPreferencePage = isPreferencePage;
63
	}
64

    
65
	public static AbcdImportConfiguratorWizardPage createPage(Abcd206ImportConfigurator configurator){
66
		return new AbcdImportConfiguratorWizardPage("Configure import parameters",
67
				"Tooltips will explain parameters in more detail", configurator);
68
	}
69

    
70
	public static AbcdImportConfiguratorWizardPage createPreferencePage(Abcd206ImportConfigurator configurator){
71
        return new AbcdImportConfiguratorWizardPage("Configure import parameters",
72
                "Tooltips will explain parameters in more detail", configurator, true);
73
    }
74

    
75

    
76

    
77
	/** {@inheritDoc} */
78
	@Override
79
    public void createControl(Composite parent) {
80
		final Composite composite = new Composite(parent, SWT.NULL);
81
		//composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
82
		GridLayout gridLayout = new GridLayout();
83
		composite.setLayout(gridLayout);
84
//        if (isPreferencePage){
85
//            ListComponent list = new ListComponent(composite, composite.getStyle());
86
//        }
87

    
88
		Button checkBoxMediaSpecimen = new Button(composite, SWT.CHECK);
89
		checkBoxMediaSpecimen.setSelection(abcdImportConfigurator.isAddMediaAsMediaSpecimen());
90
		checkBoxMediaSpecimen.setText("Import media as media specimen");
91
		checkBoxMediaSpecimen
92
				.setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
93
		checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() {
94
			@Override
95
			public void widgetSelected(SelectionEvent e) {
96
				abcdImportConfigurator.setAddMediaAsMediaSpecimen(!abcdImportConfigurator.isAddMediaAsMediaSpecimen());
97
			}
98
		});
99

    
100
		Button checkBoxIgnoreExisting = new Button(composite, SWT.CHECK);
101
		checkBoxIgnoreExisting.setSelection(abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
102
		checkBoxIgnoreExisting.setText("Do not import existing specimens");
103
		checkBoxIgnoreExisting
104
		.setToolTipText("Specimens that have previously been imported will be ignored in this import");
105
		checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() {
106
			@Override
107
			public void widgetSelected(SelectionEvent e) {
108
				abcdImportConfigurator.setIgnoreImportOfExistingSpecimen(!abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
109
			}
110
		});
111

    
112
		Button checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK);
113
		checkBoxIgnoreAuthorship.setSelection(abcdImportConfigurator.isIgnoreAuthorship());
114
		checkBoxIgnoreAuthorship.setText("Ignore Authorship for name matching");
115
		checkBoxIgnoreAuthorship
116
		.setToolTipText("Name matching with existing names will be done without "
117
				+ "the authorship part of the name");
118
		checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() {
119
			@Override
120
			public void widgetSelected(SelectionEvent e) {
121
				abcdImportConfigurator.setIgnoreAuthorship(!abcdImportConfigurator.isIgnoreAuthorship());
122
			}
123
		});
124

    
125
		Button checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.CHECK);
126
		checkBoxMapUnitIdToCatalogNumber.setSelection(abcdImportConfigurator.isMapUnitIdToCatalogNumber());
127
		checkBoxMapUnitIdToCatalogNumber.setText("Map UnitID to catalog number");
128
		checkBoxMapUnitIdToCatalogNumber
129
		.setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
130
				+ "of the specimen");
131
		checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() {
132
			@Override
133
			public void widgetSelected(SelectionEvent e) {
134
				abcdImportConfigurator.setMapUnitIdToCatalogNumber(!abcdImportConfigurator.isMapUnitIdToCatalogNumber());
135
			}
136
		});
137
//TODO: only one of the mappings can be checked!
138
		Button checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.CHECK);
139
		checkBoxMapUnitIdToAccessionNumber.setSelection(abcdImportConfigurator.isMapUnitIdToAccessionNumber());
140
		checkBoxMapUnitIdToAccessionNumber.setText("Map UnitID to accession number");
141
		checkBoxMapUnitIdToAccessionNumber
142
		.setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
143
				+ "of the specimen");
144
		checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() {
145
			@Override
146
			public void widgetSelected(SelectionEvent e) {
147
				abcdImportConfigurator.setMapUnitIdToAccessionNumber(!abcdImportConfigurator.isMapUnitIdToAccessionNumber());
148
			}
149
		});
150

    
151
		Button checkBoxMapUnitIdToBarcode = new Button(composite, SWT.CHECK);
152
		checkBoxMapUnitIdToBarcode.setSelection(abcdImportConfigurator.isMapUnitIdToBarcode());
153
		checkBoxMapUnitIdToBarcode.setText("Map UnitID to barcode");
154
		checkBoxMapUnitIdToBarcode
155
		.setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
156
				+ "of the specimen");
157
		checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() {
158
			@Override
159
			public void widgetSelected(SelectionEvent e) {
160
				abcdImportConfigurator.setMapUnitIdToBarcode(!abcdImportConfigurator.isMapUnitIdToBarcode());
161
			}
162
		});
163

    
164
		Button checkBoxRemoveCountry = new Button(composite, SWT.CHECK);
165
		checkBoxRemoveCountry.setSelection(abcdImportConfigurator.isRemoveCountryFromLocalityText());
166
		checkBoxRemoveCountry.setText("Remove country from locality text");
167
		checkBoxRemoveCountry
168
		.setToolTipText("If the locality text contains information about the "
169
				+ "country which is additionally stored in other ABCD "
170
				+ "elements then it is removed from the locality text");
171
		checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() {
172
			@Override
173
			public void widgetSelected(SelectionEvent e) {
174
				abcdImportConfigurator.setRemoveCountryFromLocalityText(!abcdImportConfigurator.isRemoveCountryFromLocalityText());
175
			}
176
		});
177

    
178
		Button checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK);
179
		checkBoxMoveToDefaultClassification.setSelection(abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
180
		checkBoxMoveToDefaultClassification.setText("Create new classification for new taxa");
181
		checkBoxMoveToDefaultClassification
182
		.setToolTipText("For taxa that do not exist in the data base "
183
				+ "a new classification will be created");
184
		checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() {
185
			@Override
186
			public void widgetSelected(SelectionEvent e) {
187
				abcdImportConfigurator.setMoveNewTaxaToDefaultClassification(!abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
188
			}
189
		});
190

    
191
		Button checkBoxImportSiblings = new Button(composite, SWT.CHECK);
192
		checkBoxImportSiblings.setSelection(abcdImportConfigurator.isGetSiblings());
193
		checkBoxImportSiblings.setText("Import all children of cultures or tissue samples");
194
		checkBoxImportSiblings
195
        	.setToolTipText("For a tissue sample or culture all children will be searched and imported");
196
		checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
197
            @Override
198
            public void widgetSelected(SelectionEvent e) {
199
                abcdImportConfigurator.setGetSiblings(checkBoxImportSiblings.getSelection());
200
            }
201
        });
202

    
203
        Button checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK);
204
        checkBoxAddIndividualsAssociations.setSelection(abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
205
        checkBoxAddIndividualsAssociations.setText("Create an Individual Association for each Specimen");
206
        checkBoxAddIndividualsAssociations
207
        	.setToolTipText("For each specimen associated to a taxon an indiviadual association to this taxon is created");
208
        checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() {
209
            @Override
210
            public void widgetSelected(SelectionEvent e) {
211
                abcdImportConfigurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
212
            }
213
        });
214

    
215
        Button checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK);
216
        checkBoxReuseDescriptiveGroups.setSelection(abcdImportConfigurator.isReuseExistingDescriptiveGroups());
217
        checkBoxReuseDescriptiveGroups.setText("Reuse existing descriptive group");
218
        checkBoxReuseDescriptiveGroups
219
        	.setToolTipText("Reuse one of the existing descriptive groups or create a new one for every import");
220
        checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() {
221
            @Override
222
            public void widgetSelected(SelectionEvent e) {
223
                abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
224
            }
225
        });
226

    
227
        Button checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK);
228
        checkBoxReuseExistingTaxa.setSelection(abcdImportConfigurator.isReuseExistingTaxaWhenPossible());
229
        checkBoxReuseExistingTaxa.setText("Reuse existing taxa when possible");
230
        checkBoxReuseExistingTaxa
231
        	.setToolTipText("Reuse existing taxa when the name matches the identified name of the specimen");
232
        checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
233
            @Override
234
            public void widgetSelected(SelectionEvent e) {
235
                abcdImportConfigurator.setReuseExistingDescriptiveGroups(!abcdImportConfigurator.isReuseExistingDescriptiveGroups());
236
            }
237
        });
238

    
239
        GridData gridData = new GridData();
240
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
241
        gridData.horizontalIndent = 5;
242
//      classificationSelection.setLayoutData(gridData);
243

    
244
        nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
245
        nomenclaturalCodeSelectionCombo.setLayoutData(gridData);
246
        for(NomenclaturalCode code: NomenclaturalCode.values()){
247
            nomenclaturalCodeSelectionCombo.add(code.getKey());
248
        }
249

    
250

    
251

    
252
        // TODO remember last selection
253
        nomenclaturalCodeSelectionCombo.addSelectionListener(this);
254
		setControl(composite);
255
	}
256

    
257
	@Override
258
    public void widgetSelected(SelectionEvent e) {
259
        this.abcdImportConfigurator.setNomenclaturalCode(NomenclaturalCode.getByKey(nomenclaturalCodeSelectionCombo.getText()));
260

    
261
    }
262

    
263
	 public void saveConfigToPrefernceStore() {
264
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS,
265
	                abcdImportConfigurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
266
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN,
267
                    abcdImportConfigurator.isAddMediaAsMediaSpecimen());
268
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS,
269
                    abcdImportConfigurator.isAllowReuseOtherClassifications());
270
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS,
271
                    abcdImportConfigurator.isDeduplicateClassifications());
272
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES,
273
                    abcdImportConfigurator.isDeduplicateReferences());
274
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS,
275
                    abcdImportConfigurator.isGetSiblings());
276
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP,
277
                    abcdImportConfigurator.isIgnoreAuthorship());
278
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN,
279
                    abcdImportConfigurator.isIgnoreImportOfExistingSpecimen());
280
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER,
281
                    abcdImportConfigurator.isMapUnitIdToAccessionNumber());
282
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE,
283
                    abcdImportConfigurator.isMapUnitIdToBarcode());
284
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER,
285
                    abcdImportConfigurator.isMapUnitIdToCatalogNumber());
286
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION,
287
                    abcdImportConfigurator.isMoveNewTaxaToDefaultClassification());
288
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN,
289
                    abcdImportConfigurator.isOverwriteExistingSpecimens());
290
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS,
291
                    abcdImportConfigurator.isReuseExistingDescriptiveGroups());
292
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA,
293
                    abcdImportConfigurator.isReuseExistingMetaData());
294
	        PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE,
295
                    abcdImportConfigurator.isReuseExistingTaxaWhenPossible());
296
	        if ( abcdImportConfigurator.getNomenclaturalCode() != null){
297
	            PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE, abcdImportConfigurator.getNomenclaturalCode().getKey());
298
	        }
299

    
300

    
301
	    }
302

    
303
	 public String createConfigString(){
304
	    return abcdImportConfigurator.toString();
305

    
306
	 }
307

    
308
	 protected IPreferenceStore doGetPreferenceStore() {
309
	        return PreferencesUtil.getPreferenceStore();
310
	    }
311

    
312
    /* (non-Javadoc)
313
     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
314
     */
315
    @Override
316
    public void widgetDefaultSelected(SelectionEvent e) {
317
        // TODO Auto-generated method stub
318

    
319
    }
320

    
321
    public void createAbcdImportConfig() {
322
        this.abcdImportConfigurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
323
        this.abcdImportConfigurator.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
324
        this.abcdImportConfigurator.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
325
        //this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
326
        this.abcdImportConfigurator.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
327
        this.abcdImportConfigurator.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
328
       // this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
329
        this.abcdImportConfigurator.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
330
        this.abcdImportConfigurator.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
331
        this.abcdImportConfigurator.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
332
        this.abcdImportConfigurator.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
333
        this.abcdImportConfigurator.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
334
        this.abcdImportConfigurator.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
335
        this.abcdImportConfigurator.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
336
        this.abcdImportConfigurator.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
337
        this.abcdImportConfigurator.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
338

    
339
    }
340
}
(1-1/30)