Project

General

Profile

Download (2.83 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.io.wizard;
12

    
13
import org.apache.log4j.Logger;
14
import org.eclipse.jface.wizard.WizardPage;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.layout.FillLayout;
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.Group;
23

    
24
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
25
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
26
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28

    
29
/**
30
 * <p>NomenclaturalCodeWizardPage class.</p>
31
 *
32
 * @author p.ciardelli
33
 * @created 11.09.2009
34
 * @version 1.0
35
 */
36
public class NomenclaturalCodeWizardPage extends WizardPage {
37
	
38
	private IImportConfigurator configurator;
39

    
40
	/**
41
	 * <p>Constructor for NomenclaturalCodeWizardPage.</p>
42
	 */
43
	public NomenclaturalCodeWizardPage() {
44
		super("Choose nomenclatural code");
45
		
46
		this.setTitle("Choose nomenclatural code");
47
		
48
		this.setDescription("Choose which code to use for imported names.");
49
	}
50

    
51
	/**
52
	 * <p>Constructor for NomenclaturalCodeWizardPage.</p>
53
	 *
54
	 * @param configurator a {@link eu.etaxonomy.cdm.io.common.IImportConfigurator} object.
55
	 */
56
	public NomenclaturalCodeWizardPage(IImportConfigurator configurator) {
57
		this();
58
		this.configurator = configurator;
59
	}
60

    
61
	private static final Logger logger = Logger
62
			.getLogger(NomenclaturalCodeWizardPage.class);
63

    
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
66
	 */
67
	/** {@inheritDoc} */
68
	public void createControl(Composite parent) {
69
		Composite container = new Composite(parent, SWT.NULL);
70
		container.setLayout(new FillLayout());
71
				
72
		final Group group = new Group(container, SWT.NONE);
73
		group.setLayout(new GridLayout());
74
		
75
		NomenclaturalCode preferredCode = PreferencesUtil.getPreferredNomenclaturalCode();
76
		
77
		// set preferred code as default
78
		configurator.setNomenclaturalCode(preferredCode);
79
		
80
		for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
81
			Button button = new Button(group, SWT.RADIO);
82
			button.setText(NomenclaturalCodeHelper.getDescription(code));
83
			button.setData(code);
84
			button.setSelection(preferredCode.equals(code));
85
			button.addSelectionListener(new SelectionAdapter() {
86
				public void widgetSelected(SelectionEvent e) {
87
					configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
88
				}
89
			});
90
		}		
91
		
92
		setControl(container);
93
	}
94
}
(16-16/20)