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)
80 public void createControl(Composite parent
) {
81 final Composite composite
= new Composite(parent
, SWT
.NULL
);
83 setPageComplete(false);
85 GridLayout gridLayout
= new GridLayout();
86 gridLayout
.numColumns
= 3;
87 composite
.setLayout(gridLayout
);
89 Label folderLabel
= new Label(composite
, SWT
.NONE
);
90 folderLabel
.setText("File");
92 fileDialog
= new FileDialog(parent
.getShell());
94 fileDialog
.setFilterExtensions(extensions
);
96 text_file
= new Text(composite
, SWT
.BORDER
);
97 text_file
.setEditable(false);
98 text_file
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
101 Button button
= new Button(composite
, SWT
.PUSH
);
102 button
.setText("Browse...");
104 button
.addSelectionListener(new SelectionAdapter(){
107 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
110 public void widgetSelected(SelectionEvent e
) {
111 String path
= fileDialog
.open();
113 text_file
.setText(path
);
114 setPageComplete(true);
121 setControl(composite
);
127 * @return a {@link java.io.File} object.
129 public File
getFile() {
130 return new File(text_file
.getText());
136 * @return a {@link java.net.URI} object.
138 public URI
getUri() {
139 return getFile().toURI();