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
;
16 import org
.eclipse
.jface
.wizard
.WizardPage
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.events
.SelectionAdapter
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.widgets
.Button
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Event
;
25 import org
.eclipse
.swt
.widgets
.FileDialog
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Listener
;
28 import org
.eclipse
.swt
.widgets
.Text
;
29 import org
.eclipse
.wb
.swt
.ResourceManager
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
32 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.SelectionDialogFactory
;
35 * <p>ImportFromFileDataSourceWizardPage class.</p>
41 public class ClassificationChooserWizardPage
extends WizardPage
implements Listener
{
43 public static final String PAGE_NAME
= "ClassificationChooserWizardPage";
46 private Text textClassification
;
47 private Classification classification
;
48 private Button btnBrowseClassification
;
50 private Button btnClear
;
53 private FileDialog fileDialogReport
;
54 private Text textFileReport
;
57 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
59 * @param title a {@link java.lang.String} object.
60 * @param description a {@link java.lang.String} object.
61 * @param extensions an array of {@link java.lang.String} objects.
63 protected ClassificationChooserWizardPage(String title
, String description
) {
68 setDescription(description
);
75 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
77 protected static ClassificationChooserWizardPage
createPage(){
78 return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
84 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
88 public void createControl(Composite parent
) {
89 final Composite composite
= new Composite(parent
, SWT
.NULL
);
91 GridLayout gridLayout
= new GridLayout();
92 gridLayout
.numColumns
= 4;
93 composite
.setLayout(gridLayout
);
96 Label label
= new Label(composite
, SWT
.NONE
);
97 label
.setText("Classification");
98 textClassification
= new Text(composite
, SWT
.NONE
);
99 textClassification
.setEnabled(false);
100 textClassification
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
101 btnBrowseClassification
= new Button(composite
, SWT
.NONE
);
102 btnBrowseClassification
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
103 btnBrowseClassification
.addListener(SWT
.Selection
, this);
104 btnClear
= new Button(composite
, SWT
.NONE
);
105 btnClear
.setImage(ResourceManager
.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
106 btnClear
.addListener(SWT
.Selection
, this);
109 Label labelReportFile
= new Label(composite
, SWT
.NONE
);
110 labelReportFile
.setText("Report File");
112 fileDialogReport
= new FileDialog(parent
.getShell());
114 fileDialogReport
.setFilterExtensions(new String
[]{"*.*"});
116 textFileReport
= new Text(composite
, SWT
.BORDER
);
117 textFileReport
.setEditable(false);
118 textFileReport
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
121 Button buttonReport
= new Button(composite
, SWT
.PUSH
);
122 buttonReport
.setText("Browse...");
124 buttonReport
.addSelectionListener(new SelectionAdapter(){
127 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
130 public void widgetSelected(SelectionEvent e
) {
131 String path
= fileDialogReport
.open();
133 textFileReport
.setText(path
);
134 setPageComplete(true);
140 setControl(composite
);
144 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
147 public void handleEvent(Event event
) {
148 if(event
.widget
==btnBrowseClassification
){
149 classification
= SelectionDialogFactory
.getSelectionFromDialog(Classification
.class, getShell(), null, null);
150 if(classification
!=null){
151 textClassification
.setText(classification
.getTitleCache());
154 else if(event
.widget
==btnClear
){
155 classification
= null;
156 textClassification
.setText("");
161 * @return the classification
163 public Classification
getClassification() {
164 return classification
;
167 public URI
getReportUri(){
168 String text
= textFileReport
.getText();
169 if(text
==null || text
.isEmpty()){
172 return new File(text
).toURI();