b79c419719af1ac09ab8313f22df727539f4ee2d
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / io / e4 / in / NomenclaturalCodeWizardPageE4.java
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.e4.in;
11
12 import javax.inject.Inject;
13
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 *
31 * @author p.ciardelli
32 * @created 11.09.2009
33 * @version 1.0
34 */
35 public class NomenclaturalCodeWizardPageE4 extends WizardPage {
36
37 private IImportConfigurator configurator;
38
39 @Inject
40 public NomenclaturalCodeWizardPageE4() {
41 super("Choose nomenclatural code");
42
43 this.setTitle("Choose nomenclatural code");
44
45 this.setDescription("Choose which code to use for imported names.");
46 }
47
48 public void setConfigurator(IImportConfigurator configurator) {
49 this.configurator = configurator;
50 }
51
52 /** {@inheritDoc} */
53 @Override
54 public void createControl(Composite parent) {
55 Composite container = new Composite(parent, SWT.NULL);
56 container.setLayout(new FillLayout());
57
58 final Group group = new Group(container, SWT.NONE);
59 group.setLayout(new GridLayout());
60
61 NomenclaturalCode preferredCode = PreferencesUtil.getPreferredNomenclaturalCode(false);
62
63 // set preferred code as default
64 configurator.setNomenclaturalCode(preferredCode);
65
66 for (final NomenclaturalCode code : NomenclaturalCodeHelper.getSupportedCodes()) {
67 Button button = new Button(group, SWT.RADIO);
68 button.setText(NomenclaturalCodeHelper.getDescription(code));
69 button.setData(code);
70 button.setSelection(preferredCode.equals(code));
71 button.addSelectionListener(new SelectionAdapter() {
72 @Override
73 public void widgetSelected(SelectionEvent e) {
74 configurator.setNomenclaturalCode((NomenclaturalCode) e.widget.getData());
75 }
76 });
77 }
78 setControl(container);
79 }
80
81 }