Fixed Recent Files & Plugins

This commit is contained in:
Konloch 2021-07-04 21:24:19 -07:00
parent 9f8c46bcdc
commit 964040e83c
3 changed files with 26 additions and 2 deletions

View file

@ -509,7 +509,11 @@ public class BytecodeViewer
*/ */
public static void startPlugin(File file) { public static void startPlugin(File file) {
if (!file.exists()) if (!file.exists())
{
BytecodeViewer.showMessage("The plugin file " + file.getAbsolutePath() + " could not be found.");
Settings.removeRecentPlugin(file);
return; return;
}
try { try {
PluginManager.runPlugin(file); PluginManager.runPlugin(file);

View file

@ -52,7 +52,7 @@ public class Settings
* *
* @param f the recent file * @param f the recent file
*/ */
public static void addRecentFile(File f) public static synchronized void addRecentFile(File f)
{ {
recentFiles.remove(f.getAbsolutePath()); // already added on the list recentFiles.remove(f.getAbsolutePath()); // already added on the list
recentFiles.add(0, f.getAbsolutePath()); recentFiles.add(0, f.getAbsolutePath());
@ -61,12 +61,21 @@ public class Settings
resetRecentFilesMenu(); resetRecentFilesMenu();
} }
public static synchronized void removeRecentFile(File f)
{
if(recentFiles.remove(f.getAbsolutePath()))
{
DiskWriter.replaceFile(filesName, MiscUtils.listToString(recentFiles), false);
resetRecentFilesMenu();
}
}
/** /**
* Add to the recent plugin list * Add to the recent plugin list
* *
* @param f the plugin file * @param f the plugin file
*/ */
public static void addRecentPlugin(File f) public static synchronized void addRecentPlugin(File f)
{ {
recentPlugins.remove(f.getAbsolutePath()); // already added on the list recentPlugins.remove(f.getAbsolutePath()); // already added on the list
recentPlugins.add(0, f.getAbsolutePath()); recentPlugins.add(0, f.getAbsolutePath());
@ -75,6 +84,15 @@ public class Settings
resetRecentFilesMenu(); resetRecentFilesMenu();
} }
public static synchronized void removeRecentPlugin(File f)
{
if(recentPlugins.remove(f.getAbsolutePath()))
{
DiskWriter.replaceFile(pluginsName, MiscUtils.listToString(recentPlugins), false);
resetRecentFilesMenu();
}
}
/** /**
* resets the recent files menu * resets the recent files menu
*/ */

View file

@ -1,6 +1,7 @@
package the.bytecode.club.bytecodeviewer.resources.importing; package the.bytecode.club.bytecodeviewer.resources.importing;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Settings;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane; import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
@ -49,6 +50,7 @@ public class ImportResource implements Runnable
{ {
update = false; update = false;
BytecodeViewer.showMessage("The file " + file.getAbsolutePath() + " could not be found."); BytecodeViewer.showMessage("The file " + file.getAbsolutePath() + " could not be found.");
Settings.removeRecentFile(file);
} }
else else
{ {