Bug 577773 - FileDialog with SWT.OPEN does not allow selection of non existing file any more
Summary: FileDialog with SWT.OPEN does not allow selection of non existing file any more
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.20   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nikita Nemkin CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks: 571571
  Show dependency tree
 
Reported: 2021-12-13 06:12 EST by Christoph Kaser CLA
Modified: 2022-06-03 01:18 EDT (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 Christoph Kaser CLA 2021-12-13 06:12:13 EST
The newest version of the SWT FileDialog with SWT.OPEN under Windows does not allow entering a nonexisting file name any longer. We use this to allow creation of a new file when using File -> Open.
I suspect this happened with the changes in bug #571571.

*****  The following snippet can be used to reproduce this behavior:  *****

package org.eclipse.swt.snippets;

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class FileOpenSnippet {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setText("Snippet 72");
		shell.open();
		FileDialog dialog = new FileDialog(shell, SWT.OPEN);
		dialog.setFileName("non_existing_file");
		System.out.println("Selected file: " + dialog.open());
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

*****  Expected behavior:  *****
The user should be able to select "Open" when a file name for a non existing file was entered

**** Observed behavior: ****
When trying to open a nonexisting file, a DialogBox appears that tells me that the file could not be found.

I can reproduce the old behavior with the swt classes from
https://archive.eclipse.org/eclipse/downloads/drops4/R-4.9-201809060745/swt-4.9-win32-win32-x86_64.zip

I can reproduce the changed behavior with the newest build
https://download.eclipse.org/eclipse/downloads/drops4/I20211212-1800/swt-I20211212-1800-win32-win32-x86_64.zip
Comment 1 Andrey Loskutov CLA 2021-12-16 01:44:36 EST
Nikita, could you please check if this a system dialog limitation or SWT bug?
Comment 2 Niraj Modi CLA 2022-04-27 04:49:28 EDT
(In reply to Andrey Loskutov from comment #1)
> Nikita, could you please check if this a system dialog limitation or SWT bug?

Hi Nikita,
Did you got a chance to look into this ?
Comment 3 Nikita Nemkin CLA 2022-04-27 05:38:37 EDT
(In reply to Niraj Modi from comment #2)
> (In reply to Andrey Loskutov from comment #1)
> > Nikita, could you please check if this a system dialog limitation or SWT bug?
> 
> Hi Nikita,
> Did you got a chance to look into this ?

Yes, I think the problem is that FOS_FILEMUSTEXIST is enabled by default for COM FileOpenDialog. I'll prepare a patch.
Comment 4 Niraj Modi CLA 2022-05-12 09:42:06 EDT
Ping!
M3 is next week
Comment 5 Niraj Modi CLA 2022-06-03 01:18:37 EDT
Please re-target as required.