Project

General

Profile

Download (2.85 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.io.wizard;
11

    
12
import org.apache.log4j.Logger;
13
import org.eclipse.jface.wizard.WizardPage;
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.layout.FillLayout;
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.Group;
22

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

    
28
/**
29
 * <p>NomenclaturalCodeWizardPage class.</p>
30
 *
31
 * @author p.ciardelli
32
 * @created 11.09.2009
33
 * @version 1.0
34
 */
35
public class NomenclaturalCodeWizardPage extends WizardPage {
36

    
37
    private static final Logger logger = Logger.getLogger(NomenclaturalCodeWizardPage.class);
38

    
39
    private IImportConfigurator configurator;
40

    
41
	/**
42
	 * <p>Constructor for NomenclaturalCodeWizardPage.</p>
43
	 */
44
	public NomenclaturalCodeWizardPage() {
45
		super("Choose nomenclatural code");
46

    
47
		this.setTitle("Choose nomenclatural code");
48

    
49
		this.setDescription("Choose which code to use for imported names.");
50
	}
51

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

    
62

    
63
	/* (non-Javadoc)
64
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
65
	 */
66
	/** {@inheritDoc} */
67
	@Override
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(false);
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
				@Override
87
                public void widgetSelected(SelectionEvent e) {
88
					configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
89
				}
90
			});
91
		}
92

    
93

    
94
		setControl(container);
95
	}
96

    
97

    
98
}
(24-24/30)