Project

General

Profile

Download (4.15 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

    
10
package eu.etaxonomy.taxeditor.store.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.store.model.Resources;
27

    
28
/** 
29
 * @author p.ciardelli
30
 * @created 05.12.2008
31
 * @version 1.0
32
 */
33
public class InitNomenclaturalCodePrefDialog extends Dialog {
34
	private static final Logger logger = Logger
35
			.getLogger(InitNomenclaturalCodePrefDialog.class);
36
	
37
	private Button icbnButton;
38
	private Button icznButton;
39

    
40
	/**
41
	 * If the user makes no chance, or cancels, preferred nom. code will be set to the default
42
	 */
43
	private String preferredCode = Resources.DEFAULT_CODE_PREFERENCE;
44

    
45
	/**
46
	 * Create the dialog
47
	 * @param parentShell
48
	 */
49
	public InitNomenclaturalCodePrefDialog(Shell parentShell) {
50
		super(parentShell);
51
	}
52
	
53
	/**
54
	 * Create contents of the dialog
55
	 * @param parent
56
	 */
57
	@Override
58
	protected Control createDialogArea(Composite parent) {
59

    
60
		Composite container = (Composite) super.createDialogArea(parent);
61

    
62
		// Create label with description of dialog
63
		final Label chooseANomenclaturalLabel = new Label(container, SWT.WRAP);
64
		chooseANomenclaturalLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
65
		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.");
66

    
67
		// Create composite to show radio buttons
68
		final Composite buttonsComposite = new Composite(container, SWT.NONE);
69
		final GridData gd_buttonsComposite = new GridData();
70
		gd_buttonsComposite.horizontalIndent = 20;
71
		buttonsComposite.setLayoutData(gd_buttonsComposite);
72
		buttonsComposite.setLayout(new GridLayout());
73

    
74
		// Create ICBN radio button
75
		icbnButton = new Button(buttonsComposite, SWT.RADIO);
76
		icbnButton.setText("International Code of Botanical Nomenclature (ICBN)");
77
		icbnButton.addSelectionListener(new SelectionAdapter() {
78
			public void widgetSelected(SelectionEvent e) {
79
				setPreferredCode(Resources.CODE_PREFERENCE_ICBN);
80
			}
81
		});
82

    
83
		// Create ICZN radio button
84
		icznButton = new Button(buttonsComposite, SWT.RADIO);
85
		icznButton.setText("International Code of Zoological Nomenclature (ICZN)");
86
		icznButton.addSelectionListener(new SelectionAdapter() {
87
			public void widgetSelected(SelectionEvent e) {
88
				setPreferredCode(Resources.CODE_PREFERENCE_ICZN);
89
			}
90
		});
91
	
92
		// More dialog text		
93
		final Label chooseANomenclaturalLabel_1 = new Label(container, SWT.WRAP);
94
		chooseANomenclaturalLabel_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
95
		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.");
96
		//
97
		return container;
98
	}
99

    
100
	protected void setPreferredCode(String preferredCode) {
101
		this.preferredCode = preferredCode;
102
	}
103

    
104
	/**
105
	 * Return the initial size of the dialog
106
	 */
107
	@Override
108
	protected Point getInitialSize() {
109
		return new Point(500, 375);
110
	}
111
	
112
	protected void configureShell(Shell newShell) {
113
		super.configureShell(newShell);
114
		newShell.setText("Choose a nomenclatural code");
115
	}
116
		
117
	public boolean close() {
118
		
119
		// Save preferred nomenclatural code before closing
120
		PreferencesUtil.setNomenclaturalCode(preferredCode);
121
		
122
		return super.close();
123
	}
124
	
125
	
126
}
(4-4/9)