Project

General

Profile

Download (2.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 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 java.util.List;
12

    
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;
17

    
18
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
20
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
21

    
22
/**
23
 * <p>
24
 * NomenclaturalCodePreferences class.
25
 * </p>
26
 * 
27
 * @author p.ciardelli
28
 * @created 16.09.2008
29
 * @version 1.0
30
 */
31
public class NomenclaturalCodePreferences extends FieldEditorPreferencePage
32
		implements IWorkbenchPreferencePage {
33

    
34
	/*
35
	 * (non-Javadoc)
36
	 * 
37
	 * @see
38
	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
39
	 * ()
40
	 */
41
	@Override
42
	protected void createFieldEditors() {
43

    
44
		addField(new RadioGroupFieldEditor(
45
				IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY,
46
				"Available Codes", 1, getLabelAndValues(),
47
				getFieldEditorParent(), true));
48

    
49
	}
50

    
51
	/**
52
	 * @return
53
	 */
54
	private String[][] getLabelAndValues() {
55
		List<NomenclaturalCode> supportedCodes = NomenclaturalCodeHelper
56
				.getSupportedCodes();
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));
63
		}
64
		return labelAndValues;
65
	}
66

    
67
	/**
68
	 * {@inheritDoc}
69
	 * 
70
	 * Initialize the preference page
71
	 */
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.");
76
	}
77

    
78
}
(15-15/24)