X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fui%2Fwizard%2FFileSelectionPage.java;fp=bundles%2Forg.simantics.document.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fui%2Fwizard%2FFileSelectionPage.java;h=eb43ee79471af3d0da638e45bb426fdcb5a131b7;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=89bbb5301c647e3c70d2802637289388b4777c45;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java index 89bbb5301..eb43ee794 100644 --- a/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java +++ b/bundles/org.simantics.document.ui/src/org/simantics/document/ui/wizard/FileSelectionPage.java @@ -1,77 +1,77 @@ -package org.simantics.document.ui.wizard; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Text; - -public class FileSelectionPage extends WizardPage { - - Text fileText; - Button browseButton; - - String fileName; - - public FileSelectionPage() { - super("FileSelction","Select a file",null); - } - - @Override - public void createControl(Composite parent) { - parent.setLayout(new GridLayout(3,false)); - fileText = new Text(parent,SWT.BORDER|SWT.SINGLE); - browseButton = new Button(parent, SWT.PUSH); - browseButton.setText("Browse"); - - GridData data; - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = SWT.FILL; - data.horizontalSpan = 2; - fileText.setLayoutData(data); - - data = new GridData(); - data.horizontalAlignment = SWT.FILL; - browseButton.setLayoutData(data); - - browseButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(),SWT.OPEN); - // TODO : is there any way to read file/executable bindings from OS? - // if is, use those extensions to filter this list. - // note: in windows using "reg query ..." to read bindings form registry would work. - dialog.setFilterExtensions(new String[]{"*.*"}); - String name = dialog.open(); - if (name != null) { - fileText.setText(name); - fileName = name; - } - } - }); - - fileText.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - fileName = fileText.getText(); - } - }); - - } - - public String getFileName() { - return fileName; - } - - - -} +package org.simantics.document.ui.wizard; + +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Text; + +public class FileSelectionPage extends WizardPage { + + Text fileText; + Button browseButton; + + String fileName; + + public FileSelectionPage() { + super("FileSelction","Select a file",null); + } + + @Override + public void createControl(Composite parent) { + parent.setLayout(new GridLayout(3,false)); + fileText = new Text(parent,SWT.BORDER|SWT.SINGLE); + browseButton = new Button(parent, SWT.PUSH); + browseButton.setText("Browse"); + + GridData data; + data = new GridData(); + data.grabExcessHorizontalSpace = true; + data.horizontalAlignment = SWT.FILL; + data.horizontalSpan = 2; + fileText.setLayoutData(data); + + data = new GridData(); + data.horizontalAlignment = SWT.FILL; + browseButton.setLayoutData(data); + + browseButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(),SWT.OPEN); + // TODO : is there any way to read file/executable bindings from OS? + // if is, use those extensions to filter this list. + // note: in windows using "reg query ..." to read bindings form registry would work. + dialog.setFilterExtensions(new String[]{"*.*"}); + String name = dialog.open(); + if (name != null) { + fileText.setText(name); + fileName = name; + } + } + }); + + fileText.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + fileName = fileText.getText(); + } + }); + + } + + public String getFileName() { + return fileName; + } + + + +}