2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.io
.e4
.in
;
15 import javax
.inject
.Inject
;
17 import org
.eclipse
.jface
.wizard
.WizardPage
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.events
.SelectionAdapter
;
20 import org
.eclipse
.swt
.events
.SelectionEvent
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Button
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.FileDialog
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Text
;
29 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
37 public class ImportFromFileDataSourceWizardPage
extends WizardPage
{
39 public static final String PAGE_NAME
= "ImportDataSourceWizardPage";
41 private String
[] extensions
= {"*.xml"};
43 private FileDialog fileDialog
;
45 protected Text text_source
;
47 protected Composite composite
;
50 public ImportFromFileDataSourceWizardPage() {
55 setDescription("Select XML file.");
57 setExtensions(new String
[]{"*.xml","*.*"});
60 public void setExtensions(String
[] extensions
) {
61 this.extensions
= extensions
;
66 public void createControl(Composite parent
) {
67 composite
= new Composite(parent
, SWT
.NULL
);
69 setPageComplete(false);
71 GridLayout gridLayout
= new GridLayout();
72 gridLayout
.numColumns
= 2;
73 composite
.setLayout(gridLayout
);
75 Label folderLabel
= new Label(composite
, SWT
.NONE
);
76 folderLabel
.setText("File");
78 fileDialog
= new FileDialog(parent
.getShell());
80 fileDialog
.setFilterExtensions(extensions
);
81 new Label(composite
, SWT
.NONE
);
83 text_source
= new Text(composite
, SWT
.BORDER
);
84 text_source
.setEditable(false);
85 text_source
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
88 Button button
= new Button(composite
, SWT
.PUSH
);
89 button
.setText("Browse...");
91 button
.addSelectionListener(new SelectionAdapter(){
94 public void widgetSelected(SelectionEvent e
) {
95 String path
= fileDialog
.open();
97 text_source
.setText(path
);
98 setPageComplete(isPageComplete());
105 setControl(composite
);
108 public File
getFile() {
109 return new File(text_source
.getText());
112 public URI
getUri() {
113 return getFile().toURI();
117 public boolean isPageComplete() {
118 return CdmUtils
.isNotBlank(text_source
.getText());