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
.FileDialog
;
25 import org
.eclipse
.swt
.widgets
.Label
;
26 import org
.eclipse
.swt
.widgets
.Text
;
29 * <p>ImportFromFileDataSourceWizardPage class.</p>
35 public class ImportFromFileDataSourceWizardPage
extends WizardPage
{
37 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
38 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
40 private String
[] extensions
= {"*.xml"};
42 private FileDialog fileDialog
;
44 private Text text_file
;
48 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
50 * @param title a {@link java.lang.String} object.
51 * @param description a {@link java.lang.String} object.
52 * @param extensions an array of {@link java.lang.String} objects.
54 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
59 setDescription(description
);
61 this.extensions
= extensions
;
67 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ImportFromFileDataSourceWizardPage} object.
69 protected static ImportFromFileDataSourceWizardPage
XML(){
70 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml"});
76 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
79 public void createControl(Composite parent
) {
80 final Composite composite
= new Composite(parent
, SWT
.NULL
);
82 setPageComplete(false);
84 GridLayout gridLayout
= new GridLayout();
85 gridLayout
.numColumns
= 3;
86 composite
.setLayout(gridLayout
);
88 Label folderLabel
= new Label(composite
, SWT
.NONE
);
89 folderLabel
.setText("File");
91 fileDialog
= new FileDialog(parent
.getShell());
93 fileDialog
.setFilterExtensions(extensions
);
95 text_file
= new Text(composite
, SWT
.BORDER
);
96 text_file
.setEditable(false);
97 text_file
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
100 Button button
= new Button(composite
, SWT
.PUSH
);
101 button
.setText("Browse...");
103 button
.addSelectionListener(new SelectionAdapter(){
106 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
109 public void widgetSelected(SelectionEvent e
) {
110 String path
= fileDialog
.open();
111 text_file
.setText(path
);
112 setPageComplete(true);
117 setControl(composite
);
123 * @return a {@link java.io.File} object.
125 public File
getFile() {
126 return new File(text_file
.getText());
132 * @return a {@link java.net.URI} object.
134 public URI
getUri() {
135 return getFile().toURI();