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.
9 package eu
.etaxonomy
.taxeditor
.io
.e4
.in
;
13 import javax
.inject
.Inject
;
15 import org
.eclipse
.jface
.wizard
.WizardPage
;
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
.URI
;
28 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
34 public class ImportFromFileDataSourceWizardPage
extends WizardPage
{
36 public static final String PAGE_NAME
= "ImportDataSourceWizardPage";
38 private String
[] extensions
= {"*.xml"};
40 private FileDialog fileDialog
;
42 protected Text text_source
;
44 protected Composite composite
;
47 public ImportFromFileDataSourceWizardPage() {
52 setDescription("Select XML file.");
54 setExtensions(new String
[]{"*.xml","*.*"});
57 public void setExtensions(String
[] extensions
) {
58 this.extensions
= extensions
;
62 public void createControl(Composite parent
) {
63 composite
= new Composite(parent
, SWT
.NULL
);
65 setPageComplete(false);
67 GridLayout gridLayout
= new GridLayout();
68 gridLayout
.numColumns
= 2;
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
);
77 new Label(composite
, SWT
.NONE
);
79 text_source
= new Text(composite
, SWT
.BORDER
);
80 text_source
.setEditable(false);
81 text_source
.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_source
.setText(path
);
94 setPageComplete(isPageComplete());
99 setControl(composite
);
102 public File
getFile() {
103 return new File(text_source
.getText());
106 public URI
getUri() {
107 return URI
.fromFile(getFile());
111 public boolean isPageComplete() {
112 return CdmUtils
.isNotBlank(text_source
.getText());