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 4026bb1d..85399013 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/MainViewerGUI.java @@ -561,6 +561,7 @@ public class MainViewerGUI extends JFrame //FERNFLOWER SETTINGS //settingsMainMenu.add(fernFlowerSettingsSecondaryMenu); settingsMainMenu.add(fernFlowerSettings); + fernFlowerSettingsSecondaryMenu.add(ren); fernFlowerSettingsSecondaryMenu.add(dc4); fernFlowerSettingsSecondaryMenu.add(nns); fernFlowerSettingsSecondaryMenu.add(ner); @@ -579,7 +580,6 @@ public class MainViewerGUI extends JFrame fernFlowerSettingsSecondaryMenu.add(udv); fernFlowerSettingsSecondaryMenu.add(fdi); fernFlowerSettingsSecondaryMenu.add(asc); - fernFlowerSettingsSecondaryMenu.add(ren); fernFlowerSettingsDialogue = new SettingsDialogue( fernFlowerSettingsSecondaryMenu, new JPanel()); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java index 8e21d82f..41666af3 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/components/BetterJOptionPane.java @@ -16,6 +16,7 @@ import static javax.swing.JOptionPane.*; * @author Scott Violet * @since 7/4/2021 */ + public class BetterJOptionPane { public static void showMessageDialog(Component parentComponent, @@ -85,30 +86,13 @@ public class BetterJOptionPane getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); - - //reflection to cheat our way around the - // private createDialog(Component parentComponent, String title, int style) - JDialog dialog = null; - try + JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> { - Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class); - createDialog.setAccessible(true); - dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style); - } - catch(Exception e) - { - e.printStackTrace(); - } + pane.selectInitialValue(); + }); pane.selectInitialValue(); - //check if the dialogue is in a poor location, attempt to correct - if(dialog.getLocation().getY() == 0) - dialog.setLocationRelativeTo(null); - - dialog.show(); - dialog.dispose(); - Object selectedValue = pane.getValue(); if(selectedValue == null) @@ -146,57 +130,49 @@ public class BetterJOptionPane getRootFrame() : parentComponent).getComponentOrientation()); int style = styleFromMessageType(messageType); - //reflection to cheat our way around the - // private createDialog(Component parentComponent, String title, int style) - JDialog dialog = null; - try + JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)-> { - Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class); - createDialog.setAccessible(true); - dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style); - } - catch(Exception e) - { - e.printStackTrace(); - } + pane.selectInitialValue(); + }); pane.selectInitialValue(); - //check if the dialogue is in a poor location, attempt to correct - if(dialog.getLocation().getY() == 0) - dialog.setLocationRelativeTo(null); - - dialog.show(); - dialog.dispose(); - Object value = pane.getInputValue(); - if (value == UNINITIALIZED_VALUE) { + if (value == UNINITIALIZED_VALUE) return null; - } + return value; } public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight) throws HeadlessException { + //create a new option pane with a empty text and just 'ok' JOptionPane pane = new JOptionPane(""); pane.add(panel, 0); + JDialog dialog = createNewJDialogue(parentComponent, pane, panel.getName(), 0, (d)-> + { + int newHeight = Math.min(minimumHeight, d.getHeight()); + d.setMinimumSize(new Dimension(d.getWidth(), newHeight)); + d.setSize(new Dimension(d.getWidth(), newHeight)); + }); + } + + private static JDialog createNewJDialogue(Component parentComponent, JOptionPane pane, String title, int style, OnCreate onCreate) + { + JDialog dialog = null; + //reflection to cheat our way around the // private createDialog(Component parentComponent, String title, int style) - JDialog dialog = null; try { Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class); createDialog.setAccessible(true); - dialog = (JDialog) createDialog.invoke(pane, parentComponent, panel.getName(), 0); + dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style); - //dialog.setResizable(true); - - int newHeight = minimumHeight < dialog.getHeight() ? minimumHeight : dialog.getHeight(); - dialog.setMinimumSize(new Dimension(dialog.getWidth(), newHeight)); - dialog.setSize(new Dimension(dialog.getWidth(), newHeight)); + onCreate.onCreate(dialog); } catch(Exception e) { @@ -209,6 +185,8 @@ public class BetterJOptionPane dialog.show(); dialog.dispose(); + + return dialog; } private static int styleFromMessageType(int messageType) @@ -228,4 +206,9 @@ public class BetterJOptionPane return JRootPane.PLAIN_DIALOG; } } + + interface OnCreate + { + void onCreate(JDialog dialog); + } } \ No newline at end of file diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java index da451a64..c227ddd5 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java @@ -83,7 +83,7 @@ public class FileViewer extends ResourceViewer // + Add file header checks // + Check for CAFEBABE // + ClassRead then quick-decompile using Pane1 Decompiler - // (If none selected, try Pane2, Pane3, default to Proycon) + // (If none selected, try Pane2, Pane3, default to Procyon) //check by file extension to display image diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java index 5cd556a1..de5f9a7b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/theme/LAFTheme.java @@ -102,7 +102,13 @@ public enum LAFTheme Configuration.showDarkLAFComponentIcons = darkLAF; if(BytecodeViewer.viewer != null) + { BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon); + SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.procyonSettingsDialogue); + SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.cfrSettingsDialogue); + SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.fernFlowerSettingsDialogue); + SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.bytecodeDecompilerSettingsDialogue); + } } /** diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java index 343ebdb2..e3b1d743 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceDecompiling.java @@ -81,7 +81,7 @@ public class ResourceDecompiling Thread t12 = new Thread(() -> { try { Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), - MiscUtils.append(javaSucks, "-proycon.zip")); + MiscUtils.append(javaSucks, "-procyon.zip")); BytecodeViewer.updateBusyStatus(false); } catch (Exception e) { BytecodeViewer.handleException(e); @@ -241,7 +241,7 @@ public class ResourceDecompiling } try { - DiskWriter.replaceFile(MiscUtils.append(file, "-proycon.java"), + DiskWriter.replaceFile(MiscUtils.append(file, "-procyon.java"), Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false); } catch (Exception e) { e.printStackTrace();