Revision 36fa3d85
Added by Katja Luther over 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/AbcdImportAdminPreference.java | ||
---|---|---|
28 | 28 |
*/ |
29 | 29 |
public class AbcdImportAdminPreference extends AbcdImportPreference implements IE4AdminPreferencePage, SelectionListener { |
30 | 30 |
|
31 |
// @Override |
|
32 |
// protected Control createContents(Composite parent) { |
|
33 |
// final Composite composite = new Composite(parent, SWT.NULL); |
|
34 |
// |
|
35 |
// GridLayout gridLayout = new GridLayout(); |
|
36 |
// composite.setLayout(gridLayout); |
|
37 |
// configurator = Abcd206ImportConfigurator.NewInstance(null,null); |
|
38 |
// ICdmRepository controller; |
|
39 |
// controller = CdmStore.getCurrentApplicationConfiguration(); |
|
40 |
// PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig); |
|
41 |
// |
|
42 |
// if (controller == null){ |
|
43 |
// return null; |
|
44 |
// } |
|
45 |
// preference = controller.getPreferenceService().find(key); |
|
46 |
// |
|
47 |
// if (preference != null ){ |
|
48 |
// allowOverride = preference.isAllowOverride(); |
|
49 |
// }else{ |
|
50 |
// preference = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AbcdImportConfig, configurator.toString()); |
|
51 |
// } |
|
52 |
// |
|
53 |
// |
|
54 |
// //configurator = PreferencesUtil.getAbcdImportConfigurationPreference(); |
|
55 |
// final CLabel description = new CLabel(composite, SWT.NULL); |
|
56 |
// description.setText(Messages.AbcdImportPreference_description); |
|
57 |
// checkBoxMediaSpecimen = new Button(composite, SWT.CHECK); |
|
58 |
// checkBoxMediaSpecimen.setSelection(configurator.isAddMediaAsMediaSpecimen()); |
|
59 |
// checkBoxMediaSpecimen.setText(Messages.AbcdImportPreference_media_as_mediaSpecimen); |
|
60 |
// checkBoxMediaSpecimen |
|
61 |
// .setToolTipText(Messages.AbcdImportPreference_media_as_subUnit); |
|
62 |
// checkBoxMediaSpecimen.addSelectionListener(new SelectionAdapter() { |
|
63 |
// @Override |
|
64 |
// public void widgetSelected(SelectionEvent e) { |
|
65 |
// configurator.setAddMediaAsMediaSpecimen(!configurator.isAddMediaAsMediaSpecimen()); |
|
66 |
// setApply(true); |
|
67 |
// } |
|
68 |
// }); |
|
69 |
// |
|
70 |
// checkBoxIgnoreExisting = new Button(composite, SWT.CHECK); |
|
71 |
// checkBoxIgnoreExisting.setSelection(configurator.isIgnoreImportOfExistingSpecimen()); |
|
72 |
// checkBoxIgnoreExisting.setText(Messages.AbcdImportPreference_not_import_existing_specimen); |
|
73 |
// checkBoxIgnoreExisting |
|
74 |
// .setToolTipText(Messages.AbcdImportPreference_not_import_existing_specimen_tooltip); |
|
75 |
// checkBoxIgnoreExisting.addSelectionListener(new SelectionAdapter() { |
|
76 |
// @Override |
|
77 |
// public void widgetSelected(SelectionEvent e) { |
|
78 |
// configurator.setIgnoreImportOfExistingSpecimen(!configurator.isIgnoreImportOfExistingSpecimen()); |
|
79 |
// setApply(true); |
|
80 |
// } |
|
81 |
// }); |
|
82 |
// |
|
83 |
// checkBoxIgnoreAuthorship = new Button(composite, SWT.CHECK); |
|
84 |
// checkBoxIgnoreAuthorship.setSelection(configurator.isIgnoreAuthorship()); |
|
85 |
// checkBoxIgnoreAuthorship.setText(Messages.AbcdImportPreference_ignore_author); |
|
86 |
// checkBoxIgnoreAuthorship |
|
87 |
// .setToolTipText(Messages.AbcdImportPreference_ignore_author_tooltip); |
|
88 |
// checkBoxIgnoreAuthorship.addSelectionListener(new SelectionAdapter() { |
|
89 |
// @Override |
|
90 |
// public void widgetSelected(SelectionEvent e) { |
|
91 |
// configurator.setIgnoreAuthorship(!configurator.isIgnoreAuthorship()); |
|
92 |
// setApply(true); |
|
93 |
// } |
|
94 |
// }); |
|
95 |
// |
|
96 |
// checkBoxMapUnitIdToCatalogNumber = new Button(composite, SWT.RADIO); |
|
97 |
// checkBoxMapUnitIdToCatalogNumber.setSelection(configurator.isMapUnitIdToCatalogNumber()); |
|
98 |
// checkBoxMapUnitIdToCatalogNumber.setText(Messages.AbcdImportPreference_map_unit_nr_catalog_number); |
|
99 |
// checkBoxMapUnitIdToCatalogNumber |
|
100 |
// .setToolTipText(Messages.AbcdImportPreference_map_unit_number_catalog_number_tooltip); |
|
101 |
// checkBoxMapUnitIdToCatalogNumber.addSelectionListener(new SelectionAdapter() { |
|
102 |
// @Override |
|
103 |
// public void widgetSelected(SelectionEvent e) { |
|
104 |
// configurator.setMapUnitIdToCatalogNumber(!configurator.isMapUnitIdToCatalogNumber()); |
|
105 |
// setApply(true); |
|
106 |
// } |
|
107 |
// }); |
|
108 |
////TODO: only one of the mappings can be checked! |
|
109 |
// checkBoxMapUnitIdToAccessionNumber = new Button(composite, SWT.RADIO); |
|
110 |
// checkBoxMapUnitIdToAccessionNumber.setSelection(configurator.isMapUnitIdToAccessionNumber()); |
|
111 |
// checkBoxMapUnitIdToAccessionNumber.setText(Messages.AbcdImportPreference_map_unit_number_to_accession_number); |
|
112 |
// checkBoxMapUnitIdToAccessionNumber |
|
113 |
// .setToolTipText(Messages.AbcdImportPreference_map_unit_number_accession_number_tooltip); |
|
114 |
// checkBoxMapUnitIdToAccessionNumber.addSelectionListener(new SelectionAdapter() { |
|
115 |
// @Override |
|
116 |
// public void widgetSelected(SelectionEvent e) { |
|
117 |
// configurator.setMapUnitIdToAccessionNumber(!configurator.isMapUnitIdToAccessionNumber()); |
|
118 |
// setApply(true); |
|
119 |
// } |
|
120 |
// }); |
|
121 |
// |
|
122 |
// checkBoxMapUnitIdToBarcode = new Button(composite, SWT.RADIO); |
|
123 |
// checkBoxMapUnitIdToBarcode.setSelection(configurator.isMapUnitIdToBarcode()); |
|
124 |
// checkBoxMapUnitIdToBarcode.setText(Messages.AbcdImportPreference_map_unit_number_barcode); |
|
125 |
// checkBoxMapUnitIdToBarcode |
|
126 |
// .setToolTipText(Messages.AbcdImportPreference_map_unit_number_barcode_tooltip); |
|
127 |
// checkBoxMapUnitIdToBarcode.addSelectionListener(new SelectionAdapter() { |
|
128 |
// @Override |
|
129 |
// public void widgetSelected(SelectionEvent e) { |
|
130 |
// configurator.setMapUnitIdToBarcode(!configurator.isMapUnitIdToBarcode()); |
|
131 |
// setApply(true); |
|
132 |
// } |
|
133 |
// }); |
|
134 |
// |
|
135 |
// checkBoxRemoveCountry = new Button(composite, SWT.CHECK); |
|
136 |
// checkBoxRemoveCountry.setSelection(configurator.isRemoveCountryFromLocalityText()); |
|
137 |
// checkBoxRemoveCountry.setText(Messages.AbcdImportPreference_remove_country_from_locality); |
|
138 |
// checkBoxRemoveCountry |
|
139 |
// .setToolTipText(Messages.AbcdImportPreference_remove_country_from_locality_tooltip); |
|
140 |
// checkBoxRemoveCountry.addSelectionListener(new SelectionAdapter() { |
|
141 |
// @Override |
|
142 |
// public void widgetSelected(SelectionEvent e) { |
|
143 |
// configurator.setRemoveCountryFromLocalityText(!configurator.isRemoveCountryFromLocalityText()); |
|
144 |
// setApply(true); |
|
145 |
// } |
|
146 |
// }); |
|
147 |
// |
|
148 |
// checkBoxMoveToDefaultClassification = new Button(composite, SWT.CHECK); |
|
149 |
// checkBoxMoveToDefaultClassification.setSelection(configurator.isMoveNewTaxaToDefaultClassification()); |
|
150 |
// checkBoxMoveToDefaultClassification.setText(Messages.AbcdImportPreference_create_new_classification_new_taxa); |
|
151 |
// checkBoxMoveToDefaultClassification |
|
152 |
// .setToolTipText(Messages.AbcdImportPreference_create_new_classification_new_taxa_tooltip); |
|
153 |
// checkBoxMoveToDefaultClassification.addSelectionListener(new SelectionAdapter() { |
|
154 |
// @Override |
|
155 |
// public void widgetSelected(SelectionEvent e) { |
|
156 |
// configurator.setMoveNewTaxaToDefaultClassification(!configurator.isMoveNewTaxaToDefaultClassification()); |
|
157 |
// setApply(true); |
|
158 |
// } |
|
159 |
// }); |
|
160 |
// |
|
161 |
// checkBoxImportSiblings = new Button(composite, SWT.CHECK); |
|
162 |
// checkBoxImportSiblings.setSelection(configurator.isGetSiblings()); |
|
163 |
// checkBoxImportSiblings.setText(Messages.AbcdImportPreference_import_all_children_for_cultures_or_tissues); |
|
164 |
// checkBoxImportSiblings |
|
165 |
// .setToolTipText(Messages.AbcdImportPreference_import_all_children_for_cultures_or_tissues_tooltip); |
|
166 |
// checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() { |
|
167 |
// @Override |
|
168 |
// public void widgetSelected(SelectionEvent e) { |
|
169 |
// configurator.setGetSiblings(!configurator.isGetSiblings()); |
|
170 |
// setApply(true); |
|
171 |
// } |
|
172 |
// }); |
|
173 |
// |
|
174 |
// checkBoxAddIndividualsAssociations = new Button(composite, SWT.CHECK); |
|
175 |
// checkBoxAddIndividualsAssociations.setSelection(configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations()); |
|
176 |
// checkBoxAddIndividualsAssociations.setText(Messages.AbcdImportPreference_create_Individual_Association); |
|
177 |
// checkBoxAddIndividualsAssociations |
|
178 |
// .setToolTipText(Messages.AbcdImportPreference_create_Individual_Association_tooltip); |
|
179 |
// checkBoxAddIndividualsAssociations.addSelectionListener(new SelectionAdapter() { |
|
180 |
// @Override |
|
181 |
// public void widgetSelected(SelectionEvent e) { |
|
182 |
// configurator.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(!configurator.isAddIndividualsAssociationsSuchAsSpecimenAndObservations()); |
|
183 |
// setApply(true); |
|
184 |
// } |
|
185 |
// }); |
|
186 |
// |
|
187 |
// checkBoxReuseDescriptiveGroups = new Button(composite, SWT.CHECK); |
|
188 |
// checkBoxReuseDescriptiveGroups.setSelection(configurator.isReuseExistingDescriptiveGroups()); |
|
189 |
// checkBoxReuseDescriptiveGroups.setText(Messages.AbcdImportPreference_reuse_descriptive_group); |
|
190 |
// checkBoxReuseDescriptiveGroups |
|
191 |
// .setToolTipText(Messages.AbcdImportPreference_reuse_descriptive_group_tooltip); |
|
192 |
// checkBoxReuseDescriptiveGroups.addSelectionListener(new SelectionAdapter() { |
|
193 |
// @Override |
|
194 |
// public void widgetSelected(SelectionEvent e) { |
|
195 |
// configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups()); |
|
196 |
// setApply(true); |
|
197 |
// } |
|
198 |
// }); |
|
199 |
// |
|
200 |
// checkBoxReuseExistingTaxa = new Button(composite, SWT.CHECK); |
|
201 |
// checkBoxReuseExistingTaxa.setSelection(configurator.isReuseExistingTaxaWhenPossible()); |
|
202 |
// checkBoxReuseExistingTaxa.setText(Messages.AbcdImportPreference_reuse_existing_taxa); |
|
203 |
// checkBoxReuseExistingTaxa |
|
204 |
// .setToolTipText(Messages.AbcdImportPreference_reuse_existing_taxa_tooltip); |
|
205 |
// checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() { |
|
206 |
// @Override |
|
207 |
// public void widgetSelected(SelectionEvent e) { |
|
208 |
// configurator.setReuseExistingTaxaWhenPossible(!configurator.isReuseExistingTaxaWhenPossible()); |
|
209 |
// setApply(true); |
|
210 |
// } |
|
211 |
// }); |
|
212 |
// |
|
213 |
// Label labelRef = new Label(composite, SWT.NONE); |
|
214 |
// labelRef.setText("Biocase provider for associated DNA"); |
|
215 |
// // new Label(composite, SWT.NONE); |
|
216 |
// textDNAProviderString = new Text(composite, SWT.NONE); |
|
217 |
// textDNAProviderString.setEnabled(true); |
|
218 |
// textDNAProviderString.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 1, 1)); |
|
219 |
// textDNAProviderString.setText(configurator.getDnaSoure().toString()); |
|
220 |
// GridData gridData = new GridData(); |
|
221 |
// gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); |
|
222 |
// gridData.horizontalIndent = 5; |
|
223 |
//// classificationSelection.setLayoutData(gridData); |
|
224 |
// Label nomenclaturalCodeLabel = new Label(composite, SWT.NONE); |
|
225 |
// nomenclaturalCodeLabel.setText("Nomenclatural Code"); |
|
226 |
// nomenclaturalCodeSelectionCombo = new Combo(composite, SWT.BORDER| SWT.READ_ONLY); |
|
227 |
// nomenclaturalCodeSelectionCombo.setLayoutData(gridData); |
|
228 |
// |
|
229 |
// for(NomenclaturalCode code: NomenclaturalCode.values()){ |
|
230 |
// nomenclaturalCodeSelectionCombo.add(code.getKey()); |
|
231 |
// } |
|
232 |
// int index = 0; |
|
233 |
// if (configurator.getNomenclaturalCode() != null){ |
|
234 |
// for (String label : nomenclaturalCodeSelectionCombo.getItems()){ |
|
235 |
// if (label.equals(configurator.getNomenclaturalCode().getKey())){ |
|
236 |
// nomenclaturalCodeSelectionCombo.select(index); |
|
237 |
// } |
|
238 |
// index++; |
|
239 |
// } |
|
240 |
// } |
|
241 |
// |
|
242 |
// // TODO remember last selection |
|
243 |
// nomenclaturalCodeSelectionCombo.addSelectionListener(this); |
|
244 |
// if (preference != null){ |
|
245 |
// allowOverride = preference.isAllowOverride(); |
|
246 |
// } |
|
247 |
// checkAllowOverride = new Button(composite, SWT.CHECK); |
|
248 |
// checkAllowOverride.setSelection(allowOverride); |
|
249 |
// checkAllowOverride.setText(Messages.AbcdImportPreference_allow_override); |
|
250 |
// checkAllowOverride |
|
251 |
// .setToolTipText(Messages.AbcdImportPreference_allow_override_tooltip); |
|
252 |
// checkAllowOverride.addSelectionListener(new SelectionAdapter() { |
|
253 |
// @Override |
|
254 |
// public void widgetSelected(SelectionEvent e) { |
|
255 |
// allowOverride = !allowOverride; |
|
256 |
// setApply(true); |
|
257 |
// } |
|
258 |
// }); |
|
259 |
// |
|
260 |
// return composite; |
|
261 |
// } |
|
262 |
|
|
263 |
|
|
264 |
|
|
265 | 31 |
@Override |
266 | 32 |
public boolean performOk() { |
267 | 33 |
if (!isApply()){ |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/e4/out/cdmlight/CdmLightExportWizardE4.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.io.e4.out.cdmlight; |
10 | 10 |
|
11 | 11 |
import java.io.File; |
12 |
import java.text.SimpleDateFormat; |
|
13 |
import java.util.Calendar; |
|
12 | 14 |
import java.util.HashSet; |
13 | 15 |
import java.util.List; |
14 | 16 |
import java.util.UUID; |
... | ... | |
44 | 46 |
private CdmLightExportConfigurator configurator; |
45 | 47 |
private ExportToFileDestinationWizardPage page; |
46 | 48 |
private MetaDataConfigurationWizardPage metaDataPage; |
49 |
public static final String DATE_FORMAT_NOW = "yyyyMMddHHmm"; |
|
50 |
TaxonNodeDto selectedNode; |
|
47 | 51 |
|
48 | 52 |
@Inject |
49 | 53 |
public CdmLightExportWizardE4(IEclipseContext context, |
... | ... | |
55 | 59 |
public void init() { |
56 | 60 |
configurator = new CdmLightExportConfigurator(null); |
57 | 61 |
if (selection instanceof TreeSelection && !selection.isEmpty() && selection.getFirstElement() instanceof TaxonNodeDto){ |
58 |
TaxonNodeDto node = (TaxonNodeDto)selection.getFirstElement(); |
|
59 |
if (node.getParentUUID() == null){ |
|
60 |
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(node.getClassificationUUID())); |
|
62 |
selectedNode = (TaxonNodeDto)selection.getFirstElement(); |
|
63 |
|
|
64 |
if (selectedNode.getParentUUID() == null){ |
|
65 |
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewClassificationInstance(selectedNode.getClassificationUUID())); |
|
61 | 66 |
}else{ |
62 |
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(node.getUuid()));
|
|
67 |
configurator.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(selectedNode.getUuid()));
|
|
63 | 68 |
} |
64 | 69 |
|
65 | 70 |
} |
... | ... | |
74 | 79 |
|
75 | 80 |
@Override |
76 | 81 |
public boolean performFinish() { |
77 |
String urlString = page.getFolderText() + File.separator; |
|
82 |
String urlString = page.getFolderText() + File.separator ; |
|
83 |
if (configurator.isCreateZipFile()){ |
|
84 |
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); |
|
85 |
Calendar cal = Calendar.getInstance(); |
|
86 |
|
|
87 |
if (!configurator.getTaxonNodeFilter().getSubtreeFilter().isEmpty()){ |
|
88 |
urlString += selectedNode.getNameCache()+"_cdmLight_"+sdf.format(cal.getTime()); |
|
89 |
}else if (!configurator.getTaxonNodeFilter().getClassificationFilter().isEmpty()){ |
|
90 |
urlString += page.getSelectedClassification().getTitleCache()+"_cdmLight_"+sdf.format(cal.getTime()); |
|
91 |
page.getSelectedClassification(); |
|
92 |
} |
|
93 |
|
|
94 |
} |
|
95 |
|
|
78 | 96 |
//+ page.getExportFileName(); |
79 | 97 |
|
80 | 98 |
final Combo combo = page.getCombo(); |
81 |
metaDataPage.fillConfig(); |
|
82 |
configurator = metaDataPage.configurator; |
|
99 |
if (metaDataPage != null){ |
|
100 |
metaDataPage.fillConfig(); |
|
101 |
configurator = metaDataPage.configurator; |
|
102 |
} |
|
103 |
|
|
83 | 104 |
final List<Classification> listClassifications = CdmStore.getCurrentApplicationConfiguration().getClassificationService().listClassifications(null, null, null, null); |
84 | 105 |
if(combo != null){ |
85 | 106 |
int selectionIndex = combo.getSelectionIndex(); |
... | ... | |
122 | 143 |
|
123 | 144 |
addPage(page); |
124 | 145 |
super.addPages(); |
125 |
metaDataPage = new MetaDataConfigurationWizardPage("Add Meta Data", configurator); |
|
126 |
addPage(metaDataPage); |
|
146 |
if (PreferencesUtil.showGfbioMetaData()){ |
|
147 |
metaDataPage = new MetaDataConfigurationWizardPage("Add Meta Data", configurator); |
|
148 |
addPage(metaDataPage); |
|
149 |
} |
|
127 | 150 |
|
128 | 151 |
} |
129 | 152 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java | ||
---|---|---|
542 | 542 |
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex()); |
543 | 543 |
} |
544 | 544 |
|
545 |
public Classification getSelectedClassification(){ |
|
546 |
return selectedClassification; |
|
547 |
} |
|
548 |
|
|
545 | 549 |
@Override |
546 | 550 |
public void widgetDefaultSelected(SelectionEvent e) { |
547 | 551 |
//not needed here |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/AbcdImportPreference.java | ||
---|---|---|
42 | 42 |
*/ |
43 | 43 |
public class AbcdImportPreference extends CdmPreferencePage implements IE4PreferencePage, SelectionListener { |
44 | 44 |
|
45 |
/** |
|
46 |
* |
|
47 |
*/ |
|
48 | 45 |
private static final String CATALOGUE_NUMBER = "Catalogue number"; |
49 | 46 |
|
50 |
/** |
|
51 |
* |
|
52 |
*/ |
|
53 | 47 |
private static final String BARCODE = "Barcode"; |
54 | 48 |
|
55 |
/** |
|
56 |
* |
|
57 |
*/ |
|
58 | 49 |
private static final String ACCESSION_NUMBER = "Accession number"; |
59 | 50 |
|
60 | 51 |
protected Abcd206ImportConfigurator configurator; |
... | ... | |
72 | 63 |
Button checkBoxIgnoreExisting; |
73 | 64 |
Button checkBoxIgnoreAuthorship; |
74 | 65 |
Combo checkBoxMapUnitId; |
75 |
// Button checkBoxMapUnitIdToAccessionNumber; |
|
76 |
// Button checkBoxMapUnitIdToBarcode; |
|
77 | 66 |
Button checkBoxRemoveCountry; |
78 | 67 |
Button checkBoxMoveToDefaultClassification; |
79 | 68 |
Button checkBoxImportSiblings; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/CdmLightExportPreference.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 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 |
package eu.etaxonomy.taxeditor.preference; |
|
10 |
|
|
11 |
import org.apache.commons.lang.StringUtils; |
|
12 |
import org.eclipse.jface.layout.GridLayoutFactory; |
|
13 |
import org.eclipse.swt.SWT; |
|
14 |
import org.eclipse.swt.events.SelectionAdapter; |
|
15 |
import org.eclipse.swt.events.SelectionEvent; |
|
16 |
import org.eclipse.swt.events.SelectionListener; |
|
17 |
import org.eclipse.swt.widgets.Button; |
|
18 |
import org.eclipse.swt.widgets.Combo; |
|
19 |
import org.eclipse.swt.widgets.Composite; |
|
20 |
import org.eclipse.swt.widgets.Control; |
|
21 |
import org.eclipse.swt.widgets.Label; |
|
22 |
|
|
23 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
|
24 |
import eu.etaxonomy.cdm.ext.geo.CondensedDistributionRecipe; |
|
25 |
import eu.etaxonomy.cdm.io.cdmLight.CdmLightExportConfigurator; |
|
26 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
|
27 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey; |
|
28 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
29 |
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject; |
|
30 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
31 |
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage; |
|
32 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author k.luther |
|
36 |
* @since Nov 12, 2020 |
|
37 |
*/ |
|
38 |
public class CdmLightExportPreference extends CdmPreferencePage implements SelectionListener { |
|
39 |
|
|
40 |
protected Combo createCondensedDistributionString; |
|
41 |
protected Combo comboDistributionStringRecipe; |
|
42 |
|
|
43 |
protected Button allowOverrideCreateCondensedDistributionString; |
|
44 |
protected Button allowOverrideDistributionStringRecipe; |
|
45 |
|
|
46 |
protected CdmPreference preferenceIsExportCondensedDistribution = null; |
|
47 |
protected boolean isAllowOverrideIsExportCondensedDistribution = false; |
|
48 |
protected boolean overrideExportCondensedDistribution = false; |
|
49 |
protected CdmPreference preferenceCondensedDistribtionRecipe = null; |
|
50 |
protected boolean isAllowOverrideCondensedDistributionRecipe = false; |
|
51 |
protected boolean overrideCondensedDistributionRecipe = false; |
|
52 |
protected Boolean isExportCondensedDistribution = null; |
|
53 |
protected CondensedDistributionRecipe recipe = null; |
|
54 |
|
|
55 |
@Override |
|
56 |
protected Control createContents(Composite parent) { |
|
57 |
getValues(); |
|
58 |
Composite composite = createComposite(parent); |
|
59 |
// GridLayout gridLayout = new GridLayout(); |
|
60 |
// composite.setLayout(gridLayout); |
|
61 |
|
|
62 |
Label description = new Label(composite, SWT.NULL); |
|
63 |
description.setText(Messages.CdmLightPreference_description); |
|
64 |
|
|
65 |
createCondensedDistributionString = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.CdmLightExportCondensedDistributionString, Messages.CdmLightPreference_distributionString, isAdminPreference); |
|
66 |
|
|
67 |
createCondensedDistributionString |
|
68 |
.setToolTipText(Messages.CdmLightPreference_distributionString_tooltip); |
|
69 |
int index = 0; |
|
70 |
for (String itemLabel : createCondensedDistributionString.getItems()) { |
|
71 |
if (isExportCondensedDistribution == null && itemLabel.startsWith(Messages.Preference_Use_Default)) { |
|
72 |
createCondensedDistributionString.select(index); |
|
73 |
break; |
|
74 |
} |
|
75 |
if (isExportCondensedDistribution != null && itemLabel.equals(Messages.GeneralPreference_yes) && isExportCondensedDistribution){ |
|
76 |
createCondensedDistributionString.select(index); |
|
77 |
break; |
|
78 |
} |
|
79 |
if (isExportCondensedDistribution != null && itemLabel.equals(Messages.GeneralPreference_no) && !isExportCondensedDistribution){ |
|
80 |
createCondensedDistributionString.select(index); |
|
81 |
break; |
|
82 |
} |
|
83 |
index++; |
|
84 |
} |
|
85 |
createCondensedDistributionString.addSelectionListener(this); |
|
86 |
|
|
87 |
if (isAdminPreference){ |
|
88 |
allowOverrideCreateCondensedDistributionString = createAllowOverrideButton(composite); |
|
89 |
allowOverrideCreateCondensedDistributionString.setSelection(this.preferenceIsExportCondensedDistribution != null? this.preferenceIsExportCondensedDistribution.isAllowOverride(): isAdminPreference); |
|
90 |
allowOverrideCreateCondensedDistributionString.addSelectionListener(new SelectionAdapter() { |
|
91 |
@Override |
|
92 |
public void widgetSelected(SelectionEvent e) { |
|
93 |
setApply(true); |
|
94 |
// if (preferenceIsExportCondensedDistribution == null){ |
|
95 |
// preferenceIsExportCondensedDistribution = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CdmLightExportCondensedDistributionString, PreferencePredicate.CdmLightExportCondensedDistributionString.getDefaultValue() != null ? PreferencePredicate.CdmLightExportCondensedDistributionString.getDefaultValue().toString(): null); |
|
96 |
// } |
|
97 |
// preferenceIsExportCondensedDistribution.setAllowOverride(!preferenceIsExportCondensedDistribution.isAllowOverride()); |
|
98 |
isAllowOverrideIsExportCondensedDistribution = !isAllowOverrideIsExportCondensedDistribution; |
|
99 |
} |
|
100 |
}); |
|
101 |
} |
|
102 |
|
|
103 |
comboDistributionStringRecipe = createCombo(composite, CondensedDistributionRecipe.values(), PreferencePredicate.CdmLightExportCondensedDistributionRecipe, "Condensed Distribution String recipe", isAdminPreference); |
|
104 |
|
|
105 |
// GridData gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false); |
|
106 |
// gridData.horizontalIndent = 9; |
|
107 |
// comboDistributionStringRecipe.setLayoutData(gridData); |
|
108 |
GridLayoutFactory.fillDefaults(); |
|
109 |
|
|
110 |
comboDistributionStringRecipe.addSelectionListener(this); |
|
111 |
comboDistributionStringRecipe.setEnabled((isExportCondensedDistribution != null && isExportCondensedDistribution )|| (isExportCondensedDistribution == null) && Boolean.valueOf(preferenceIsExportCondensedDistribution.getValue())); |
|
112 |
index = 0; |
|
113 |
|
|
114 |
for (String itemLabel : comboDistributionStringRecipe.getItems()) { |
|
115 |
if (itemLabel.startsWith(Messages.Preference_Use_Default) && recipe == null){ |
|
116 |
comboDistributionStringRecipe.select(index); |
|
117 |
break; |
|
118 |
} |
|
119 |
if (itemLabel.equals(recipe.getLabel())) { |
|
120 |
comboDistributionStringRecipe.select(index); |
|
121 |
break; |
|
122 |
} |
|
123 |
|
|
124 |
index++; |
|
125 |
} |
|
126 |
if (isAdminPreference){ |
|
127 |
allowOverrideDistributionStringRecipe = createAllowOverrideButton(composite); |
|
128 |
allowOverrideDistributionStringRecipe.setSelection(this.preferenceCondensedDistribtionRecipe != null? this.preferenceCondensedDistribtionRecipe.isAllowOverride(): true); |
|
129 |
allowOverrideDistributionStringRecipe.addSelectionListener(new SelectionAdapter() { |
|
130 |
@Override |
|
131 |
public void widgetSelected(SelectionEvent e) { |
|
132 |
setApply(true); |
|
133 |
// if (preferenceCondensedDistribtionRecipe == null){ |
|
134 |
// preferenceCondensedDistribtionRecipe = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CdmLightExportCondensedDistributionRecipe, PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue() != null ? PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue().toString(): null); |
|
135 |
// } |
|
136 |
// preferenceCondensedDistribtionRecipe.setAllowOverride(!preferenceCondensedDistribtionRecipe.isAllowOverride()); |
|
137 |
isAllowOverrideCondensedDistributionRecipe = !isAllowOverrideCondensedDistributionRecipe; |
|
138 |
} |
|
139 |
}); |
|
140 |
} |
|
141 |
|
|
142 |
return composite; |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
@Override |
|
150 |
public void widgetSelected(SelectionEvent e) { |
|
151 |
setApply(true); |
|
152 |
if (e.getSource().equals(this.comboDistributionStringRecipe)){ |
|
153 |
int selIndex = comboDistributionStringRecipe.getSelectionIndex(); |
|
154 |
if (selIndex == 0){ |
|
155 |
overrideCondensedDistributionRecipe = false; |
|
156 |
}else{ |
|
157 |
overrideCondensedDistributionRecipe = true; |
|
158 |
} |
|
159 |
recipe = (CondensedDistributionRecipe) comboDistributionStringRecipe.getData(comboDistributionStringRecipe.getText()); |
|
160 |
|
|
161 |
} |
|
162 |
if (e.getSource().equals(this.createCondensedDistributionString)){ |
|
163 |
String text = createCondensedDistributionString.getText(); |
|
164 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
165 |
isExportCondensedDistribution = null; |
|
166 |
overrideExportCondensedDistribution = false; |
|
167 |
isAllowOverrideIsExportCondensedDistribution = true; |
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
172 |
isExportCondensedDistribution = true; |
|
173 |
overrideExportCondensedDistribution = true; |
|
174 |
}else if (text.equals(Messages.GeneralPreference_no)){ |
|
175 |
isExportCondensedDistribution = false; |
|
176 |
overrideExportCondensedDistribution = true; |
|
177 |
} |
|
178 |
comboDistributionStringRecipe.setEnabled((isExportCondensedDistribution != null && isExportCondensedDistribution )|| (isExportCondensedDistribution == null) && Boolean.valueOf(preferenceIsExportCondensedDistribution.getValue())); |
|
179 |
} |
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
|
|
186 |
@Override |
|
187 |
public boolean performOk() { |
|
188 |
if (!isApply()){ |
|
189 |
return true; |
|
190 |
} |
|
191 |
if(overrideExportCondensedDistribution){ |
|
192 |
PreferencesUtil.setBooleanValue(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey(), isExportCondensedDistribution); |
|
193 |
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()), overrideExportCondensedDistribution); |
|
194 |
}else{ |
|
195 |
PreferencesUtil.setBooleanValue( PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()), overrideExportCondensedDistribution); |
|
196 |
} |
|
197 |
if(overrideCondensedDistributionRecipe){ |
|
198 |
PreferencesUtil.setStringValue(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey(), recipe.getKey()); |
|
199 |
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey()), overrideCondensedDistributionRecipe); |
|
200 |
}else{ |
|
201 |
PreferencesUtil.setBooleanValue( PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey()), overrideCondensedDistributionRecipe); |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
return true; |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* {@inheritDoc} |
|
211 |
*/ |
|
212 |
@Override |
|
213 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
214 |
// TODO Auto-generated method stub |
|
215 |
|
|
216 |
} |
|
217 |
|
|
218 |
@Override |
|
219 |
protected void performDefaults() { |
|
220 |
isExportCondensedDistribution = Boolean.valueOf(PreferencePredicate.CdmLightExportCondensedDistributionString.getDefaultValue().toString()); |
|
221 |
createCondensedDistributionString.select(0); |
|
222 |
recipe = PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue() != null? CondensedDistributionRecipe.valueOf(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue().toString()): null; |
|
223 |
comboDistributionStringRecipe.select(0); |
|
224 |
setApply(true); |
|
225 |
} |
|
226 |
|
|
227 |
|
|
228 |
@Override |
|
229 |
public void getValues() { |
|
230 |
isAdminPreference = false; |
|
231 |
|
|
232 |
CdmLightExportConfigurator configurator = new CdmLightExportConfigurator(null); |
|
233 |
ICdmRepository controller; |
|
234 |
controller = CdmStore.getCurrentApplicationConfiguration(); |
|
235 |
// general export of condensed string |
|
236 |
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.CdmLightExportCondensedDistributionString); |
|
237 |
preferenceIsExportCondensedDistribution = controller.getPreferenceService().find(key); |
|
238 |
|
|
239 |
if (preferenceIsExportCondensedDistribution != null ){ |
|
240 |
isAllowOverrideIsExportCondensedDistribution = preferenceIsExportCondensedDistribution.isAllowOverride(); |
|
241 |
}else{ |
|
242 |
preferenceIsExportCondensedDistribution = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CdmLightExportCondensedDistributionString, PreferencePredicate.CdmLightExportCondensedDistributionString.getDefaultValue().toString()); |
|
243 |
isAllowOverrideIsExportCondensedDistribution = true; |
|
244 |
} |
|
245 |
|
|
246 |
overrideExportCondensedDistribution = PreferencesUtil.getBooleanValue( |
|
247 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()), true) != null? PreferencesUtil.getBooleanValue( |
|
248 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey()), true):false; |
|
249 |
|
|
250 |
if (isAllowOverrideIsExportCondensedDistribution){ |
|
251 |
if( overrideExportCondensedDistribution){ |
|
252 |
isExportCondensedDistribution = PreferencesUtil.getBooleanValue(PreferencePredicate.CdmLightExportCondensedDistributionString.getKey(), true); |
|
253 |
}else{ |
|
254 |
isExportCondensedDistribution = null; |
|
255 |
} |
|
256 |
|
|
257 |
}else{ |
|
258 |
isExportCondensedDistribution = preferenceIsExportCondensedDistribution.getValue()!= null?Boolean.valueOf(preferenceIsExportCondensedDistribution.getValue()): null; |
|
259 |
} |
|
260 |
// recipe for creation of condensed string |
|
261 |
|
|
262 |
key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.CdmLightExportCondensedDistributionRecipe); |
|
263 |
preferenceCondensedDistribtionRecipe = controller.getPreferenceService().find(key); |
|
264 |
|
|
265 |
if (preferenceCondensedDistribtionRecipe != null ){ |
|
266 |
isAllowOverrideCondensedDistributionRecipe = preferenceCondensedDistribtionRecipe.isAllowOverride(); |
|
267 |
}else{ |
|
268 |
preferenceCondensedDistribtionRecipe = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CdmLightExportCondensedDistributionRecipe, |
|
269 |
PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue() != null? PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getDefaultValue().toString(): null); |
|
270 |
isAllowOverrideCondensedDistributionRecipe = true; |
|
271 |
} |
|
272 |
|
|
273 |
overrideCondensedDistributionRecipe = PreferencesUtil.getBooleanValue( |
|
274 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey()), true) != null? PreferencesUtil.getBooleanValue( |
|
275 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey()), true):false; |
|
276 |
|
|
277 |
if (isAllowOverrideCondensedDistributionRecipe && overrideCondensedDistributionRecipe){ |
|
278 |
String configString = PreferencesUtil.getStringValue(PreferencePredicate.CdmLightExportCondensedDistributionRecipe.getKey(), true); |
|
279 |
if (StringUtils.isNotBlank(configString)){ |
|
280 |
recipe = CondensedDistributionRecipe.valueOf(configString); |
|
281 |
} |
|
282 |
}else{ |
|
283 |
if (preferenceCondensedDistribtionRecipe.getValue() != null){ |
|
284 |
recipe = CondensedDistributionRecipe.valueOf(preferenceCondensedDistribtionRecipe.getValue()); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
} |
|
292 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/ChecklistEditorGeneralPreference.java | ||
---|---|---|
123 | 123 |
GridData sepGrid = createTextGridData(); |
124 | 124 |
separator.setLayoutData(sepGrid); |
125 | 125 |
separator.setVisible(false); |
126 |
CdmPreference dbPref; |
|
126 |
|
|
127 | 127 |
GridData textGrid = createTextGridData(); |
128 | 128 |
textGrid.verticalSpan = 2; |
129 | 129 |
separator.setLayoutData(sepGrid); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/NomenclaturalCodePreferences.java | ||
---|---|---|
139 | 139 |
/** |
140 | 140 |
* @return |
141 | 141 |
*/ |
142 |
private Map<NomenclaturalCode, String> getLabelAndValues() {
|
|
142 |
private void getLabelAndValues() {
|
|
143 | 143 |
List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper |
144 | 144 |
.getSupportedCodes(); |
145 | 145 |
labelAndValues = new HashMap<>(); |
... | ... | |
149 | 149 |
.getDescription(supportedCodes.get(i))) ; |
150 | 150 |
|
151 | 151 |
} |
152 |
return labelAndValues; |
|
152 |
|
|
153 | 153 |
} |
154 | 154 |
|
155 | 155 |
/** |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java | ||
---|---|---|
1792 | 1792 |
* @return |
1793 | 1793 |
*/ |
1794 | 1794 |
public static boolean getLocalActive() { |
1795 |
// TODO this needs to be adapted!!! |
|
1795 |
// TODO: this needs to be adapted!!!
|
|
1796 | 1796 |
return true; |
1797 | 1797 |
} |
1798 |
|
|
1799 |
/** |
|
1800 |
* @return |
|
1801 |
*/ |
|
1802 |
public static boolean showGfbioMetaData() { |
|
1803 |
//TODO: needs to be adapted!!! |
|
1804 |
return false; |
|
1805 |
} |
|
1798 | 1806 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/CdmPreferencePage.java | ||
---|---|---|
176 | 176 |
booleanCombo.add(Messages.Preference_Use_Default + defaultString); |
177 | 177 |
booleanCombo.add(textTrue); |
178 | 178 |
booleanCombo.add(textFalse); |
179 |
|
|
179 |
if (!isAdminPage){ |
|
180 |
booleanCombo.setEnabled(dbPref.isAllowOverride()); |
|
181 |
} |
|
180 | 182 |
return booleanCombo; |
181 | 183 |
} |
182 | 184 |
|
Also available in: Unified diff
ref #9297: add preferences and some code cleaning