Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347430 - FileDialog's overwrite & setFilterExtensions options do not play well together.
Summary: FileDialog's overwrite & setFilterExtensions options do not play well together.
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Abhishek Kishore CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-27 06:56 EDT by Robert Konigsberg CLA
Modified: 2018-01-04 08:52 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Konigsberg CLA 2011-05-27 06:56:08 EDT
Build Identifier: I20110310-1119

org.eclipse.swt.widgets.FileDialog --

        fd.setOverwrite(true);
        fd.setFilterExtensions(new String[] { "*.epf" });
        String file = fd.open();

OK so if i have a file called "asdf.epf", and in this dialog I enter "asdf", it does not give me an overwrite warning. However, when fd.open returns, it returns "asdf.epf". So it's now returning a file which will be overwritten, yet I wasn't prepared for it.

Reproducible: Always
Comment 1 Remy Suen CLA 2011-05-27 08:08:26 EDT
Perhaps this is an OS thing, not sure. SWT, please advise.

Rob, I'm guessing this is Cocoa, correct?
Comment 2 Robert Konigsberg CLA 2011-05-27 08:10:07 EDT
I kinda doubt it's OS-related. But it's Cocoa.
Comment 3 Remy Suen CLA 2011-05-27 08:24:16 EDT
I ran this on Windows XP. I typed "test" and it gave me "...\test" (unlike comment 0) even though I had a "...\test.epf" file in that folder. It didn't prompt me to overwrite...but I guess since the returned value isn't "test.epf" there was actually no overwriting involved.

Entering in "test.epf" doesn't prompt me though. So there's definitely a bug here. Very odd.

Display display = new Display();
Shell shell = new Shell(display);
FileDialog dialog = new FileDialog(shell);
dialog.setOverwrite(true);
dialog.setFilterExtensions(new String[] { "*.epf" });
System.out.println(dialog.open());
shell.dispose();
display.dispose();
Comment 4 Remy Suen CLA 2011-05-27 13:40:03 EDT
Looks like this might be broken on Linux also. See bug 332178. I knew this sounded familiar...
Comment 5 Praveen CLA 2011-06-21 06:09:53 EDT
Bug 348233 will fix this problem for at least Windows Vista and Windows 7.
Comment 6 Abhishek Kishore CLA 2014-02-13 00:10:55 EST
(In reply to Remy Suen from comment #3)
> I ran this on Windows XP. I typed "test" and it gave me "...\test" (unlike
> comment 0) even though I had a "...\test.epf" file in that folder. It didn't
> prompt me to overwrite...but I guess since the returned value isn't
> "test.epf" there was actually no overwriting involved.
> 
> Entering in "test.epf" doesn't prompt me though. So there's definitely a bug
> here. Very odd.
> 
> Display display = new Display();
> Shell shell = new Shell(display);
> FileDialog dialog = new FileDialog(shell);
> dialog.setOverwrite(true);
> dialog.setFilterExtensions(new String[] { "*.epf" });
> System.out.println(dialog.open());
> shell.dispose();
> display.dispose();

setOverWrite() matters only for Save dialogs(style SWT.SAVE). So, with the above code, the user will not be prompted, irrespective of the platform and filter. Bug 332178 talks specifically about a Save dialog as well. 

I'm assuming the bug was reported was reported for a Save dialog. I'm able to recreate the issue on a Mac OS X Mavericks platform - typing "test.epf" prompts me, but entering "test" doesn't(I have a filter - "*.epf"). Also, its working fine on Windows 7 for me.
Comment 7 Abhishek Kishore CLA 2014-03-13 01:43:22 EDT
Arun, https://git.eclipse.org/r/#/c/23299 waiting for your review.
Comment 8 Abhishek Kishore CLA 2014-03-13 02:48:00 EDT
(In reply to Abhishek Kishore from comment #7)
> Arun, https://git.eclipse.org/r/#/c/23299 waiting for your review.

Please note that this patch should fix Bug 428216 as well.
Comment 9 Abhishek Kishore CLA 2014-03-25 23:46:14 EDT
Review comments have been incorporated, and changes have been committed - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=d2444ea11626b1e659e4e7a174b1438fa903c689