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
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.events
.SelectionAdapter
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.layout
.GridData
;
18 import org
.eclipse
.swt
.layout
.GridLayout
;
19 import org
.eclipse
.swt
.widgets
.Button
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.FileDialog
;
22 import org
.eclipse
.swt
.widgets
.Label
;
23 import org
.eclipse
.swt
.widgets
.Text
;
25 import eu
.etaxonomy
.cdm
.common
.URI
;
26 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
32 public class ImportFromFileDataSourceWizardPage
extends AbcdSourceSelectionPage
{
34 /** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
35 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
37 private String
[] extensions
= {"*.xml"};
39 private FileDialog fileDialog
;
40 private Text textReferenceString
;
42 protected ImportFromFileDataSourceWizardPage(String title
, String description
, String
[] extensions
) {
47 setDescription(description
);
49 this.extensions
= extensions
;
52 protected static ImportFromFileDataSourceWizardPage
XML(){
53 return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String
[]{"*.xml","*.*"});
58 public void createControl(Composite parent
) {
59 final Composite composite
= new Composite(parent
, SWT
.NULL
);
61 setPageComplete(false);
63 GridLayout gridLayout
= new GridLayout();
64 gridLayout
.numColumns
= 3;
65 composite
.setLayout(gridLayout
);
67 Label folderLabel
= new Label(composite
, SWT
.NONE
);
68 folderLabel
.setText("File");
70 fileDialog
= new FileDialog(parent
.getShell());
72 fileDialog
.setFilterExtensions(extensions
);
74 text_source
= new Text(composite
, SWT
.BORDER
);
75 text_source
.setEditable(false);
76 text_source
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
79 Button button
= new Button(composite
, SWT
.PUSH
);
80 button
.setText("Browse...");
82 button
.addSelectionListener(new SelectionAdapter(){
85 public void widgetSelected(SelectionEvent e
) {
86 String path
= fileDialog
.open();
88 text_source
.setText(path
);
89 setPageComplete(isPageComplete());
95 Label labelRef
= new Label(composite
, SWT
.NONE
);
96 labelRef
.setText("Default import souce reference");
97 labelRef
.setLayoutData(new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 3, 1));
98 textReferenceString
= new Text(composite
, SWT
.NONE
);
99 textReferenceString
.setEnabled(true);
100 GridData gd_textReferenceString
= new GridData(SWT
.LEFT
, SWT
.TOP
, true, true, 1, 1);
101 gd_textReferenceString
.widthHint
= 229;
102 textReferenceString
.setLayoutData(gd_textReferenceString
);
103 setControl(composite
);
106 public File
getFile() {
107 return new File(text_source
.getText());
110 public Text
getTextReferenceString() {
111 return textReferenceString
;
114 public void setTextReferenceString(Text textReferenceString
) {
115 this.textReferenceString
= textReferenceString
;
119 public URI
getUri() {
120 return URI
.fromFile(getFile());
124 public boolean isPageComplete() {
125 return CdmUtils
.isNotBlank(text_source
.getText());