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
.FieldEditorPreferencePage
;
14 import org
.eclipse
.jface
.preference
.RadioGroupFieldEditor
;
15 import org
.eclipse
.ui
.IWorkbench
;
16 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
19 import eu
.etaxonomy
.taxeditor
.model
.NomenclaturalCodeHelper
;
20 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
24 * NomenclaturalCodePreferences class.
31 public class NomenclaturalCodePreferences
extends FieldEditorPreferencePage
32 implements IWorkbenchPreferencePage
{
38 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
42 protected void createFieldEditors() {
44 addField(new RadioGroupFieldEditor(
45 IPreferenceKeys
.PREFERRED_NOMENCLATURAL_CODE_KEY
,
46 "Available Codes", 1, getLabelAndValues(),
47 getFieldEditorParent(), true));
54 private String
[][] getLabelAndValues() {
55 List
<NomenclaturalCode
> supportedCodes
= NomenclaturalCodeHelper
57 String
[][] labelAndValues
= new String
[supportedCodes
.size()][2];
58 for (int i
= 0; i
< supportedCodes
.size(); i
++) {
59 labelAndValues
[i
][0] = NomenclaturalCodeHelper
60 .getDescription(supportedCodes
.get(i
));
61 labelAndValues
[i
][1] = PreferencesUtil
62 .getPreferenceKey(supportedCodes
.get(i
));
64 return labelAndValues
;
70 * Initialize the preference page
72 public void init(IWorkbench workbench
) {
73 setPreferenceStore(TaxeditorStorePlugin
.getDefault()
74 .getPreferenceStore());
75 setDescription("Choose which nomenclatural code you would like to use for scientific names unless otherwise specified.");