diff options
| author | 2016-07-02 20:13:13 +1000 | |
|---|---|---|
| committer | 2016-07-02 20:13:13 +1000 | |
| commit | 74edc74c2c7b3236f00bf92499bb884837673b7d (patch) | |
| tree | 155556b4d6e390574f16082583f2853e35e3c716 /src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java | |
| parent | Renamed Fields (diff) | |
| download | enigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.tar.gz enigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.tar.xz enigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.zip | |
Reformatting code
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java | 86 |
1 files changed, 20 insertions, 66 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java b/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java index 4b79b77..f083e50 100644 --- a/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java +++ b/src/main/java/cuchaz/enigma/gui/MemberMatchingGui.java | |||
| @@ -17,7 +17,6 @@ import java.awt.BorderLayout; | |||
| 17 | import java.awt.Container; | 17 | import java.awt.Container; |
| 18 | import java.awt.Dimension; | 18 | import java.awt.Dimension; |
| 19 | import java.awt.FlowLayout; | 19 | import java.awt.FlowLayout; |
| 20 | import java.awt.event.ActionEvent; | ||
| 21 | import java.awt.event.ActionListener; | 20 | import java.awt.event.ActionListener; |
| 22 | import java.awt.event.KeyAdapter; | 21 | import java.awt.event.KeyAdapter; |
| 23 | import java.awt.event.KeyEvent; | 22 | import java.awt.event.KeyEvent; |
| @@ -30,12 +29,10 @@ import javax.swing.text.Highlighter.HighlightPainter; | |||
| 30 | 29 | ||
| 31 | import cuchaz.enigma.Constants; | 30 | import cuchaz.enigma.Constants; |
| 32 | import cuchaz.enigma.Deobfuscator; | 31 | import cuchaz.enigma.Deobfuscator; |
| 33 | import cuchaz.enigma.analysis.EntryReference; | ||
| 34 | import cuchaz.enigma.analysis.SourceIndex; | 32 | import cuchaz.enigma.analysis.SourceIndex; |
| 35 | import cuchaz.enigma.analysis.Token; | 33 | import cuchaz.enigma.analysis.Token; |
| 36 | import cuchaz.enigma.convert.ClassMatches; | 34 | import cuchaz.enigma.convert.ClassMatches; |
| 37 | import cuchaz.enigma.convert.MemberMatches; | 35 | import cuchaz.enigma.convert.MemberMatches; |
| 38 | import cuchaz.enigma.gui.ClassSelector.ClassSelectionListener; | ||
| 39 | import cuchaz.enigma.mapping.ClassEntry; | 36 | import cuchaz.enigma.mapping.ClassEntry; |
| 40 | import cuchaz.enigma.mapping.Entry; | 37 | import cuchaz.enigma.mapping.Entry; |
| 41 | import de.sciss.syntaxpane.DefaultSyntaxKit; | 38 | import de.sciss.syntaxpane.DefaultSyntaxKit; |
| @@ -108,7 +105,7 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 108 | m_destDeobfuscator = destDeobfuscator; | 105 | m_destDeobfuscator = destDeobfuscator; |
| 109 | 106 | ||
| 110 | // init frame | 107 | // init frame |
| 111 | m_frame = new JFrame(Constants.Name + " - Member Matcher"); | 108 | m_frame = new JFrame(Constants.NAME + " - Member Matcher"); |
| 112 | final Container pane = m_frame.getContentPane(); | 109 | final Container pane = m_frame.getContentPane(); |
| 113 | pane.setLayout(new BorderLayout()); | 110 | pane.setLayout(new BorderLayout()); |
| 114 | 111 | ||
| @@ -123,12 +120,7 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 123 | JPanel sourceTypePanel = new JPanel(); | 120 | JPanel sourceTypePanel = new JPanel(); |
| 124 | classesPanel.add(sourceTypePanel); | 121 | classesPanel.add(sourceTypePanel); |
| 125 | sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS)); | 122 | sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS)); |
| 126 | ActionListener sourceTypeListener = new ActionListener() { | 123 | ActionListener sourceTypeListener = event -> setSourceType(SourceType.valueOf(event.getActionCommand())); |
| 127 | @Override | ||
| 128 | public void actionPerformed(ActionEvent event) { | ||
| 129 | setSourceType(SourceType.valueOf(event.getActionCommand())); | ||
| 130 | } | ||
| 131 | }; | ||
| 132 | ButtonGroup sourceTypeButtons = new ButtonGroup(); | 124 | ButtonGroup sourceTypeButtons = new ButtonGroup(); |
| 133 | m_sourceTypeButtons = Maps.newHashMap(); | 125 | m_sourceTypeButtons = Maps.newHashMap(); |
| 134 | for (SourceType sourceType : SourceType.values()) { | 126 | for (SourceType sourceType : SourceType.values()) { |
| @@ -138,37 +130,26 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 138 | } | 130 | } |
| 139 | 131 | ||
| 140 | m_sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); | 132 | m_sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); |
| 141 | m_sourceClasses.setListener(new ClassSelectionListener() { | 133 | m_sourceClasses.setListener(this::setSourceClass); |
| 142 | @Override | ||
| 143 | public void onSelectClass(ClassEntry classEntry) { | ||
| 144 | setSourceClass(classEntry); | ||
| 145 | } | ||
| 146 | }); | ||
| 147 | JScrollPane sourceScroller = new JScrollPane(m_sourceClasses); | 134 | JScrollPane sourceScroller = new JScrollPane(m_sourceClasses); |
| 148 | classesPanel.add(sourceScroller); | 135 | classesPanel.add(sourceScroller); |
| 149 | 136 | ||
| 150 | // init readers | 137 | // init readers |
| 151 | DefaultSyntaxKit.initKit(); | 138 | DefaultSyntaxKit.initKit(); |
| 152 | m_sourceReader = new CodeReader(); | 139 | m_sourceReader = new CodeReader(); |
| 153 | m_sourceReader.setSelectionListener(new CodeReader.SelectionListener() { | 140 | m_sourceReader.setSelectionListener(reference -> { |
| 154 | @Override | 141 | if (reference != null) { |
| 155 | public void onSelect(EntryReference<Entry, Entry> reference) { | 142 | onSelectSource(reference.entry); |
| 156 | if (reference != null) { | 143 | } else { |
| 157 | onSelectSource(reference.entry); | 144 | onSelectSource(null); |
| 158 | } else { | ||
| 159 | onSelectSource(null); | ||
| 160 | } | ||
| 161 | } | 145 | } |
| 162 | }); | 146 | }); |
| 163 | m_destReader = new CodeReader(); | 147 | m_destReader = new CodeReader(); |
| 164 | m_destReader.setSelectionListener(new CodeReader.SelectionListener() { | 148 | m_destReader.setSelectionListener(reference -> { |
| 165 | @Override | 149 | if (reference != null) { |
| 166 | public void onSelect(EntryReference<Entry, Entry> reference) { | 150 | onSelectDest(reference.entry); |
| 167 | if (reference != null) { | 151 | } else { |
| 168 | onSelectDest(reference.entry); | 152 | onSelectDest(null); |
| 169 | } else { | ||
| 170 | onSelectDest(null); | ||
| 171 | } | ||
| 172 | } | 153 | } |
| 173 | }); | 154 | }); |
| 174 | 155 | ||
| @@ -267,18 +248,8 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 267 | throw new Error("No matching dest class for source class: " + m_obfSourceClass); | 248 | throw new Error("No matching dest class for source class: " + m_obfSourceClass); |
| 268 | } | 249 | } |
| 269 | 250 | ||
| 270 | m_sourceReader.decompileClass(m_obfSourceClass, m_sourceDeobfuscator, false, new Runnable() { | 251 | m_sourceReader.decompileClass(m_obfSourceClass, m_sourceDeobfuscator, false, this::updateSourceHighlights); |
| 271 | @Override | 252 | m_destReader.decompileClass(m_obfDestClass, m_destDeobfuscator, false, this::updateDestHighlights); |
| 272 | public void run() { | ||
| 273 | updateSourceHighlights(); | ||
| 274 | } | ||
| 275 | }); | ||
| 276 | m_destReader.decompileClass(m_obfDestClass, m_destDeobfuscator, false, new Runnable() { | ||
| 277 | @Override | ||
| 278 | public void run() { | ||
| 279 | updateDestHighlights(); | ||
| 280 | } | ||
| 281 | }); | ||
| 282 | } | 253 | } |
| 283 | 254 | ||
| 284 | protected void updateSourceHighlights() { | 255 | protected void updateSourceHighlights() { |
| @@ -382,21 +353,19 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 382 | } | 353 | } |
| 383 | 354 | ||
| 384 | private void setSource(T obfEntry) { | 355 | private void setSource(T obfEntry) { |
| 356 | m_obfSourceEntry = obfEntry; | ||
| 385 | if (obfEntry == null) { | 357 | if (obfEntry == null) { |
| 386 | m_obfSourceEntry = obfEntry; | ||
| 387 | m_sourceLabel.setText(""); | 358 | m_sourceLabel.setText(""); |
| 388 | } else { | 359 | } else { |
| 389 | m_obfSourceEntry = obfEntry; | ||
| 390 | m_sourceLabel.setText(getEntryLabel(obfEntry, m_sourceDeobfuscator)); | 360 | m_sourceLabel.setText(getEntryLabel(obfEntry, m_sourceDeobfuscator)); |
| 391 | } | 361 | } |
| 392 | } | 362 | } |
| 393 | 363 | ||
| 394 | private void setDest(T obfEntry) { | 364 | private void setDest(T obfEntry) { |
| 365 | m_obfDestEntry = obfEntry; | ||
| 395 | if (obfEntry == null) { | 366 | if (obfEntry == null) { |
| 396 | m_obfDestEntry = obfEntry; | ||
| 397 | m_destLabel.setText(""); | 367 | m_destLabel.setText(""); |
| 398 | } else { | 368 | } else { |
| 399 | m_obfDestEntry = obfEntry; | ||
| 400 | m_destLabel.setText(getEntryLabel(obfEntry, m_destDeobfuscator)); | 369 | m_destLabel.setText(getEntryLabel(obfEntry, m_destDeobfuscator)); |
| 401 | } | 370 | } |
| 402 | } | 371 | } |
| @@ -414,27 +383,12 @@ public class MemberMatchingGui<T extends Entry> { | |||
| 414 | 383 | ||
| 415 | if (m_obfSourceEntry != null && m_obfDestEntry != null) { | 384 | if (m_obfSourceEntry != null && m_obfDestEntry != null) { |
| 416 | if (m_memberMatches.isMatched(m_obfSourceEntry, m_obfDestEntry)) { | 385 | if (m_memberMatches.isMatched(m_obfSourceEntry, m_obfDestEntry)) { |
| 417 | GuiTricks.activateButton(m_matchButton, "Unmatch", new ActionListener() { | 386 | GuiTricks.activateButton(m_matchButton, "Unmatch", event -> unmatch()); |
| 418 | @Override | ||
| 419 | public void actionPerformed(ActionEvent event) { | ||
| 420 | unmatch(); | ||
| 421 | } | ||
| 422 | }); | ||
| 423 | } else if (!m_memberMatches.isMatchedSourceEntry(m_obfSourceEntry) && !m_memberMatches.isMatchedDestEntry(m_obfDestEntry)) { | 387 | } else if (!m_memberMatches.isMatchedSourceEntry(m_obfSourceEntry) && !m_memberMatches.isMatchedDestEntry(m_obfDestEntry)) { |
| 424 | GuiTricks.activateButton(m_matchButton, "Match", new ActionListener() { | 388 | GuiTricks.activateButton(m_matchButton, "Match", event -> match()); |
| 425 | @Override | ||
| 426 | public void actionPerformed(ActionEvent event) { | ||
| 427 | match(); | ||
| 428 | } | ||
| 429 | }); | ||
| 430 | } | 389 | } |
| 431 | } else if (m_obfSourceEntry != null) { | 390 | } else if (m_obfSourceEntry != null) { |
| 432 | GuiTricks.activateButton(m_unmatchableButton, "Set Unmatchable", new ActionListener() { | 391 | GuiTricks.activateButton(m_unmatchableButton, "Set Unmatchable", event -> unmatchable()); |
| 433 | @Override | ||
| 434 | public void actionPerformed(ActionEvent event) { | ||
| 435 | unmatchable(); | ||
| 436 | } | ||
| 437 | }); | ||
| 438 | } | 392 | } |
| 439 | } | 393 | } |
| 440 | 394 | ||