1 package org.simantics.document.ui.wizard;
3 import org.eclipse.jface.wizard.WizardPage;
4 import org.eclipse.swt.SWT;
5 import org.eclipse.swt.events.KeyAdapter;
6 import org.eclipse.swt.events.KeyEvent;
7 import org.eclipse.swt.events.SelectionAdapter;
8 import org.eclipse.swt.events.SelectionEvent;
9 import org.eclipse.swt.layout.GridData;
10 import org.eclipse.swt.layout.GridLayout;
11 import org.eclipse.swt.widgets.Button;
12 import org.eclipse.swt.widgets.Composite;
13 import org.eclipse.swt.widgets.Display;
14 import org.eclipse.swt.widgets.FileDialog;
15 import org.eclipse.swt.widgets.Text;
17 public class FileSelectionPage extends WizardPage {
24 public FileSelectionPage() {
25 super("FileSelction","Select a file",null);
29 public void createControl(Composite parent) {
30 parent.setLayout(new GridLayout(3,false));
31 fileText = new Text(parent,SWT.BORDER|SWT.SINGLE);
32 browseButton = new Button(parent, SWT.PUSH);
33 browseButton.setText("Browse");
36 data = new GridData();
37 data.grabExcessHorizontalSpace = true;
38 data.horizontalAlignment = SWT.FILL;
39 data.horizontalSpan = 2;
40 fileText.setLayoutData(data);
42 data = new GridData();
43 data.horizontalAlignment = SWT.FILL;
44 browseButton.setLayoutData(data);
46 browseButton.addSelectionListener(new SelectionAdapter() {
48 public void widgetSelected(SelectionEvent e) {
49 FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(),SWT.OPEN);
50 // TODO : is there any way to read file/executable bindings from OS?
51 // if is, use those extensions to filter this list.
52 // note: in windows using "reg query ..." to read bindings form registry would work.
53 dialog.setFilterExtensions(new String[]{"*.*"});
54 String name = dialog.open();
56 fileText.setText(name);
62 fileText.addKeyListener(new KeyAdapter() {
64 public void keyReleased(KeyEvent e) {
65 fileName = fileText.getText();
71 public String getFileName() {