Features lists now sorted alphabetically. Added microreference, cache strings to...
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / preference / InitNomenclaturalCodePrefDialog.java
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
10 package eu.etaxonomy.taxeditor.preference;
11
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;
25
26 import eu.etaxonomy.taxeditor.ITaxEditorConstants;
27 import eu.etaxonomy.taxeditor.controller.PreferencesController;
28
29 /**
30 * @author p.ciardelli
31 * @created 05.12.2008
32 * @version 1.0
33 */
34 public class InitNomenclaturalCodePrefDialog extends Dialog {
35 private static final Logger logger = Logger
36 .getLogger(InitNomenclaturalCodePrefDialog.class);
37
38 private Button icbnButton;
39 private Button icznButton;
40
41 /**
42 * If the user makes no chance, or cancels, preferred nom. code will be set to the default
43 */
44 private String preferredCode = ITaxEditorConstants.DEFAULT_CODE_PREFERENCE;
45
46 /**
47 * Create the dialog
48 * @param parentShell
49 */
50 public InitNomenclaturalCodePrefDialog(Shell parentShell) {
51 super(parentShell);
52 }
53
54 /**
55 * Create contents of the dialog
56 * @param parent
57 */
58 @Override
59 protected Control createDialogArea(Composite parent) {
60
61 Composite container = (Composite) super.createDialogArea(parent);
62
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.");
67
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());
74
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);
81 }
82 });
83
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);
90 }
91 });
92
93 // More dialog text
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.");
97 //
98 return container;
99 }
100
101 protected void setPreferredCode(String preferredCode) {
102 this.preferredCode = preferredCode;
103 }
104
105 /**
106 * Return the initial size of the dialog
107 */
108 @Override
109 protected Point getInitialSize() {
110 return new Point(500, 375);
111 }
112
113 protected void configureShell(Shell newShell) {
114 super.configureShell(newShell);
115 newShell.setText("Choose a nomenclatural code");
116 }
117
118 public boolean close() {
119
120 // Save preferred nomenclatural code before closing
121 PreferencesController.setNomenclaturalCode(preferredCode);
122
123 return super.close();
124 }
125
126
127 }