Skip to content

Commit

Permalink
fix(gui): set current dir directly in file chooser constructor (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jun 28, 2022
1 parent e4ca52a commit b282d97
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions jadx-gui/src/main/java/jadx/gui/ui/dialog/FileDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.jetbrains.annotations.Nullable;

import jadx.api.plugins.utils.CommonFileUtils;
import jadx.core.utils.Utils;
import jadx.core.utils.files.FileUtils;
import jadx.gui.settings.JadxProject;
Expand Down Expand Up @@ -134,7 +135,7 @@ private void initForMode(OpenMode mode) {
}

private FileChooser buildFileChooser() {
FileChooser fileChooser = new FileChooser();
FileChooser fileChooser = new FileChooser(currentDir);
fileChooser.setToolTipText(title);
fileChooser.setFileSelectionMode(selectionMode);
fileChooser.setMultiSelectionEnabled(isOpen);
Expand All @@ -143,16 +144,18 @@ private FileChooser buildFileChooser() {
String description = NLS.str("file_dialog.supported_files") + ": (" + Utils.listToString(fileExtList) + ')';
fileChooser.setFileFilter(new FileNameExtensionFilter(description, fileExtList.toArray(new String[0])));
}
if (currentDir != null) {
fileChooser.setCurrentDirectory(currentDir.toFile());
}
if (selectedFile != null) {
fileChooser.setSelectedFile(selectedFile.toFile());
}
return fileChooser;
}

private class FileChooser extends JFileChooser {

public FileChooser(@Nullable Path currentDirectory) {
super(currentDirectory == null ? CommonFileUtils.CWD : currentDirectory.toFile());
}

@Override
protected JDialog createDialog(Component parent) throws HeadlessException {
JDialog dialog = super.createDialog(parent);
Expand Down

0 comments on commit b282d97

Please sign in to comment.