Cleanup
This commit is contained in:
parent
8116cacd49
commit
69b282aa2d
5 changed files with 41 additions and 52 deletions
|
@ -561,6 +561,7 @@ public class MainViewerGUI extends JFrame
|
||||||
//FERNFLOWER SETTINGS
|
//FERNFLOWER SETTINGS
|
||||||
//settingsMainMenu.add(fernFlowerSettingsSecondaryMenu);
|
//settingsMainMenu.add(fernFlowerSettingsSecondaryMenu);
|
||||||
settingsMainMenu.add(fernFlowerSettings);
|
settingsMainMenu.add(fernFlowerSettings);
|
||||||
|
fernFlowerSettingsSecondaryMenu.add(ren);
|
||||||
fernFlowerSettingsSecondaryMenu.add(dc4);
|
fernFlowerSettingsSecondaryMenu.add(dc4);
|
||||||
fernFlowerSettingsSecondaryMenu.add(nns);
|
fernFlowerSettingsSecondaryMenu.add(nns);
|
||||||
fernFlowerSettingsSecondaryMenu.add(ner);
|
fernFlowerSettingsSecondaryMenu.add(ner);
|
||||||
|
@ -579,7 +580,6 @@ public class MainViewerGUI extends JFrame
|
||||||
fernFlowerSettingsSecondaryMenu.add(udv);
|
fernFlowerSettingsSecondaryMenu.add(udv);
|
||||||
fernFlowerSettingsSecondaryMenu.add(fdi);
|
fernFlowerSettingsSecondaryMenu.add(fdi);
|
||||||
fernFlowerSettingsSecondaryMenu.add(asc);
|
fernFlowerSettingsSecondaryMenu.add(asc);
|
||||||
fernFlowerSettingsSecondaryMenu.add(ren);
|
|
||||||
fernFlowerSettingsDialogue = new SettingsDialogue(
|
fernFlowerSettingsDialogue = new SettingsDialogue(
|
||||||
fernFlowerSettingsSecondaryMenu,
|
fernFlowerSettingsSecondaryMenu,
|
||||||
new JPanel());
|
new JPanel());
|
||||||
|
|
|
@ -16,6 +16,7 @@ import static javax.swing.JOptionPane.*;
|
||||||
* @author Scott Violet
|
* @author Scott Violet
|
||||||
* @since 7/4/2021
|
* @since 7/4/2021
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class BetterJOptionPane
|
public class BetterJOptionPane
|
||||||
{
|
{
|
||||||
public static void showMessageDialog(Component parentComponent,
|
public static void showMessageDialog(Component parentComponent,
|
||||||
|
@ -85,30 +86,13 @@ public class BetterJOptionPane
|
||||||
getRootFrame() : parentComponent).getComponentOrientation());
|
getRootFrame() : parentComponent).getComponentOrientation());
|
||||||
|
|
||||||
int style = styleFromMessageType(messageType);
|
int style = styleFromMessageType(messageType);
|
||||||
|
JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)->
|
||||||
//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);
|
pane.selectInitialValue();
|
||||||
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();
|
Object selectedValue = pane.getValue();
|
||||||
|
|
||||||
if(selectedValue == null)
|
if(selectedValue == null)
|
||||||
|
@ -146,57 +130,49 @@ public class BetterJOptionPane
|
||||||
getRootFrame() : parentComponent).getComponentOrientation());
|
getRootFrame() : parentComponent).getComponentOrientation());
|
||||||
|
|
||||||
int style = styleFromMessageType(messageType);
|
int style = styleFromMessageType(messageType);
|
||||||
//reflection to cheat our way around the
|
JDialog dialog = createNewJDialogue(parentComponent, pane, title, style, (d)->
|
||||||
// private createDialog(Component parentComponent, String title, int style)
|
|
||||||
JDialog dialog = null;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class);
|
pane.selectInitialValue();
|
||||||
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();
|
Object value = pane.getInputValue();
|
||||||
|
|
||||||
if (value == UNINITIALIZED_VALUE) {
|
if (value == UNINITIALIZED_VALUE)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight)
|
public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight)
|
||||||
throws HeadlessException
|
throws HeadlessException
|
||||||
{
|
{
|
||||||
|
//create a new option pane with a empty text and just 'ok'
|
||||||
JOptionPane pane = new JOptionPane("");
|
JOptionPane pane = new JOptionPane("");
|
||||||
pane.add(panel, 0);
|
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
|
//reflection to cheat our way around the
|
||||||
// private createDialog(Component parentComponent, String title, int style)
|
// private createDialog(Component parentComponent, String title, int style)
|
||||||
JDialog dialog = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class);
|
Method createDialog = pane.getClass().getDeclaredMethod("createDialog", Component.class, String.class, int.class);
|
||||||
createDialog.setAccessible(true);
|
createDialog.setAccessible(true);
|
||||||
dialog = (JDialog) createDialog.invoke(pane, parentComponent, panel.getName(), 0);
|
dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style);
|
||||||
|
|
||||||
//dialog.setResizable(true);
|
onCreate.onCreate(dialog);
|
||||||
|
|
||||||
int newHeight = minimumHeight < dialog.getHeight() ? minimumHeight : dialog.getHeight();
|
|
||||||
dialog.setMinimumSize(new Dimension(dialog.getWidth(), newHeight));
|
|
||||||
dialog.setSize(new Dimension(dialog.getWidth(), newHeight));
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +185,8 @@ public class BetterJOptionPane
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
|
|
||||||
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int styleFromMessageType(int messageType)
|
private static int styleFromMessageType(int messageType)
|
||||||
|
@ -228,4 +206,9 @@ public class BetterJOptionPane
|
||||||
return JRootPane.PLAIN_DIALOG;
|
return JRootPane.PLAIN_DIALOG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface OnCreate
|
||||||
|
{
|
||||||
|
void onCreate(JDialog dialog);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -83,7 +83,7 @@ public class FileViewer extends ResourceViewer
|
||||||
// + Add file header checks
|
// + Add file header checks
|
||||||
// + Check for CAFEBABE
|
// + Check for CAFEBABE
|
||||||
// + ClassRead then quick-decompile using Pane1 Decompiler
|
// + 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
|
//check by file extension to display image
|
||||||
|
|
|
@ -102,7 +102,13 @@ public enum LAFTheme
|
||||||
Configuration.showDarkLAFComponentIcons = darkLAF;
|
Configuration.showDarkLAFComponentIcons = darkLAF;
|
||||||
|
|
||||||
if(BytecodeViewer.viewer != null)
|
if(BytecodeViewer.viewer != null)
|
||||||
|
{
|
||||||
BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ResourceDecompiling
|
||||||
Thread t12 = new Thread(() -> {
|
Thread t12 = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
||||||
MiscUtils.append(javaSucks, "-proycon.zip"));
|
MiscUtils.append(javaSucks, "-procyon.zip"));
|
||||||
BytecodeViewer.updateBusyStatus(false);
|
BytecodeViewer.updateBusyStatus(false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
|
@ -241,7 +241,7 @@ public class ResourceDecompiling
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DiskWriter.replaceFile(MiscUtils.append(file, "-proycon.java"),
|
DiskWriter.replaceFile(MiscUtils.append(file, "-procyon.java"),
|
||||||
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
|
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray()), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in a new issue