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
.swt
.SWT
;
17 import org
.eclipse
.swt
.events
.SelectionAdapter
;
18 import org
.eclipse
.swt
.events
.SelectionEvent
;
19 import org
.eclipse
.swt
.layout
.GridData
;
20 import org
.eclipse
.swt
.layout
.GridLayout
;
21 import org
.eclipse
.swt
.widgets
.Button
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.FileDialog
;
24 import org
.eclipse
.swt
.widgets
.Label
;
25 import org
.eclipse
.swt
.widgets
.Text
;
27 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
35 public class ImportFromFileDataSourceWizardPage
extends AbcdSourceSelectionPage
{
37 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
38 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
40 private String
[] extensions
= {"*.xml"};
42 private FileDialog fileDialog
;
46 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
51 setDescription(description
);
53 this.extensions
= extensions
;
56 protected static ImportFromFileDataSourceWizardPage
XML(){
57 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml","*.*"});
62 public void createControl(Composite parent
) {
63 final Composite composite
= new Composite(parent
, SWT
.NULL
);
65 setPageComplete(false);
67 GridLayout gridLayout
= new GridLayout();
68 gridLayout
.numColumns
= 3;
69 composite
.setLayout(gridLayout
);
71 Label folderLabel
= new Label(composite
, SWT
.NONE
);
72 folderLabel
.setText("File");
74 fileDialog
= new FileDialog(parent
.getShell());
76 fileDialog
.setFilterExtensions(extensions
);
78 text_source
= new Text(composite
, SWT
.BORDER
);
79 text_source
.setEditable(false);
80 text_source
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
83 Button button
= new Button(composite
, SWT
.PUSH
);
84 button
.setText("Browse...");
86 button
.addSelectionListener(new SelectionAdapter(){
89 public void widgetSelected(SelectionEvent e
) {
90 String path
= fileDialog
.open();
92 text_source
.setText(path
);
93 setPageComplete(true);
100 setControl(composite
);
103 public File
getFile() {
104 return new File(text_source
.getText());
108 public URI
getUri() {
109 return getFile().toURI();
113 public boolean isPageComplete() {
114 return CdmUtils
.isNotBlank(text_source
.getText());