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
;
28 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
31 * <p>ImportFromFileDataSourceWizardPage class.</p>
37 public class ImportFromFileDataSourceWizardPage
extends WizardPage
{
39 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
40 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
42 private String
[] extensions
= {"*.xml"};
44 private FileDialog fileDialog
;
46 private Text text_file
;
50 * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
52 * @param title a {@link java.lang.String} object.
53 * @param description a {@link java.lang.String} object.
54 * @param extensions an array of {@link java.lang.String} objects.
56 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
61 setDescription(description
);
63 this.extensions
= extensions
;
69 * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ImportFromFileDataSourceWizardPage} object.
71 protected static ImportFromFileDataSourceWizardPage
XML(){
72 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml","*.*"});
78 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
82 public void createControl(Composite parent
) {
83 final Composite composite
= new Composite(parent
, SWT
.NULL
);
85 setPageComplete(false);
87 GridLayout gridLayout
= new GridLayout();
88 gridLayout
.numColumns
= 3;
89 composite
.setLayout(gridLayout
);
91 Label folderLabel
= new Label(composite
, SWT
.NONE
);
92 folderLabel
.setText("File");
94 fileDialog
= new FileDialog(parent
.getShell());
96 fileDialog
.setFilterExtensions(extensions
);
98 text_file
= new Text(composite
, SWT
.BORDER
);
99 text_file
.setEditable(false);
100 text_file
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
103 Button button
= new Button(composite
, SWT
.PUSH
);
104 button
.setText("Browse...");
106 button
.addSelectionListener(new SelectionAdapter(){
109 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
112 public void widgetSelected(SelectionEvent e
) {
113 String path
= fileDialog
.open();
115 text_file
.setText(path
);
116 setPageComplete(true);
123 setControl(composite
);
129 * @return a {@link java.io.File} object.
131 public File
getFile() {
132 return new File(text_file
.getText());
138 * @return a {@link java.net.URI} object.
140 public URI
getUri() {
141 return getFile().toURI();
145 public boolean isPageComplete() {
146 return CdmUtils
.isNotBlank(text_file
.getText());