78a40b855648a5e44b23f21a22aac194e838fe19
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
.menu
;
11 import java
.util
.List
;
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
.widgets
.Button
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
20 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
21 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
22 import eu
.etaxonomy
.taxeditor
.store
.TermStore
;
25 * Allows the user to choose which <code>Rank</code>s to display in the
26 * <code>PropertySheet</code> drop-down menu for <code>TaxonNameBase</code>.
33 public class RankMenuPreferences
extends AbstractMenuPreferences
<Rank
> implements
34 IWorkbenchPreferencePage
{
36 /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.rank"{trunked}</code> */
37 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.preferences.ranks";
40 * <p>Constructor for RankMenuPreferences.</p>
42 public RankMenuPreferences() {
43 super("Rank Preferences",
44 "Choose which ranks to display in the property sheet drop-down menu.",
49 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#createAdditionalContent(org.eclipse.swt.widgets.Composite)
53 protected void createAdditionalContent(Composite container
) {
55 // TODO create option to sort ranks either alphabetically or hierarchically (asc- or descending)
57 final Button checkbox
= new Button(container
, SWT
.CHECK
);
58 checkbox
.setText("Sort ranks hierarchically (default is alphabetically)");
60 checkbox
.setSelection(PreferencesUtil
.getSortRanksHierarchichally());
62 checkbox
.addSelectionListener(new SelectionAdapter() {
64 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
67 public void widgetSelected(SelectionEvent e
) {
68 PreferencesUtil
.setSortRanksHierarchichally(checkbox
.getSelection());
69 refresh(TermStore
.getRanks());
76 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
80 protected Class
<Rank
> getTermClass() {
85 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTerms()
88 protected List
<Rank
> getTerms() {
89 return TermStore
.getRanks();