2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.io
.e4
.in
;
12 import javax
.inject
.Inject
;
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
;
35 public class NomenclaturalCodeWizardPageE4
extends WizardPage
{
37 private IImportConfigurator configurator
;
40 public NomenclaturalCodeWizardPageE4() {
41 super("Choose nomenclatural code");
43 this.setTitle("Choose nomenclatural code");
45 this.setDescription("Choose which code to use for imported names.");
48 public void setConfigurator(IImportConfigurator configurator
) {
49 this.configurator
= configurator
;
54 public void createControl(Composite parent
) {
55 Composite container
= new Composite(parent
, SWT
.NULL
);
56 container
.setLayout(new FillLayout());
58 final Group group
= new Group(container
, SWT
.NONE
);
59 group
.setLayout(new GridLayout());
61 NomenclaturalCode preferredCode
= PreferencesUtil
.getPreferredNomenclaturalCode(false);
63 // set preferred code as default
64 configurator
.setNomenclaturalCode(preferredCode
);
66 for (final NomenclaturalCode code
: NomenclaturalCodeHelper
.getSupportedCodes()) {
67 Button button
= new Button(group
, SWT
.RADIO
);
68 button
.setText(NomenclaturalCodeHelper
.getDescription(code
));
70 button
.setSelection(preferredCode
.equals(code
));
71 button
.addSelectionListener(new SelectionAdapter() {
73 public void widgetSelected(SelectionEvent e
) {
74 configurator
.setNomenclaturalCode((NomenclaturalCode
) e
.widget
.getData());
78 setControl(container
);