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
.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
.layout
.GridLayout
;
21 import org
.eclipse
.swt
.widgets
.Button
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
24 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
25 import eu
.etaxonomy
.taxeditor
.databaseAdmin
.wizard
.AbstractPreferenceWizard
;
26 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
27 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
34 public class AbcdImportConfiguratorWizardPage
extends AbstractPreferenceWizard
{
36 public static final String PAGE_NAME
= "AbcdImportConfiguratorWizardPage";
38 private Abcd206ImportConfigurator configurator
;
40 private List
<URI
> biocaseProvider
= new ArrayList
<>();
42 private boolean isPreferencePage
= false;
44 protected AbcdImportConfiguratorWizardPage(String title
, String description
, Abcd206ImportConfigurator configurator
) {
46 this.configurator
= configurator
;
48 setDescription(description
);
51 protected AbcdImportConfiguratorWizardPage(String title
, String description
, Abcd206ImportConfigurator configurator
, boolean isPreferencePage
) {
53 this.configurator
= configurator
;
55 setDescription(description
);
56 this.isPreferencePage
= isPreferencePage
;
59 public static AbcdImportConfiguratorWizardPage
createPage(Abcd206ImportConfigurator configurator
){
60 return new AbcdImportConfiguratorWizardPage("Configure import parameters",
61 "Tooltips will explain parameters in more detail", configurator
);
64 public static AbcdImportConfiguratorWizardPage
createPreferencePage(Abcd206ImportConfigurator configurator
){
65 return new AbcdImportConfiguratorWizardPage("Configure import parameters",
66 "Tooltips will explain parameters in more detail", configurator
, true);
73 public void createControl(Composite parent
) {
74 final Composite composite
= new Composite(parent
, SWT
.NULL
);
75 //composite = addTab(Messages.DatabasePreferencesPage_Define_Default_NomenclaturalCode);
76 GridLayout gridLayout
= new GridLayout();
77 composite
.setLayout(gridLayout
);
78 // if (isPreferencePage){
79 // ListComponent list = new ListComponent(composite, composite.getStyle());
82 Button checkBoxMediaSpecimen
= new Button(composite
, SWT
.CHECK
);
83 checkBoxMediaSpecimen
.setSelection(configurator
.isAddMediaAsMediaSpecimen());
84 checkBoxMediaSpecimen
.setText("Import media as media specimen");
86 .setToolTipText("Any media attached to a ABCD unit will be imported as a sub derivative of the specimen created from this unit");
87 checkBoxMediaSpecimen
.addSelectionListener(new SelectionAdapter() {
89 public void widgetSelected(SelectionEvent e
) {
90 configurator
.setAddMediaAsMediaSpecimen(!configurator
.isAddMediaAsMediaSpecimen());
94 Button checkBoxIgnoreExisting
= new Button(composite
, SWT
.CHECK
);
95 checkBoxIgnoreExisting
.setSelection(configurator
.isIgnoreImportOfExistingSpecimen());
96 checkBoxIgnoreExisting
.setText("Do not import existing specimens");
97 checkBoxIgnoreExisting
98 .setToolTipText("Specimens that have previously been imported will be ignored in this import");
99 checkBoxIgnoreExisting
.addSelectionListener(new SelectionAdapter() {
101 public void widgetSelected(SelectionEvent e
) {
102 configurator
.setIgnoreImportOfExistingSpecimen(!configurator
.isIgnoreImportOfExistingSpecimen());
106 Button checkBoxIgnoreAuthorship
= new Button(composite
, SWT
.CHECK
);
107 checkBoxIgnoreAuthorship
.setSelection(configurator
.isIgnoreAuthorship());
108 checkBoxIgnoreAuthorship
.setText("Ignore Authorship for name matching");
109 checkBoxIgnoreAuthorship
110 .setToolTipText("Name matching with existing names will be done without "
111 + "the authorship part of the name");
112 checkBoxIgnoreAuthorship
.addSelectionListener(new SelectionAdapter() {
114 public void widgetSelected(SelectionEvent e
) {
115 configurator
.setIgnoreAuthorship(!configurator
.isIgnoreAuthorship());
119 Button checkBoxMapUnitIdToCatalogNumber
= new Button(composite
, SWT
.CHECK
);
120 checkBoxMapUnitIdToCatalogNumber
.setSelection(configurator
.isMapUnitIdToCatalogNumber());
121 checkBoxMapUnitIdToCatalogNumber
.setText("Map UnitID to catalog number");
122 checkBoxMapUnitIdToCatalogNumber
123 .setToolTipText("The UnitID of every ABCD unit will be mapped the catalog number "
124 + "of the specimen");
125 checkBoxMapUnitIdToCatalogNumber
.addSelectionListener(new SelectionAdapter() {
127 public void widgetSelected(SelectionEvent e
) {
128 configurator
.setMapUnitIdToCatalogNumber(!configurator
.isMapUnitIdToCatalogNumber());
131 //TODO: only one of the mappings can be checked!
132 Button checkBoxMapUnitIdToAccessionNumber
= new Button(composite
, SWT
.CHECK
);
133 checkBoxMapUnitIdToAccessionNumber
.setSelection(configurator
.isMapUnitIdToAccessionNumber());
134 checkBoxMapUnitIdToAccessionNumber
.setText("Map UnitID to accession number");
135 checkBoxMapUnitIdToAccessionNumber
136 .setToolTipText("The UnitID of every ABCD unit will be mapped the accession number "
137 + "of the specimen");
138 checkBoxMapUnitIdToAccessionNumber
.addSelectionListener(new SelectionAdapter() {
140 public void widgetSelected(SelectionEvent e
) {
141 configurator
.setMapUnitIdToAccessionNumber(!configurator
.isMapUnitIdToAccessionNumber());
145 Button checkBoxMapUnitIdToBarcode
= new Button(composite
, SWT
.CHECK
);
146 checkBoxMapUnitIdToBarcode
.setSelection(configurator
.isMapUnitIdToBarcode());
147 checkBoxMapUnitIdToBarcode
.setText("Map UnitID to barcode");
148 checkBoxMapUnitIdToBarcode
149 .setToolTipText("The UnitID of every ABCD unit will be mapped the barcode "
150 + "of the specimen");
151 checkBoxMapUnitIdToBarcode
.addSelectionListener(new SelectionAdapter() {
153 public void widgetSelected(SelectionEvent e
) {
154 configurator
.setMapUnitIdToBarcode(!configurator
.isMapUnitIdToBarcode());
158 Button checkBoxRemoveCountry
= new Button(composite
, SWT
.CHECK
);
159 checkBoxRemoveCountry
.setSelection(configurator
.isRemoveCountryFromLocalityText());
160 checkBoxRemoveCountry
.setText("Remove country from locality text");
161 checkBoxRemoveCountry
162 .setToolTipText("If the locality text contains information about the "
163 + "country which is additionally stored in other ABCD "
164 + "elements then it is removed from the locality text");
165 checkBoxRemoveCountry
.addSelectionListener(new SelectionAdapter() {
167 public void widgetSelected(SelectionEvent e
) {
168 configurator
.setRemoveCountryFromLocalityText(!configurator
.isRemoveCountryFromLocalityText());
172 Button checkBoxMoveToDefaultClassification
= new Button(composite
, SWT
.CHECK
);
173 checkBoxMoveToDefaultClassification
.setSelection(configurator
.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() {
180 public void widgetSelected(SelectionEvent e
) {
181 configurator
.setMoveNewTaxaToDefaultClassification(!configurator
.isMoveNewTaxaToDefaultClassification());
185 Button checkBoxImportSiblings
= new Button(composite
, SWT
.CHECK
);
186 checkBoxImportSiblings
.setSelection(configurator
.isGetSiblings());
187 checkBoxImportSiblings
.setText("Import all children of cultures or tissue samples");
188 checkBoxImportSiblings
189 .setToolTipText("for a tissue sample or culture all children will be searched and imported");
190 checkBoxImportSiblings
.addSelectionListener(new SelectionAdapter() {
192 public void widgetSelected(SelectionEvent e
) {
193 configurator
.setGetSiblings(!configurator
.isGetSiblings());
197 Button checkBoxAddIndividualsAssociations
= new Button(composite
, SWT
.CHECK
);
198 checkBoxAddIndividualsAssociations
.setSelection(configurator
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
199 checkBoxAddIndividualsAssociations
.setText("Create an Individual Association for each Specimen");
200 checkBoxAddIndividualsAssociations
201 .setToolTipText("for each specimen associated to a taxon an indiviadual association to this taxon is created");
202 checkBoxAddIndividualsAssociations
.addSelectionListener(new SelectionAdapter() {
204 public void widgetSelected(SelectionEvent e
) {
205 configurator
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
209 Button checkBoxReuseDescriptiveGroups
= new Button(composite
, SWT
.CHECK
);
210 checkBoxReuseDescriptiveGroups
.setSelection(configurator
.isReuseExistingDescriptiveGroups());
211 checkBoxReuseDescriptiveGroups
.setText("Reuse existing descriptive group");
212 checkBoxReuseDescriptiveGroups
213 .setToolTipText("reuse one of the existing descriptive groups or create a new one for every import");
214 checkBoxReuseDescriptiveGroups
.addSelectionListener(new SelectionAdapter() {
216 public void widgetSelected(SelectionEvent e
) {
217 configurator
.setReuseExistingDescriptiveGroups(!configurator
.isReuseExistingDescriptiveGroups());
221 Button checkBoxReuseExistingTaxa
= new Button(composite
, SWT
.CHECK
);
222 checkBoxReuseExistingTaxa
.setSelection(configurator
.isReuseExistingTaxaWhenPossible());
223 checkBoxReuseExistingTaxa
.setText("Reuse existing taxa when possible");
224 checkBoxReuseExistingTaxa
225 .setToolTipText("reuse existing taxa when the name matches the identified name of the specimen");
226 checkBoxReuseExistingTaxa
.addSelectionListener(new SelectionAdapter() {
228 public void widgetSelected(SelectionEvent e
) {
229 configurator
.setReuseExistingDescriptiveGroups(!configurator
.isReuseExistingDescriptiveGroups());
234 setControl(composite
);
237 public void saveConfigToPrefernceStore() {
238 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
,
239 configurator
.isAddIndividualsAssociationsSuchAsSpecimenAndObservations());
240 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
,
241 configurator
.isAddMediaAsMediaSpecimen());
242 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
,
243 configurator
.isAllowReuseOtherClassifications());
244 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
,
245 configurator
.isDeduplicateClassifications());
246 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
,
247 configurator
.isDeduplicateReferences());
248 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
,
249 configurator
.isGetSiblings());
250 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
,
251 configurator
.isIgnoreAuthorship());
252 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
,
253 configurator
.isIgnoreImportOfExistingSpecimen());
254 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
,
255 configurator
.isMapUnitIdToAccessionNumber());
256 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
,
257 configurator
.isMapUnitIdToBarcode());
258 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
,
259 configurator
.isMapUnitIdToCatalogNumber());
260 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
,
261 configurator
.isMoveNewTaxaToDefaultClassification());
262 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN
,
263 configurator
.isOverwriteExistingSpecimens());
264 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
,
265 configurator
.isReuseExistingDescriptiveGroups());
266 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA
,
267 configurator
.isReuseExistingMetaData());
268 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
,
269 configurator
.isReuseExistingTaxaWhenPossible());
273 public String
createConfigString(){
274 return configurator
.toString();
278 protected IPreferenceStore
doGetPreferenceStore() {
279 return PreferencesUtil
.getPreferenceStore();