From c940bf5c8d12e5f2f3d7bd0284376de79972ee50 Mon Sep 17 00:00:00 2001 From: Konloch Date: Mon, 21 Jun 2021 16:37:55 -0700 Subject: [PATCH] GUI Code Cleanup --- .../club/bytecodeviewer/BytecodeViewer.java | 24 ++-- .../bytecodeviewer/api/BytecodeViewer.java | 2 +- .../club/bytecodeviewer/api/Plugin.java | 4 +- .../club/bytecodeviewer/gui/ClassViewer.java | 18 +-- .../club/bytecodeviewer/gui/FileViewer.java | 2 +- .../bytecodeviewer/gui/MainViewerGUI.java | 105 +++++++++--------- .../bytecodeviewer/gui/ResourceListPane.java | 14 +-- .../bytecodeviewer/gui/SearchBoxPane.java | 34 ++---- .../bytecodeviewer/gui/VisibleComponent.java | 29 +---- .../club/bytecodeviewer/gui/WorkPane.java | 23 +--- .../gui/{ => extras}/AboutWindow.java | 2 +- .../gui/{ => extras}/ExportJar.java | 6 +- .../gui/{ => extras}/RunOptions.java | 2 +- .../gui/{ => extras}/SystemErrConsole.java | 2 +- .../gui/hexviewer}/JHexEditor.java | 2 +- .../gui/hexviewer}/JHexEditorASCII.java | 2 +- .../gui/hexviewer}/JHexEditorHEX.java | 2 +- .../{ => plugins}/GraphicalReflectionKit.java | 2 +- .../MaliciousCodeScannerOptions.java | 2 +- .../{ => plugins}/ReplaceStringsOptions.java | 2 +- .../obfuscators/JavaObfuscator.java | 4 +- .../plugin/preinstalled/EZInjection.java | 6 +- .../searching/BackgroundSearchThread.java | 4 +- .../util/FileChangeNotifier.java | 33 ------ .../club/bytecodeviewer/util/FileDrop.java | 21 ++-- .../club/bytecodeviewer/util/OpenFile.java | 10 +- .../util/ResourceDecompiling.java | 51 +++++---- .../util/ResourceExporting.java | 14 +-- .../club/bytecodeviewer/util/SecurityMan.java | 16 ++- 29 files changed, 177 insertions(+), 261 deletions(-) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => extras}/AboutWindow.java (99%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => extras}/ExportJar.java (94%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => extras}/RunOptions.java (99%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => extras}/SystemErrConsole.java (99%) rename src/main/java/{com/jhe/hexed => the/bytecode/club/bytecodeviewer/gui/hexviewer}/JHexEditor.java (99%) rename src/main/java/{com/jhe/hexed => the/bytecode/club/bytecodeviewer/gui/hexviewer}/JHexEditorASCII.java (98%) rename src/main/java/{com/jhe/hexed => the/bytecode/club/bytecodeviewer/gui/hexviewer}/JHexEditorHEX.java (98%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => plugins}/GraphicalReflectionKit.java (97%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => plugins}/MaliciousCodeScannerOptions.java (99%) rename src/main/java/the/bytecode/club/bytecodeviewer/gui/{ => plugins}/ReplaceStringsOptions.java (98%) delete mode 100644 src/main/java/the/bytecode/club/bytecodeviewer/util/FileChangeNotifier.java diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 4190510c..3c5a1a6d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -26,9 +26,9 @@ import the.bytecode.club.bytecodeviewer.compilers.Compilers; import the.bytecode.club.bytecodeviewer.gui.ClassViewer; import the.bytecode.club.bytecodeviewer.gui.ResourceListPane; import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; -import the.bytecode.club.bytecodeviewer.gui.RunOptions; +import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions; import the.bytecode.club.bytecodeviewer.gui.SearchBoxPane; -import the.bytecode.club.bytecodeviewer.gui.SystemErrConsole; +import the.bytecode.club.bytecodeviewer.gui.extras.SystemErrConsole; import the.bytecode.club.bytecodeviewer.gui.WorkPane; import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer; import the.bytecode.club.bytecodeviewer.plugin.PluginManager; @@ -374,7 +374,7 @@ public class BytecodeViewer * @return true if no errors, false if it failed to compile. */ public static boolean compile(boolean message) { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); boolean actuallyTried = false; for (java.awt.Component c : BytecodeViewer.viewer.workPane.getLoadedViewers()) { @@ -401,7 +401,7 @@ public class BytecodeViewer } else { BytecodeViewer.showMessage("There has been an error with assembling your Smali code, " + "please check this. Class: " + origNode.name); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); return false; } } @@ -429,7 +429,7 @@ public class BytecodeViewer } else { BytecodeViewer.showMessage("There has been an error with assembling your Krakatau " + "Bytecode, please check this. Class: " + origNode.name); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); return false; } } @@ -463,7 +463,7 @@ public class BytecodeViewer errConsole.pretty(); errConsole.setVisible(true); errConsole.finished(); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); return false; } } @@ -477,7 +477,7 @@ public class BytecodeViewer else BytecodeViewer.showMessage("You have no editable panes opened, make one editable and try again."); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); return true; } @@ -493,7 +493,7 @@ public class BytecodeViewer if (f.exists()) BytecodeViewer.addRecentFile(f); - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Configuration.needsReDump = true; Thread t = new Thread(new OpenFile(files)); t.start(); @@ -698,9 +698,9 @@ public class BytecodeViewer if (returnVal == JFileChooser.APPROVE_OPTION) { Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath(); try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e1) { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e1); } @@ -773,11 +773,11 @@ public class BytecodeViewer final File file2 = file; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Thread t1 = new Thread(() -> { JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file2.getAbsolutePath()); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); }); t1.start(); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java index 4365689b..26e71837 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/BytecodeViewer.java @@ -184,7 +184,7 @@ public class BytecodeViewer { * @param busy if it should display the busy icon or not */ public static void setBusy(boolean busy) { - the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer.setIcon(busy); + the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer.updateBusyStatus(busy); } /** diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java index a4d7edf0..04e6fdf9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java @@ -32,7 +32,7 @@ public abstract class Plugin extends Thread { @Override public void run() { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); try { if (BytecodeViewer.getLoadedClasses().isEmpty()) { BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file."); @@ -43,7 +43,7 @@ public abstract class Plugin extends Thread { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } finally { finished = true; - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java index 2ac6d649..ef7b04f0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/ClassViewer.java @@ -1,6 +1,6 @@ package the.bytecode.club.bytecodeviewer.gui; -import com.jhe.hexed.JHexEditor; +import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -460,7 +460,7 @@ public class ClassViewer extends Viewer { viewer = THIS; decompiler = pane1; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); if (pane1 == 1) { // procyon panelArea = new RSyntaxTextArea(); panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); @@ -834,7 +834,7 @@ public class ClassViewer extends Viewer { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } finally { resetDivider(); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); if (button != null) button.setEnabled(true); } @@ -850,7 +850,7 @@ public class ClassViewer extends Viewer { viewer = THIS; decompiler = pane2; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); if (pane2 == 1) { panelArea = new RSyntaxTextArea(); panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); @@ -1223,7 +1223,7 @@ public class ClassViewer extends Viewer { new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } finally { resetDivider(); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); if (button != null) button.setEnabled(true); } @@ -1239,7 +1239,7 @@ public class ClassViewer extends Viewer { viewer = THIS; decompiler = pane3; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); if (pane3 == 1) { panelArea = new RSyntaxTextArea(); panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); @@ -1612,7 +1612,7 @@ public class ClassViewer extends Viewer { //new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e); } finally { resetDivider(); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); if (button != null) button.setEnabled(true); } @@ -1620,7 +1620,7 @@ public class ClassViewer extends Viewer { }; Thread t = new Thread(() -> { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); while (Configuration.currentlyDumping) { //wait until it's not dumping try { @@ -1631,7 +1631,7 @@ public class ClassViewer extends Viewer { } tempFiles = BytecodeViewer.dumpTempFile(container); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); if (pane1 > 0) t1.start(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java index c044e593..cc94aafe 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java @@ -1,6 +1,6 @@ package the.bytecode.club.bytecodeviewer.gui; -import com.jhe.hexed.JHexEditor; +import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.KeyEvent; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java index f531b168..1f72411a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -28,6 +28,10 @@ import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Resources; import the.bytecode.club.bytecodeviewer.Settings; import the.bytecode.club.bytecodeviewer.api.ExceptionUI; +import the.bytecode.club.bytecodeviewer.gui.extras.AboutWindow; +import the.bytecode.club.bytecodeviewer.gui.extras.RunOptions; +import the.bytecode.club.bytecodeviewer.gui.plugins.MaliciousCodeScannerOptions; +import the.bytecode.club.bytecodeviewer.gui.plugins.ReplaceStringsOptions; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameClasses; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameFields; import the.bytecode.club.bytecodeviewer.obfuscators.rename.RenameMethods; @@ -66,17 +70,20 @@ import static the.bytecode.club.bytecodeviewer.Constants.*; * * @author Konloch */ -public class MainViewerGUI extends JFrame implements FileChangeNotifier { +public class MainViewerGUI extends JFrame { public static final long serialVersionUID = 1851409230530948543L; - private static final ArrayList uiComponents = new ArrayList<>(); public AboutWindow aboutWindow = new AboutWindow(); - public ResourceListPane resourcePane = new ResourceListPane(this); - public SearchBoxPane searchBoxPane; public boolean isMaximized; + public final JMenuItem[] waitIcons; + + //main UI components + private static final ArrayList uiComponents = new ArrayList<>(); + public final WorkPane workPane = new WorkPane(); + public final ResourceListPane resourcePane = new ResourceListPane(); + public final SearchBoxPane searchBoxPane = new SearchBoxPane(); public JSplitPane splitPane1; public JSplitPane splitPane2; - public final JMenuItem[] waitIcons; //the root menu bar public final JMenuBar rootMenu = new JMenuBar(); @@ -119,12 +126,31 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JMenuItem zStringArrayDecrypter = new JMenuItem("ZStringArray Decrypter"); //all of the settings main menu components - private final JCheckBoxMenuItem deleteForeignOutdatedLibs = new JCheckBoxMenuItem("Delete Foreign/Outdated Libs"); public final ButtonGroup apkConversionGroup = new ButtonGroup(); public final JRadioButtonMenuItem apkConversionDex = new JRadioButtonMenuItem("Dex2Jar"); public final JRadioButtonMenuItem apkConversionEnjarify = new JRadioButtonMenuItem("Enjarify"); public final JMenu fontSize = new JMenu("Font Size"); public final JSpinner fontSpinner = new JSpinner(); + //BCV settings + public final JCheckBoxMenuItem refreshOnChange = new JCheckBoxMenuItem("Refresh On View Change"); + private final JCheckBoxMenuItem deleteForeignOutdatedLibs = new JCheckBoxMenuItem("Delete Foreign/Outdated Libs"); + public final JMenu settingsMainMenu = new JMenu("Settings"); + public final JMenu visualSettings = new JMenu("Visual Settings"); + public final JMenu apkConversion = new JMenu("APK Conversion"); + public final JMenu bytecodeDecompilerSettingsSecondaryMenu = new JMenu("Bytecode Decompiler"); + public final JCheckBoxMenuItem updateCheck = new JCheckBoxMenuItem("Update Check"); + public final JMenuItem setPython2 = new JMenuItem("Set Python 2.7 Executable"); + public final JMenuItem setPython3 = new JMenuItem("Set Python 3.X Executable"); + public final JMenuItem setJRERT = new JMenuItem("Set JRE RT Library"); + public final JMenuItem setJavac = new JMenuItem("Set Javac Executable"); + public final JMenuItem setOptionalLibrary = new JMenuItem("Set Optional Library Folder"); + public final JCheckBoxMenuItem compileOnSave = new JCheckBoxMenuItem("Compile On Save"); + public final JCheckBoxMenuItem showFileInTabTitle = new JCheckBoxMenuItem("Show File In Tab Title"); + public final JCheckBoxMenuItem forcePureAsciiAsText = new JCheckBoxMenuItem("Force Pure Ascii As Text"); + public final JCheckBoxMenuItem autoCompileOnRefresh = new JCheckBoxMenuItem("Compile On Refresh"); + public final JCheckBoxMenuItem decodeAPKResources = new JCheckBoxMenuItem("Decode APK Resources"); + public final JCheckBoxMenuItem synchronizedViewing = new JCheckBoxMenuItem("Synchronized Viewing"); + public final JCheckBoxMenuItem showClassMethods = new JCheckBoxMenuItem("Show Class Methods"); //CFIDE settings public final JCheckBoxMenuItem appendBracketsToLabels = new JCheckBoxMenuItem("Append Brackets To Labels"); public JCheckBoxMenuItem debugHelpers = new JCheckBoxMenuItem("Debug Helpers"); @@ -161,6 +187,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JCheckBoxMenuItem mergeVariables = new JCheckBoxMenuItem("Merge Variables"); public final JCheckBoxMenuItem forceExplicitTypeArguments = new JCheckBoxMenuItem("Force Explicit Type Arguments"); public final JCheckBoxMenuItem forceExplicitImports = new JCheckBoxMenuItem("Force Explicit Imports"); + public final JCheckBoxMenuItem flattenSwitchBlocks = new JCheckBoxMenuItem("Flatten Switch Blocks"); + public final JCheckBoxMenuItem retainPointlessSwitches = new JCheckBoxMenuItem("Retain Pointless Switches"); + public final JCheckBoxMenuItem retainRedunantCasts = new JCheckBoxMenuItem("Retain Redundant Casts"); + public final JCheckBoxMenuItem unicodeOutputEnabled = new JCheckBoxMenuItem("Unicode Output Enabled"); //CFR public final JMenu cfrSettingsSecondaryMenu = new JMenu("CFR"); public final JCheckBoxMenuItem decodeEnumSwitch = new JCheckBoxMenuItem("Decode Enum Switch"); @@ -186,6 +216,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JCheckBoxMenuItem comments = new JCheckBoxMenuItem("Comments"); public final JCheckBoxMenuItem forceTopSort = new JCheckBoxMenuItem("Force Top Sort"); public final JCheckBoxMenuItem forceTopSortAggress = new JCheckBoxMenuItem("Force Top Sort Aggress"); + public final JCheckBoxMenuItem forceExceptionPrune = new JCheckBoxMenuItem("Force Exception Prune"); public final JCheckBoxMenuItem stringBuffer = new JCheckBoxMenuItem("String Buffer"); public final JCheckBoxMenuItem stringBuilder = new JCheckBoxMenuItem("String Builder"); public final JCheckBoxMenuItem silent = new JCheckBoxMenuItem("Silent"); @@ -206,12 +237,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JCheckBoxMenuItem recoveryTypehInts = new JCheckBoxMenuItem("Recover Type Hints"); public final JCheckBoxMenuItem forceTurningIFs = new JCheckBoxMenuItem("Force Returning IFs"); public final JCheckBoxMenuItem forLoopAGGCapture = new JCheckBoxMenuItem("For Loop AGG Capture"); - public final JCheckBoxMenuItem forceExceptionPrune = new JCheckBoxMenuItem("Force Exception Prune"); - public final JCheckBoxMenuItem unicodeOutputEnabled = new JCheckBoxMenuItem("Unicode Output Enabled"); - public final JCheckBoxMenuItem retainPointlessSwitches = new JCheckBoxMenuItem("Retain Pointless Switches"); - public final JCheckBoxMenuItem retainRedunantCasts = new JCheckBoxMenuItem("Retain Redundant Casts"); - public final JCheckBoxMenuItem flattenSwitchBlocks = new JCheckBoxMenuItem("Flatten Switch Blocks"); - public final JCheckBoxMenuItem updateCheck = new JCheckBoxMenuItem("Update Check"); + //obfuscation public final JMenu obfuscate = new JMenu("Obfuscate"); public final JMenuItem renameFields = new JMenuItem("Rename Fields"); public final JMenuItem renameMethods = new JMenuItem("Rename Methods"); @@ -222,24 +248,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public final JRadioButtonMenuItem strongObf = new JRadioButtonMenuItem("Strong Obfuscation"); public final JRadioButtonMenuItem lightObf = new JRadioButtonMenuItem("Light Obfuscation"); public final JMenuItem renameClasses = new JMenuItem("Rename Classes"); - public final JMenu settingsMainMenu = new JMenu("Settings"); - public final JCheckBoxMenuItem compileOnSave = new JCheckBoxMenuItem("Compile On Save"); - public final JCheckBoxMenuItem showFileInTabTitle = new JCheckBoxMenuItem("Show File In Tab Title"); - public final JCheckBoxMenuItem forcePureAsciiAsText = new JCheckBoxMenuItem("Force Pure Ascii As Text"); - public final JCheckBoxMenuItem autoCompileOnRefresh = new JCheckBoxMenuItem("Compile On Refresh"); - public final JMenuItem setPython2 = new JMenuItem("Set Python 2.7 Executable"); - public final JMenuItem setJRERT = new JMenuItem("Set JRE RT Library"); - public final JCheckBoxMenuItem decodeAPKResources = new JCheckBoxMenuItem("Decode APK Resources"); - public final JCheckBoxMenuItem synchronizedViewing = new JCheckBoxMenuItem("Synchronized Viewing"); - public final JCheckBoxMenuItem showClassMethods = new JCheckBoxMenuItem("Show Class Methods"); - public final JMenu visualSettings = new JMenu("Visual Settings"); - public final JMenu apkConversion = new JMenu("APK Conversion"); - public final JMenuItem setPython3 = new JMenuItem("Set Python 3.X Executable"); - public final JMenuItem setOptionalLibrary = new JMenuItem("Set Optional Library Folder"); - public final JMenuItem setJavac = new JMenuItem("Set Javac Executable"); - public final JMenu bytecodeDecompilerSettingsSecondaryMenu = new JMenu("Bytecode Decompiler"); - public synchronized void setIcon(final boolean busy) { + public synchronized void updateBusyStatus(final boolean busy) { SwingUtilities.invokeLater(() -> { if (busy) { for (int i = 0; i < 10; i++) { @@ -268,9 +278,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { public void calledAfterLoad() { deleteForeignOutdatedLibs.setSelected(Configuration.deleteForeignLibraries); } - - public final JCheckBoxMenuItem refreshOnChange = new JCheckBoxMenuItem("Refresh On View Change"); - public final WorkPane workPane = new WorkPane(this); public MainViewerGUI() { @@ -302,24 +309,21 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); - // scrollPane.setViewportView(tree); resourcePane.setMinimumSize(new Dimension(200, 50)); - // panel.add(cn); - searchBoxPane = new SearchBoxPane(this); + resourcePane.setPreferredSize(new Dimension(200, 50)); + resourcePane.setMaximumSize(new Dimension(200, 2147483647)); + searchBoxPane.setPreferredSize(new Dimension(200, 50)); searchBoxPane.setMinimumSize(new Dimension(200, 50)); searchBoxPane.setMaximumSize(new Dimension(200, 2147483647)); - // panel.add(s); + splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, resourcePane, searchBoxPane); - // panel.add(sp1); - resourcePane.setPreferredSize(new Dimension(200, 50)); - resourcePane.setMaximumSize(new Dimension(200, 2147483647)); splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane1, workPane); getContentPane().add(splitPane2); splitPane2.setResizeWeight(0.05); splitPane1.setResizeWeight(0.5); + uiComponents.add(resourcePane); - uiComponents.add(searchBoxPane); uiComponents.add(workPane); @@ -667,18 +671,12 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { appendBracketsToLabels.setSelected(true); } - @Override public void openClassFile(final FileContainer container, final String name, final ClassNode cn) { - for (final VisibleComponent vc : uiComponents) { - vc.openClassFile(container, name, cn); - } + workPane.addWorkingFile(container, name, cn); } - @Override public void openFile(final FileContainer container, final String name, byte[] content) { - for (final VisibleComponent vc : uiComponents) { - vc.openFile(container, name, content); - } + workPane.addFile(container, name, content); } @SuppressWarnings("unchecked") @@ -729,9 +727,9 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { if (returnVal == JFileChooser.APPROVE_OPTION) { Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath(); try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); BytecodeViewer.openFiles(new File[]{fc.getSelectedFile()}, true); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e1) { new ExceptionUI(e1); } @@ -962,9 +960,9 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { if (returnVal == JFileChooser.APPROVE_OPTION) try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); BytecodeViewer.startPlugin(fc.getSelectedFile()); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e1) { new ExceptionUI(e1); } @@ -990,5 +988,4 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier { System.exit(0); } } - -} +} \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/ResourceListPane.java index f0ccda94..ebfd64ad 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/ResourceListPane.java @@ -40,7 +40,6 @@ import javax.swing.tree.TreePath; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; -import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileContainer; import the.bytecode.club.bytecodeviewer.util.FileDrop; import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; @@ -71,10 +70,8 @@ import the.bytecode.club.bytecodeviewer.util.LazyNameUtil; * @author afffsdd */ -public class ResourceListPane extends VisibleComponent implements - FileDrop.Listener { - - FileChangeNotifier fcn; +public class ResourceListPane extends VisibleComponent implements FileDrop.Listener +{ JCheckBox exact = new JCheckBox("Exact"); JButton open = new JButton("+"); JButton close = new JButton("-"); @@ -245,9 +242,8 @@ public class ResourceListPane extends VisibleComponent implements LazyNameUtil.removeName(fileContainer.name); } - public ResourceListPane(final FileChangeNotifier fcn) { + public ResourceListPane() { super("ClassNavigation"); - this.fcn = fcn; tree.setRootVisible(false); tree.setShowsRootHandles(true); quickSearch.setForeground(Color.gray); @@ -374,11 +370,11 @@ public class ResourceListPane extends VisibleComponent implements } public void openClassFileToWorkSpace(final FileContainer container, final String name, final ClassNode node) { - fcn.openClassFile(container, name, node); + BytecodeViewer.viewer.openClassFile(container, name, node); } public void openFileToWorkSpace(final FileContainer container, String name, byte[] contents) { - fcn.openFile(container, name, contents); + BytecodeViewer.viewer.openFile(container, name, contents); } @Override diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SearchBoxPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/SearchBoxPane.java index fd00f1f6..1876492d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SearchBoxPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/SearchBoxPane.java @@ -26,7 +26,6 @@ import the.bytecode.club.bytecodeviewer.searching.RegexInsnFinder; import the.bytecode.club.bytecodeviewer.searching.RegexSearch; import the.bytecode.club.bytecodeviewer.searching.SearchResultNotifier; import the.bytecode.club.bytecodeviewer.searching.SearchTypeDetails; -import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileContainer; /*************************************************************************** @@ -61,8 +60,6 @@ public class SearchBoxPane extends VisibleComponent { public static final SearchRadius[] SEARCH_RADII = SearchRadius.values(); public static final SearchType[] SEARCH_TYPES = SearchType.values(); - FileChangeNotifier fcn; - JCheckBox exact = new JCheckBox("Exact"); DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode("Results"); JTree tree; @@ -81,11 +78,9 @@ public class SearchBoxPane extends VisibleComponent { }; @SuppressWarnings("unchecked") - public SearchBoxPane(final FileChangeNotifier fcn) { + public SearchBoxPane() { super("Search"); - this.fcn = fcn; - final JPanel optionPanel = new JPanel(new BorderLayout()); final JPanel searchRadiusOpt = new JPanel(new BorderLayout()); @@ -186,8 +181,7 @@ public class SearchBoxPane extends VisibleComponent { public void doSearch() { try { - Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), - Pattern.MULTILINE); + Pattern.compile(RegexInsnFinder.processRegex(RegexSearch.searchText.getText()), Pattern.MULTILINE); } catch (PatternSyntaxException ex) { BytecodeViewer.showMessage("You have an error in your regex syntax."); } @@ -196,23 +190,23 @@ public class SearchBoxPane extends VisibleComponent { for (ClassNode c : container.classes) searchType.details.search(container, c, srn, exact.isSelected()); - Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search.setEnabled(true); - Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search.setText( - "Search"); + Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)) + .search.setEnabled(true); + Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)) + .search.setText("Search"); + tree.expandPath(new TreePath(tree.getModel().getRoot())); tree.updateUI(); } }; - Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search - .setEnabled(false); - Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).search - .setText("Searching, please wait.."); + Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)) + .search.setEnabled(false); + Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)) + .search.setText("Searching, please wait.."); t.start(); } else { // this should really never be called. - BytecodeViewer - .showMessage("You currently have a search performing in the background, please wait for that " - + "to finish."); + BytecodeViewer.showMessage("You currently have a search performing in the background, please wait for that to finish."); } } else if (radius == SearchRadius.Current_Class) { final Viewer cv = Objects.requireNonNull(MainViewerGUI.getComponent(WorkPane.class)).getCurrentViewer(); @@ -243,8 +237,4 @@ public class SearchBoxPane extends VisibleComponent { treeRoot.removeAllChildren(); tree.updateUI(); } - - @Override - public void openFile(final FileContainer container, String name, byte[] contents) { - } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/VisibleComponent.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/VisibleComponent.java index ed44fe39..bf59ff97 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/VisibleComponent.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/VisibleComponent.java @@ -2,7 +2,6 @@ package the.bytecode.club.bytecodeviewer.gui; import javax.swing.JInternalFrame; import org.objectweb.asm.tree.ClassNode; -import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileContainer; /*************************************************************************** @@ -24,34 +23,18 @@ import the.bytecode.club.bytecodeviewer.util.FileContainer; ***************************************************************************/ /** - * Used to represent all the panes inside of Bytecode Viewer, this is temp code - * that was included from porting in J-RET, this needs to be re-written. + * Used to represent all the panes inside of Bytecode Viewer. * * @author Konloch * @author WaterWolf */ - -public abstract class VisibleComponent extends JInternalFrame implements - FileChangeNotifier { - +public abstract class VisibleComponent extends JInternalFrame +{ private static final long serialVersionUID = -6453413772343643526L; - public VisibleComponent(final String title) { + public VisibleComponent(final String title) + { super(title, false, false, false, false); this.setFrameIcon(null); } - - @SuppressWarnings("unused") - private VisibleComponent() { // because we want to enforce the title - // argument - - } - - @Override - public void openClassFile(final FileContainer container, final String name, final ClassNode cn) { - } - - @Override - public void openFile(final FileContainer container, final String name, byte[] contents) { - } -} +} \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java index 1ccffd5d..af8955f9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/WorkPane.java @@ -20,7 +20,6 @@ import javax.swing.JTabbedPane; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; -import the.bytecode.club.bytecodeviewer.util.FileChangeNotifier; import the.bytecode.club.bytecodeviewer.util.FileContainer; import static the.bytecode.club.bytecodeviewer.Constants.BLOCK_TAB_MENU; @@ -54,7 +53,6 @@ public class WorkPane extends VisibleComponent implements ActionListener { private static final long serialVersionUID = 6542337997679487946L; - FileChangeNotifier fcn; public JTabbedPane tabs; JPanel buttonPanel; @@ -62,12 +60,11 @@ public class WorkPane extends VisibleComponent implements ActionListener { HashMap workingOn = new HashMap<>(); - public WorkPane(final FileChangeNotifier fcn) { + public WorkPane() { super("WorkPanel"); setTitle("Work Space"); this.tabs = new JTabbedPane(); - this.fcn = fcn; JPopupMenu pop_up = new JPopupMenu() { @@ -251,16 +248,6 @@ public class WorkPane extends VisibleComponent implements ActionListener { } } - @Override - public void openClassFile(final FileContainer container, final String name, final ClassNode cn) { - addWorkingFile(container, name, cn); - } - - @Override - public void openFile(final FileContainer container, final String name, byte[] content) { - addFile(container, name, content); - } - public Viewer getCurrentViewer() { return (Viewer) tabs.getSelectedComponent(); } @@ -285,14 +272,14 @@ public class WorkPane extends VisibleComponent implements ActionListener { if (tabComp != null) { if (tabComp instanceof ClassViewer) { src.setEnabled(false); - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); ((ClassViewer) tabComp).startPaneUpdater(src); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } else if (tabComp instanceof FileViewer) { src.setEnabled(false); - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); ((FileViewer) tabComp).refresh(src); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/AboutWindow.java similarity index 99% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/AboutWindow.java index dd96fa0f..3ad418e7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/AboutWindow.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/AboutWindow.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.extras; import java.awt.CardLayout; import java.awt.Color; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ExportJar.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/ExportJar.java similarity index 94% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/ExportJar.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/ExportJar.java index 6ff911c0..5e368be9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ExportJar.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/ExportJar.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.extras; import java.awt.Dimension; import javax.swing.BoxLayout; @@ -59,11 +59,11 @@ public class ExportJar extends JFrame { getContentPane().add(btnNewButton); btnNewButton.addActionListener(arg0 -> { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Thread t = new Thread(() -> { JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath, mani.getText()); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); }); t.start(); dispose(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/RunOptions.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/RunOptions.java similarity index 99% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/RunOptions.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/RunOptions.java index f9f52df7..2436e127 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/RunOptions.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/RunOptions.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.extras; import java.awt.Dimension; import javax.swing.JButton; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/SystemErrConsole.java similarity index 99% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/SystemErrConsole.java index aa5388b8..6f661221 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/SystemErrConsole.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/extras/SystemErrConsole.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.extras; import java.awt.BorderLayout; import java.awt.Color; diff --git a/src/main/java/com/jhe/hexed/JHexEditor.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java similarity index 99% rename from src/main/java/com/jhe/hexed/JHexEditor.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java index a71239b2..272d511c 100644 --- a/src/main/java/com/jhe/hexed/JHexEditor.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java @@ -1,4 +1,4 @@ -package com.jhe.hexed; +package the.bytecode.club.bytecodeviewer.gui.hexviewer; import java.awt.BorderLayout; import java.awt.Color; diff --git a/src/main/java/com/jhe/hexed/JHexEditorASCII.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java similarity index 98% rename from src/main/java/com/jhe/hexed/JHexEditorASCII.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java index 90379a07..2fa0d5dd 100644 --- a/src/main/java/com/jhe/hexed/JHexEditorASCII.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java @@ -1,4 +1,4 @@ -package com.jhe.hexed; +package the.bytecode.club.bytecodeviewer.gui.hexviewer; import java.awt.Color; import java.awt.Dimension; diff --git a/src/main/java/com/jhe/hexed/JHexEditorHEX.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorHEX.java similarity index 98% rename from src/main/java/com/jhe/hexed/JHexEditorHEX.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorHEX.java index b409003d..56c1da98 100644 --- a/src/main/java/com/jhe/hexed/JHexEditorHEX.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorHEX.java @@ -1,4 +1,4 @@ -package com.jhe.hexed; +package the.bytecode.club.bytecodeviewer.gui.hexviewer; import java.awt.Color; import java.awt.Dimension; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/GraphicalReflectionKit.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/GraphicalReflectionKit.java similarity index 97% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/GraphicalReflectionKit.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/GraphicalReflectionKit.java index 75d1b91f..5b4a0786 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/GraphicalReflectionKit.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/GraphicalReflectionKit.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.plugins; import java.awt.BorderLayout; import java.awt.Dimension; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MaliciousCodeScannerOptions.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/MaliciousCodeScannerOptions.java similarity index 99% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/MaliciousCodeScannerOptions.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/MaliciousCodeScannerOptions.java index bab06399..d4edb3e7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MaliciousCodeScannerOptions.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/MaliciousCodeScannerOptions.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.plugins; import java.awt.Dimension; import javax.swing.JButton; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ReplaceStringsOptions.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/ReplaceStringsOptions.java similarity index 98% rename from src/main/java/the/bytecode/club/bytecodeviewer/gui/ReplaceStringsOptions.java rename to src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/ReplaceStringsOptions.java index 757794fe..75d14ea7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/ReplaceStringsOptions.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/plugins/ReplaceStringsOptions.java @@ -1,4 +1,4 @@ -package the.bytecode.club.bytecodeviewer.gui; +package the.bytecode.club.bytecodeviewer.gui.plugins; import java.awt.Dimension; import javax.swing.JButton; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/JavaObfuscator.java b/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/JavaObfuscator.java index e31cba32..5e6797ad 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/JavaObfuscator.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/obfuscators/JavaObfuscator.java @@ -33,12 +33,12 @@ public abstract class JavaObfuscator extends Thread { @Override public void run() { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Configuration.runningObfuscation = true; obfuscate(); BytecodeViewer.refactorer.run(); Configuration.runningObfuscation = false; - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } public int getStringLength() { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java index fe04efe0..89253dbd 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/EZInjection.java @@ -14,7 +14,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.BytecodeHook; import the.bytecode.club.bytecodeviewer.api.Plugin; import the.bytecode.club.bytecodeviewer.api.PluginConsole; -import the.bytecode.club.bytecodeviewer.gui.GraphicalReflectionKit; +import the.bytecode.club.bytecodeviewer.gui.plugins.GraphicalReflectionKit; import static the.bytecode.club.bytecodeviewer.Constants.*; @@ -135,7 +135,7 @@ public class EZInjection extends Plugin { @Override public void execute(ArrayList classNodeList) { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); gui.setText(""); if (console) @@ -307,6 +307,6 @@ public class EZInjection extends Plugin { } } - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/searching/BackgroundSearchThread.java b/src/main/java/the/bytecode/club/bytecodeviewer/searching/BackgroundSearchThread.java index eba20b71..7dccc1d5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/searching/BackgroundSearchThread.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/searching/BackgroundSearchThread.java @@ -42,9 +42,9 @@ public abstract class BackgroundSearchThread extends Thread { @Override public void run() { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); doSearch(); finished = true; - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/FileChangeNotifier.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/FileChangeNotifier.java deleted file mode 100644 index 1af817c2..00000000 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/FileChangeNotifier.java +++ /dev/null @@ -1,33 +0,0 @@ -package the.bytecode.club.bytecodeviewer.util; - -import org.objectweb.asm.tree.ClassNode; - -/*************************************************************************** - * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * - * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - ***************************************************************************/ - -/** - * Used to represent whenever a file has been opened - * - * @author Konloch - */ - -public interface FileChangeNotifier { - void openClassFile(final FileContainer container, String name, ClassNode cn); - - void openFile(final FileContainer container, String name, byte[] contents); -} \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/FileDrop.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/FileDrop.java index a505048e..0b773375 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/FileDrop.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/FileDrop.java @@ -30,12 +30,11 @@ import java.io.Reader; * a Java program. Any java.awt.Component can be dropped onto, but only * javax.swing.JComponents will indicate the drop event with a changed * border. - *

+ * * To use this class, construct a new FileDrop by passing it the target * component and a Listener to receive notification when file(s) have * been dropped. Here is an example: - *

- *

+ *
  *      JPanel myPanel = new JPanel();
  *      new FileDrop( myPanel, new FileDrop.Listener()
  *      {   public void filesDropped( java.io.File[] files )
@@ -44,27 +43,21 @@ import java.io.Reader;
  *              ...
  *          }   // end filesDropped
  *      }); // end FileDrop.Listener
- * 
- *

+ * * You can specify the border that will appear when files are being dragged by * calling the constructor with a javax.swing.border.Border. Only * JComponents will show any indication with a border. - *

+ * * You can turn on some debugging features by passing a PrintStream * object (such as System.out) into the full constructor. A * null value will result in no extra debugging information being * output. - *

- *

- *

+ * * I'm releasing this code into the Public Domain. Enjoy. - *

- *

+ * * Original author: Robert Harder, rharder@usa.net - *

- *

+ * * 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. - *

* * @author Robert Harder * @author rharder@users.sf.net diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java index 5e18d1dd..6f33dadc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/OpenFile.java @@ -131,7 +131,7 @@ public class OpenFile implements Runnable } } else if (fn.endsWith(".apk")) { try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk"); @@ -159,7 +159,7 @@ public class OpenFile implements Runnable container.classes = JarUtils.loadClasses(output); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); BytecodeViewer.files.add(container); } catch (final Exception e) { new ExceptionUI(e); @@ -167,7 +167,7 @@ public class OpenFile implements Runnable return; } else if (fn.endsWith(".dex")) { try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex"); @@ -186,7 +186,7 @@ public class OpenFile implements Runnable container.classes = JarUtils.loadClasses(output); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); BytecodeViewer.files.add(container); } catch (final Exception e) { new ExceptionUI(e); @@ -208,7 +208,7 @@ public class OpenFile implements Runnable } catch (final Exception e) { new ExceptionUI(e); } finally { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); if (update) try { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceDecompiling.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceDecompiling.java index c70b370f..dff45163 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceDecompiling.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceDecompiling.java @@ -6,7 +6,6 @@ import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.decompilers.Decompilers; -import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI; import javax.swing.*; import javax.swing.filechooser.FileFilter; @@ -91,7 +90,7 @@ public class ResourceDecompiling if (options[k].equals(obj)) result = k; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); File tempZip = new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar"); if (tempZip.exists()) @@ -104,7 +103,7 @@ public class ResourceDecompiling try { Decompilers.procyon.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-proycon.zip")); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -112,10 +111,10 @@ public class ResourceDecompiling t12.start(); Thread t2 = new Thread(() -> { try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Decompilers.cfr.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-CFR.zip")); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -123,10 +122,10 @@ public class ResourceDecompiling t2.start(); Thread t3 = new Thread(() -> { try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Decompilers.fernflower.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-fernflower.zip")); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -134,10 +133,10 @@ public class ResourceDecompiling t3.start(); Thread t4 = new Thread(() -> { try { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Decompilers.krakatau.decompileToZip(tempZip.getAbsolutePath(), MiscUtils.append(javaSucks, "-kraktau.zip")); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -148,7 +147,7 @@ public class ResourceDecompiling Thread t12 = new Thread(() -> { try { Decompilers.procyon.decompileToZip(tempZip.getAbsolutePath(), path); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -159,7 +158,7 @@ public class ResourceDecompiling Thread t12 = new Thread(() -> { try { Decompilers.cfr.decompileToZip(tempZip.getAbsolutePath(), path); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -170,7 +169,7 @@ public class ResourceDecompiling Thread t12 = new Thread(() -> { try { Decompilers.fernflower.decompileToZip(tempZip.getAbsolutePath(), path); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -182,7 +181,7 @@ public class ResourceDecompiling Thread t12 = new Thread(() -> { try { Decompilers.krakatau.decompileToZip(tempZip.getAbsolutePath(), path); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { new ExceptionUI(e); } @@ -191,7 +190,7 @@ public class ResourceDecompiling } if (result == 5) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } }); @@ -232,7 +231,7 @@ public class ResourceDecompiling if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); final String path = MiscUtils.append(file, ".java"); // cheap hax cause // string is final @@ -315,9 +314,9 @@ public class ResourceDecompiling e.printStackTrace(); } - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); new ExceptionUI(e); } }); @@ -341,9 +340,9 @@ public class ResourceDecompiling String contents = Decompilers.procyon.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(path, contents, false); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); new ExceptionUI( e); } @@ -367,9 +366,9 @@ public class ResourceDecompiling } String contents = Decompilers.cfr.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(path, contents, false); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); new ExceptionUI( e); } @@ -395,9 +394,9 @@ public class ResourceDecompiling String contents = Decompilers.fernflower.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(path, contents, false); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); new ExceptionUI( e); } @@ -423,9 +422,9 @@ public class ResourceDecompiling String contents = Decompilers.krakatau.decompileClassNode(cn, cw.toByteArray()); DiskWriter.replaceFile(path, contents, false); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } catch (Exception e) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); new ExceptionUI( e); } @@ -433,7 +432,7 @@ public class ResourceDecompiling t1.start(); } if (result == 5) { - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); } } }); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceExporting.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceExporting.java index 08c74938..085de699 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceExporting.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/ResourceExporting.java @@ -1,7 +1,7 @@ package the.bytecode.club.bytecodeviewer.util; import the.bytecode.club.bytecodeviewer.BytecodeViewer; -import the.bytecode.club.bytecodeviewer.gui.ExportJar; +import the.bytecode.club.bytecodeviewer.gui.extras.ExportJar; import javax.swing.*; import javax.swing.filechooser.FileFilter; @@ -128,11 +128,11 @@ public class ResourceExporting final File file2 = file; - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); Thread t17 = new Thread(() -> { JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file2.getAbsolutePath()); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); }); t17.start(); } @@ -195,14 +195,14 @@ public class ResourceExporting } Thread t16 = new Thread(() -> { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar"; JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input); Thread t15 = new Thread(() -> { Dex2Jar.saveAsDex(new File(input), file2); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); }); t15.start(); }); @@ -307,14 +307,14 @@ public class ResourceExporting } Thread t14 = new Thread(() -> { - BytecodeViewer.viewer.setIcon(true); + BytecodeViewer.viewer.updateBusyStatus(true); final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar"; JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input); Thread t13 = new Thread(() -> { APKTool.buildAPK(new File(input), file2, finalContainer); - BytecodeViewer.viewer.setIcon(false); + BytecodeViewer.viewer.updateBusyStatus(false); }); t13.start(); }); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java index 6704b72d..4f033efc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SecurityMan.java @@ -105,7 +105,8 @@ public class SecurityMan extends SecurityManager { @Override public void checkAccess(ThreadGroup g) { } - + + @SuppressWarnings("deprecation") public void checkAwtEventQueueAccess() { } @@ -135,18 +136,20 @@ public class SecurityMan extends SecurityManager { @Override public void checkLink(String lib) { } - + + @SuppressWarnings("deprecation") public void checkMemberAccess(Class clazz, int which) { } @Override public void checkMulticast(InetAddress maddr) { } - - @Override + + @SuppressWarnings("deprecation") public void checkMulticast(InetAddress maddr, byte ttl) { } - + + @SuppressWarnings("deprecation") public void checkPackageAccess(String pkg) { } @@ -185,7 +188,8 @@ public class SecurityMan extends SecurityManager { @Override public void checkSetFactory() { } - + + @SuppressWarnings("deprecation") public void checkSystemClipboardAccess() { }