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