Skip to content

Commit

Permalink
feat(gui): use FileDialog on Windows (#1213)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Apr 23, 2022
1 parent 1832f2a commit 79405f9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
Expand All @@ -23,10 +24,12 @@
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -283,6 +286,22 @@ public void onUpdate(Release r) {

public void openFileOrProject() {
String title = NLS.str("file.open_title");
if (SystemInfo.IS_WINDOWS) {
FileDialog fileDialog = new FileDialog(this, title);
fileDialog.setMode(FileDialog.LOAD);
fileDialog.setMultipleMode(true);
Path currentDirectory = settings.getLastOpenFilePath();
if (currentDirectory != null) {
fileDialog.setDirectory(currentDirectory.toAbsolutePath().toString());
}
fileDialog.setVisible(true);
File[] files = fileDialog.getFiles();
if (!Utils.isEmpty(files)) {
settings.setLastOpenFilePath(Paths.get(fileDialog.getDirectory()));
open(toPaths(files));
}
return;
}
JFileChooser fileChooser = buildFileChooser(false, title);
int ret = fileChooser.showDialog(this, title);
if (ret == JFileChooser.APPROVE_OPTION) {
Expand Down

0 comments on commit 79405f9

Please sign in to comment.