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.
9 package eu
.etaxonomy
.taxeditor
.preference
;
11 import java
.util
.List
;
13 import org
.eclipse
.jface
.preference
.BooleanFieldEditor
;
14 import org
.eclipse
.jface
.preference
.ComboFieldEditor
;
15 import org
.eclipse
.jface
.preference
.FieldEditorPreferencePage
;
16 import org
.eclipse
.ui
.IWorkbench
;
17 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
20 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
21 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
25 * NomenclaturalCodePreferences class.
32 public class NomenclaturalCodePreferences
extends FieldEditorPreferencePage
33 implements IWorkbenchPreferencePage
{
39 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
43 protected void createFieldEditors() {
45 addField(new ComboFieldEditor(
46 IPreferenceKeys
.PREFERRED_NOMENCLATURAL_CODE_KEY
,
47 "Available Codes", getLabelAndValues(),
48 getFieldEditorParent()));
49 addField(new BooleanFieldEditor(
50 IPreferenceKeys
.OVERRIDE_NOMENCLATURAL_CODE_KEY
,
51 "Use local nomenclatural code",
52 getFieldEditorParent()));
59 private String
[][] getLabelAndValues() {
60 List
<NomenclaturalCode
> supportedCodes
= NomenclaturalCodeHelper
62 String
[][] labelAndValues
= new String
[supportedCodes
.size()][2];
63 for (int i
= 0; i
< supportedCodes
.size(); i
++) {
64 labelAndValues
[i
][0] = NomenclaturalCodeHelper
65 .getDescription(supportedCodes
.get(i
));
66 labelAndValues
[i
][1] = PreferencesUtil
67 .getPreferenceKey(supportedCodes
.get(i
));
69 return labelAndValues
;
75 * Initialize the preference page
78 public void init(IWorkbench workbench
) {
79 setPreferenceStore(TaxeditorStorePlugin
.getDefault()
80 .getPreferenceStore());
81 setDescription("Choose which nomenclatural code you would like to use in your local application for scientific names unless otherwise specified.");
82 //PreferencesUtil.setPreferredNomenclaturalCode(null, true);
86 public boolean performOk() {
88 boolean result
= super.performOk();
90 // String value = getPreferenceStore().getString(IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY);
91 // CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
92 // ICdmApplicationConfiguration controller = CdmStore.getCurrentApplicationConfiguration();
93 // if (controller == null){
96 // IPreferenceService service = controller.getPreferenceService();