2 * Copyright (C) 2016 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.
9 package eu
.etaxonomy
.taxeditor
.databaseAdmin
.wizard
;
11 import java
.util
.List
;
13 import org
.eclipse
.jface
.preference
.IPreferenceStore
;
14 import org
.eclipse
.jface
.wizard
.IWizard
;
15 import org
.eclipse
.jface
.wizard
.IWizardPage
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
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
.Combo
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Label
;
26 import eu
.etaxonomy
.cdm
.io
.specimen
.abcd206
.in
.Abcd206ImportConfigurator
;
27 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmPreference
;
28 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
29 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
30 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
31 import eu
.etaxonomy
.taxeditor
.preference
.IPreferenceKeys
;
32 import eu
.etaxonomy
.taxeditor
.preference
.NameDetailsConfigurator
;
33 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
40 public class DatabasePreferencesPage
extends AbstractPreferenceWizard
implements IWizardPage
{
42 CdmPreference preferedNomenclaturalCode
;
43 NameDetailsConfigurator config
;
44 CdmPreference isRedListPreference
;
45 CdmPreference determinationOnlyForFieldUnitsPreference
;
46 CdmPreference showCollectingAreaInGeneralSectionPreference
;
47 CdmPreference showTaxonAssociationsPreference
;
49 boolean isSimpleDetailsViewActivated
;
52 NameDetailsViewComposite nameDetailsConfig
;
53 protected NameDetailsViewComposite
getNameDetailsConfig() {
54 return nameDetailsConfig
;
57 String selectedPreferenceKey
= null;
59 ListComponent biocaseProviderList
;
60 Abcd206ImportConfigurator abcdImportConfigurator
;
62 String
[][] labelAndValues
;
67 public DatabasePreferencesPage(String pageName
) {
69 this.preferedNomenclaturalCode
= PreferencesUtil
.setPreferredNomenclaturalCode(null, false);
70 this.config
= PreferencesUtil
.setPreferredNameDetailsConfiguration( false);
72 config
= new NameDetailsConfigurator(false);
79 protected IPreferenceStore
doGetPreferenceStore() {
80 return PreferencesUtil
.getPreferenceStore();
86 private String
[][] getLabelAndValues() {
87 List
<NomenclaturalCode
> supportedCodes
= NomenclaturalCodeHelper
89 labelAndValues
= new String
[supportedCodes
.size()][2];
90 for (int i
= 0; i
< supportedCodes
.size(); i
++) {
91 labelAndValues
[i
][0] = NomenclaturalCodeHelper
92 .getDescription(supportedCodes
.get(i
));
93 labelAndValues
[i
][1] = PreferencesUtil
94 .getPreferenceKey(supportedCodes
.get(i
));
96 return labelAndValues
;
102 public void createNomenclaturalCodeTab(Composite parent
){
104 Combo nomenclaturalCodeCombo
;
105 Label nomenclaturalCodeLabel
;
107 composite
= addTab(Messages
.DatabasePreferencesPage_Define_Default_NomenclaturalCode
);
108 nomenclaturalCodeCombo
= new Combo(composite
, SWT
.DROP_DOWN
);
110 List
<NomenclaturalCode
> supportedCodes
= NomenclaturalCodeHelper
111 .getSupportedCodes();
112 for (NomenclaturalCode code
: supportedCodes
) {
113 nomenclaturalCodeCombo
.add(NomenclaturalCodeHelper
114 .getDescription(code
));
117 nomenclaturalCodeCombo
.select(0);
119 //get the actual nomenclatural code and set it as selection: doGetPreferenceStore().getString(IPreferenceKeys.CDM_NOMENCLATURAL_CODE_KEY);
120 nomenclaturalCodeCombo
.addSelectionListener(new SelectionAdapter() {
122 public void widgetSelected(SelectionEvent evt
) {
124 String name
= nomenclaturalCodeCombo
.getText();
126 for (String
[] labelAndValue
: labelAndValues
){
127 if (labelAndValue
[0].equals(name
)){
128 selectedPreferenceKey
= labelAndValue
[1];
133 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.CDM_NOMENCLATURAL_CODE_KEY
, selectedPreferenceKey
);
137 nomenclaturalCodeLabel
= new Label(composite
, SWT
.READ_ONLY
);
140 final Button useLocalPreference
= new Button(composite
, SWT
.CHECK
);
141 boolean isUseLocalPreference
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
);
142 useLocalPreference
.setText(Messages
.DatabasePreferencesPage_UseLocalPreferences
);
143 useLocalPreference
.setSelection(isUseLocalPreference
);
144 useLocalPreference
.addSelectionListener(new SelectionAdapter(){
146 public void widgetSelected(SelectionEvent e
) {
147 boolean isUseLocalPreference
= useLocalPreference
.getSelection();
148 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY
, isUseLocalPreference
);
157 public void createBiocaseProviderTab(Composite parent
){
158 composite
= addTab(Messages
.DatabasePreferencesPage_Biocase_Provider
);
159 GridLayout gridLayout
= new GridLayout();
160 gridLayout
.numColumns
= 2;
161 composite
.setLayout(gridLayout
);
162 biocaseProviderList
= new ListComponent(composite
, SWT
.SCROLL_LINE
);
166 public ListComponent
getBiocaseProviderList() {
167 return biocaseProviderList
;
170 public void createNameDetailsViewConfigurationTab(Composite parent
, NameDetailsConfigurator config
){
173 composite
= addTab(Messages
.DatabasePreferencesPage_details_view_configuration
);
174 GridLayout gridLayout
= new GridLayout();
175 gridLayout
.numColumns
= 2;
176 composite
.setLayout(gridLayout
);
177 nameDetailsConfig
= new NameDetailsViewComposite(composite
, SWT
.SCROLL_LINE
, config
);
181 public void createSpecimenOrObservationTab(Composite parent
){
182 composite
= addTab(Messages
.DatabasePreferencesPage_Specimen_Or_Observation
);
184 final Button showCollectingAreaInGeneralSectionButton
= new Button(composite
, SWT
.CHECK
);
185 boolean isShowCollectingAreaInGeneralSection
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
);
186 showCollectingAreaInGeneralSectionButton
.setText(Messages
.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section
);
187 showCollectingAreaInGeneralSectionButton
.setSelection(isShowCollectingAreaInGeneralSection
);
188 showCollectingAreaInGeneralSectionButton
.addSelectionListener(new SelectionAdapter(){
190 public void widgetSelected(SelectionEvent e
) {
191 boolean isShowCollectingAreaInGeneralSection
= showCollectingAreaInGeneralSectionButton
.getSelection();
192 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION
, isShowCollectingAreaInGeneralSection
);
196 final Button determinationOnlyForFieldUnitsButton
= new Button(composite
, SWT
.CHECK
);
197 boolean isDeterminationOnlyForFieldUnits
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.DETERMINATION_ONLY_FOR_FIELD_UNITS
);
198 determinationOnlyForFieldUnitsButton
.setText(Messages
.DatabasePreferncesPage_Determination_only_for_field_unnits
);
199 determinationOnlyForFieldUnitsButton
.setSelection(isDeterminationOnlyForFieldUnits
);
200 determinationOnlyForFieldUnitsButton
.addSelectionListener(new SelectionAdapter(){
202 public void widgetSelected(SelectionEvent e
) {
203 boolean isDeterminationOnlyForFieldUnits
= determinationOnlyForFieldUnitsButton
.getSelection();
204 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DETERMINATION_ONLY_FOR_FIELD_UNITS
, isDeterminationOnlyForFieldUnits
);
208 final Button showTaxonAssociationButton
= new Button(composite
, SWT
.CHECK
);
209 boolean isShowTaxonAssociation
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS
);
210 showTaxonAssociationButton
.setText(Messages
.DatabasePreferncesPage_Taxon_Associations
);
211 showTaxonAssociationButton
.setSelection(isShowTaxonAssociation
);
212 showTaxonAssociationButton
.addSelectionListener(new SelectionAdapter(){
214 public void widgetSelected(SelectionEvent e
) {
215 boolean isShowTaxonAssociation
= showTaxonAssociationButton
.getSelection();
216 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_TAXON_ASSOCIATIONS
, isShowTaxonAssociation
);
220 final Button showLifeFormButton
= new Button(composite
, SWT
.CHECK
);
221 boolean isShowLifeForm
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_LIFE_FORM
);
222 showLifeFormButton
.setText(Messages
.DatabasePreferncesPage_Life_Form
);
223 showLifeFormButton
.setSelection(isShowLifeForm
);
224 showLifeFormButton
.addSelectionListener(new SelectionAdapter(){
226 public void widgetSelected(SelectionEvent e
) {
227 boolean isShowLifeForm
= showLifeFormButton
.getSelection();
228 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.SHOW_LIFE_FORM
, isShowLifeForm
);
240 public boolean canFlipToNextPage() {
241 // TODO Auto-generated method stub
251 public String
getName() {
252 // TODO Auto-generated method stub
262 public IWizardPage
getNextPage() {
263 // TODO Auto-generated method stub
273 public IWizardPage
getPreviousPage() {
274 // TODO Auto-generated method stub
284 public IWizard
getWizard() {
285 // TODO Auto-generated method stub
295 public boolean isPageComplete() {
306 public void setPreviousPage(IWizardPage page
) {
307 // TODO Auto-generated method stub
317 public void setWizard(IWizard newWizard
) {
318 // TODO Auto-generated method stub
326 public void createControl(Composite parent
) {
327 createNameDetailsViewConfigurationTab(parent
, config
);
328 createNomenclaturalCodeTab(parent
);
330 createSpecimenOrObservationTab(parent
);
331 createBiocaseProviderTab(parent
);
338 public NameDetailsConfigurator
getConfig() {
345 public Abcd206ImportConfigurator
getAbcdImportConfig() {
346 return abcdImportConfigurator
;
353 public void createAbcdImportConfig() {
354 this.abcdImportConfigurator
.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS
));
355 this.abcdImportConfigurator
.setAddMediaAsMediaSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN
));
356 this.abcdImportConfigurator
.setAllowReuseOtherClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS
));
357 //this.abcdImportConfigurator.setClassificationUuid(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_CLASSIFICATION_UUID));
358 this.abcdImportConfigurator
.setDeduplicateClassifications(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS
));
359 this.abcdImportConfigurator
.setDeduplicateReferences(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES
));
360 // this.abcdImportConfigurator.setDefaultAuthor(doGetPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEFAULT_AUTHOR));
361 this.abcdImportConfigurator
.setGetSiblings(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS
));
362 this.abcdImportConfigurator
.setIgnoreAuthorship(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP
));
363 this.abcdImportConfigurator
.setIgnoreImportOfExistingSpecimen(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN
));
364 this.abcdImportConfigurator
.setMapUnitIdToAccessionNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER
));
365 this.abcdImportConfigurator
.setMapUnitIdToBarcode(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE
));
366 this.abcdImportConfigurator
.setMapUnitIdToCatalogNumber(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER
));
367 this.abcdImportConfigurator
.setMoveNewTaxaToDefaultClassification(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION
));
368 this.abcdImportConfigurator
.setReuseExistingDescriptiveGroups(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS
));
369 this.abcdImportConfigurator
.setReuseExistingTaxaWhenPossible(doGetPreferenceStore().getBoolean(IPreferenceKeys
.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE
));