Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileDialog does not remember previous directory #95

Closed
Phillipus opened this issue May 5, 2022 · 3 comments · Fixed by #142
Closed

FileDialog does not remember previous directory #95

Phillipus opened this issue May 5, 2022 · 3 comments · Fixed by #142
Assignees
Labels
bug Something isn't working fix verified The implemented fix has been verified with an I-build regression Something that used to work Windows Happens on Windows OS
Milestone

Comments

@Phillipus
Copy link
Contributor

Windows 10
Eclipse 4.23 and 4.24

This seems to be a regression as this is working in Eclipse 4.22 but not in 4.23 and 4.24.

In the SWT as used in Eclipse 4.22 and earlier, a FileDialog would remember the last open directory. In the SWT in Eclipse 4.23 and later it reverts to the root "Computer" directory on Windows.

Run the snippet below against a target of Eclipse 4.22 and compare with a target of 4.23. Click the "Open" button, navigate to a file and open this. Repeat. On Eclipse 4.22 target the previous directory is remembered. Not on 4.23 target.

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;

public class FileOpen {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new GridLayout());
        shell.setSize(300, 200);
        
        Button button = new Button(shell, SWT.PUSH);
        button.setText("Open");
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                new FileDialog(shell, SWT.OPEN).open();
            }
        });
        
        shell.open();

        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }
}
@Phillipus
Copy link
Contributor Author

Just discovered a workaround:

FileDialog.setFilterPath(null);

@niraj-modi
Copy link
Member

@nnemkin is working on this issue via bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=579359

@lshanmug lshanmug added regression Something that used to work Windows Happens on Windows OS labels May 6, 2022
niraj-modi pushed a commit that referenced this issue May 13, 2022
Miration to COM API in Bug 571571 resulted in unexpected changes in
behavior. This patch restores original behavior.

 * Allow non-existent file names in SWT.OPEN dialog (Bug 579359).

 * Let the system remember last used directory and override
   FileDialog.setFilterPath (Bug 577773 and Issue #95).
   This change reverts the fix for Bug 577190 and Bug 578415.
@niraj-modi niraj-modi added the bug Something isn't working label May 16, 2022
@niraj-modi niraj-modi added this to the 4.24 M3 milestone May 16, 2022
@niraj-modi niraj-modi linked a pull request May 16, 2022 that will close this issue
@niraj-modi
Copy link
Member

With is issue fixed below bug is now reopened:
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=577190 is reopened now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix verified The implemented fix has been verified with an I-build regression Something that used to work Windows Happens on Windows OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants