Commit e9439653 authored by Skylot's avatar Skylot

gui: open file selection dialog on start

parent cc1be673
...@@ -26,7 +26,9 @@ public class JadxGUI { ...@@ -26,7 +26,9 @@ public class JadxGUI {
mainWindow.setLocationRelativeTo(null); mainWindow.setLocationRelativeTo(null);
mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
if (!jadxArgs.getInput().isEmpty()) { if (jadxArgs.getInput().isEmpty()) {
mainWindow.openFile();
} else {
mainWindow.openFile(jadxArgs.getInput().get(0)); mainWindow.openFile(jadxArgs.getInput().get(0));
} }
} }
......
...@@ -62,6 +62,8 @@ public class MainWindow extends JFrame { ...@@ -62,6 +62,8 @@ public class MainWindow extends JFrame {
private static final ImageIcon ICON_FLAT_PKG = Utils.openIcon("empty_logical_package_obj"); private static final ImageIcon ICON_FLAT_PKG = Utils.openIcon("empty_logical_package_obj");
private static final ImageIcon ICON_SEARCH = Utils.openIcon("magnifier"); private static final ImageIcon ICON_SEARCH = Utils.openIcon("magnifier");
private static final File WORK_DIR = new File(System.getProperty("user.dir"));
private final JadxWrapper wrapper; private final JadxWrapper wrapper;
private JPanel mainPanel; private JPanel mainPanel;
private JTree tree; private JTree tree;
...@@ -77,6 +79,18 @@ public class MainWindow extends JFrame { ...@@ -77,6 +79,18 @@ public class MainWindow extends JFrame {
initMenuAndToolbar(); initMenuAndToolbar();
} }
public void openFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setFileFilter(new FileNameExtensionFilter("supported files", "dex", "apk", "jar"));
fileChooser.setToolTipText(NLS.str("file.open"));
// fileChooser.setCurrentDirectory(WORK_DIR);
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open"));
if (ret == JFileChooser.APPROVE_OPTION) {
openFile(fileChooser.getSelectedFile());
}
}
public void openFile(File file) { public void openFile(File file) {
wrapper.openFile(file); wrapper.openFile(file);
initTree(); initTree();
...@@ -86,7 +100,8 @@ public class MainWindow extends JFrame { ...@@ -86,7 +100,8 @@ public class MainWindow extends JFrame {
private void saveAllAction() { private void saveAllAction() {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.save_all_msg")); fileChooser.setToolTipText(NLS.str("file.save_all_msg"));
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select"));
if (ret == JFileChooser.APPROVE_OPTION) { if (ret == JFileChooser.APPROVE_OPTION) {
ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, "Saving sources", "", 0, 100); ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, "Saving sources", "", 0, 100);
...@@ -298,12 +313,7 @@ public class MainWindow extends JFrame { ...@@ -298,12 +313,7 @@ public class MainWindow extends JFrame {
private class OpenListener implements ActionListener { private class OpenListener implements ActionListener {
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
JFileChooser fileChooser = new JFileChooser(); openFile();
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("dex files", "dex", "apk", "jar"));
int ret = fileChooser.showDialog(mainPanel, "Open file");
if (ret == JFileChooser.APPROVE_OPTION) {
openFile(fileChooser.getSelectedFile());
}
} }
} }
} }
...@@ -2,6 +2,7 @@ file.open=Open file ...@@ -2,6 +2,7 @@ file.open=Open file
file.save=Save file file.save=Save file
file.save_all=Save all file.save_all=Save all
file.save_all_msg=Select directory for save decompiled sources file.save_all_msg=Select directory for save decompiled sources
file.select=Select
file.exit=Exit file.exit=Exit
tree.flatten=Flatten packages tree.flatten=Flatten packages
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment