Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330407 - setFilterPath only obeyed if a file has not already been loaded from a different path
Summary: setFilterPath only obeyed if a file has not already been loaded from a differ...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-16 16:15 EST by merry-v CLA
Modified: 2019-11-27 07:26 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description merry-v CLA 2010-11-16 16:15:59 EST
Build Identifier: M20100909-0800

I have a FileDialog, which is set to use the same path (from the app preferences) every time by setFilterPath().
But after selecting a file from a different path, and clicking "Open", the future behaviour changes. Now the FileDialog opens up in the location of the last file selected, ignoring the path given by setFilterPath().

Here is the code sample -

  // wft_path is set from preferences
  FileDialog loaddlg = new FileDialog(wc.getShell());
  loaddlg.setFilterExtensions(new String [] {"*.xml"});		
  loaddlg.setFilterPath(wft_path);  //value of wft_path is verified by debug
  loaddlg.open();

Here is the value of wft_path when this code is run -
  c:\data\_090_PROJECTS\_030_MINOR_ACTIVE\eclipse workflow\eclipse_workspaces\wf3\wf2\dc_created_save_dir\

Here is the value of the alternative path - 
  c:\data\_090_PROJECTS\_030_MINOR_ACTIVE\eclipse workflow\eclipse_workspaces\wf3\



Reproducible: Always

Steps to Reproduce:
1. Run the code specified in the Details secion in this bug report, the file dialog appears, and its using the path specified by wft_path . Let's call it "path A". So far so good.

2. Navigate the file open dialog to a different path ("path B") and select a file there. Click Open.

3. Exit and restart the app, run the file dialog code again. The dialog opens but now it is open at "path B". If setFilterPath was obeyed, I would expect it to open in "path A".
Comment 1 merry-v CLA 2010-11-16 16:18:01 EST
My version of Eclipse SDK is 3.6.1
Comment 2 Felipe Heidrich CLA 2010-11-22 11:48:13 EST
Works for me, always open at C:\Users\Public

public static void main(String[] args) {
	Display display = new Display();
	final Shell shell = new Shell(display);
	final FileDialog dialog = new FileDialog(shell, SWT.OPEN); 
	shell.addListener(SWT.MouseDown, new Listener() {
		public void handleEvent(Event e) {
			dialog.setFilterPath("C:\\Users\\Public");
			System.out.println(dialog.open());
		}
	});
	shell.pack();
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}

Does it work for you ?
Comment 3 Hinse ter Schuur CLA 2012-07-02 05:50:46 EDT
According to http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx the behavior of the lpstrInitialDir member is changed on Windows 7.

David Washington (Program Manager at Microsoft) explains why this behavior was changed in a discussion related to this issue on the Microsoft MSDN forums: http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/7c6614ea-bef9-4421-9778-f8e42b95456a/
Comment 4 Lars Vogel CLA 2019-11-27 07:26:37 EST
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it.
The information can be, for example, that the problem still occurs, that you
still want the feature, that more information is needed, or that the bug is
(for whatever reason) no longer relevant.

If the bug is still relevant, please remove the stalebug whiteboard tag.