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
.preference
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.jface
.dialogs
.Dialog
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.events
.SelectionAdapter
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.graphics
.Point
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.layout
.GridLayout
;
20 import org
.eclipse
.swt
.widgets
.Button
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.Control
;
23 import org
.eclipse
.swt
.widgets
.Label
;
24 import org
.eclipse
.swt
.widgets
.Shell
;
26 import eu
.etaxonomy
.taxeditor
.ITaxEditorConstants
;
27 import eu
.etaxonomy
.taxeditor
.controller
.PreferencesController
;
34 public class InitNomenclaturalCodePrefDialog
extends Dialog
{
35 private static final Logger logger
= Logger
36 .getLogger(InitNomenclaturalCodePrefDialog
.class);
38 private Button icbnButton
;
39 private Button icznButton
;
42 * If the user makes no chance, or cancels, preferred nom. code will be set to the default
44 private String preferredCode
= ITaxEditorConstants
.DEFAULT_CODE_PREFERENCE
;
50 public InitNomenclaturalCodePrefDialog(Shell parentShell
) {
55 * Create contents of the dialog
59 protected Control
createDialogArea(Composite parent
) {
61 Composite container
= (Composite
) super.createDialogArea(parent
);
63 // Create label with description of dialog
64 final Label chooseANomenclaturalLabel
= new Label(container
, SWT
.WRAP
);
65 chooseANomenclaturalLabel
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
66 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.");
68 // Create composite to show radio buttons
69 final Composite buttonsComposite
= new Composite(container
, SWT
.NONE
);
70 final GridData gd_buttonsComposite
= new GridData();
71 gd_buttonsComposite
.horizontalIndent
= 20;
72 buttonsComposite
.setLayoutData(gd_buttonsComposite
);
73 buttonsComposite
.setLayout(new GridLayout());
75 // Create ICBN radio button
76 icbnButton
= new Button(buttonsComposite
, SWT
.RADIO
);
77 icbnButton
.setText("International Code of Botanical Nomenclature (ICBN)");
78 icbnButton
.addSelectionListener(new SelectionAdapter() {
79 public void widgetSelected(SelectionEvent e
) {
80 setPreferredCode(ITaxEditorConstants
.CODE_PREFERENCE_ICBN
);
84 // Create ICZN radio button
85 icznButton
= new Button(buttonsComposite
, SWT
.RADIO
);
86 icznButton
.setText("International Code of Zoological Nomenclature (ICZN)");
87 icznButton
.addSelectionListener(new SelectionAdapter() {
88 public void widgetSelected(SelectionEvent e
) {
89 setPreferredCode(ITaxEditorConstants
.CODE_PREFERENCE_ICZN
);
94 final Label chooseANomenclaturalLabel_1
= new Label(container
, SWT
.WRAP
);
95 chooseANomenclaturalLabel_1
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
96 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 botanical code at any time in the \"Preferences\" menu.");
101 protected void setPreferredCode(String preferredCode
) {
102 this.preferredCode
= preferredCode
;
106 * Return the initial size of the dialog
109 protected Point
getInitialSize() {
110 return new Point(500, 375);
113 protected void configureShell(Shell newShell
) {
114 super.configureShell(newShell
);
115 newShell
.setText("Choose a nomenclatural code");
118 public boolean close() {
120 // Save preferred nomenclatural code before closing
121 PreferencesController
.setNomenclaturalCode(preferredCode
);
123 return super.close();