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