Code Cleanup

This commit is contained in:
Konloch 2021-07-19 03:56:52 -07:00
parent 69b282aa2d
commit 244ed68599
2 changed files with 12 additions and 13 deletions

View file

@ -1,7 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui.components; package the.bytecode.club.bytecodeviewer.gui.components;
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,31 +30,36 @@ import java.util.List;
public class SettingsDialogue extends JScrollPane public class SettingsDialogue extends JScrollPane
{ {
private final List<JCheckBoxMenuItem> options = new ArrayList<>(); public static final List<SettingsDialogue> dialogues = 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;
public SettingsDialogue(JMenu menu, JPanel display) public SettingsDialogue(JMenu menu, JPanel display)
{ {
super(display); super(display);
List<JCheckBoxMenuItem> options = new ArrayList<>(); List<JMenuItem> options = new ArrayList<>();
for(Component child : menu.getMenuComponents()) for(Component child : menu.getMenuComponents())
{ {
if(!(child instanceof JCheckBoxMenuItem)) if(!(child instanceof JMenuItem))
continue; continue;
options.add((JCheckBoxMenuItem) child); options.add((JMenuItem) child);
} }
this.menu = menu; this.menu = menu;
this.options.addAll(options); this.options.addAll(options);
this.display = display; this.display = display;
buildPanel(); buildPanel();
dialogues.add(this);
} }
private void buildPanel() private void buildPanel()
{ {
display.setLayout(new BoxLayout(display, BoxLayout.Y_AXIS)); display.setLayout(new BoxLayout(display, BoxLayout.Y_AXIS));
for(JCheckBoxMenuItem menuItem : options) for(JMenuItem menuItem : options)
display.add(menuItem); display.add(menuItem);
} }

View file

@ -4,12 +4,11 @@ import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.*; import com.github.weisj.darklaf.theme.*;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.SettingsDialogue;
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent; 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.util.Map;
import java.util.Set;
/** /**
* @author Konloch * @author Konloch
@ -104,10 +103,7 @@ public enum LAFTheme
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); SettingsDialogue.dialogues.forEach(SwingUtilities::updateComponentTreeUI);
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.cfrSettingsDialogue);
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.fernFlowerSettingsDialogue);
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer.bytecodeDecompilerSettingsDialogue);
} }
} }