1 |
13862f35
|
n.hoffmann
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
650cafb4
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
13862f35
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
650cafb4
|
Patric Plitzner
|
*
|
6 |
13862f35
|
n.hoffmann
|
* 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.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.taxeditor.io.wizard;
|
11 |
|
|
|
12 |
ddb51c5b
|
n.hoffmann
|
import java.io.File;
|
13 |
|
|
import java.net.URI;
|
14 |
|
|
|
15 |
13862f35
|
n.hoffmann
|
import org.eclipse.swt.SWT;
|
16 |
79b9396a
|
n.hoffmann
|
import org.eclipse.swt.events.SelectionAdapter;
|
17 |
|
|
import org.eclipse.swt.events.SelectionEvent;
|
18 |
13862f35
|
n.hoffmann
|
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;
|
25 |
|
|
|
26 |
7df92cb1
|
p.plitzner
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
27 |
|
|
|
28 |
13862f35
|
n.hoffmann
|
/**
|
29 |
3be6ef3e
|
n.hoffmann
|
*
|
30 |
13862f35
|
n.hoffmann
|
* @author n.hoffmann
|
31 |
|
|
* @created 04.08.2009
|
32 |
|
|
* @version 1.0
|
33 |
|
|
*/
|
34 |
7563a18e
|
Katja Luther
|
public class ImportFromFileDataSourceWizardPage extends AbcdSourceSelectionPage {
|
35 |
650cafb4
|
Patric Plitzner
|
|
36 |
3be6ef3e
|
n.hoffmann
|
/** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
|
37 |
13862f35
|
n.hoffmann
|
public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage";
|
38 |
|
|
|
39 |
|
|
private String[] extensions = {"*.xml"};
|
40 |
|
|
|
41 |
|
|
private FileDialog fileDialog;
|
42 |
eeaf651a
|
Katja Luther
|
private Text textReferenceString;
|
43 |
650cafb4
|
Patric Plitzner
|
|
44 |
13862f35
|
n.hoffmann
|
protected ImportFromFileDataSourceWizardPage(String title, String description, String[] extensions) {
|
45 |
|
|
super(PAGE_NAME);
|
46 |
650cafb4
|
Patric Plitzner
|
|
47 |
13862f35
|
n.hoffmann
|
setTitle(title);
|
48 |
650cafb4
|
Patric Plitzner
|
|
49 |
13862f35
|
n.hoffmann
|
setDescription(description);
|
50 |
650cafb4
|
Patric Plitzner
|
|
51 |
13862f35
|
n.hoffmann
|
this.extensions = extensions;
|
52 |
|
|
}
|
53 |
650cafb4
|
Patric Plitzner
|
|
54 |
13862f35
|
n.hoffmann
|
protected static ImportFromFileDataSourceWizardPage XML(){
|
55 |
1fee3517
|
Patric Plitzner
|
return new ImportFromFileDataSourceWizardPage("Xml File", "Select XML file.", new String[]{"*.xml","*.*"});
|
56 |
13862f35
|
n.hoffmann
|
}
|
57 |
|
|
|
58 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
59 |
650cafb4
|
Patric Plitzner
|
@Override
|
60 |
|
|
public void createControl(Composite parent) {
|
61 |
13862f35
|
n.hoffmann
|
final Composite composite = new Composite(parent, SWT.NULL);
|
62 |
650cafb4
|
Patric Plitzner
|
|
63 |
13862f35
|
n.hoffmann
|
setPageComplete(false);
|
64 |
650cafb4
|
Patric Plitzner
|
|
65 |
13862f35
|
n.hoffmann
|
GridLayout gridLayout = new GridLayout();
|
66 |
|
|
gridLayout.numColumns = 3;
|
67 |
|
|
composite.setLayout(gridLayout);
|
68 |
650cafb4
|
Patric Plitzner
|
|
69 |
13862f35
|
n.hoffmann
|
Label folderLabel = new Label(composite, SWT.NONE);
|
70 |
|
|
folderLabel.setText("File");
|
71 |
650cafb4
|
Patric Plitzner
|
|
72 |
13862f35
|
n.hoffmann
|
fileDialog = new FileDialog(parent.getShell());
|
73 |
650cafb4
|
Patric Plitzner
|
|
74 |
13862f35
|
n.hoffmann
|
fileDialog.setFilterExtensions(extensions);
|
75 |
650cafb4
|
Patric Plitzner
|
|
76 |
7563a18e
|
Katja Luther
|
text_source = new Text(composite, SWT.BORDER);
|
77 |
|
|
text_source.setEditable(false);
|
78 |
|
|
text_source.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
79 |
13862f35
|
n.hoffmann
|
|
80 |
650cafb4
|
Patric Plitzner
|
|
81 |
13862f35
|
n.hoffmann
|
Button button = new Button(composite, SWT.PUSH);
|
82 |
|
|
button.setText("Browse...");
|
83 |
650cafb4
|
Patric Plitzner
|
|
84 |
79b9396a
|
n.hoffmann
|
button.addSelectionListener(new SelectionAdapter(){
|
85 |
13862f35
|
n.hoffmann
|
|
86 |
|
|
@Override
|
87 |
79b9396a
|
n.hoffmann
|
public void widgetSelected(SelectionEvent e) {
|
88 |
13862f35
|
n.hoffmann
|
String path = fileDialog.open();
|
89 |
650cafb4
|
Patric Plitzner
|
if(path!=null){
|
90 |
7563a18e
|
Katja Luther
|
text_source.setText(path);
|
91 |
c03c14f8
|
Katja Luther
|
setPageComplete(isPageComplete());
|
92 |
650cafb4
|
Patric Plitzner
|
}
|
93 |
13862f35
|
n.hoffmann
|
}
|
94 |
650cafb4
|
Patric Plitzner
|
|
95 |
13862f35
|
n.hoffmann
|
});
|
96 |
650cafb4
|
Patric Plitzner
|
|
97 |
eeaf651a
|
Katja Luther
|
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 |
d3dc900f
|
Katja Luther
|
GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
|
103 |
eeaf651a
|
Katja Luther
|
gd_textReferenceString.widthHint = 229;
|
104 |
|
|
textReferenceString.setLayoutData(gd_textReferenceString);
|
105 |
13862f35
|
n.hoffmann
|
setControl(composite);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
ddb51c5b
|
n.hoffmann
|
public File getFile() {
|
109 |
7563a18e
|
Katja Luther
|
return new File(text_source.getText());
|
110 |
ddb51c5b
|
n.hoffmann
|
}
|
111 |
eeaf651a
|
Katja Luther
|
|
112 |
|
|
public Text getTextReferenceString() {
|
113 |
|
|
return textReferenceString;
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
public void setTextReferenceString(Text textReferenceString) {
|
117 |
|
|
this.textReferenceString = textReferenceString;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
ddb51c5b
|
n.hoffmann
|
|
121 |
7563a18e
|
Katja Luther
|
@Override
|
122 |
|
|
public URI getUri() {
|
123 |
ddb51c5b
|
n.hoffmann
|
return getFile().toURI();
|
124 |
13862f35
|
n.hoffmann
|
}
|
125 |
1fee3517
|
Patric Plitzner
|
|
126 |
7df92cb1
|
p.plitzner
|
@Override
|
127 |
|
|
public boolean isPageComplete() {
|
128 |
7563a18e
|
Katja Luther
|
return CdmUtils.isNotBlank(text_source.getText());
|
129 |
7df92cb1
|
p.plitzner
|
}
|
130 |
1fee3517
|
Patric Plitzner
|
|
131 |
13862f35
|
n.hoffmann
|
}
|