From b5c87e4eef2bb8c8abd2b9885d31961733e35e14 Mon Sep 17 00:00:00 2001 From: Konloch Date: Wed, 21 Aug 2024 10:36:26 -0600 Subject: [PATCH] General Refactoring --- .../bytecodeviewer/api/ASMResourceUtil.java | 2 +- .../bytecode/club/bytecodeviewer/api/BCV.java | 2 +- .../resourceviewer/viewer/ClassViewer.java | 84 ++++++++++++------- .../viewer/ComponentViewer.java | 3 +- 4 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java index ed492e13..c5b11beb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java @@ -38,7 +38,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; public final class ASMResourceUtil { /** - * Attempts to a method main inside of the loaded resources and returns the fully qualified name + * Attempts to a method main inside the loaded resources and returns the fully qualified name */ public static String findMainMethod(String defaultFQN) { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java index 0e48c6ac..39d0e106 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/BCV.java @@ -60,7 +60,7 @@ public class BCV /** * Grab the loader instance * - * @return + * @return the static ClassNodeLoader instance */ public static ClassNodeLoader getClassNodeLoader() { return loader; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java index aa583557..8c053135 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java @@ -154,38 +154,46 @@ public class ClassViewer extends ResourceViewer } } - public void setPanes() { + public void setPanes() + { bytecodeViewPanel1.decompiler = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler(); bytecodeViewPanel2.decompiler = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler(); bytecodeViewPanel3.decompiler = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler(); } - public boolean isPanel1Editable() { + public boolean isPanel1Editable() + { setPanes(); return BytecodeViewer.viewer.viewPane1.isPaneEditable(); } - public boolean isPanel2Editable() { + public boolean isPanel2Editable() + { setPanes(); return BytecodeViewer.viewer.viewPane2.isPaneEditable(); } - public boolean isPanel3Editable() { + public boolean isPanel3Editable() + { setPanes(); return BytecodeViewer.viewer.viewPane3.isPaneEditable(); } - public static void selectMethod(RSyntaxTextArea area, int methodLine) { - if (methodLine != area.getCaretLineNumber()) { + public static void selectMethod(RSyntaxTextArea area, int methodLine) + { + if (methodLine != area.getCaretLineNumber()) + { setCaretLine(area, methodLine); setViewLine(area, methodLine); } } - public static void selectMethod(ClassViewer classViewer, int paneId, Method method) { + public static void selectMethod(ClassViewer classViewer, int paneId, Method method) + { RSyntaxTextArea area = null; - switch (paneId) { + switch (paneId) + { case 0: area = classViewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea; break; @@ -197,11 +205,14 @@ public class ClassViewer extends ResourceViewer break; } - if (area != null) { + if (area != null) + { MethodParser methods = classViewer.methods.get(paneId); - if (methods != null) { + if (methods != null) + { int methodLine = methods.findMethod(method); - if (methodLine != -1) { + if (methodLine != -1) + { selectMethod(area, methodLine); } } @@ -261,27 +272,31 @@ public class ClassViewer extends ResourceViewer { sp.setResizeWeight(0.5); - if (bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE) { + if (bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE) setDividerLocation(sp, 0.5); - } else if (bytecodeViewPanel1.decompiler != Decompiler.NONE) { + else if (bytecodeViewPanel1.decompiler != Decompiler.NONE) setDividerLocation(sp, 1); - } else if (bytecodeViewPanel2.decompiler != Decompiler.NONE) { + else if (bytecodeViewPanel2.decompiler != Decompiler.NONE) + { sp.setResizeWeight(1); setDividerLocation(sp, 0); - } else { - setDividerLocation(sp, 0); } + else + setDividerLocation(sp, 0); - if (bytecodeViewPanel3.decompiler != Decompiler.NONE) { + if (bytecodeViewPanel3.decompiler != Decompiler.NONE) + { sp2.setResizeWeight(0.7); setDividerLocation(sp2, 0.7); if ((bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel1.decompiler != Decompiler.NONE) || (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE)) { setDividerLocation(sp2, 0.5); - } else if (bytecodeViewPanel1.decompiler == Decompiler.NONE) { - setDividerLocation(sp2, 0); } - } else { + else if (bytecodeViewPanel1.decompiler == Decompiler.NONE) + setDividerLocation(sp2, 0); + } + else + { sp.setResizeWeight(1); sp2.setResizeWeight(0); setDividerLocation(sp2, 1); @@ -294,30 +309,39 @@ public class ClassViewer extends ResourceViewer */ public static JSplitPane setDividerLocation(JSplitPane splitter, double proportion) { - if (splitter.isShowing()) { - if (splitter.getWidth() > 0 && splitter.getHeight() > 0) { + if (splitter.isShowing()) + { + if (splitter.getWidth() > 0 && splitter.getHeight() > 0) splitter.setDividerLocation(proportion); - } else { - splitter.addComponentListener(new ComponentAdapter() { + else + { + splitter.addComponentListener(new ComponentAdapter() + { @Override - public void componentResized(ComponentEvent ce) { + public void componentResized(ComponentEvent ce) + { splitter.removeComponentListener(this); setDividerLocation(splitter, proportion); } }); } - } else { - splitter.addHierarchyListener(new HierarchyListener() { + } + else + { + splitter.addHierarchyListener(new HierarchyListener() + { @Override - public void hierarchyChanged(HierarchyEvent e) { - if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 - && splitter.isShowing()) { + public void hierarchyChanged(HierarchyEvent e) + { + if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && splitter.isShowing()) + { splitter.removeHierarchyListener(this); setDividerLocation(splitter, proportion); } } }); } + return splitter; } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java index c570a9d9..659de792 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ComponentViewer.java @@ -51,8 +51,7 @@ public class ComponentViewer extends ResourceViewer { String workingName = containerName + title; ComponentViewer componentViewer = new ComponentViewer(title, c); - BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer, - workingName, containerName, title); + BytecodeViewer.viewer.workPane.addResourceToTab(componentViewer, workingName, containerName, title); return componentViewer; }