Error Prompt Cleanup

This commit is contained in:
Konloch 2021-07-06 19:46:12 -07:00
parent 2a5977d980
commit deb23d3dd3
12 changed files with 42 additions and 48 deletions

View file

@ -523,6 +523,28 @@ public class BytecodeViewer
viewer.clearBusyStatus();
}
/**
* Returns true if there are no loaded resource classes
*/
public static boolean promptIfNoLoadedClasses()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
return true;
}
return false;
}
/**
* Handle the exception by creating a new window for bug reporting
*/
public static void handleException(Throwable t)
{
new ExceptionUI(t);
}
/**
* Refreshes the title on all of the opened tabs
*/

View file

@ -47,18 +47,16 @@ public class GlobalHotKeys
t.start();
} else if ((e.getKeyCode() == KeyEvent.VK_R) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
Configuration.lastHotKeyExecuted = System.currentTimeMillis();
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
new RunOptions().setVisible(true);
} else if ((e.getKeyCode() == KeyEvent.VK_S) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
Configuration.lastHotKeyExecuted = System.currentTimeMillis();
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
Thread resourceExport = new Thread(() ->
{

View file

@ -37,11 +37,8 @@ public abstract class Plugin extends Thread
try
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
execute(BytecodeViewer.getLoadedClasses());
} catch (Exception e) {

View file

@ -791,10 +791,8 @@ public class MainViewerGUI extends JFrame
public void runResources()
{
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
new RunOptions().setVisible(true);
}

View file

@ -41,11 +41,8 @@ public class MaliciousCodeScannerOptions extends JFrame
public static void open()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
new MaliciousCodeScannerOptions().setVisible(true);
}

View file

@ -40,10 +40,9 @@ public class ReplaceStringsOptions extends JFrame
{
public static void open()
{
if (BytecodeViewer.getLoadedClasses().isEmpty()) {
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
new ReplaceStringsOptions().setVisible(true);
}

View file

@ -46,17 +46,18 @@ public class CodeSequenceDiagram extends Plugin
{
public static void open()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
PluginManager.runPlugin(new CodeSequenceDiagram());
}
@Override
public void execute(ArrayList<ClassNode> classNodeList)
{
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer))
{
BytecodeViewer.showMessage("First open a class file.");

View file

@ -28,11 +28,8 @@ public class ResourceDecompiling
{
public static void decompileSaveAll()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
Thread decompileThread = new Thread(() ->
{
@ -182,11 +179,8 @@ public class ResourceDecompiling
public static void decompileSaveOpenedOnly()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer))
{

View file

@ -24,11 +24,8 @@ public class APKExport implements Exporter
@Override
public void promptForExport()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
List<FileContainer> containers = BytecodeViewer.getFiles();
List<FileContainer> validContainers = new ArrayList<>();

View file

@ -25,11 +25,8 @@ public class DexExport implements Exporter
@Override
public void promptForExport()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
Thread exportThread = new Thread(() ->
{

View file

@ -19,11 +19,8 @@ public class RunnableJarExporter implements Exporter
@Override
public void promptForExport()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
Thread exportThread = new Thread(() ->
{

View file

@ -19,11 +19,8 @@ public class ZipExport implements Exporter
@Override
public void promptForExport()
{
if (BytecodeViewer.getLoadedClasses().isEmpty())
{
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
if (BytecodeViewer.promptIfNoLoadedClasses())
return;
}
Thread exportThread = new Thread(() ->
{