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 ImportFromFileDataSourceWizardPageE4
extends WizardPage
{
39 public static final String PAGE_NAME
= "CdmXmlDataSourceWizardPage";
41 private String
[] extensions
= {"*.xml"};
43 private FileDialog fileDialog
;
44 private Text textReferenceString
;
46 protected Text text_source
;
49 public ImportFromFileDataSourceWizardPageE4() {
54 setDescription("Select XML file.");
56 setExtensions(new String
[]{"*.xml","*.*"});
59 public void setExtensions(String
[] extensions
) {
60 this.extensions
= extensions
;
65 public void createControl(Composite parent
) {
66 final Composite composite
= new Composite(parent
, SWT
.NULL
);
68 setPageComplete(false);
70 GridLayout gridLayout
= new GridLayout();
71 gridLayout
.numColumns
= 3;
72 composite
.setLayout(gridLayout
);
74 Label folderLabel
= new Label(composite
, SWT
.NONE
);
75 folderLabel
.setText("File");
77 fileDialog
= new FileDialog(parent
.getShell());
79 fileDialog
.setFilterExtensions(extensions
);
81 text_source
= new Text(composite
, SWT
.BORDER
);
82 text_source
.setEditable(false);
83 text_source
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
86 Button button
= new Button(composite
, SWT
.PUSH
);
87 button
.setText("Browse...");
89 button
.addSelectionListener(new SelectionAdapter(){
92 public void widgetSelected(SelectionEvent e
) {
93 String path
= fileDialog
.open();
95 text_source
.setText(path
);
96 setPageComplete(isPageComplete());
102 Label labelRef
= new Label(composite
, SWT
.NONE
);
103 labelRef
.setText("Default import souce reference");
104 labelRef
.setLayoutData(new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 3, 1));
105 textReferenceString
= new Text(composite
, SWT
.NONE
);
106 textReferenceString
.setEnabled(true);
107 GridData gd_textReferenceString
= new GridData(SWT
.LEFT
, SWT
.TOP
, true, true, 1, 1);
108 gd_textReferenceString
.widthHint
= 229;
109 textReferenceString
.setLayoutData(gd_textReferenceString
);
110 setControl(composite
);
113 public File
getFile() {
114 return new File(text_source
.getText());
117 public Text
getTextReferenceString() {
118 return textReferenceString
;
121 public void setTextReferenceString(Text textReferenceString
) {
122 this.textReferenceString
= textReferenceString
;
125 public URI
getUri() {
126 return getFile().toURI();
130 public boolean isPageComplete() {
131 return CdmUtils
.isNotBlank(text_source
.getText());