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.
10 package eu
.etaxonomy
.taxeditor
.store
.preference
;
12 import org
.eclipse
.jface
.dialogs
.Dialog
;
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
.graphics
.Point
;
17 import org
.eclipse
.swt
.layout
.GridData
;
18 import org
.eclipse
.swt
.layout
.GridLayout
;
19 import org
.eclipse
.swt
.widgets
.Button
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Control
;
22 import org
.eclipse
.swt
.widgets
.Label
;
23 import org
.eclipse
.swt
.widgets
.Shell
;
25 import eu
.etaxonomy
.taxeditor
.store
.model
.Resources
;
32 public class InitNomenclaturalCodePrefDialog
extends Dialog
{
34 private Button icbnButton
;
35 private Button icznButton
;
38 * If the user makes no chance, or cancels, preferred nom. code will be set to the default
40 private String preferredCode
= Resources
.DEFAULT_CODE_PREFERENCE
;
46 public InitNomenclaturalCodePrefDialog(Shell parentShell
) {
51 * Create contents of the dialog
55 protected Control
createDialogArea(Composite parent
) {
57 Composite container
= (Composite
) super.createDialogArea(parent
);
59 // Create label with description of dialog
60 final Label chooseANomenclaturalLabel
= new Label(container
, SWT
.WRAP
);
61 chooseANomenclaturalLabel
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
62 chooseANomenclaturalLabel
.setText("Welcome to the EDIT Taxonomic Editor.\n\nBefore proceeding, please choose a nomenclatural code. This code will be used to create new names and to parse name text.");
64 // Create composite to show radio buttons
65 final Composite buttonsComposite
= new Composite(container
, SWT
.NONE
);
66 final GridData gd_buttonsComposite
= new GridData();
67 gd_buttonsComposite
.horizontalIndent
= 20;
68 buttonsComposite
.setLayoutData(gd_buttonsComposite
);
69 buttonsComposite
.setLayout(new GridLayout());
71 // Create ICBN radio button
72 icbnButton
= new Button(buttonsComposite
, SWT
.RADIO
);
73 icbnButton
.setText("International Code of Botanical Nomenclature (ICBN)");
74 icbnButton
.addSelectionListener(new SelectionAdapter() {
75 public void widgetSelected(SelectionEvent e
) {
76 setPreferredCode(Resources
.CODE_PREFERENCE_ICBN
);
80 // Create ICZN radio button
81 icznButton
= new Button(buttonsComposite
, SWT
.RADIO
);
82 icznButton
.setText("International Code of Zoological Nomenclature (ICZN)");
83 icznButton
.addSelectionListener(new SelectionAdapter() {
84 public void widgetSelected(SelectionEvent e
) {
85 setPreferredCode(Resources
.CODE_PREFERENCE_ICZN
);
90 final Label chooseANomenclaturalLabel_1
= new Label(container
, SWT
.WRAP
);
91 chooseANomenclaturalLabel_1
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
92 chooseANomenclaturalLabel_1
.setText("If you hit \"Cancel\", & the International Code of Botanical Nomenclature (ICBN) will be set as your default nomenclatural code.\n\nYou can change the nomenclatural code at any time in the \"Preferences\" menu.");
97 protected void setPreferredCode(String preferredCode
) {
98 this.preferredCode
= preferredCode
;
102 * Return the initial size of the dialog
105 protected Point
getInitialSize() {
106 return new Point(500, 375);
109 protected void configureShell(Shell newShell
) {
110 super.configureShell(newShell
);
111 newShell
.setText("Choose a nomenclatural code");
114 public boolean close() {
116 // Save preferred nomenclatural code before closing
117 PreferencesUtil
.setNomenclaturalCode(preferredCode
);
119 return super.close();