Project

General

Profile

Download (3.36 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.io.e4;
11

    
12
import java.io.File;
13
import java.net.URI;
14

    
15
import javax.inject.Inject;
16

    
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;
28

    
29
import eu.etaxonomy.cdm.common.CdmUtils;
30

    
31
/**
32
 *
33
 * @author n.hoffmann
34
 * @created 04.08.2009
35
 * @version 1.0
36
 */
37
public class ImportFromFileDataSourceWizardPageE4 extends WizardPage {
38

    
39
	/** Constant <code>PAGE_NAME="CdmXmlDataSourceWizardPage"</code> */
40
	public static final String PAGE_NAME = "CdmXmlDataSourceWizardPage";
41

    
42
	private String[] extensions = {"*.xml"};
43

    
44
	private FileDialog fileDialog;
45
	private Text textReferenceString;
46

    
47
    protected Text text_source;
48

    
49
    @Inject
50
	public ImportFromFileDataSourceWizardPageE4() {
51
		super(PAGE_NAME);
52

    
53
		setTitle("Xml File");
54

    
55
		setDescription("Select XML file.");
56

    
57
		this.extensions = new String[]{"*.xml","*.*"};
58
	}
59

    
60
	/** {@inheritDoc} */
61
	@Override
62
    public void createControl(Composite parent) {
63
		final Composite composite = new Composite(parent, SWT.NULL);
64

    
65
		setPageComplete(false);
66

    
67
		GridLayout gridLayout = new GridLayout();
68
		gridLayout.numColumns = 3;
69
		composite.setLayout(gridLayout);
70

    
71
		Label folderLabel = new Label(composite, SWT.NONE);
72
		folderLabel.setText("File");
73

    
74
		fileDialog = new FileDialog(parent.getShell());
75

    
76
		fileDialog.setFilterExtensions(extensions);
77

    
78
		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

    
82

    
83
		Button button = new Button(composite, SWT.PUSH);
84
		button.setText("Browse...");
85

    
86
		button.addSelectionListener(new SelectionAdapter(){
87

    
88
			@Override
89
			public void widgetSelected(SelectionEvent e) {
90
				String path = fileDialog.open();
91
				if(path!=null){
92
				    text_source.setText(path);
93
				    setPageComplete(isPageComplete());
94
				}
95
			}
96

    
97
		});
98

    
99
		Label labelRef = new Label(composite, SWT.NONE);
100
        labelRef.setText("Default import souce reference");
101
        labelRef.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
102
        textReferenceString = new Text(composite, SWT.NONE);
103
        textReferenceString.setEnabled(true);
104
        GridData gd_textReferenceString = new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1);
105
        gd_textReferenceString.widthHint = 229;
106
        textReferenceString.setLayoutData(gd_textReferenceString);
107
		setControl(composite);
108
	}
109

    
110
	public File getFile() {
111
		return new File(text_source.getText());
112
	}
113

    
114
	public Text getTextReferenceString() {
115
		return textReferenceString;
116
	}
117

    
118
	public void setTextReferenceString(Text textReferenceString) {
119
		this.textReferenceString = textReferenceString;
120
	}
121

    
122
    public URI getUri() {
123
		return getFile().toURI();
124
	}
125

    
126
	@Override
127
	public boolean isPageComplete() {
128
		return CdmUtils.isNotBlank(text_source.getText());
129
	}
130

    
131
}
(4-4/5)