Better Last Directories

This commit is contained in:
Konloch 2021-07-19 07:11:14 -07:00
parent b8b4312e37
commit 05388b574b

AI 샘플 코드 생성 중입니다

Loading...
12 changed files with 43 additions and 18 deletions

View File

@ -53,10 +53,25 @@ public class Configuration
public static RSTATheme rstaTheme = lafTheme.getRSTATheme();
public static long lastHotKeyExecuted = 0;
public static void setLastOpenDirectory(File file)
{
lastOpenDirectory = file.getAbsolutePath();
}
public static void setLastSaveDirectory(File file)
{
lastSaveDirectory = file.getAbsolutePath();
}
public static void setLastPluginDirectory(File file)
{
lastPluginDirectory = file.getAbsolutePath();
}
public static File getLastOpenDirectory()
{
File lastDir = new File(lastOpenDirectory);
if(lastDir.exists())
if(lastDir.getParentFile().exists())
return lastDir;
return new File(".");
@ -65,7 +80,7 @@ public class Configuration
public static File getLastSaveDirectory()
{
File lastDir = new File(lastSaveDirectory);
if(lastDir.exists())
if(lastDir.getParentFile().exists())
return lastDir;
return new File(".");
@ -74,7 +89,8 @@ public class Configuration
public static File getLastPluginDirectory()
{
File lastDir = new File(lastPluginDirectory);
if(lastDir.exists())
if(lastDir.getParentFile().exists())
return lastDir;
return new File(".");

View File

@ -94,7 +94,8 @@ public class GlobalHotKeys
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
if (!file.getAbsolutePath().endsWith(".zip"))

View File

@ -898,7 +898,7 @@ public class MainViewerGUI extends JFrame
"External Plugin",
Configuration.getLastPluginDirectory(),
PluginManager.fileFilter(),
(f)-> Configuration.lastPluginDirectory = f.getAbsolutePath(),
Configuration::setLastPluginDirectory,
FileChooser.EVERYTHING);
if(file == null)

View File

@ -5,6 +5,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
@ -16,13 +17,12 @@ public class FileChooser extends JFileChooser
{
public static final String EVERYTHING = "everything";
public FileChooser(File filePath, String title, String description, String... extensions)
public FileChooser(File file, String title, String description, String... extensions)
{
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
try {
if (filePath.exists())
setSelectedFile(filePath);
setSelectedFile(file);
} catch (Exception ignored) { }
setDialogTitle(title);

View File

@ -105,7 +105,7 @@ public class PluginWriter extends JFrame
"External Plugin",
Configuration.getLastPluginDirectory(),
PluginManager.fileFilter(),
(f)-> Configuration.lastPluginDirectory = f.getAbsolutePath(),
Configuration::setLastPluginDirectory,
FileChooser.EVERYTHING);
if(file == null || !file.exists())
@ -168,7 +168,8 @@ public class PluginWriter extends JFrame
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastPluginDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastPluginDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
String path = file.getAbsolutePath();

View File

@ -43,7 +43,8 @@ public class ResourceDecompiling
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
//auto appened zip
@ -202,7 +203,8 @@ public class ResourceDecompiling
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
BytecodeViewer.updateBusyStatus(true);

View File

@ -76,7 +76,8 @@ public class APKExport implements Exporter
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
final File file = fc.getSelectedFile();
String output = file.getAbsolutePath();

View File

@ -41,7 +41,8 @@ public class DexExport implements Exporter
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
final File file = fc.getSelectedFile();
String output = file.getAbsolutePath();

View File

@ -35,7 +35,8 @@ public class RunnableJarExporter implements Exporter
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
String path = file.getAbsolutePath();

View File

@ -35,7 +35,8 @@ public class ZipExport implements Exporter
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastSaveDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
//auto append .zip

View File

@ -78,7 +78,7 @@ public class DialogueUtils
public static File fileChooser(String title, String description, FileFilter filter, String... extensions)
{
return fileChooser(title, description, Configuration.getLastOpenDirectory(), filter,
(f)-> Configuration.lastOpenDirectory = f.getAbsolutePath(), extensions);
Configuration::setLastOpenDirectory, extensions);
}
/**

View File

@ -90,7 +90,8 @@ public class VersionChecker implements Runnable
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
Configuration.lastOpenDirectory = fc.getSelectedFile().getAbsolutePath();
Configuration.setLastOpenDirectory(fc.getSelectedFile());
File file = fc.getSelectedFile();
if (!file.getAbsolutePath().endsWith(".zip"))
file = new File(file.getAbsolutePath() + ".zip");