summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java
diff options
context:
space:
mode:
authorGravatar lclc982016-07-02 20:13:13 +1000
committerGravatar lclc982016-07-02 20:13:13 +1000
commit74edc74c2c7b3236f00bf92499bb884837673b7d (patch)
tree155556b4d6e390574f16082583f2853e35e3c716 /src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java
parentRenamed Fields (diff)
downloadenigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.tar.gz
enigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.tar.xz
enigma-fork-74edc74c2c7b3236f00bf92499bb884837673b7d.zip
Reformatting code
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java')
-rw-r--r--src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java263
1 files changed, 123 insertions, 140 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java b/src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java
index 440565c..a069bca 100644
--- a/src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java
+++ b/src/main/java/cuchaz/enigma/gui/ClassMatchingGui.java
@@ -77,35 +77,35 @@ public class ClassMatchingGui {
77 } 77 }
78 78
79 // controls 79 // controls
80 private JFrame m_frame; 80 private JFrame frame;
81 private ClassSelector m_sourceClasses; 81 private ClassSelector sourceClasses;
82 private ClassSelector m_destClasses; 82 private ClassSelector destClasses;
83 private CodeReader m_sourceReader; 83 private CodeReader sourceReader;
84 private CodeReader m_destReader; 84 private CodeReader destReader;
85 private JLabel m_sourceClassLabel; 85 private JLabel sourceClassLabel;
86 private JLabel m_destClassLabel; 86 private JLabel destClassLabel;
87 private JButton m_matchButton; 87 private JButton matchButton;
88 private Map<SourceType, JRadioButton> m_sourceTypeButtons; 88 private Map<SourceType, JRadioButton> sourceTypeButtons;
89 private JCheckBox m_advanceCheck; 89 private JCheckBox advanceCheck;
90 private JCheckBox m_top10Matches; 90 private JCheckBox top10Matches;
91 91
92 private ClassMatches m_classMatches; 92 private ClassMatches classMatches;
93 private Deobfuscator m_sourceDeobfuscator; 93 private Deobfuscator sourceDeobfuscator;
94 private Deobfuscator m_destDeobfuscator; 94 private Deobfuscator destDeobfuscator;
95 private ClassEntry m_sourceClass; 95 private ClassEntry sourceClass;
96 private ClassEntry m_destClass; 96 private ClassEntry destClass;
97 private SourceType m_sourceType; 97 private SourceType sourceType;
98 private SaveListener m_saveListener; 98 private SaveListener saveListener;
99 99
100 public ClassMatchingGui(ClassMatches matches, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) { 100 public ClassMatchingGui(ClassMatches matches, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) {
101 101
102 m_classMatches = matches; 102 this.classMatches = matches;
103 m_sourceDeobfuscator = sourceDeobfuscator; 103 this.sourceDeobfuscator = sourceDeobfuscator;
104 m_destDeobfuscator = destDeobfuscator; 104 this.destDeobfuscator = destDeobfuscator;
105 105
106 // init frame 106 // init frame
107 m_frame = new JFrame(Constants.Name + " - Class Matcher"); 107 this.frame = new JFrame(Constants.NAME + " - Class Matcher");
108 final Container pane = m_frame.getContentPane(); 108 final Container pane = this.frame.getContentPane();
109 pane.setLayout(new BorderLayout()); 109 pane.setLayout(new BorderLayout());
110 110
111 // init source side 111 // init source side
@@ -121,16 +121,16 @@ public class ClassMatchingGui {
121 sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS)); 121 sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS));
122 ActionListener sourceTypeListener = event -> setSourceType(SourceType.valueOf(event.getActionCommand())); 122 ActionListener sourceTypeListener = event -> setSourceType(SourceType.valueOf(event.getActionCommand()));
123 ButtonGroup sourceTypeButtons = new ButtonGroup(); 123 ButtonGroup sourceTypeButtons = new ButtonGroup();
124 m_sourceTypeButtons = Maps.newHashMap(); 124 this.sourceTypeButtons = Maps.newHashMap();
125 for (SourceType sourceType : SourceType.values()) { 125 for (SourceType sourceType : SourceType.values()) {
126 JRadioButton button = sourceType.newRadio(sourceTypeListener, sourceTypeButtons); 126 JRadioButton button = sourceType.newRadio(sourceTypeListener, sourceTypeButtons);
127 m_sourceTypeButtons.put(sourceType, button); 127 this.sourceTypeButtons.put(sourceType, button);
128 sourceTypePanel.add(button); 128 sourceTypePanel.add(button);
129 } 129 }
130 130
131 m_sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); 131 this.sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
132 m_sourceClasses.setListener(classEntry -> setSourceClass(classEntry)); 132 this.sourceClasses.setListener(this::setSourceClass);
133 JScrollPane sourceScroller = new JScrollPane(m_sourceClasses); 133 JScrollPane sourceScroller = new JScrollPane(this.sourceClasses);
134 sourcePanel.add(sourceScroller); 134 sourcePanel.add(sourceScroller);
135 135
136 // init dest side 136 // init dest side
@@ -140,13 +140,13 @@ public class ClassMatchingGui {
140 pane.add(destPanel, BorderLayout.WEST); 140 pane.add(destPanel, BorderLayout.WEST);
141 destPanel.add(new JLabel("Destination Classes")); 141 destPanel.add(new JLabel("Destination Classes"));
142 142
143 m_top10Matches = new JCheckBox("Show only top 10 matches"); 143 this.top10Matches = new JCheckBox("Show only top 10 matches");
144 destPanel.add(m_top10Matches); 144 destPanel.add(this.top10Matches);
145 m_top10Matches.addActionListener(event -> toggleTop10Matches()); 145 this.top10Matches.addActionListener(event -> toggleTop10Matches());
146 146
147 m_destClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); 147 this.destClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
148 m_destClasses.setListener(this::setDestClass); 148 this.destClasses.setListener(this::setDestClass);
149 JScrollPane destScroller = new JScrollPane(m_destClasses); 149 JScrollPane destScroller = new JScrollPane(this.destClasses);
150 destPanel.add(destScroller); 150 destPanel.add(destScroller);
151 151
152 JButton autoMatchButton = new JButton("AutoMatch"); 152 JButton autoMatchButton = new JButton("AutoMatch");
@@ -155,13 +155,13 @@ public class ClassMatchingGui {
155 155
156 // init source panels 156 // init source panels
157 DefaultSyntaxKit.initKit(); 157 DefaultSyntaxKit.initKit();
158 m_sourceReader = new CodeReader(); 158 this.sourceReader = new CodeReader();
159 m_destReader = new CodeReader(); 159 this.destReader = new CodeReader();
160 160
161 // init all the splits 161 // init all the splits
162 JSplitPane splitLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, sourcePanel, new JScrollPane(m_sourceReader)); 162 JSplitPane splitLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, sourcePanel, new JScrollPane(this.sourceReader));
163 splitLeft.setResizeWeight(0); // let the right side take all the slack 163 splitLeft.setResizeWeight(0); // let the right side take all the slack
164 JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(m_destReader), destPanel); 164 JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(this.destReader), destPanel);
165 splitRight.setResizeWeight(1); // let the left side take all the slack 165 splitRight.setResizeWeight(1); // let the left side take all the slack
166 JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, splitLeft, splitRight); 166 JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, splitLeft, splitRight);
167 splitCenter.setResizeWeight(0.5); // resize 50:50 167 splitCenter.setResizeWeight(0.5); // resize 50:50
@@ -172,81 +172,75 @@ public class ClassMatchingGui {
172 JPanel bottomPanel = new JPanel(); 172 JPanel bottomPanel = new JPanel();
173 bottomPanel.setLayout(new FlowLayout()); 173 bottomPanel.setLayout(new FlowLayout());
174 174
175 m_sourceClassLabel = new JLabel(); 175 this.sourceClassLabel = new JLabel();
176 m_sourceClassLabel.setHorizontalAlignment(SwingConstants.RIGHT); 176 this.sourceClassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
177 m_destClassLabel = new JLabel(); 177 this.destClassLabel = new JLabel();
178 m_destClassLabel.setHorizontalAlignment(SwingConstants.LEFT); 178 this.destClassLabel.setHorizontalAlignment(SwingConstants.LEFT);
179 179
180 m_matchButton = new JButton(); 180 this.matchButton = new JButton();
181 181
182 m_advanceCheck = new JCheckBox("Advance to next likely match"); 182 this.advanceCheck = new JCheckBox("Advance to next likely match");
183 m_advanceCheck.addActionListener(event -> { 183 this.advanceCheck.addActionListener(event -> {
184 if (m_advanceCheck.isSelected()) { 184 if (this.advanceCheck.isSelected()) {
185 advance(); 185 advance();
186 } 186 }
187 }); 187 });
188 188
189 bottomPanel.add(m_sourceClassLabel); 189 bottomPanel.add(this.sourceClassLabel);
190 bottomPanel.add(m_matchButton); 190 bottomPanel.add(this.matchButton);
191 bottomPanel.add(m_destClassLabel); 191 bottomPanel.add(this.destClassLabel);
192 bottomPanel.add(m_advanceCheck); 192 bottomPanel.add(this.advanceCheck);
193 pane.add(bottomPanel, BorderLayout.SOUTH); 193 pane.add(bottomPanel, BorderLayout.SOUTH);
194 194
195 // show the frame 195 // show the frame
196 pane.doLayout(); 196 pane.doLayout();
197 m_frame.setSize(1024, 576); 197 this.frame.setSize(1024, 576);
198 m_frame.setMinimumSize(new Dimension(640, 480)); 198 this.frame.setMinimumSize(new Dimension(640, 480));
199 m_frame.setVisible(true); 199 this.frame.setVisible(true);
200 m_frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 200 this.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
201 201
202 // init state 202 // init state
203 updateDestMappings(); 203 updateDestMappings();
204 setSourceType(SourceType.getDefault()); 204 setSourceType(SourceType.getDefault());
205 updateMatchButton(); 205 updateMatchButton();
206 m_saveListener = null; 206 this.saveListener = null;
207 } 207 }
208 208
209 public void setSaveListener(SaveListener val) { 209 public void setSaveListener(SaveListener val) {
210 m_saveListener = val; 210 this.saveListener = val;
211 } 211 }
212 212
213 private void updateDestMappings() { 213 private void updateDestMappings() {
214 214
215 Mappings newMappings = MappingsConverter.newMappings( 215 Mappings newMappings = MappingsConverter.newMappings(this.classMatches, this.sourceDeobfuscator.getMappings(), this.sourceDeobfuscator, this.destDeobfuscator);
216 m_classMatches,
217 m_sourceDeobfuscator.getMappings(),
218 m_sourceDeobfuscator,
219 m_destDeobfuscator
220 );
221 216
222 // look for dropped mappings 217 // look for dropped mappings
223 MappingsChecker checker = new MappingsChecker(m_destDeobfuscator.getJarIndex()); 218 MappingsChecker checker = new MappingsChecker(this.destDeobfuscator.getJarIndex());
224 checker.dropBrokenMappings(newMappings); 219 checker.dropBrokenMappings(newMappings);
225 220
226 // count them 221 // count them
227 int numDroppedFields = checker.getDroppedFieldMappings().size(); 222 int numDroppedFields = checker.getDroppedFieldMappings().size();
228 int numDroppedMethods = checker.getDroppedMethodMappings().size(); 223 int numDroppedMethods = checker.getDroppedMethodMappings().size();
229 System.out.println(String.format( 224 System.out.println(String.format("%d mappings from matched classes don't match the dest jar:\n\t%5d fields\n\t%5d methods",
230 "%d mappings from matched classes don't match the dest jar:\n\t%5d fields\n\t%5d methods",
231 numDroppedFields + numDroppedMethods, 225 numDroppedFields + numDroppedMethods,
232 numDroppedFields, 226 numDroppedFields,
233 numDroppedMethods 227 numDroppedMethods
234 )); 228 ));
235 229
236 m_destDeobfuscator.setMappings(newMappings); 230 this.destDeobfuscator.setMappings(newMappings);
237 } 231 }
238 232
239 protected void setSourceType(SourceType val) { 233 protected void setSourceType(SourceType val) {
240 234
241 // show the source classes 235 // show the source classes
242 m_sourceType = val; 236 this.sourceType = val;
243 m_sourceClasses.setClasses(deobfuscateClasses(m_sourceType.getSourceClasses(m_classMatches), m_sourceDeobfuscator)); 237 this.sourceClasses.setClasses(deobfuscateClasses(this.sourceType.getSourceClasses(this.classMatches), this.sourceDeobfuscator));
244 238
245 // update counts 239 // update counts
246 for (SourceType sourceType : SourceType.values()) { 240 for (SourceType sourceType : SourceType.values()) {
247 m_sourceTypeButtons.get(sourceType).setText(String.format("%s (%d)", 241 this.sourceTypeButtons.get(sourceType).setText(String.format("%s (%d)",
248 sourceType.name(), 242 sourceType.name(),
249 sourceType.getSourceClasses(m_classMatches).size() 243 sourceType.getSourceClasses(this.classMatches).size()
250 )); 244 ));
251 } 245 }
252 } 246 }
@@ -270,7 +264,7 @@ public class ClassMatchingGui {
270 protected void setSourceClass(ClassEntry classEntry) { 264 protected void setSourceClass(ClassEntry classEntry) {
271 265
272 Runnable onGetDestClasses = null; 266 Runnable onGetDestClasses = null;
273 if (m_advanceCheck.isSelected()) { 267 if (this.advanceCheck.isSelected()) {
274 onGetDestClasses = this::pickBestDestClass; 268 onGetDestClasses = this::pickBestDestClass;
275 } 269 }
276 270
@@ -280,24 +274,24 @@ public class ClassMatchingGui {
280 protected void setSourceClass(ClassEntry classEntry, final Runnable onGetDestClasses) { 274 protected void setSourceClass(ClassEntry classEntry, final Runnable onGetDestClasses) {
281 275
282 // update the current source class 276 // update the current source class
283 m_sourceClass = classEntry; 277 this.sourceClass = classEntry;
284 m_sourceClassLabel.setText(m_sourceClass != null ? m_sourceClass.getName() : ""); 278 this.sourceClassLabel.setText(this.sourceClass != null ? this.sourceClass.getName() : "");
285 279
286 if (m_sourceClass != null) { 280 if (this.sourceClass != null) {
287 281
288 // show the dest class(es) 282 // show the dest class(es)
289 ClassMatch match = m_classMatches.getMatchBySource(m_sourceDeobfuscator.obfuscateEntry(m_sourceClass)); 283 ClassMatch match = this.classMatches.getMatchBySource(this.sourceDeobfuscator.obfuscateEntry(this.sourceClass));
290 assert (match != null); 284 assert (match != null);
291 if (match.destClasses.isEmpty()) { 285 if (match.destClasses.isEmpty()) {
292 286
293 m_destClasses.setClasses(null); 287 this.destClasses.setClasses(null);
294 288
295 // run in a separate thread to keep ui responsive 289 // run in a separate thread to keep ui responsive
296 new Thread() { 290 new Thread() {
297 @Override 291 @Override
298 public void run() { 292 public void run() {
299 m_destClasses.setClasses(deobfuscateClasses(getLikelyMatches(m_sourceClass), m_destDeobfuscator)); 293 destClasses.setClasses(deobfuscateClasses(getLikelyMatches(sourceClass), destDeobfuscator));
300 m_destClasses.expandAll(); 294 destClasses.expandAll();
301 295
302 if (onGetDestClasses != null) { 296 if (onGetDestClasses != null) {
303 onGetDestClasses.run(); 297 onGetDestClasses.run();
@@ -307,8 +301,8 @@ public class ClassMatchingGui {
307 301
308 } else { 302 } else {
309 303
310 m_destClasses.setClasses(deobfuscateClasses(match.destClasses, m_destDeobfuscator)); 304 this.destClasses.setClasses(deobfuscateClasses(match.destClasses, this.destDeobfuscator));
311 m_destClasses.expandAll(); 305 this.destClasses.expandAll();
312 306
313 if (onGetDestClasses != null) { 307 if (onGetDestClasses != null) {
314 onGetDestClasses.run(); 308 onGetDestClasses.run();
@@ -317,39 +311,33 @@ public class ClassMatchingGui {
317 } 311 }
318 312
319 setDestClass(null); 313 setDestClass(null);
320 m_sourceReader.decompileClass(m_sourceClass, m_sourceDeobfuscator, () -> m_sourceReader.navigateToClassDeclaration(m_sourceClass)); 314 this.sourceReader.decompileClass(this.sourceClass, this.sourceDeobfuscator, () -> this.sourceReader.navigateToClassDeclaration(this.sourceClass));
321 315
322 updateMatchButton(); 316 updateMatchButton();
323 } 317 }
324 318
325 private Collection<ClassEntry> getLikelyMatches(ClassEntry sourceClass) { 319 private Collection<ClassEntry> getLikelyMatches(ClassEntry sourceClass) {
326 320
327 ClassEntry obfSourceClass = m_sourceDeobfuscator.obfuscateEntry(sourceClass); 321 ClassEntry obfSourceClass = this.sourceDeobfuscator.obfuscateEntry(sourceClass);
328 322
329 // set up identifiers 323 // set up identifiers
330 ClassNamer namer = new ClassNamer(m_classMatches.getUniqueMatches()); 324 ClassNamer namer = new ClassNamer(this.classMatches.getUniqueMatches());
331 ClassIdentifier sourceIdentifier = new ClassIdentifier( 325 ClassIdentifier sourceIdentifier = new ClassIdentifier(this.sourceDeobfuscator.getJar(), this.sourceDeobfuscator.getJarIndex(), namer.getSourceNamer(), true);
332 m_sourceDeobfuscator.getJar(), m_sourceDeobfuscator.getJarIndex(), 326 ClassIdentifier destIdentifier = new ClassIdentifier(this.destDeobfuscator.getJar(), this.destDeobfuscator.getJarIndex(), namer.getDestNamer(), true);
333 namer.getSourceNamer(), true
334 );
335 ClassIdentifier destIdentifier = new ClassIdentifier(
336 m_destDeobfuscator.getJar(), m_destDeobfuscator.getJarIndex(),
337 namer.getDestNamer(), true
338 );
339 327
340 try { 328 try {
341 329
342 // rank all the unmatched dest classes against the source class 330 // rank all the unmatched dest classes against the source class
343 ClassIdentity sourceIdentity = sourceIdentifier.identify(obfSourceClass); 331 ClassIdentity sourceIdentity = sourceIdentifier.identify(obfSourceClass);
344 List<ClassEntry> scoredDestClasses = Lists.newArrayList(); 332 List<ClassEntry> scoredDestClasses = Lists.newArrayList();
345 for (ClassEntry unmatchedDestClass : m_classMatches.getUnmatchedDestClasses()) { 333 for (ClassEntry unmatchedDestClass : this.classMatches.getUnmatchedDestClasses()) {
346 ClassIdentity destIdentity = destIdentifier.identify(unmatchedDestClass); 334 ClassIdentity destIdentity = destIdentifier.identify(unmatchedDestClass);
347 float score = 100.0f * (sourceIdentity.getMatchScore(destIdentity) + destIdentity.getMatchScore(sourceIdentity)) 335 float score = 100.0f * (sourceIdentity.getMatchScore(destIdentity) + destIdentity.getMatchScore(sourceIdentity))
348 / (sourceIdentity.getMaxMatchScore() + destIdentity.getMaxMatchScore()); 336 / (sourceIdentity.getMaxMatchScore() + destIdentity.getMaxMatchScore());
349 scoredDestClasses.add(new ScoredClassEntry(unmatchedDestClass, score)); 337 scoredDestClasses.add(new ScoredClassEntry(unmatchedDestClass, score));
350 } 338 }
351 339
352 if (m_top10Matches.isSelected() && scoredDestClasses.size() > 10) { 340 if (this.top10Matches.isSelected() && scoredDestClasses.size() > 10) {
353 Collections.sort(scoredDestClasses, (a, b) -> { 341 Collections.sort(scoredDestClasses, (a, b) -> {
354 ScoredClassEntry sa = (ScoredClassEntry) a; 342 ScoredClassEntry sa = (ScoredClassEntry) a;
355 ScoredClassEntry sb = (ScoredClassEntry) b; 343 ScoredClassEntry sb = (ScoredClassEntry) b;
@@ -368,30 +356,30 @@ public class ClassMatchingGui {
368 protected void setDestClass(ClassEntry classEntry) { 356 protected void setDestClass(ClassEntry classEntry) {
369 357
370 // update the current source class 358 // update the current source class
371 m_destClass = classEntry; 359 this.destClass = classEntry;
372 m_destClassLabel.setText(m_destClass != null ? m_destClass.getName() : ""); 360 this.destClassLabel.setText(this.destClass != null ? this.destClass.getName() : "");
373 361
374 m_destReader.decompileClass(m_destClass, m_destDeobfuscator, () -> m_destReader.navigateToClassDeclaration(m_destClass)); 362 this.destReader.decompileClass(this.destClass, this.destDeobfuscator, () -> this.destReader.navigateToClassDeclaration(this.destClass));
375 363
376 updateMatchButton(); 364 updateMatchButton();
377 } 365 }
378 366
379 private void updateMatchButton() { 367 private void updateMatchButton() {
380 368
381 ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass); 369 ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
382 ClassEntry obfDest = m_destDeobfuscator.obfuscateEntry(m_destClass); 370 ClassEntry obfDest = this.destDeobfuscator.obfuscateEntry(this.destClass);
383 371
384 BiMap<ClassEntry, ClassEntry> uniqueMatches = m_classMatches.getUniqueMatches(); 372 BiMap<ClassEntry, ClassEntry> uniqueMatches = this.classMatches.getUniqueMatches();
385 boolean twoSelected = m_sourceClass != null && m_destClass != null; 373 boolean twoSelected = this.sourceClass != null && this.destClass != null;
386 boolean isMatched = uniqueMatches.containsKey(obfSource) && uniqueMatches.containsValue(obfDest); 374 boolean isMatched = uniqueMatches.containsKey(obfSource) && uniqueMatches.containsValue(obfDest);
387 boolean canMatch = !uniqueMatches.containsKey(obfSource) && !uniqueMatches.containsValue(obfDest); 375 boolean canMatch = !uniqueMatches.containsKey(obfSource) && !uniqueMatches.containsValue(obfDest);
388 376
389 GuiTricks.deactivateButton(m_matchButton); 377 GuiTricks.deactivateButton(this.matchButton);
390 if (twoSelected) { 378 if (twoSelected) {
391 if (isMatched) { 379 if (isMatched) {
392 GuiTricks.activateButton(m_matchButton, "Unmatch", event -> onUnmatchClick()); 380 GuiTricks.activateButton(this.matchButton, "Unmatch", event -> onUnmatchClick());
393 } else if (canMatch) { 381 } else if (canMatch) {
394 GuiTricks.activateButton(m_matchButton, "Match", event -> onMatchClick()); 382 GuiTricks.activateButton(this.matchButton, "Match", event -> onMatchClick());
395 } 383 }
396 } 384 }
397 } 385 }
@@ -399,19 +387,19 @@ public class ClassMatchingGui {
399 private void onMatchClick() { 387 private void onMatchClick() {
400 // precondition: source and dest classes are set correctly 388 // precondition: source and dest classes are set correctly
401 389
402 ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass); 390 ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
403 ClassEntry obfDest = m_destDeobfuscator.obfuscateEntry(m_destClass); 391 ClassEntry obfDest = this.destDeobfuscator.obfuscateEntry(this.destClass);
404 392
405 // remove the classes from their match 393 // remove the classes from their match
406 m_classMatches.removeSource(obfSource); 394 this.classMatches.removeSource(obfSource);
407 m_classMatches.removeDest(obfDest); 395 this.classMatches.removeDest(obfDest);
408 396
409 // add them as matched classes 397 // add them as matched classes
410 m_classMatches.add(new ClassMatch(obfSource, obfDest)); 398 this.classMatches.add(new ClassMatch(obfSource, obfDest));
411 399
412 ClassEntry nextClass = null; 400 ClassEntry nextClass = null;
413 if (m_advanceCheck.isSelected()) { 401 if (this.advanceCheck.isSelected()) {
414 nextClass = m_sourceClasses.getNextClass(m_sourceClass); 402 nextClass = this.sourceClasses.getNextClass(this.sourceClass);
415 } 403 }
416 404
417 save(); 405 save();
@@ -425,11 +413,11 @@ public class ClassMatchingGui {
425 private void onUnmatchClick() { 413 private void onUnmatchClick() {
426 // precondition: source and dest classes are set to a unique match 414 // precondition: source and dest classes are set to a unique match
427 415
428 ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass); 416 ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
429 417
430 // remove the source to break the match, then add the source back as unmatched 418 // remove the source to break the match, then add the source back as unmatched
431 m_classMatches.removeSource(obfSource); 419 this.classMatches.removeSource(obfSource);
432 m_classMatches.add(new ClassMatch(obfSource, null)); 420 this.classMatches.add(new ClassMatch(obfSource, null));
433 421
434 save(); 422 save();
435 updateMatches(); 423 updateMatches();
@@ -438,20 +426,20 @@ public class ClassMatchingGui {
438 private void updateMatches() { 426 private void updateMatches() {
439 updateDestMappings(); 427 updateDestMappings();
440 setDestClass(null); 428 setDestClass(null);
441 m_destClasses.setClasses(null); 429 this.destClasses.setClasses(null);
442 updateMatchButton(); 430 updateMatchButton();
443 431
444 // remember where we were in the source tree 432 // remember where we were in the source tree
445 String packageName = m_sourceClasses.getSelectedPackage(); 433 String packageName = this.sourceClasses.getSelectedPackage();
446 434
447 setSourceType(m_sourceType); 435 setSourceType(this.sourceType);
448 436
449 m_sourceClasses.expandPackage(packageName); 437 this.sourceClasses.expandPackage(packageName);
450 } 438 }
451 439
452 private void save() { 440 private void save() {
453 if (m_saveListener != null) { 441 if (this.saveListener != null) {
454 m_saveListener.save(m_classMatches); 442 this.saveListener.save(this.classMatches);
455 } 443 }
456 } 444 }
457 445
@@ -460,18 +448,13 @@ public class ClassMatchingGui {
460 System.out.println("Automatching..."); 448 System.out.println("Automatching...");
461 449
462 // compute a new matching 450 // compute a new matching
463 ClassMatching matching = MappingsConverter.computeMatching( 451 ClassMatching matching = MappingsConverter.computeMatching(this.sourceDeobfuscator.getJar(), this.sourceDeobfuscator.getJarIndex(),
464 m_sourceDeobfuscator.getJar(), m_sourceDeobfuscator.getJarIndex(), 452 this.destDeobfuscator.getJar(), this.destDeobfuscator.getJarIndex(), this.classMatches.getUniqueMatches());
465 m_destDeobfuscator.getJar(), m_destDeobfuscator.getJarIndex(),
466 m_classMatches.getUniqueMatches()
467 );
468 ClassMatches newMatches = new ClassMatches(matching.matches()); 453 ClassMatches newMatches = new ClassMatches(matching.matches());
469 System.out.println(String.format("Automatch found %d new matches", 454 System.out.println(String.format("Automatch found %d new matches", newMatches.getUniqueMatches().size() - this.classMatches.getUniqueMatches().size()));
470 newMatches.getUniqueMatches().size() - m_classMatches.getUniqueMatches().size()
471 ));
472 455
473 // update the current matches 456 // update the current matches
474 m_classMatches = newMatches; 457 this.classMatches = newMatches;
475 save(); 458 save();
476 updateMatches(); 459 updateMatches();
477 } 460 }
@@ -484,17 +467,17 @@ public class ClassMatchingGui {
484 467
485 // make sure we have a source class 468 // make sure we have a source class
486 if (sourceClass == null) { 469 if (sourceClass == null) {
487 sourceClass = m_sourceClasses.getSelectedClass(); 470 sourceClass = this.sourceClasses.getSelectedClass();
488 if (sourceClass != null) { 471 if (sourceClass != null) {
489 sourceClass = m_sourceClasses.getNextClass(sourceClass); 472 sourceClass = this.sourceClasses.getNextClass(sourceClass);
490 } else { 473 } else {
491 sourceClass = m_sourceClasses.getFirstClass(); 474 sourceClass = this.sourceClasses.getFirstClass();
492 } 475 }
493 } 476 }
494 477
495 // set the source class 478 // set the source class
496 setSourceClass(sourceClass, this::pickBestDestClass); 479 setSourceClass(sourceClass, this::pickBestDestClass);
497 m_sourceClasses.setSelectionClass(sourceClass); 480 this.sourceClasses.setSelectionClass(sourceClass);
498 } 481 }
499 482
500 private void pickBestDestClass() { 483 private void pickBestDestClass() {
@@ -502,8 +485,8 @@ public class ClassMatchingGui {
502 // then, pick the best dest class 485 // then, pick the best dest class
503 ClassEntry firstClass = null; 486 ClassEntry firstClass = null;
504 ScoredClassEntry bestDestClass = null; 487 ScoredClassEntry bestDestClass = null;
505 for (ClassSelectorPackageNode packageNode : m_destClasses.packageNodes()) { 488 for (ClassSelectorPackageNode packageNode : this.destClasses.packageNodes()) {
506 for (ClassSelectorClassNode classNode : m_destClasses.classNodes(packageNode)) { 489 for (ClassSelectorClassNode classNode : this.destClasses.classNodes(packageNode)) {
507 if (firstClass == null) { 490 if (firstClass == null) {
508 firstClass = classNode.getClassEntry(); 491 firstClass = classNode.getClassEntry();
509 } 492 }
@@ -525,14 +508,14 @@ public class ClassMatchingGui {
525 } 508 }
526 509
527 setDestClass(destClass); 510 setDestClass(destClass);
528 m_destClasses.setSelectionClass(destClass); 511 this.destClasses.setSelectionClass(destClass);
529 } 512 }
530 513
531 private void toggleTop10Matches() { 514 private void toggleTop10Matches() {
532 if (m_sourceClass != null) { 515 if (this.sourceClass != null) {
533 m_destClasses.clearSelection(); 516 this.destClasses.clearSelection();
534 m_destClasses.setClasses(deobfuscateClasses(getLikelyMatches(m_sourceClass), m_destDeobfuscator)); 517 this.destClasses.setClasses(deobfuscateClasses(getLikelyMatches(this.sourceClass), this.destDeobfuscator));
535 m_destClasses.expandAll(); 518 this.destClasses.expandAll();
536 } 519 }
537 } 520 }
538} 521}