From 79405f94e0c64639b9faee50da8eff21d0cb96d6 Mon Sep 17 00:00:00 2001 From: Skylot Date: Sun, 25 Jul 2021 16:27:42 +0100 Subject: [PATCH] feat(gui): use FileDialog on Windows (#1213) --- .../src/main/java/jadx/gui/ui/MainWindow.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java b/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java index 02f48f66bb0..c1f95b18657 100644 --- a/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java +++ b/jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java @@ -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; @@ -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; @@ -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) {