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
;
36 public class ImportFromFileDataSourceWizardPage
extends WizardPage
{
38 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
39 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
41 private String
[] extensions
= {"*.xml"};
43 private FileDialog fileDialog
;
45 private Text text_file
;
47 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
52 setDescription(description
);
54 this.extensions
= extensions
;
57 protected static ImportFromFileDataSourceWizardPage
XML(){
58 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml","*.*"});
63 public void createControl(Composite parent
) {
64 final Composite composite
= new Composite(parent
, SWT
.NULL
);
66 setPageComplete(false);
68 GridLayout gridLayout
= new GridLayout();
69 gridLayout
.numColumns
= 3;
70 composite
.setLayout(gridLayout
);
72 Label folderLabel
= new Label(composite
, SWT
.NONE
);
73 folderLabel
.setText("File");
75 fileDialog
= new FileDialog(parent
.getShell());
77 fileDialog
.setFilterExtensions(extensions
);
79 text_file
= new Text(composite
, SWT
.BORDER
);
80 text_file
.setEditable(false);
81 text_file
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
84 Button button
= new Button(composite
, SWT
.PUSH
);
85 button
.setText("Browse...");
87 button
.addSelectionListener(new SelectionAdapter(){
90 public void widgetSelected(SelectionEvent e
) {
91 String path
= fileDialog
.open();
93 text_file
.setText(path
);
94 setPageComplete(true);
101 setControl(composite
);
104 public File
getFile() {
105 return new File(text_file
.getText());
108 public URI
getUri() {
109 return getFile().toURI();
113 public boolean isPageComplete() {
114 return CdmUtils
.isNotBlank(text_file
.getText());