diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 06e7842..8ec58f9 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -22,9 +22,7 @@ import cuchaz.enigma.gui.elements.MenuBar; | |||
| 22 | import cuchaz.enigma.gui.elements.PopupMenuBar; | 22 | import cuchaz.enigma.gui.elements.PopupMenuBar; |
| 23 | import cuchaz.enigma.gui.filechooser.FileChooserAny; | 23 | import cuchaz.enigma.gui.filechooser.FileChooserAny; |
| 24 | import cuchaz.enigma.gui.filechooser.FileChooserFolder; | 24 | import cuchaz.enigma.gui.filechooser.FileChooserFolder; |
| 25 | import cuchaz.enigma.gui.highlight.DeobfuscatedHighlightPainter; | 25 | import cuchaz.enigma.gui.highlight.BoxHighlightPainter; |
| 26 | import cuchaz.enigma.gui.highlight.ObfuscatedHighlightPainter; | ||
| 27 | import cuchaz.enigma.gui.highlight.OtherHighlightPainter; | ||
| 28 | import cuchaz.enigma.gui.highlight.SelectionHighlightPainter; | 26 | import cuchaz.enigma.gui.highlight.SelectionHighlightPainter; |
| 29 | import cuchaz.enigma.gui.node.ClassSelectorPackageNode; | 27 | import cuchaz.enigma.gui.node.ClassSelectorPackageNode; |
| 30 | import cuchaz.enigma.gui.panels.PanelDeobf; | 28 | import cuchaz.enigma.gui.panels.PanelDeobf; |
| @@ -48,10 +46,8 @@ import java.awt.*; | |||
| 48 | import java.awt.event.*; | 46 | import java.awt.event.*; |
| 49 | import java.io.File; | 47 | import java.io.File; |
| 50 | import java.io.IOException; | 48 | import java.io.IOException; |
| 51 | import java.util.Collection; | 49 | import java.util.*; |
| 52 | import java.util.Collections; | ||
| 53 | import java.util.List; | 50 | import java.util.List; |
| 54 | import java.util.Vector; | ||
| 55 | import java.util.function.Function; | 51 | import java.util.function.Function; |
| 56 | 52 | ||
| 57 | public class Gui { | 53 | public class Gui { |
| @@ -75,9 +71,7 @@ public class Gui { | |||
| 75 | private JPanel classesPanel; | 71 | private JPanel classesPanel; |
| 76 | private JSplitPane splitClasses; | 72 | private JSplitPane splitClasses; |
| 77 | private PanelIdentifier infoPanel; | 73 | private PanelIdentifier infoPanel; |
| 78 | public ObfuscatedHighlightPainter obfuscatedHighlightPainter; | 74 | public Map<String, BoxHighlightPainter> boxHighlightPainters; |
| 79 | public DeobfuscatedHighlightPainter deobfuscatedHighlightPainter; | ||
| 80 | public OtherHighlightPainter otherHighlightPainter; | ||
| 81 | private SelectionHighlightPainter selectionHighlightPainter; | 75 | private SelectionHighlightPainter selectionHighlightPainter; |
| 82 | private JTree inheritanceTree; | 76 | private JTree inheritanceTree; |
| 83 | private JTree implementationsTree; | 77 | private JTree implementationsTree; |
| @@ -145,7 +139,7 @@ public class Gui { | |||
| 145 | selectionHighlightPainter = new SelectionHighlightPainter(); | 139 | selectionHighlightPainter = new SelectionHighlightPainter(); |
| 146 | this.editor = new PanelEditor(this); | 140 | this.editor = new PanelEditor(this); |
| 147 | JScrollPane sourceScroller = new JScrollPane(this.editor); | 141 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| 148 | this.editor.setContentType("text/minecraft"); | 142 | this.editor.setContentType("text/enigma-sources"); |
| 149 | this.editor.setBackground(new Color(Config.getInstance().editorBackground)); | 143 | this.editor.setBackground(new Color(Config.getInstance().editorBackground)); |
| 150 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); | 144 | DefaultSyntaxKit kit = (DefaultSyntaxKit) this.editor.getEditorKit(); |
| 151 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); | 145 | kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); |
| @@ -311,11 +305,11 @@ public class Gui { | |||
| 311 | return this.controller; | 305 | return this.controller; |
| 312 | } | 306 | } |
| 313 | 307 | ||
| 314 | public void onStartOpenJar() { | 308 | public void onStartOpenJar(String message) { |
| 315 | this.classesPanel.removeAll(); | 309 | this.classesPanel.removeAll(); |
| 316 | JPanel panel = new JPanel(); | 310 | JPanel panel = new JPanel(); |
| 317 | panel.setLayout(new FlowLayout()); | 311 | panel.setLayout(new FlowLayout()); |
| 318 | panel.add(new JLabel("Loading...")); | 312 | panel.add(new JLabel(message)); |
| 319 | this.classesPanel.add(panel); | 313 | this.classesPanel.add(panel); |
| 320 | 314 | ||
| 321 | redraw(); | 315 | redraw(); |
| @@ -407,20 +401,17 @@ public class Gui { | |||
| 407 | showToken(sortedTokens.get(0)); | 401 | showToken(sortedTokens.get(0)); |
| 408 | } | 402 | } |
| 409 | 403 | ||
| 410 | public void setHighlightedTokens(Iterable<Token> obfuscatedTokens, Iterable<Token> deobfuscatedTokens, Iterable<Token> otherTokens) { | 404 | public void setHighlightedTokens(Map<String, Iterable<Token>> tokens) { |
| 411 | |||
| 412 | // remove any old highlighters | 405 | // remove any old highlighters |
| 413 | this.editor.getHighlighter().removeAllHighlights(); | 406 | this.editor.getHighlighter().removeAllHighlights(); |
| 414 | 407 | ||
| 415 | // color things based on the index | 408 | if (boxHighlightPainters != null) { |
| 416 | if (obfuscatedTokens != null) { | 409 | for (String s : tokens.keySet()) { |
| 417 | setHighlightedTokens(obfuscatedTokens, obfuscatedHighlightPainter); | 410 | BoxHighlightPainter painter = boxHighlightPainters.get(s); |
| 418 | } | 411 | if (painter != null) { |
| 419 | if (deobfuscatedTokens != null) { | 412 | setHighlightedTokens(tokens.get(s), painter); |
| 420 | setHighlightedTokens(deobfuscatedTokens, deobfuscatedHighlightPainter); | 413 | } |
| 421 | } | 414 | } |
| 422 | if (otherTokens != null) { | ||
| 423 | setHighlightedTokens(otherTokens, otherHighlightPainter); | ||
| 424 | } | 415 | } |
| 425 | 416 | ||
| 426 | redraw(); | 417 | redraw(); |
| @@ -582,7 +573,7 @@ public class Gui { | |||
| 582 | 573 | ||
| 583 | // init the text box | 574 | // init the text box |
| 584 | final JTextField text = new JTextField(); | 575 | final JTextField text = new JTextField(); |
| 585 | text.setText(reference.getNamableName()); | 576 | text.setText(reference.getNameableName()); |
| 586 | text.setPreferredSize(new Dimension(360, text.getPreferredSize().height)); | 577 | text.setPreferredSize(new Dimension(360, text.getPreferredSize().height)); |
| 587 | text.addKeyListener(new KeyAdapter() { | 578 | text.addKeyListener(new KeyAdapter() { |
| 588 | @Override | 579 | @Override |
| @@ -633,7 +624,7 @@ public class Gui { | |||
| 633 | // abort the rename | 624 | // abort the rename |
| 634 | JPanel panel = (JPanel) infoPanel.getComponent(0); | 625 | JPanel panel = (JPanel) infoPanel.getComponent(0); |
| 635 | panel.remove(panel.getComponentCount() - 1); | 626 | panel.remove(panel.getComponentCount() - 1); |
| 636 | panel.add(Utils.unboldLabel(new JLabel(reference.getNamableName(), JLabel.LEFT))); | 627 | panel.add(Utils.unboldLabel(new JLabel(reference.getNameableName(), JLabel.LEFT))); |
| 637 | 628 | ||
| 638 | this.editor.grabFocus(); | 629 | this.editor.grabFocus(); |
| 639 | 630 | ||