Skip to content
Snippets Groups Projects
Commit 39e332b3 authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Add FileDialog Utils

Change-Id: Iba11bd67482f68e2c4433082b4e8f33bbd4daf46
parent d1bfd176
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
package org.polarsys.chess.service.gui.utils;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
......@@ -49,4 +50,23 @@ public class DialogUtils {
return directoryName;
}
public String getFileNameFromDialog() throws Exception {
return getFileNameFromDialog("Select the file",null);
}
public String getFileNameFromDialog(String title, String filterExtension) throws Exception {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final FileDialog fileDialog = new FileDialog(shell);
fileDialog.setText(title);
fileDialog.setFilterPath(directoryUtils.getCurrentProjectDir());
if(filterExtension!=null){
String[] extensions = {filterExtension};
fileDialog.setFilterExtensions(extensions);
}
String directoryName = fileDialog.open();
return directoryName;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment