3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.io
.wizard
;
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
;
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
;
30 * <p>NomenclaturalCodeWizardPage class.</p>
36 public class NomenclaturalCodeWizardPage
extends WizardPage
{
38 private static final Logger logger
= Logger
.getLogger(NomenclaturalCodeWizardPage
.class);
40 private IImportConfigurator configurator
;
43 * <p>Constructor for NomenclaturalCodeWizardPage.</p>
45 public NomenclaturalCodeWizardPage() {
46 super("Choose nomenclatural code");
48 this.setTitle("Choose nomenclatural code");
50 this.setDescription("Choose which code to use for imported names.");
54 * <p>Constructor for NomenclaturalCodeWizardPage.</p>
56 * @param configurator a {@link eu.etaxonomy.cdm.io.common.IImportConfigurator} object.
58 public NomenclaturalCodeWizardPage(IImportConfigurator configurator
) {
60 this.configurator
= configurator
;
65 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
69 public void createControl(Composite parent
) {
70 Composite container
= new Composite(parent
, SWT
.NULL
);
71 container
.setLayout(new FillLayout());
73 final Group group
= new Group(container
, SWT
.NONE
);
74 group
.setLayout(new GridLayout());
76 NomenclaturalCode preferredCode
= PreferencesUtil
.getPreferredNomenclaturalCode();
78 // set preferred code as default
79 configurator
.setNomenclaturalCode(preferredCode
);
81 for (final NomenclaturalCode code
: NomenclaturalCodeHelper
.getSupportedCodes()) {
82 Button button
= new Button(group
, SWT
.RADIO
);
83 button
.setText(NomenclaturalCodeHelper
.getDescription(code
));
85 button
.setSelection(preferredCode
.equals(code
));
86 button
.addSelectionListener(new SelectionAdapter() {
88 public void widgetSelected(SelectionEvent e
) {
89 configurator
.setNomenclaturalCode((NomenclaturalCode
) e
.widget
.getData());
95 setControl(container
);