Settings Dialogues
This commit is contained in:
parent
b678d98949
commit
0eb9622634
4 changed files with 47 additions and 27 deletions
|
@ -126,8 +126,14 @@ public class MainViewerGUI extends JFrame
|
||||||
|
|
||||||
//all of the settings main menu components
|
//all of the settings main menu components
|
||||||
public final JMenu rstaTheme = new TranslatedJMenu("Text Area Theme", Translation.TEXT_AREA_THEME);
|
public final JMenu rstaTheme = new TranslatedJMenu("Text Area Theme", Translation.TEXT_AREA_THEME);
|
||||||
|
public final JMenuItem rstaThemeSettings = new TranslatedJMenuItem("Text Area Theme", Translation.TEXT_AREA_THEME);
|
||||||
|
public SettingsDialogue rstaThemeSettingsDialogue;
|
||||||
public final JMenu lafTheme = new TranslatedJMenu("Window Theme", Translation.WINDOW_THEME);
|
public final JMenu lafTheme = new TranslatedJMenu("Window Theme", Translation.WINDOW_THEME);
|
||||||
|
public final JMenuItem lafThemeSettings = new TranslatedJMenuItem("Window Theme", Translation.WINDOW_THEME);
|
||||||
|
public SettingsDialogue lafThemeSettingsDialogue;
|
||||||
public final JMenu language = new TranslatedJMenu("Language", Translation.LANGUAGE);
|
public final JMenu language = new TranslatedJMenu("Language", Translation.LANGUAGE);
|
||||||
|
public final JMenuItem languageSettings = new TranslatedJMenuItem("Language", Translation.LANGUAGE);
|
||||||
|
public SettingsDialogue languageSettingsDialogue;
|
||||||
public final JMenu fontSize = new TranslatedJMenu("Font Size", Translation.FONT_SIZE);
|
public final JMenu fontSize = new TranslatedJMenu("Font Size", Translation.FONT_SIZE);
|
||||||
public final JSpinner fontSpinner = new JSpinner();
|
public final JSpinner fontSpinner = new JSpinner();
|
||||||
public final Map<RSTATheme, JRadioButtonMenuItem> rstaThemes = new HashMap<>();
|
public final Map<RSTATheme, JRadioButtonMenuItem> rstaThemes = new HashMap<>();
|
||||||
|
@ -438,6 +444,9 @@ public class MainViewerGUI extends JFrame
|
||||||
rstaTheme.add(item);
|
rstaTheme.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rstaThemeSettingsDialogue = new SettingsDialogue(rstaTheme, new JPanel());
|
||||||
|
rstaThemeSettings.addActionListener((e)-> rstaThemeSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
ButtonGroup lafGroup = new ButtonGroup();
|
ButtonGroup lafGroup = new ButtonGroup();
|
||||||
for (LAFTheme theme : LAFTheme.values())
|
for (LAFTheme theme : LAFTheme.values())
|
||||||
{
|
{
|
||||||
|
@ -470,6 +479,9 @@ public class MainViewerGUI extends JFrame
|
||||||
lafTheme.add(item);
|
lafTheme.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lafThemeSettingsDialogue = new SettingsDialogue(lafTheme, new JPanel());
|
||||||
|
lafThemeSettings.addActionListener((e)-> lafThemeSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
ButtonGroup languageGroup = new ButtonGroup();
|
ButtonGroup languageGroup = new ButtonGroup();
|
||||||
for (Language l : Language.values())
|
for (Language l : Language.values())
|
||||||
{
|
{
|
||||||
|
@ -489,9 +501,12 @@ public class MainViewerGUI extends JFrame
|
||||||
language.add(item);
|
language.add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
visualSettings.add(lafTheme);
|
languageSettingsDialogue = new SettingsDialogue(language, new JPanel());
|
||||||
visualSettings.add(rstaTheme);
|
languageSettings.addActionListener((e)-> languageSettingsDialogue.showDialogue());
|
||||||
visualSettings.add(language);
|
|
||||||
|
visualSettings.add(useNewSettingsDialogue ? lafThemeSettings : lafTheme);
|
||||||
|
visualSettings.add(useNewSettingsDialogue ? rstaThemeSettings : rstaTheme);
|
||||||
|
visualSettings.add(useNewSettingsDialogue ? languageSettings : language);
|
||||||
visualSettings.add(fontSize);
|
visualSettings.add(fontSize);
|
||||||
visualSettings.add(showFileInTabTitle);
|
visualSettings.add(showFileInTabTitle);
|
||||||
visualSettings.add(simplifyNameInTabTitle);
|
visualSettings.add(simplifyNameInTabTitle);
|
||||||
|
@ -514,9 +529,7 @@ public class MainViewerGUI extends JFrame
|
||||||
procyonSettingsSecondaryMenu.add(retainPointlessSwitches);
|
procyonSettingsSecondaryMenu.add(retainPointlessSwitches);
|
||||||
procyonSettingsSecondaryMenu.add(retainRedunantCasts);
|
procyonSettingsSecondaryMenu.add(retainRedunantCasts);
|
||||||
procyonSettingsSecondaryMenu.add(unicodeOutputEnabled);
|
procyonSettingsSecondaryMenu.add(unicodeOutputEnabled);
|
||||||
procyonSettingsDialogue = new SettingsDialogue(
|
procyonSettingsDialogue = new SettingsDialogue(procyonSettingsSecondaryMenu, new JPanel());
|
||||||
procyonSettingsSecondaryMenu,
|
|
||||||
new JPanel());
|
|
||||||
procyonSettings.addActionListener((e)-> procyonSettingsDialogue.showDialogue());
|
procyonSettings.addActionListener((e)-> procyonSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
//CFR SETTINGS
|
//CFR SETTINGS
|
||||||
|
@ -565,9 +578,7 @@ public class MainViewerGUI extends JFrame
|
||||||
cfrSettingsSecondaryMenu.add(recoveryTypehInts);
|
cfrSettingsSecondaryMenu.add(recoveryTypehInts);
|
||||||
cfrSettingsSecondaryMenu.add(forceTurningIFs);
|
cfrSettingsSecondaryMenu.add(forceTurningIFs);
|
||||||
cfrSettingsSecondaryMenu.add(forLoopAGGCapture);
|
cfrSettingsSecondaryMenu.add(forLoopAGGCapture);
|
||||||
cfrSettingsDialogue = new SettingsDialogue(
|
cfrSettingsDialogue = new SettingsDialogue(cfrSettingsSecondaryMenu, new JPanel());
|
||||||
cfrSettingsSecondaryMenu,
|
|
||||||
new JPanel());
|
|
||||||
cfrSettings.addActionListener((e)-> cfrSettingsDialogue.showDialogue());
|
cfrSettings.addActionListener((e)-> cfrSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
//FERNFLOWER SETTINGS
|
//FERNFLOWER SETTINGS
|
||||||
|
@ -591,18 +602,14 @@ public class MainViewerGUI extends JFrame
|
||||||
fernFlowerSettingsSecondaryMenu.add(udv);
|
fernFlowerSettingsSecondaryMenu.add(udv);
|
||||||
fernFlowerSettingsSecondaryMenu.add(fdi);
|
fernFlowerSettingsSecondaryMenu.add(fdi);
|
||||||
fernFlowerSettingsSecondaryMenu.add(asc);
|
fernFlowerSettingsSecondaryMenu.add(asc);
|
||||||
fernFlowerSettingsDialogue = new SettingsDialogue(
|
fernFlowerSettingsDialogue = new SettingsDialogue(fernFlowerSettingsSecondaryMenu, new JPanel());
|
||||||
fernFlowerSettingsSecondaryMenu,
|
|
||||||
new JPanel());
|
|
||||||
fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialogue.showDialogue());
|
fernFlowerSettings.addActionListener((e)-> fernFlowerSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
//CFIDE SETTINGS
|
//CFIDE SETTINGS
|
||||||
settingsMainMenu.add(useNewSettingsDialogue ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu);
|
settingsMainMenu.add(useNewSettingsDialogue ? bytecodeDecompilerSettings : bytecodeDecompilerSettingsSecondaryMenu);
|
||||||
bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers);
|
bytecodeDecompilerSettingsSecondaryMenu.add(debugHelpers);
|
||||||
bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels);
|
bytecodeDecompilerSettingsSecondaryMenu.add(appendBracketsToLabels);
|
||||||
bytecodeDecompilerSettingsDialogue = new SettingsDialogue(
|
bytecodeDecompilerSettingsDialogue = new SettingsDialogue(bytecodeDecompilerSettingsSecondaryMenu, new JPanel());
|
||||||
bytecodeDecompilerSettingsSecondaryMenu,
|
|
||||||
new JPanel());
|
|
||||||
bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialogue.showDialogue());
|
bytecodeDecompilerSettings.addActionListener((e)-> bytecodeDecompilerSettingsDialogue.showDialogue());
|
||||||
|
|
||||||
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
|
deleteForeignOutdatedLibs.addActionListener(arg0 -> showForeignLibraryWarning());
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package the.bytecode.club.bytecodeviewer.gui.components;
|
package the.bytecode.club.bytecodeviewer.gui.components;
|
||||||
|
|
||||||
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -7,9 +9,7 @@ import java.lang.reflect.Method;
|
||||||
import static javax.swing.JOptionPane.*;
|
import static javax.swing.JOptionPane.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All this does is fix the bug with parentComponents being minimized.
|
* Extends the JOptionPane
|
||||||
* The bug is the JOptionPane location ends up 0,0 instead of centered.
|
|
||||||
* The fix is to center the frame manually before showing.
|
|
||||||
*
|
*
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
* @author James Gosling
|
* @author James Gosling
|
||||||
|
@ -145,7 +145,7 @@ public class BetterJOptionPane
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight)
|
public static void showJPanelDialogue(Component parentComponent, JScrollPane panel, int minimumHeight, OnCreate onCreate)
|
||||||
throws HeadlessException
|
throws HeadlessException
|
||||||
{
|
{
|
||||||
//create a new option pane with a empty text and just 'ok'
|
//create a new option pane with a empty text and just 'ok'
|
||||||
|
@ -157,6 +157,9 @@ public class BetterJOptionPane
|
||||||
int newHeight = Math.min(minimumHeight, d.getHeight());
|
int newHeight = Math.min(minimumHeight, d.getHeight());
|
||||||
d.setMinimumSize(new Dimension(d.getWidth(), newHeight));
|
d.setMinimumSize(new Dimension(d.getWidth(), newHeight));
|
||||||
d.setSize(new Dimension(d.getWidth(), newHeight));
|
d.setSize(new Dimension(d.getWidth(), newHeight));
|
||||||
|
|
||||||
|
if(onCreate != null)
|
||||||
|
onCreate.onCreate(d);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +175,12 @@ public class BetterJOptionPane
|
||||||
createDialog.setAccessible(true);
|
createDialog.setAccessible(true);
|
||||||
dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style);
|
dialog = (JDialog) createDialog.invoke(pane, parentComponent, title, style);
|
||||||
|
|
||||||
|
//check if the dialogue is in a poor location, attempt to correct
|
||||||
|
if(dialog.getLocation().getY() == 0 || dialog.getLocation().getY() == 1)
|
||||||
|
dialog.setLocationRelativeTo(null); //TODO check if BytecodeViewer.viewer is better on multi monitor for this edgecase
|
||||||
|
else
|
||||||
|
dialog.setLocationRelativeTo(BytecodeViewer.viewer);
|
||||||
|
|
||||||
onCreate.onCreate(dialog);
|
onCreate.onCreate(dialog);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
|
@ -179,10 +188,6 @@ public class BetterJOptionPane
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if the dialogue is in a poor location, attempt to correct
|
|
||||||
if(dialog.getLocation().getY() == 0 || dialog.getLocation().getY() == 1)
|
|
||||||
dialog.setLocationRelativeTo(null);
|
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialo
|
||||||
|
|
||||||
public class SettingsDialogue extends JScrollPane
|
public class SettingsDialogue extends JScrollPane
|
||||||
{
|
{
|
||||||
public static final List<SettingsDialogue> dialogues = new ArrayList<>();
|
public static final List<JComponent> components = new ArrayList<>();
|
||||||
|
public static final List<JDialog> dialogues = new ArrayList<>();
|
||||||
private final List<JMenuItem> options = new ArrayList<>();
|
private final List<JMenuItem> options = new ArrayList<>();
|
||||||
private final JMenu menu;
|
private final JMenu menu;
|
||||||
private final JPanel display;
|
private final JPanel display;
|
||||||
|
@ -60,7 +61,7 @@ public class SettingsDialogue extends JScrollPane
|
||||||
|
|
||||||
buildPanel();
|
buildPanel();
|
||||||
|
|
||||||
dialogues.add(this);
|
components.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildPanel()
|
private void buildPanel()
|
||||||
|
@ -72,7 +73,7 @@ public class SettingsDialogue extends JScrollPane
|
||||||
|
|
||||||
public void showDialogue()
|
public void showDialogue()
|
||||||
{
|
{
|
||||||
BetterJOptionPane.showJPanelDialogue(null, this, 460);
|
BetterJOptionPane.showJPanelDialogue(null, this, 460, dialogues::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,6 +9,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.Translation;
|
import the.bytecode.club.bytecodeviewer.translation.Translation;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -103,7 +104,13 @@ public enum LAFTheme
|
||||||
if(BytecodeViewer.viewer != null)
|
if(BytecodeViewer.viewer != null)
|
||||||
{
|
{
|
||||||
BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon);
|
BytecodeViewer.viewer.uiComponents.forEach(VisibleComponent::setDefaultIcon);
|
||||||
SettingsDialogue.dialogues.forEach(SwingUtilities::updateComponentTreeUI);
|
//update all of the setting dialogue components
|
||||||
|
SettingsDialogue.components.forEach(SwingUtilities::updateComponentTreeUI);
|
||||||
|
|
||||||
|
//TODO instead of hiding this should update/rebuild the dialogue
|
||||||
|
|
||||||
|
//hide any existing jDialogues
|
||||||
|
SettingsDialogue.dialogues.forEach(Dialog::dispose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue