Better Last Directories
This commit is contained in:
parent
b8b4312e37
commit
05388b574b
12 changed files with 43 additions and 18 deletions
|
@ -53,10 +53,25 @@ public class Configuration
|
||||||
public static RSTATheme rstaTheme = lafTheme.getRSTATheme();
|
public static RSTATheme rstaTheme = lafTheme.getRSTATheme();
|
||||||
public static long lastHotKeyExecuted = 0;
|
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()
|
public static File getLastOpenDirectory()
|
||||||
{
|
{
|
||||||
File lastDir = new File(lastOpenDirectory);
|
File lastDir = new File(lastOpenDirectory);
|
||||||
if(lastDir.exists())
|
if(lastDir.getParentFile().exists())
|
||||||
return lastDir;
|
return lastDir;
|
||||||
|
|
||||||
return new File(".");
|
return new File(".");
|
||||||
|
@ -65,7 +80,7 @@ public class Configuration
|
||||||
public static File getLastSaveDirectory()
|
public static File getLastSaveDirectory()
|
||||||
{
|
{
|
||||||
File lastDir = new File(lastSaveDirectory);
|
File lastDir = new File(lastSaveDirectory);
|
||||||
if(lastDir.exists())
|
if(lastDir.getParentFile().exists())
|
||||||
return lastDir;
|
return lastDir;
|
||||||
|
|
||||||
return new File(".");
|
return new File(".");
|
||||||
|
@ -74,7 +89,8 @@ public class Configuration
|
||||||
public static File getLastPluginDirectory()
|
public static File getLastPluginDirectory()
|
||||||
{
|
{
|
||||||
File lastDir = new File(lastPluginDirectory);
|
File lastDir = new File(lastPluginDirectory);
|
||||||
if(lastDir.exists())
|
|
||||||
|
if(lastDir.getParentFile().exists())
|
||||||
return lastDir;
|
return lastDir;
|
||||||
|
|
||||||
return new File(".");
|
return new File(".");
|
||||||
|
|
|
@ -94,7 +94,8 @@ public class GlobalHotKeys
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
|
|
||||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||||
|
|
|
@ -898,7 +898,7 @@ public class MainViewerGUI extends JFrame
|
||||||
"External Plugin",
|
"External Plugin",
|
||||||
Configuration.getLastPluginDirectory(),
|
Configuration.getLastPluginDirectory(),
|
||||||
PluginManager.fileFilter(),
|
PluginManager.fileFilter(),
|
||||||
(f)-> Configuration.lastPluginDirectory = f.getAbsolutePath(),
|
Configuration::setLastPluginDirectory,
|
||||||
FileChooser.EVERYTHING);
|
FileChooser.EVERYTHING);
|
||||||
|
|
||||||
if(file == null)
|
if(file == null)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
@ -16,13 +17,12 @@ public class FileChooser extends JFileChooser
|
||||||
{
|
{
|
||||||
public static final String EVERYTHING = "everything";
|
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));
|
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (filePath.exists())
|
setSelectedFile(file);
|
||||||
setSelectedFile(filePath);
|
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) { }
|
||||||
|
|
||||||
setDialogTitle(title);
|
setDialogTitle(title);
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class PluginWriter extends JFrame
|
||||||
"External Plugin",
|
"External Plugin",
|
||||||
Configuration.getLastPluginDirectory(),
|
Configuration.getLastPluginDirectory(),
|
||||||
PluginManager.fileFilter(),
|
PluginManager.fileFilter(),
|
||||||
(f)-> Configuration.lastPluginDirectory = f.getAbsolutePath(),
|
Configuration::setLastPluginDirectory,
|
||||||
FileChooser.EVERYTHING);
|
FileChooser.EVERYTHING);
|
||||||
|
|
||||||
if(file == null || !file.exists())
|
if(file == null || !file.exists())
|
||||||
|
@ -168,7 +168,8 @@ public class PluginWriter extends JFrame
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastPluginDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastPluginDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
String path = file.getAbsolutePath();
|
String path = file.getAbsolutePath();
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class ResourceDecompiling
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
|
|
||||||
//auto appened zip
|
//auto appened zip
|
||||||
|
@ -202,7 +203,8 @@ public class ResourceDecompiling
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
|
|
||||||
BytecodeViewer.updateBusyStatus(true);
|
BytecodeViewer.updateBusyStatus(true);
|
||||||
|
|
|
@ -76,7 +76,8 @@ public class APKExport implements Exporter
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
final File file = fc.getSelectedFile();
|
final File file = fc.getSelectedFile();
|
||||||
String output = file.getAbsolutePath();
|
String output = file.getAbsolutePath();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ public class DexExport implements Exporter
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
final File file = fc.getSelectedFile();
|
final File file = fc.getSelectedFile();
|
||||||
String output = file.getAbsolutePath();
|
String output = file.getAbsolutePath();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ public class RunnableJarExporter implements Exporter
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
String path = file.getAbsolutePath();
|
String path = file.getAbsolutePath();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ public class ZipExport implements Exporter
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastSaveDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastSaveDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
|
|
||||||
//auto append .zip
|
//auto append .zip
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class DialogueUtils
|
||||||
public static File fileChooser(String title, String description, FileFilter filter, String... extensions)
|
public static File fileChooser(String title, String description, FileFilter filter, String... extensions)
|
||||||
{
|
{
|
||||||
return fileChooser(title, description, Configuration.getLastOpenDirectory(), filter,
|
return fileChooser(title, description, Configuration.getLastOpenDirectory(), filter,
|
||||||
(f)-> Configuration.lastOpenDirectory = f.getAbsolutePath(), extensions);
|
Configuration::setLastOpenDirectory, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -90,7 +90,8 @@ public class VersionChecker implements Runnable
|
||||||
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
int returnVal = fc.showSaveDialog(BytecodeViewer.viewer);
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION)
|
if (returnVal == JFileChooser.APPROVE_OPTION)
|
||||||
{
|
{
|
||||||
Configuration.lastOpenDirectory = fc.getSelectedFile().getAbsolutePath();
|
Configuration.setLastOpenDirectory(fc.getSelectedFile());
|
||||||
|
|
||||||
File file = fc.getSelectedFile();
|
File file = fc.getSelectedFile();
|
||||||
if (!file.getAbsolutePath().endsWith(".zip"))
|
if (!file.getAbsolutePath().endsWith(".zip"))
|
||||||
file = new File(file.getAbsolutePath() + ".zip");
|
file = new File(file.getAbsolutePath() + ".zip");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue