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
.eclipse
.jface
.wizard
.WizardPage
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.layout
.GridData
;
16 import org
.eclipse
.swt
.layout
.GridLayout
;
17 import org
.eclipse
.swt
.widgets
.Button
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Event
;
20 import org
.eclipse
.swt
.widgets
.Label
;
21 import org
.eclipse
.swt
.widgets
.Listener
;
22 import org
.eclipse
.swt
.widgets
.Text
;
23 import org
.eclipse
.wb
.swt
.ResourceManager
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
26 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.SelectionDialogFactory
;
29 * <p>ImportFromFileDataSourceWizardPage class.</p>
35 public class ClassificationChooserWizardPage
extends WizardPage
implements Listener
{
37 public static final String PAGE_NAME
= "ClassificationChooserWizardPage";
39 private Text textClassification
;
40 private Classification classification
;
41 private Button btnBrowseClassification
;
43 private Button btnClear
;
46 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
48 * @param title a {@link java.lang.String} object.
49 * @param description a {@link java.lang.String} object.
50 * @param extensions an array of {@link java.lang.String} objects.
52 protected ClassificationChooserWizardPage(String title
, String description
) {
57 setDescription(description
);
64 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
66 protected static ClassificationChooserWizardPage
createPage(){
67 return new ClassificationChooserWizardPage("Choose Classification", "Selecting no classification will create a default one.");
73 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
77 public void createControl(Composite parent
) {
78 final Composite composite
= new Composite(parent
, SWT
.NULL
);
80 setPageComplete(false);
82 GridLayout gridLayout
= new GridLayout();
83 gridLayout
.numColumns
= 4;
84 composite
.setLayout(gridLayout
);
86 Label label
= new Label(composite
, SWT
.NONE
);
87 label
.setText("Classification");
88 textClassification
= new Text(composite
, SWT
.NONE
);
89 textClassification
.setEnabled(false);
90 textClassification
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
91 btnBrowseClassification
= new Button(composite
, SWT
.NONE
);
92 btnBrowseClassification
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
93 btnBrowseClassification
.addListener(SWT
.Selection
, this);
94 btnClear
= new Button(composite
, SWT
.NONE
);
95 btnClear
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
96 btnClear
.addListener(SWT
.Selection
, this);
98 setControl(composite
);
102 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
105 public void handleEvent(Event event
) {
106 if(event
.widget
==btnBrowseClassification
){
107 classification
= SelectionDialogFactory
.getSelectionFromDialog(Classification
.class, getShell(), null, null);
108 if(classification
!=null){
109 textClassification
.setText(classification
.getTitleCache());
112 else if(event
.widget
==btnClear
){
113 classification
= null;
114 textClassification
.setText("");
120 * @return the classification
122 public Classification
getClassification() {
123 return classification
;