diff options
| author | 2018-11-28 10:54:38 +0100 | |
|---|---|---|
| committer | 2018-11-28 10:54:38 +0100 | |
| commit | ec03792398d1b78ab5af20dbf5a2d171871396ce (patch) | |
| tree | 8df37c2e47ba719c89a623b81cf85572915f5cf7 /src/main/java/cuchaz/enigma/gui/Gui.java | |
| parent | refactors and bugfixes (diff) | |
| download | enigma-fork-ec03792398d1b78ab5af20dbf5a2d171871396ce.tar.gz enigma-fork-ec03792398d1b78ab5af20dbf5a2d171871396ce.tar.xz enigma-fork-ec03792398d1b78ab5af20dbf5a2d171871396ce.zip | |
add line number coloring, bugfixes
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 95fde43..06e7842 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -70,6 +70,7 @@ public class Gui { | |||
| 70 | public FileDialog exportJarFileChooser; | 70 | public FileDialog exportJarFileChooser; |
| 71 | private GuiController controller; | 71 | private GuiController controller; |
| 72 | private JFrame frame; | 72 | private JFrame frame; |
| 73 | public Config.LookAndFeel editorFeel; | ||
| 73 | public PanelEditor editor; | 74 | public PanelEditor editor; |
| 74 | private JPanel classesPanel; | 75 | private JPanel classesPanel; |
| 75 | private JSplitPane splitClasses; | 76 | private JSplitPane splitClasses; |
| @@ -84,13 +85,26 @@ public class Gui { | |||
| 84 | private JList<Token> tokens; | 85 | private JList<Token> tokens; |
| 85 | private JTabbedPane tabs; | 86 | private JTabbedPane tabs; |
| 86 | 87 | ||
| 87 | public Gui() { | 88 | public void setEditorTheme(Config.LookAndFeel feel) { |
| 89 | if (editor != null && (editorFeel == null || editorFeel != feel)) { | ||
| 90 | editor.updateUI(); | ||
| 91 | editor.setBackground(new Color(Config.getInstance().editorBackground)); | ||
| 92 | if (editorFeel != null) { | ||
| 93 | getController().refreshCurrentClass(); | ||
| 94 | } | ||
| 95 | |||
| 96 | editorFeel = feel; | ||
| 97 | } | ||
| 98 | } | ||
| 88 | 99 | ||
| 100 | public Gui() { | ||
| 89 | // init frame | 101 | // init frame |
| 90 | this.frame = new JFrame(Constants.NAME); | 102 | this.frame = new JFrame(Constants.NAME); |
| 91 | final Container pane = this.frame.getContentPane(); | 103 | final Container pane = this.frame.getContentPane(); |
| 92 | pane.setLayout(new BorderLayout()); | 104 | pane.setLayout(new BorderLayout()); |
| 93 | 105 | ||
| 106 | Config.getInstance().lookAndFeel.setGlobalLAF(); | ||
| 107 | |||
| 94 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { | 108 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { |
| 95 | // install a global exception handler to the event thread | 109 | // install a global exception handler to the event thread |
| 96 | CrashDialog.init(this.frame); | 110 | CrashDialog.init(this.frame); |
| @@ -127,11 +141,7 @@ public class Gui { | |||
| 127 | infoPanel.clearReference(); | 141 | infoPanel.clearReference(); |
| 128 | 142 | ||
| 129 | // init editor | 143 | // init editor |
| 130 | DefaultSyntaxKit.initKit(); | 144 | Themes.updateTheme(this); |
| 131 | DefaultSyntaxKit.registerContentType("text/minecraft", MinecraftSyntaxKit.class.getName()); | ||
| 132 | obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | ||
| 133 | deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | ||
| 134 | otherHighlightPainter = new OtherHighlightPainter(); | ||
| 135 | selectionHighlightPainter = new SelectionHighlightPainter(); | 145 | selectionHighlightPainter = new SelectionHighlightPainter(); |
| 136 | this.editor = new PanelEditor(this); | 146 | this.editor = new PanelEditor(this); |
| 137 | JScrollPane sourceScroller = new JScrollPane(this.editor); | 147 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| @@ -308,8 +318,6 @@ public class Gui { | |||
| 308 | panel.add(new JLabel("Loading...")); | 318 | panel.add(new JLabel("Loading...")); |
| 309 | this.classesPanel.add(panel); | 319 | this.classesPanel.add(panel); |
| 310 | 320 | ||
| 311 | Themes.updateTheme(this); | ||
| 312 | |||
| 313 | redraw(); | 321 | redraw(); |
| 314 | } | 322 | } |
| 315 | 323 | ||
| @@ -332,8 +340,6 @@ public class Gui { | |||
| 332 | this.menuBar.exportSourceMenu.setEnabled(true); | 340 | this.menuBar.exportSourceMenu.setEnabled(true); |
| 333 | this.menuBar.exportJarMenu.setEnabled(true); | 341 | this.menuBar.exportJarMenu.setEnabled(true); |
| 334 | 342 | ||
| 335 | Themes.updateTheme(this); | ||
| 336 | |||
| 337 | redraw(); | 343 | redraw(); |
| 338 | } | 344 | } |
| 339 | 345 | ||
| @@ -357,8 +363,6 @@ public class Gui { | |||
| 357 | this.menuBar.exportSourceMenu.setEnabled(false); | 363 | this.menuBar.exportSourceMenu.setEnabled(false); |
| 358 | this.menuBar.exportJarMenu.setEnabled(false); | 364 | this.menuBar.exportJarMenu.setEnabled(false); |
| 359 | 365 | ||
| 360 | Themes.updateTheme(this); | ||
| 361 | |||
| 362 | redraw(); | 366 | redraw(); |
| 363 | } | 367 | } |
| 364 | 368 | ||
| @@ -489,13 +493,14 @@ public class Gui { | |||
| 489 | private void addNameValue(JPanel container, String name, String value) { | 493 | private void addNameValue(JPanel container, String name, String value) { |
| 490 | JPanel panel = new JPanel(); | 494 | JPanel panel = new JPanel(); |
| 491 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); | 495 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); |
| 492 | container.add(panel); | ||
| 493 | 496 | ||
| 494 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); | 497 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); |
| 495 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); | 498 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); |
| 496 | panel.add(label); | 499 | panel.add(label); |
| 497 | 500 | ||
| 498 | panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT))); | 501 | panel.add(Utils.unboldLabel(new JLabel(value, JLabel.LEFT))); |
| 502 | |||
| 503 | container.add(panel); | ||
| 499 | } | 504 | } |
| 500 | 505 | ||
| 501 | private JComboBox<Mappings.EntryModifier> addModifierComboBox(JPanel container, String name, Entry entry) { | 506 | private JComboBox<Mappings.EntryModifier> addModifierComboBox(JPanel container, String name, Entry entry) { |
| @@ -503,7 +508,6 @@ public class Gui { | |||
| 503 | return null; | 508 | return null; |
| 504 | JPanel panel = new JPanel(); | 509 | JPanel panel = new JPanel(); |
| 505 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); | 510 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); |
| 506 | container.add(panel); | ||
| 507 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); | 511 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); |
| 508 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); | 512 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); |
| 509 | panel.add(label); | 513 | panel.add(label); |
| @@ -513,6 +517,9 @@ public class Gui { | |||
| 513 | combo.setSelectedIndex(getController().getDeobfuscator().getModifier(entry).ordinal()); | 517 | combo.setSelectedIndex(getController().getDeobfuscator().getModifier(entry).ordinal()); |
| 514 | combo.addItemListener(getController()::modifierChange); | 518 | combo.addItemListener(getController()::modifierChange); |
| 515 | panel.add(combo); | 519 | panel.add(combo); |
| 520 | |||
| 521 | container.add(panel); | ||
| 522 | |||
| 516 | return combo; | 523 | return combo; |
| 517 | } | 524 | } |
| 518 | 525 | ||
| @@ -607,8 +614,6 @@ public class Gui { | |||
| 607 | else | 614 | else |
| 608 | text.selectAll(); | 615 | text.selectAll(); |
| 609 | 616 | ||
| 610 | Themes.updateTheme(this); | ||
| 611 | |||
| 612 | redraw(); | 617 | redraw(); |
| 613 | } | 618 | } |
| 614 | 619 | ||
| @@ -665,8 +670,6 @@ public class Gui { | |||
| 665 | 670 | ||
| 666 | tabs.setSelectedIndex(0); | 671 | tabs.setSelectedIndex(0); |
| 667 | 672 | ||
| 668 | Themes.updateTheme(this); | ||
| 669 | |||
| 670 | redraw(); | 673 | redraw(); |
| 671 | } | 674 | } |
| 672 | 675 | ||
| @@ -697,8 +700,6 @@ public class Gui { | |||
| 697 | 700 | ||
| 698 | tabs.setSelectedIndex(1); | 701 | tabs.setSelectedIndex(1); |
| 699 | 702 | ||
| 700 | Themes.updateTheme(this); | ||
| 701 | |||
| 702 | redraw(); | 703 | redraw(); |
| 703 | } | 704 | } |
| 704 | 705 | ||
| @@ -720,8 +721,6 @@ public class Gui { | |||
| 720 | 721 | ||
| 721 | tabs.setSelectedIndex(2); | 722 | tabs.setSelectedIndex(2); |
| 722 | 723 | ||
| 723 | Themes.updateTheme(this); | ||
| 724 | |||
| 725 | redraw(); | 724 | redraw(); |
| 726 | } | 725 | } |
| 727 | 726 | ||