Saturday, May 5, 2007

File Dialog in Eclipse RCP

I was trying out a simple application in Eclipse RCP. I needed a simple file open and file save dialog, like the Swing ones. I could not easily find an example on how to do this, from a Google search. Finally, this is what I came up with:

FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN);
String selectedFileName =;
if (selectedFileName == null)
File selectedFile = new File(selectedFileName);