Skip to main content



      Home
Home » Newcomers » Newcomers » Opening file with FileDialog not working...
Opening file with FileDialog not working... [message #492051] Sat, 17 October 2009 13:39 Go to next message
Eclipse UserFriend
Hi there,

a created a XML file from a model created with GMF. Everything works fine, the file exists after generation.
I used the following code to show a FileDialog in order to allow to the user to open the XML-file which has recently being created:

Shell shell = new Shell();
String[] filterExt = {"*.xml"};
FileDialog fd = new FileDialog(shell, SWT.OPEN);
fd.setText("Open");
fd.setFilterExtensions(filterExt);
fd.setFilterPath(file.getAbsolutePath());
fd.setFileName(fileName);
String fil = fd.open();

The FileDialog actually pops up. However, when I select the XML-file and press the open button, the file does not show up, for instance in the windows editor. Surprisingly, when I use the open function of the context menu, it works fine...

Since I prefer to use the open button, I would be very pleased if anyone could help me with this issue...

Thanks, Scholle
Re: Opening file with FileDialog not working... [message #492053 is a reply to message #492051] Sat, 17 October 2009 13:50 Go to previous messageGo to next message
Eclipse UserFriend
On Sat, 17 Oct 2009 13:39:53 -0400, Scholle wrote:
> The FileDialog actually pops up. However, when I select the XML-file and
> press the open button, the file does not show up, for instance in the
> windows editor.

What do you mean? Does the open() method return null?

Remy
Re: Opening file with FileDialog not working... [message #492056 is a reply to message #492051] Sat, 17 October 2009 14:07 Go to previous messageGo to next message
Eclipse UserFriend
The open() method returns the absolute path to the file which has been selected... o this works fine, but what I want is to open the file and to show its content in an external editor (e.g. windows standard editor)...
Re: Opening file with FileDialog not working... [message #492063 is a reply to message #492056] Sat, 17 October 2009 16:58 Go to previous messageGo to next message
Eclipse UserFriend
On Sat, 17 Oct 2009 14:07:13 -0400, Scholle wrote:

> The open() method returns the absolute path to the file which has been
> selected... o this works fine, but what I want is to open the file and
> to show its content in an external editor (e.g. windows standard
> editor)...

Take a look at the API for org.eclipse.swt.program.Program.

Remy
Re: Opening file with FileDialog not working... [message #492066 is a reply to message #492051] Sat, 17 October 2009 18:45 Go to previous message
Eclipse UserFriend
One solution is to use:

desktop.open(file)
Previous Topic:Proxy Configuration
Next Topic:eclipse 3.0 FAQ code examples
Goto Forum:
  


Current Time: Thu Sep 25 10:54:34 EDT 2025

Powered by FUDForum. Page generated in 0.09482 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top