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
.wizard
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.events
.SelectionAdapter
;
17 import org
.eclipse
.swt
.events
.SelectionEvent
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.layout
.GridLayout
;
20 import org
.eclipse
.swt
.widgets
.Button
;
21 import org
.eclipse
.swt
.widgets
.Composite
;
22 import org
.eclipse
.swt
.widgets
.FileDialog
;
23 import org
.eclipse
.swt
.widgets
.Label
;
24 import org
.eclipse
.swt
.widgets
.Text
;
26 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
34 public class ImportFromFileDataSourceWizardPage
extends AbcdSourceSelectionPage
{
36 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
37 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
39 private String
[] extensions
= {"*.xml"};
41 private FileDialog fileDialog
;
42 private Text textReferenceString
;
44 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
49 setDescription(description
);
51 this.extensions
= extensions
;
54 protected static ImportFromFileDataSourceWizardPage
XML(){
55 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml","*.*"});
60 public void createControl(Composite parent
) {
61 final Composite composite
= new Composite(parent
, SWT
.NULL
);
63 setPageComplete(false);
65 GridLayout gridLayout
= new GridLayout();
66 gridLayout
.numColumns
= 3;
67 composite
.setLayout(gridLayout
);
69 Label folderLabel
= new Label(composite
, SWT
.NONE
);
70 folderLabel
.setText("File");
72 fileDialog
= new FileDialog(parent
.getShell());
74 fileDialog
.setFilterExtensions(extensions
);
76 text_source
= new Text(composite
, SWT
.BORDER
);
77 text_source
.setEditable(false);
78 text_source
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
81 Button button
= new Button(composite
, SWT
.PUSH
);
82 button
.setText("Browse...");
84 button
.addSelectionListener(new SelectionAdapter(){
87 public void widgetSelected(SelectionEvent e
) {
88 String path
= fileDialog
.open();
90 text_source
.setText(path
);
91 setPageComplete(isPageComplete());
97 Label labelRef
= new Label(composite
, SWT
.NONE
);
98 labelRef
.setText("Default import souce reference");
99 labelRef
.setLayoutData(new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 3, 1));
100 textReferenceString
= new Text(composite
, SWT
.NONE
);
101 textReferenceString
.setEnabled(true);
102 GridData gd_textReferenceString
= new GridData(SWT
.LEFT
, SWT
.TOP
, true, true, 1, 1);
103 gd_textReferenceString
.widthHint
= 229;
104 textReferenceString
.setLayoutData(gd_textReferenceString
);
105 setControl(composite
);
108 public File
getFile() {
109 return new File(text_source
.getText());
112 public Text
getTextReferenceString() {
113 return textReferenceString
;
116 public void setTextReferenceString(Text textReferenceString
) {
117 this.textReferenceString
= textReferenceString
;
122 public URI
getUri() {
123 return getFile().toURI();
127 public boolean isPageComplete() {
128 return CdmUtils
.isNotBlank(text_source
.getText());