From 74edc74c2c7b3236f00bf92499bb884837673b7d Mon Sep 17 00:00:00 2001
From: lclc98
Date: Sat, 2 Jul 2016 20:13:13 +1000
Subject: Reformatting code
---
src/main/java/cuchaz/enigma/gui/AboutDialog.java | 8 +-
.../cuchaz/enigma/gui/BoxHighlightPainter.java | 16 +-
src/main/java/cuchaz/enigma/gui/BrowserCaret.java | 5 +-
.../cuchaz/enigma/gui/ClassListCellRenderer.java | 36 ---
.../java/cuchaz/enigma/gui/ClassMatchingGui.java | 263 ++++++++++-----------
src/main/java/cuchaz/enigma/gui/ClassSelector.java | 16 +-
.../cuchaz/enigma/gui/ClassSelectorClassNode.java | 19 +-
.../enigma/gui/ClassSelectorPackageNode.java | 15 +-
src/main/java/cuchaz/enigma/gui/CodeReader.java | 66 ++----
src/main/java/cuchaz/enigma/gui/CrashDialog.java | 24 +-
.../enigma/gui/DeobfuscatedHighlightPainter.java | 1 -
src/main/java/cuchaz/enigma/gui/Gui.java | 221 +++++------------
src/main/java/cuchaz/enigma/gui/GuiController.java | 212 +++++++----------
src/main/java/cuchaz/enigma/gui/GuiTricks.java | 8 +-
.../java/cuchaz/enigma/gui/MemberMatchingGui.java | 86 ++-----
.../enigma/gui/ObfuscatedHighlightPainter.java | 1 -
.../cuchaz/enigma/gui/OtherHighlightPainter.java | 1 -
.../java/cuchaz/enigma/gui/ProgressDialog.java | 54 ++---
.../java/cuchaz/enigma/gui/RenameListener.java | 17 --
.../java/cuchaz/enigma/gui/ScoredClassEntry.java | 7 +-
.../cuchaz/enigma/gui/TokenListCellRenderer.java | 12 +-
21 files changed, 402 insertions(+), 686 deletions(-)
delete mode 100644 src/main/java/cuchaz/enigma/gui/ClassListCellRenderer.java
delete mode 100644 src/main/java/cuchaz/enigma/gui/RenameListener.java
(limited to 'src/main/java/cuchaz/enigma/gui')
diff --git a/src/main/java/cuchaz/enigma/gui/AboutDialog.java b/src/main/java/cuchaz/enigma/gui/AboutDialog.java
index a874399..bb12466 100644
--- a/src/main/java/cuchaz/enigma/gui/AboutDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/AboutDialog.java
@@ -25,14 +25,14 @@ public class AboutDialog {
public static void show(JFrame parent) {
// init frame
- final JFrame frame = new JFrame(Constants.Name + " - About");
+ final JFrame frame = new JFrame(Constants.NAME + " - About");
final Container pane = frame.getContentPane();
pane.setLayout(new FlowLayout());
// load the content
try {
String html = Util.readResourceToString("/about.html");
- html = String.format(html, Constants.Name, Constants.Version);
+ html = String.format(html, Constants.NAME, Constants.VERSION);
JLabel label = new JLabel(html);
label.setHorizontalAlignment(JLabel.CENTER);
pane.add(label);
@@ -42,9 +42,9 @@ public class AboutDialog {
// show the link
String html = "%s";
- html = String.format(html, Constants.Url, Constants.Url);
+ html = String.format(html, Constants.URL, Constants.URL);
JButton link = new JButton(html);
- link.addActionListener(event -> Util.openUrl(Constants.Url));
+ link.addActionListener(event -> Util.openUrl(Constants.URL));
link.setBorderPainted(false);
link.setOpaque(false);
link.setBackground(Color.WHITE);
diff --git a/src/main/java/cuchaz/enigma/gui/BoxHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/BoxHighlightPainter.java
index efe6b50..b66d13d 100644
--- a/src/main/java/cuchaz/enigma/gui/BoxHighlightPainter.java
+++ b/src/main/java/cuchaz/enigma/gui/BoxHighlightPainter.java
@@ -21,12 +21,12 @@ import javax.swing.text.JTextComponent;
public abstract class BoxHighlightPainter implements Highlighter.HighlightPainter {
- private Color m_fillColor;
- private Color m_borderColor;
+ private Color fillColor;
+ private Color borderColor;
protected BoxHighlightPainter(Color fillColor, Color borderColor) {
- m_fillColor = fillColor;
- m_borderColor = borderColor;
+ this.fillColor = fillColor;
+ this.borderColor = borderColor;
}
@Override
@@ -34,17 +34,17 @@ public abstract class BoxHighlightPainter implements Highlighter.HighlightPainte
Rectangle bounds = getBounds(text, start, end);
// fill the area
- if (m_fillColor != null) {
- g.setColor(m_fillColor);
+ if (this.fillColor != null) {
+ g.setColor(this.fillColor);
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
}
// draw a box around the area
- g.setColor(m_borderColor);
+ g.setColor(this.borderColor);
g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
}
- protected static Rectangle getBounds(JTextComponent text, int start, int end) {
+ public static Rectangle getBounds(JTextComponent text, int start, int end) {
try {
// determine the bounds of the text
Rectangle bounds = text.modelToView(start).union(text.modelToView(end));
diff --git a/src/main/java/cuchaz/enigma/gui/BrowserCaret.java b/src/main/java/cuchaz/enigma/gui/BrowserCaret.java
index b4acbce..094b69b 100644
--- a/src/main/java/cuchaz/enigma/gui/BrowserCaret.java
+++ b/src/main/java/cuchaz/enigma/gui/BrowserCaret.java
@@ -17,8 +17,7 @@ public class BrowserCaret extends DefaultCaret {
private static final long serialVersionUID = 1158977422507969940L;
- private static final Highlighter.HighlightPainter m_selectionPainter = (g, p0, p1, bounds, c) -> {
- // don't paint anything
+ private static final Highlighter.HighlightPainter selectionPainter = (g, p0, p1, bounds, c) -> {
};
@Override
@@ -33,6 +32,6 @@ public class BrowserCaret extends DefaultCaret {
@Override
public Highlighter.HighlightPainter getSelectionPainter() {
- return m_selectionPainter;
+ return this.selectionPainter;
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/ClassListCellRenderer.java b/src/main/java/cuchaz/enigma/gui/ClassListCellRenderer.java
deleted file mode 100644
index 89b9bdd..0000000
--- a/src/main/java/cuchaz/enigma/gui/ClassListCellRenderer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
-package cuchaz.enigma.gui;
-
-import java.awt.Component;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-
-import javassist.bytecode.Descriptor;
-
-public class ClassListCellRenderer implements ListCellRenderer {
-
- private DefaultListCellRenderer m_defaultRenderer;
-
- public ClassListCellRenderer() {
- m_defaultRenderer = new DefaultListCellRenderer();
- }
-
- @Override
- public Component getListCellRendererComponent(JList extends String> list, String className, int index, boolean isSelected, boolean hasFocus) {
- JLabel label = (JLabel) m_defaultRenderer.getListCellRendererComponent(list, className, index, isSelected, hasFocus);
- label.setText(Descriptor.toJavaName(className));
- return label;
- }
-}
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 {
}
// controls
- private JFrame m_frame;
- private ClassSelector m_sourceClasses;
- private ClassSelector m_destClasses;
- private CodeReader m_sourceReader;
- private CodeReader m_destReader;
- private JLabel m_sourceClassLabel;
- private JLabel m_destClassLabel;
- private JButton m_matchButton;
- private Map m_sourceTypeButtons;
- private JCheckBox m_advanceCheck;
- private JCheckBox m_top10Matches;
-
- private ClassMatches m_classMatches;
- private Deobfuscator m_sourceDeobfuscator;
- private Deobfuscator m_destDeobfuscator;
- private ClassEntry m_sourceClass;
- private ClassEntry m_destClass;
- private SourceType m_sourceType;
- private SaveListener m_saveListener;
+ private JFrame frame;
+ private ClassSelector sourceClasses;
+ private ClassSelector destClasses;
+ private CodeReader sourceReader;
+ private CodeReader destReader;
+ private JLabel sourceClassLabel;
+ private JLabel destClassLabel;
+ private JButton matchButton;
+ private Map sourceTypeButtons;
+ private JCheckBox advanceCheck;
+ private JCheckBox top10Matches;
+
+ private ClassMatches classMatches;
+ private Deobfuscator sourceDeobfuscator;
+ private Deobfuscator destDeobfuscator;
+ private ClassEntry sourceClass;
+ private ClassEntry destClass;
+ private SourceType sourceType;
+ private SaveListener saveListener;
public ClassMatchingGui(ClassMatches matches, Deobfuscator sourceDeobfuscator, Deobfuscator destDeobfuscator) {
- m_classMatches = matches;
- m_sourceDeobfuscator = sourceDeobfuscator;
- m_destDeobfuscator = destDeobfuscator;
+ this.classMatches = matches;
+ this.sourceDeobfuscator = sourceDeobfuscator;
+ this.destDeobfuscator = destDeobfuscator;
// init frame
- m_frame = new JFrame(Constants.Name + " - Class Matcher");
- final Container pane = m_frame.getContentPane();
+ this.frame = new JFrame(Constants.NAME + " - Class Matcher");
+ final Container pane = this.frame.getContentPane();
pane.setLayout(new BorderLayout());
// init source side
@@ -121,16 +121,16 @@ public class ClassMatchingGui {
sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS));
ActionListener sourceTypeListener = event -> setSourceType(SourceType.valueOf(event.getActionCommand()));
ButtonGroup sourceTypeButtons = new ButtonGroup();
- m_sourceTypeButtons = Maps.newHashMap();
+ this.sourceTypeButtons = Maps.newHashMap();
for (SourceType sourceType : SourceType.values()) {
JRadioButton button = sourceType.newRadio(sourceTypeListener, sourceTypeButtons);
- m_sourceTypeButtons.put(sourceType, button);
+ this.sourceTypeButtons.put(sourceType, button);
sourceTypePanel.add(button);
}
- m_sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
- m_sourceClasses.setListener(classEntry -> setSourceClass(classEntry));
- JScrollPane sourceScroller = new JScrollPane(m_sourceClasses);
+ this.sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
+ this.sourceClasses.setListener(this::setSourceClass);
+ JScrollPane sourceScroller = new JScrollPane(this.sourceClasses);
sourcePanel.add(sourceScroller);
// init dest side
@@ -140,13 +140,13 @@ public class ClassMatchingGui {
pane.add(destPanel, BorderLayout.WEST);
destPanel.add(new JLabel("Destination Classes"));
- m_top10Matches = new JCheckBox("Show only top 10 matches");
- destPanel.add(m_top10Matches);
- m_top10Matches.addActionListener(event -> toggleTop10Matches());
+ this.top10Matches = new JCheckBox("Show only top 10 matches");
+ destPanel.add(this.top10Matches);
+ this.top10Matches.addActionListener(event -> toggleTop10Matches());
- m_destClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
- m_destClasses.setListener(this::setDestClass);
- JScrollPane destScroller = new JScrollPane(m_destClasses);
+ this.destClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
+ this.destClasses.setListener(this::setDestClass);
+ JScrollPane destScroller = new JScrollPane(this.destClasses);
destPanel.add(destScroller);
JButton autoMatchButton = new JButton("AutoMatch");
@@ -155,13 +155,13 @@ public class ClassMatchingGui {
// init source panels
DefaultSyntaxKit.initKit();
- m_sourceReader = new CodeReader();
- m_destReader = new CodeReader();
+ this.sourceReader = new CodeReader();
+ this.destReader = new CodeReader();
// init all the splits
- JSplitPane splitLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, sourcePanel, new JScrollPane(m_sourceReader));
+ JSplitPane splitLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, sourcePanel, new JScrollPane(this.sourceReader));
splitLeft.setResizeWeight(0); // let the right side take all the slack
- JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(m_destReader), destPanel);
+ JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(this.destReader), destPanel);
splitRight.setResizeWeight(1); // let the left side take all the slack
JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, splitLeft, splitRight);
splitCenter.setResizeWeight(0.5); // resize 50:50
@@ -172,81 +172,75 @@ public class ClassMatchingGui {
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new FlowLayout());
- m_sourceClassLabel = new JLabel();
- m_sourceClassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- m_destClassLabel = new JLabel();
- m_destClassLabel.setHorizontalAlignment(SwingConstants.LEFT);
+ this.sourceClassLabel = new JLabel();
+ this.sourceClassLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+ this.destClassLabel = new JLabel();
+ this.destClassLabel.setHorizontalAlignment(SwingConstants.LEFT);
- m_matchButton = new JButton();
+ this.matchButton = new JButton();
- m_advanceCheck = new JCheckBox("Advance to next likely match");
- m_advanceCheck.addActionListener(event -> {
- if (m_advanceCheck.isSelected()) {
+ this.advanceCheck = new JCheckBox("Advance to next likely match");
+ this.advanceCheck.addActionListener(event -> {
+ if (this.advanceCheck.isSelected()) {
advance();
}
});
- bottomPanel.add(m_sourceClassLabel);
- bottomPanel.add(m_matchButton);
- bottomPanel.add(m_destClassLabel);
- bottomPanel.add(m_advanceCheck);
+ bottomPanel.add(this.sourceClassLabel);
+ bottomPanel.add(this.matchButton);
+ bottomPanel.add(this.destClassLabel);
+ bottomPanel.add(this.advanceCheck);
pane.add(bottomPanel, BorderLayout.SOUTH);
// show the frame
pane.doLayout();
- m_frame.setSize(1024, 576);
- m_frame.setMinimumSize(new Dimension(640, 480));
- m_frame.setVisible(true);
- m_frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ this.frame.setSize(1024, 576);
+ this.frame.setMinimumSize(new Dimension(640, 480));
+ this.frame.setVisible(true);
+ this.frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
// init state
updateDestMappings();
setSourceType(SourceType.getDefault());
updateMatchButton();
- m_saveListener = null;
+ this.saveListener = null;
}
public void setSaveListener(SaveListener val) {
- m_saveListener = val;
+ this.saveListener = val;
}
private void updateDestMappings() {
- Mappings newMappings = MappingsConverter.newMappings(
- m_classMatches,
- m_sourceDeobfuscator.getMappings(),
- m_sourceDeobfuscator,
- m_destDeobfuscator
- );
+ Mappings newMappings = MappingsConverter.newMappings(this.classMatches, this.sourceDeobfuscator.getMappings(), this.sourceDeobfuscator, this.destDeobfuscator);
// look for dropped mappings
- MappingsChecker checker = new MappingsChecker(m_destDeobfuscator.getJarIndex());
+ MappingsChecker checker = new MappingsChecker(this.destDeobfuscator.getJarIndex());
checker.dropBrokenMappings(newMappings);
// count them
int numDroppedFields = checker.getDroppedFieldMappings().size();
int numDroppedMethods = checker.getDroppedMethodMappings().size();
- System.out.println(String.format(
- "%d mappings from matched classes don't match the dest jar:\n\t%5d fields\n\t%5d methods",
+ System.out.println(String.format("%d mappings from matched classes don't match the dest jar:\n\t%5d fields\n\t%5d methods",
numDroppedFields + numDroppedMethods,
numDroppedFields,
numDroppedMethods
));
- m_destDeobfuscator.setMappings(newMappings);
+ this.destDeobfuscator.setMappings(newMappings);
}
protected void setSourceType(SourceType val) {
// show the source classes
- m_sourceType = val;
- m_sourceClasses.setClasses(deobfuscateClasses(m_sourceType.getSourceClasses(m_classMatches), m_sourceDeobfuscator));
+ this.sourceType = val;
+ this.sourceClasses.setClasses(deobfuscateClasses(this.sourceType.getSourceClasses(this.classMatches), this.sourceDeobfuscator));
// update counts
for (SourceType sourceType : SourceType.values()) {
- m_sourceTypeButtons.get(sourceType).setText(String.format("%s (%d)",
+ this.sourceTypeButtons.get(sourceType).setText(String.format("%s (%d)",
sourceType.name(),
- sourceType.getSourceClasses(m_classMatches).size()
+ sourceType.getSourceClasses(this.classMatches).size()
));
}
}
@@ -270,7 +264,7 @@ public class ClassMatchingGui {
protected void setSourceClass(ClassEntry classEntry) {
Runnable onGetDestClasses = null;
- if (m_advanceCheck.isSelected()) {
+ if (this.advanceCheck.isSelected()) {
onGetDestClasses = this::pickBestDestClass;
}
@@ -280,24 +274,24 @@ public class ClassMatchingGui {
protected void setSourceClass(ClassEntry classEntry, final Runnable onGetDestClasses) {
// update the current source class
- m_sourceClass = classEntry;
- m_sourceClassLabel.setText(m_sourceClass != null ? m_sourceClass.getName() : "");
+ this.sourceClass = classEntry;
+ this.sourceClassLabel.setText(this.sourceClass != null ? this.sourceClass.getName() : "");
- if (m_sourceClass != null) {
+ if (this.sourceClass != null) {
// show the dest class(es)
- ClassMatch match = m_classMatches.getMatchBySource(m_sourceDeobfuscator.obfuscateEntry(m_sourceClass));
+ ClassMatch match = this.classMatches.getMatchBySource(this.sourceDeobfuscator.obfuscateEntry(this.sourceClass));
assert (match != null);
if (match.destClasses.isEmpty()) {
- m_destClasses.setClasses(null);
+ this.destClasses.setClasses(null);
// run in a separate thread to keep ui responsive
new Thread() {
@Override
public void run() {
- m_destClasses.setClasses(deobfuscateClasses(getLikelyMatches(m_sourceClass), m_destDeobfuscator));
- m_destClasses.expandAll();
+ destClasses.setClasses(deobfuscateClasses(getLikelyMatches(sourceClass), destDeobfuscator));
+ destClasses.expandAll();
if (onGetDestClasses != null) {
onGetDestClasses.run();
@@ -307,8 +301,8 @@ public class ClassMatchingGui {
} else {
- m_destClasses.setClasses(deobfuscateClasses(match.destClasses, m_destDeobfuscator));
- m_destClasses.expandAll();
+ this.destClasses.setClasses(deobfuscateClasses(match.destClasses, this.destDeobfuscator));
+ this.destClasses.expandAll();
if (onGetDestClasses != null) {
onGetDestClasses.run();
@@ -317,39 +311,33 @@ public class ClassMatchingGui {
}
setDestClass(null);
- m_sourceReader.decompileClass(m_sourceClass, m_sourceDeobfuscator, () -> m_sourceReader.navigateToClassDeclaration(m_sourceClass));
+ this.sourceReader.decompileClass(this.sourceClass, this.sourceDeobfuscator, () -> this.sourceReader.navigateToClassDeclaration(this.sourceClass));
updateMatchButton();
}
private Collection getLikelyMatches(ClassEntry sourceClass) {
- ClassEntry obfSourceClass = m_sourceDeobfuscator.obfuscateEntry(sourceClass);
+ ClassEntry obfSourceClass = this.sourceDeobfuscator.obfuscateEntry(sourceClass);
// set up identifiers
- ClassNamer namer = new ClassNamer(m_classMatches.getUniqueMatches());
- ClassIdentifier sourceIdentifier = new ClassIdentifier(
- m_sourceDeobfuscator.getJar(), m_sourceDeobfuscator.getJarIndex(),
- namer.getSourceNamer(), true
- );
- ClassIdentifier destIdentifier = new ClassIdentifier(
- m_destDeobfuscator.getJar(), m_destDeobfuscator.getJarIndex(),
- namer.getDestNamer(), true
- );
+ ClassNamer namer = new ClassNamer(this.classMatches.getUniqueMatches());
+ ClassIdentifier sourceIdentifier = new ClassIdentifier(this.sourceDeobfuscator.getJar(), this.sourceDeobfuscator.getJarIndex(), namer.getSourceNamer(), true);
+ ClassIdentifier destIdentifier = new ClassIdentifier(this.destDeobfuscator.getJar(), this.destDeobfuscator.getJarIndex(), namer.getDestNamer(), true);
try {
// rank all the unmatched dest classes against the source class
ClassIdentity sourceIdentity = sourceIdentifier.identify(obfSourceClass);
List scoredDestClasses = Lists.newArrayList();
- for (ClassEntry unmatchedDestClass : m_classMatches.getUnmatchedDestClasses()) {
+ for (ClassEntry unmatchedDestClass : this.classMatches.getUnmatchedDestClasses()) {
ClassIdentity destIdentity = destIdentifier.identify(unmatchedDestClass);
float score = 100.0f * (sourceIdentity.getMatchScore(destIdentity) + destIdentity.getMatchScore(sourceIdentity))
/ (sourceIdentity.getMaxMatchScore() + destIdentity.getMaxMatchScore());
scoredDestClasses.add(new ScoredClassEntry(unmatchedDestClass, score));
}
- if (m_top10Matches.isSelected() && scoredDestClasses.size() > 10) {
+ if (this.top10Matches.isSelected() && scoredDestClasses.size() > 10) {
Collections.sort(scoredDestClasses, (a, b) -> {
ScoredClassEntry sa = (ScoredClassEntry) a;
ScoredClassEntry sb = (ScoredClassEntry) b;
@@ -368,30 +356,30 @@ public class ClassMatchingGui {
protected void setDestClass(ClassEntry classEntry) {
// update the current source class
- m_destClass = classEntry;
- m_destClassLabel.setText(m_destClass != null ? m_destClass.getName() : "");
+ this.destClass = classEntry;
+ this.destClassLabel.setText(this.destClass != null ? this.destClass.getName() : "");
- m_destReader.decompileClass(m_destClass, m_destDeobfuscator, () -> m_destReader.navigateToClassDeclaration(m_destClass));
+ this.destReader.decompileClass(this.destClass, this.destDeobfuscator, () -> this.destReader.navigateToClassDeclaration(this.destClass));
updateMatchButton();
}
private void updateMatchButton() {
- ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass);
- ClassEntry obfDest = m_destDeobfuscator.obfuscateEntry(m_destClass);
+ ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
+ ClassEntry obfDest = this.destDeobfuscator.obfuscateEntry(this.destClass);
- BiMap uniqueMatches = m_classMatches.getUniqueMatches();
- boolean twoSelected = m_sourceClass != null && m_destClass != null;
+ BiMap uniqueMatches = this.classMatches.getUniqueMatches();
+ boolean twoSelected = this.sourceClass != null && this.destClass != null;
boolean isMatched = uniqueMatches.containsKey(obfSource) && uniqueMatches.containsValue(obfDest);
boolean canMatch = !uniqueMatches.containsKey(obfSource) && !uniqueMatches.containsValue(obfDest);
- GuiTricks.deactivateButton(m_matchButton);
+ GuiTricks.deactivateButton(this.matchButton);
if (twoSelected) {
if (isMatched) {
- GuiTricks.activateButton(m_matchButton, "Unmatch", event -> onUnmatchClick());
+ GuiTricks.activateButton(this.matchButton, "Unmatch", event -> onUnmatchClick());
} else if (canMatch) {
- GuiTricks.activateButton(m_matchButton, "Match", event -> onMatchClick());
+ GuiTricks.activateButton(this.matchButton, "Match", event -> onMatchClick());
}
}
}
@@ -399,19 +387,19 @@ public class ClassMatchingGui {
private void onMatchClick() {
// precondition: source and dest classes are set correctly
- ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass);
- ClassEntry obfDest = m_destDeobfuscator.obfuscateEntry(m_destClass);
+ ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
+ ClassEntry obfDest = this.destDeobfuscator.obfuscateEntry(this.destClass);
// remove the classes from their match
- m_classMatches.removeSource(obfSource);
- m_classMatches.removeDest(obfDest);
+ this.classMatches.removeSource(obfSource);
+ this.classMatches.removeDest(obfDest);
// add them as matched classes
- m_classMatches.add(new ClassMatch(obfSource, obfDest));
+ this.classMatches.add(new ClassMatch(obfSource, obfDest));
ClassEntry nextClass = null;
- if (m_advanceCheck.isSelected()) {
- nextClass = m_sourceClasses.getNextClass(m_sourceClass);
+ if (this.advanceCheck.isSelected()) {
+ nextClass = this.sourceClasses.getNextClass(this.sourceClass);
}
save();
@@ -425,11 +413,11 @@ public class ClassMatchingGui {
private void onUnmatchClick() {
// precondition: source and dest classes are set to a unique match
- ClassEntry obfSource = m_sourceDeobfuscator.obfuscateEntry(m_sourceClass);
+ ClassEntry obfSource = this.sourceDeobfuscator.obfuscateEntry(this.sourceClass);
// remove the source to break the match, then add the source back as unmatched
- m_classMatches.removeSource(obfSource);
- m_classMatches.add(new ClassMatch(obfSource, null));
+ this.classMatches.removeSource(obfSource);
+ this.classMatches.add(new ClassMatch(obfSource, null));
save();
updateMatches();
@@ -438,20 +426,20 @@ public class ClassMatchingGui {
private void updateMatches() {
updateDestMappings();
setDestClass(null);
- m_destClasses.setClasses(null);
+ this.destClasses.setClasses(null);
updateMatchButton();
// remember where we were in the source tree
- String packageName = m_sourceClasses.getSelectedPackage();
+ String packageName = this.sourceClasses.getSelectedPackage();
- setSourceType(m_sourceType);
+ setSourceType(this.sourceType);
- m_sourceClasses.expandPackage(packageName);
+ this.sourceClasses.expandPackage(packageName);
}
private void save() {
- if (m_saveListener != null) {
- m_saveListener.save(m_classMatches);
+ if (this.saveListener != null) {
+ this.saveListener.save(this.classMatches);
}
}
@@ -460,18 +448,13 @@ public class ClassMatchingGui {
System.out.println("Automatching...");
// compute a new matching
- ClassMatching matching = MappingsConverter.computeMatching(
- m_sourceDeobfuscator.getJar(), m_sourceDeobfuscator.getJarIndex(),
- m_destDeobfuscator.getJar(), m_destDeobfuscator.getJarIndex(),
- m_classMatches.getUniqueMatches()
- );
+ ClassMatching matching = MappingsConverter.computeMatching(this.sourceDeobfuscator.getJar(), this.sourceDeobfuscator.getJarIndex(),
+ this.destDeobfuscator.getJar(), this.destDeobfuscator.getJarIndex(), this.classMatches.getUniqueMatches());
ClassMatches newMatches = new ClassMatches(matching.matches());
- System.out.println(String.format("Automatch found %d new matches",
- newMatches.getUniqueMatches().size() - m_classMatches.getUniqueMatches().size()
- ));
+ System.out.println(String.format("Automatch found %d new matches", newMatches.getUniqueMatches().size() - this.classMatches.getUniqueMatches().size()));
// update the current matches
- m_classMatches = newMatches;
+ this.classMatches = newMatches;
save();
updateMatches();
}
@@ -484,17 +467,17 @@ public class ClassMatchingGui {
// make sure we have a source class
if (sourceClass == null) {
- sourceClass = m_sourceClasses.getSelectedClass();
+ sourceClass = this.sourceClasses.getSelectedClass();
if (sourceClass != null) {
- sourceClass = m_sourceClasses.getNextClass(sourceClass);
+ sourceClass = this.sourceClasses.getNextClass(sourceClass);
} else {
- sourceClass = m_sourceClasses.getFirstClass();
+ sourceClass = this.sourceClasses.getFirstClass();
}
}
// set the source class
setSourceClass(sourceClass, this::pickBestDestClass);
- m_sourceClasses.setSelectionClass(sourceClass);
+ this.sourceClasses.setSelectionClass(sourceClass);
}
private void pickBestDestClass() {
@@ -502,8 +485,8 @@ public class ClassMatchingGui {
// then, pick the best dest class
ClassEntry firstClass = null;
ScoredClassEntry bestDestClass = null;
- for (ClassSelectorPackageNode packageNode : m_destClasses.packageNodes()) {
- for (ClassSelectorClassNode classNode : m_destClasses.classNodes(packageNode)) {
+ for (ClassSelectorPackageNode packageNode : this.destClasses.packageNodes()) {
+ for (ClassSelectorClassNode classNode : this.destClasses.classNodes(packageNode)) {
if (firstClass == null) {
firstClass = classNode.getClassEntry();
}
@@ -525,14 +508,14 @@ public class ClassMatchingGui {
}
setDestClass(destClass);
- m_destClasses.setSelectionClass(destClass);
+ this.destClasses.setSelectionClass(destClass);
}
private void toggleTop10Matches() {
- if (m_sourceClass != null) {
- m_destClasses.clearSelection();
- m_destClasses.setClasses(deobfuscateClasses(getLikelyMatches(m_sourceClass), m_destDeobfuscator));
- m_destClasses.expandAll();
+ if (this.sourceClass != null) {
+ this.destClasses.clearSelection();
+ this.destClasses.setClasses(deobfuscateClasses(getLikelyMatches(this.sourceClass), this.destDeobfuscator));
+ this.destClasses.expandAll();
}
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/ClassSelector.java b/src/main/java/cuchaz/enigma/gui/ClassSelector.java
index 0c93c43..f6abd51 100644
--- a/src/main/java/cuchaz/enigma/gui/ClassSelector.java
+++ b/src/main/java/cuchaz/enigma/gui/ClassSelector.java
@@ -58,11 +58,11 @@ public class ClassSelector extends JTree {
};
}
- private ClassSelectionListener m_listener;
- private Comparator m_comparator;
+ private ClassSelectionListener listener;
+ private Comparator comparator;
public ClassSelector(Comparator comparator) {
- m_comparator = comparator;
+ this.comparator = comparator;
// configure the tree control
setRootVisible(false);
@@ -73,23 +73,23 @@ public class ClassSelector extends JTree {
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
- if (m_listener != null && event.getClickCount() == 2) {
+ if (listener != null && event.getClickCount() == 2) {
// get the selected node
TreePath path = getSelectionPath();
if (path != null && path.getLastPathComponent() instanceof ClassSelectorClassNode) {
ClassSelectorClassNode node = (ClassSelectorClassNode) path.getLastPathComponent();
- m_listener.onSelectClass(node.getClassEntry());
+ listener.onSelectClass(node.getClassEntry());
}
}
}
});
// init defaults
- m_listener = null;
+ this.listener = null;
}
public void setListener(ClassSelectionListener val) {
- m_listener = val;
+ this.listener = val;
}
public void setClasses(Collection classEntries) {
@@ -144,7 +144,7 @@ public class ClassSelector extends JTree {
for (String packageName : packagedClassEntries.keySet()) {
// sort the class entries
List classEntriesInPackage = Lists.newArrayList(packagedClassEntries.get(packageName));
- Collections.sort(classEntriesInPackage, m_comparator);
+ Collections.sort(classEntriesInPackage, this.comparator);
// create the nodes in order
for (ClassEntry classEntry : classEntriesInPackage) {
diff --git a/src/main/java/cuchaz/enigma/gui/ClassSelectorClassNode.java b/src/main/java/cuchaz/enigma/gui/ClassSelectorClassNode.java
index 6da9782..e73340a 100644
--- a/src/main/java/cuchaz/enigma/gui/ClassSelectorClassNode.java
+++ b/src/main/java/cuchaz/enigma/gui/ClassSelectorClassNode.java
@@ -18,33 +18,30 @@ public class ClassSelectorClassNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = -8956754339813257380L;
- private ClassEntry m_classEntry;
+ private ClassEntry classEntry;
public ClassSelectorClassNode(ClassEntry classEntry) {
- m_classEntry = classEntry;
+ this.classEntry = classEntry;
}
public ClassEntry getClassEntry() {
- return m_classEntry;
+ return this.classEntry;
}
@Override
public String toString() {
- if (m_classEntry instanceof ScoredClassEntry) {
- return String.format("%d%% %s", (int) ((ScoredClassEntry) m_classEntry).getScore(), m_classEntry.getSimpleName());
+ if (this.classEntry instanceof ScoredClassEntry) {
+ return String.format("%d%% %s", (int) ((ScoredClassEntry) this.classEntry).getScore(), this.classEntry.getSimpleName());
}
- return m_classEntry.getSimpleName();
+ return this.classEntry.getSimpleName();
}
@Override
public boolean equals(Object other) {
- if (other instanceof ClassSelectorClassNode) {
- return equals((ClassSelectorClassNode) other);
- }
- return false;
+ return other instanceof ClassSelectorClassNode && equals((ClassSelectorClassNode) other);
}
public boolean equals(ClassSelectorClassNode other) {
- return m_classEntry.equals(other.m_classEntry);
+ return this.classEntry.equals(other.classEntry);
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/ClassSelectorPackageNode.java b/src/main/java/cuchaz/enigma/gui/ClassSelectorPackageNode.java
index 3622042..3b5ba8c 100644
--- a/src/main/java/cuchaz/enigma/gui/ClassSelectorPackageNode.java
+++ b/src/main/java/cuchaz/enigma/gui/ClassSelectorPackageNode.java
@@ -16,30 +16,27 @@ public class ClassSelectorPackageNode extends DefaultMutableTreeNode {
private static final long serialVersionUID = -3730868701219548043L;
- private String m_packageName;
+ private String packageName;
public ClassSelectorPackageNode(String packageName) {
- m_packageName = packageName;
+ this.packageName = packageName;
}
public String getPackageName() {
- return m_packageName;
+ return this.packageName;
}
@Override
public String toString() {
- return m_packageName;
+ return this.packageName;
}
@Override
public boolean equals(Object other) {
- if (other instanceof ClassSelectorPackageNode) {
- return equals((ClassSelectorPackageNode) other);
- }
- return false;
+ return other instanceof ClassSelectorPackageNode && equals((ClassSelectorPackageNode) other);
}
public boolean equals(ClassSelectorPackageNode other) {
- return m_packageName.equals(other.m_packageName);
+ return this.packageName.equals(other.packageName);
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/CodeReader.java b/src/main/java/cuchaz/enigma/gui/CodeReader.java
index 93f9a75..a476fa5 100644
--- a/src/main/java/cuchaz/enigma/gui/CodeReader.java
+++ b/src/main/java/cuchaz/enigma/gui/CodeReader.java
@@ -19,8 +19,6 @@ import java.awt.event.ActionListener;
import javax.swing.JEditorPane;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter.HighlightPainter;
@@ -37,15 +35,15 @@ public class CodeReader extends JEditorPane {
private static final long serialVersionUID = 3673180950485748810L;
- private static final Object m_lock = new Object();
+ private static final Object lock = new Object();
public interface SelectionListener {
void onSelect(EntryReference reference);
}
- private SelectionHighlightPainter m_selectionHighlightPainter;
- private SourceIndex m_sourceIndex;
- private SelectionListener m_selectionListener;
+ private SelectionHighlightPainter selectionHighlightPainter;
+ private SourceIndex sourceIndex;
+ private SelectionListener selectionListener;
public CodeReader() {
@@ -57,42 +55,35 @@ public class CodeReader extends JEditorPane {
kit.toggleComponent(this, "de.sciss.syntaxpane.components.TokenMarker");
// hook events
- addCaretListener(new CaretListener() {
- @Override
- public void caretUpdate(CaretEvent event) {
- if (m_selectionListener != null && m_sourceIndex != null) {
- Token token = m_sourceIndex.getReferenceToken(event.getDot());
- if (token != null) {
- m_selectionListener.onSelect(m_sourceIndex.getDeobfReference(token));
- } else {
- m_selectionListener.onSelect(null);
- }
+ addCaretListener(event -> {
+ if (this.selectionListener != null && this.sourceIndex != null) {
+ Token token = this.sourceIndex.getReferenceToken(event.getDot());
+ if (token != null) {
+ this.selectionListener.onSelect(this.sourceIndex.getDeobfReference(token));
+ } else {
+ this.selectionListener.onSelect(null);
}
}
});
- m_selectionHighlightPainter = new SelectionHighlightPainter();
- m_sourceIndex = null;
- m_selectionListener = null;
+ this.selectionHighlightPainter = new SelectionHighlightPainter();
+ this.sourceIndex = null;
+ this.selectionListener = null;
}
public void setSelectionListener(SelectionListener val) {
- m_selectionListener = val;
+ this.selectionListener = val;
}
public void setCode(String code) {
// sadly, the java lexer is not thread safe, so we have to serialize all these calls
- synchronized (m_lock) {
+ synchronized (lock) {
setText(code);
}
}
public SourceIndex getSourceIndex() {
- return m_sourceIndex;
- }
-
- public void decompileClass(ClassEntry classEntry, Deobfuscator deobfuscator) {
- decompileClass(classEntry, deobfuscator, null);
+ return this.sourceIndex;
}
public void decompileClass(ClassEntry classEntry, Deobfuscator deobfuscator, Runnable callback) {
@@ -117,7 +108,7 @@ public class CodeReader extends JEditorPane {
CompilationUnit sourceTree = deobfuscator.getSourceTree(classEntry.getOutermostClassName());
String source = deobfuscator.getSource(sourceTree);
setCode(source);
- m_sourceIndex = deobfuscator.getSourceIndex(sourceTree, source, ignoreBadTokens);
+ sourceIndex = deobfuscator.getSourceIndex(sourceTree, source, ignoreBadTokens);
if (callback != null) {
callback.run();
@@ -129,13 +120,13 @@ public class CodeReader extends JEditorPane {
public void navigateToClassDeclaration(ClassEntry classEntry) {
// navigate to the class declaration
- Token token = m_sourceIndex.getDeclarationToken(classEntry);
+ Token token = this.sourceIndex.getDeclarationToken(classEntry);
if (token == null) {
// couldn't find the class declaration token, might be an anonymous class
// look for any declaration in that class instead
- for (Entry entry : m_sourceIndex.declarations()) {
+ for (Entry entry : this.sourceIndex.declarations()) {
if (entry.getClassEntry().equals(classEntry)) {
- token = m_sourceIndex.getDeclarationToken(entry);
+ token = this.sourceIndex.getDeclarationToken(entry);
break;
}
}
@@ -150,7 +141,7 @@ public class CodeReader extends JEditorPane {
}
public void navigateToToken(final Token token) {
- navigateToToken(this, token, m_selectionHighlightPainter);
+ navigateToToken(this, token, this.selectionHighlightPainter);
}
// HACKHACK: someday we can update the main GUI to use this code reader
@@ -166,12 +157,7 @@ public class CodeReader extends JEditorPane {
Rectangle end = editor.modelToView(token.end);
final Rectangle show = start.union(end);
show.grow(start.width * 10, start.height * 6);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- editor.scrollRectToVisible(show);
- }
- });
+ SwingUtilities.invokeLater(() -> editor.scrollRectToVisible(show));
} catch (BadLocationException ex) {
throw new Error(ex);
}
@@ -202,12 +188,6 @@ public class CodeReader extends JEditorPane {
timer.start();
}
- public void setHighlightedTokens(Iterable tokens, HighlightPainter painter) {
- for (Token token : tokens) {
- setHighlightedToken(token, painter);
- }
- }
-
public void setHighlightedToken(Token token, HighlightPainter painter) {
try {
getHighlighter().addHighlight(token.start, token.end, painter);
diff --git a/src/main/java/cuchaz/enigma/gui/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/CrashDialog.java
index c0c0869..3806f54 100644
--- a/src/main/java/cuchaz/enigma/gui/CrashDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/CrashDialog.java
@@ -13,8 +13,6 @@ package cuchaz.enigma.gui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -31,11 +29,11 @@ public class CrashDialog {
private CrashDialog(JFrame parent) {
// init frame
- m_frame = new JFrame(Constants.Name + " - Crash Report");
+ m_frame = new JFrame(Constants.NAME + " - Crash Report");
final Container pane = m_frame.getContentPane();
pane.setLayout(new BorderLayout());
- JLabel label = new JLabel(Constants.Name + " has crashed! =(");
+ JLabel label = new JLabel(Constants.NAME + " has crashed! =(");
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
pane.add(label, BorderLayout.NORTH);
@@ -51,21 +49,15 @@ public class CrashDialog {
buttonsPanel.setLayout(buttonsLayout);
buttonsPanel.add(GuiTricks.unboldLabel(new JLabel("If you choose exit, you will lose any unsaved work.")));
JButton ignoreButton = new JButton("Ignore");
- ignoreButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- // close (hide) the dialog
- m_frame.setVisible(false);
- }
+ ignoreButton.addActionListener(event -> {
+ // close (hide) the dialog
+ m_frame.setVisible(false);
});
buttonsPanel.add(ignoreButton);
JButton exitButton = new JButton("Exit");
- exitButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- // exit enigma
- System.exit(1);
- }
+ exitButton.addActionListener(event -> {
+ // exit enigma
+ System.exit(1);
});
buttonsPanel.add(exitButton);
pane.add(buttonsPanel, BorderLayout.SOUTH);
diff --git a/src/main/java/cuchaz/enigma/gui/DeobfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/DeobfuscatedHighlightPainter.java
index d92bb0d..d5ad0c8 100644
--- a/src/main/java/cuchaz/enigma/gui/DeobfuscatedHighlightPainter.java
+++ b/src/main/java/cuchaz/enigma/gui/DeobfuscatedHighlightPainter.java
@@ -15,7 +15,6 @@ import java.awt.Color;
public class DeobfuscatedHighlightPainter extends BoxHighlightPainter {
public DeobfuscatedHighlightPainter() {
- // green ish
super(new Color(220, 255, 220), new Color(80, 160, 80));
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java
index eb26ddd..fee9c9f 100644
--- a/src/main/java/cuchaz/enigma/gui/Gui.java
+++ b/src/main/java/cuchaz/enigma/gui/Gui.java
@@ -16,7 +16,6 @@ import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;
-import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -24,8 +23,6 @@ import java.util.Vector;
import java.util.jar.JarFile;
import javax.swing.*;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Highlighter;
import javax.swing.tree.DefaultTreeModel;
@@ -35,7 +32,6 @@ import javax.swing.tree.TreePath;
import cuchaz.enigma.Constants;
import cuchaz.enigma.ExceptionIgnorer;
import cuchaz.enigma.analysis.*;
-import cuchaz.enigma.gui.ClassSelector.ClassSelectionListener;
import cuchaz.enigma.mapping.*;
import de.sciss.syntaxpane.DefaultSyntaxKit;
@@ -90,20 +86,17 @@ public class Gui {
public Gui() {
// init frame
- m_frame = new JFrame(Constants.Name);
+ m_frame = new JFrame(Constants.NAME);
final Container pane = m_frame.getContentPane();
pane.setLayout(new BorderLayout());
if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) {
// install a global exception handler to the event thread
CrashDialog.init(m_frame);
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
- @Override
- public void uncaughtException(Thread thread, Throwable t) {
- t.printStackTrace(System.err);
- if (!ExceptionIgnorer.shouldIgnore(t)) {
- CrashDialog.show(t);
- }
+ Thread.setDefaultUncaughtExceptionHandler((thread, t) -> {
+ t.printStackTrace(System.err);
+ if (!ExceptionIgnorer.shouldIgnore(t)) {
+ CrashDialog.show(t);
}
});
}
@@ -116,19 +109,14 @@ public class Gui {
m_mappingsFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
m_mappingsFileChooser.setAcceptAllFileFilterUsed(false);
- m_oldMappingsFileChooser= new JFileChooser();
+ m_oldMappingsFileChooser = new JFileChooser();
m_exportSourceFileChooser = new JFileChooser();
m_exportSourceFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
m_exportJarFileChooser = new JFileChooser();
// init obfuscated classes list
m_obfClasses = new ClassSelector(ClassSelector.ObfuscatedClassEntryComparator);
- m_obfClasses.setListener(new ClassSelectionListener() {
- @Override
- public void onSelectClass(ClassEntry classEntry) {
- navigateTo(classEntry);
- }
- });
+ m_obfClasses.setListener(this::navigateTo);
JScrollPane obfScroller = new JScrollPane(m_obfClasses);
JPanel obfPanel = new JPanel();
obfPanel.setLayout(new BorderLayout());
@@ -137,12 +125,7 @@ public class Gui {
// init deobfuscated classes list
m_deobfClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
- m_deobfClasses.setListener(new ClassSelectionListener() {
- @Override
- public void onSelectClass(ClassEntry classEntry) {
- navigateTo(classEntry);
- }
- });
+ m_deobfClasses.setListener(this::navigateTo);
JScrollPane deobfScroller = new JScrollPane(m_deobfClasses);
JPanel deobfPanel = new JPanel();
deobfPanel.setLayout(new BorderLayout());
@@ -174,12 +157,7 @@ public class Gui {
m_editor.setCaret(new BrowserCaret());
JScrollPane sourceScroller = new JScrollPane(m_editor);
m_editor.setContentType("text/java");
- m_editor.addCaretListener(new CaretListener() {
- @Override
- public void caretUpdate(CaretEvent event) {
- onCaretMove(event.getDot());
- }
- });
+ m_editor.addCaretListener(event -> onCaretMove(event.getDot()));
m_editor.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
@@ -224,12 +202,7 @@ public class Gui {
m_editor.setComponentPopupMenu(popupMenu);
{
JMenuItem menu = new JMenuItem("Rename");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- startRename();
- }
- });
+ menu.addActionListener(event -> startRename());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -237,12 +210,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Show Inheritance");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- showInheritance();
- }
- });
+ menu.addActionListener(event -> showInheritance());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -250,12 +218,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Show Implementations");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- showImplementations();
- }
- });
+ menu.addActionListener(event -> showImplementations());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -263,12 +226,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Show Calls");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- showCalls();
- }
- });
+ menu.addActionListener(event -> showCalls());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -276,12 +234,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Go to Declaration");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- navigateTo(m_reference.entry);
- }
- });
+ menu.addActionListener(event -> navigateTo(m_reference.entry));
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -289,12 +242,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Go to previous");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- m_controller.openPreviousReference();
- }
- });
+ menu.addActionListener(event -> m_controller.openPreviousReference());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -302,12 +250,7 @@ public class Gui {
}
{
JMenuItem menu = new JMenuItem("Mark as deobfuscated");
- menu.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- toggleMapping();
- }
- });
+ menu.addActionListener(event -> toggleMapping());
menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, 0));
menu.setEnabled(false);
popupMenu.add(menu);
@@ -398,7 +341,7 @@ public class Gui {
}
}
});
- m_tokens = new JList();
+ m_tokens = new JList<>();
m_tokens.setCellRenderer(new TokenListCellRenderer(m_controller));
m_tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_tokens.setLayoutOrientation(JList.VERTICAL);
@@ -450,51 +393,40 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Open Jar...");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (m_jarFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
- // load the jar in a separate thread
- new Thread() {
- @Override
- public void run() {
- try {
- m_controller.openJar(new JarFile(m_jarFileChooser.getSelectedFile()));
- } catch (IOException ex) {
- throw new Error(ex);
- }
+ item.addActionListener(event -> {
+ if (m_jarFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
+ // load the jar in a separate thread
+ new Thread() {
+ @Override
+ public void run() {
+ try {
+ m_controller.openJar(new JarFile(m_jarFileChooser.getSelectedFile()));
+ } catch (IOException ex) {
+ throw new Error(ex);
}
- }.start();
- }
+ }
+ }.start();
}
});
}
{
JMenuItem item = new JMenuItem("Close Jar");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- m_controller.closeJar();
- }
- });
+ item.addActionListener(event -> m_controller.closeJar());
m_closeJarMenu = item;
}
menu.addSeparator();
{
JMenuItem item = new JMenuItem("Open Mappings...");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (m_mappingsFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
- try {
- m_controller.openMappings(m_mappingsFileChooser.getSelectedFile());
- } catch (IOException ex) {
- throw new Error(ex);
- } catch (MappingParseException ex) {
- JOptionPane.showMessageDialog(m_frame, ex.getMessage());
- }
+ item.addActionListener(event -> {
+ if (m_mappingsFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
+ try {
+ m_controller.openMappings(m_mappingsFileChooser.getSelectedFile());
+ } catch (IOException ex) {
+ throw new Error(ex);
+ } catch (MappingParseException ex) {
+ JOptionPane.showMessageDialog(m_frame, ex.getMessage());
}
}
});
@@ -520,14 +452,11 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Save Mappings");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- try {
- m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile());
- } catch (IOException ex) {
- throw new Error(ex);
- }
+ item.addActionListener(event -> {
+ try {
+ m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile());
+ } catch (IOException ex) {
+ throw new Error(ex);
}
});
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
@@ -536,16 +465,13 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Save Mappings As...");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
- try {
- m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile());
- m_saveMappingsMenu.setEnabled(true);
- } catch (IOException ex) {
- throw new Error(ex);
- }
+ item.addActionListener(event -> {
+ if (m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
+ try {
+ m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile());
+ m_saveMappingsMenu.setEnabled(true);
+ } catch (IOException ex) {
+ throw new Error(ex);
}
}
});
@@ -555,24 +481,16 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Close Mappings");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- m_controller.closeMappings();
- }
- });
+ item.addActionListener(event -> m_controller.closeMappings());
m_closeMappingsMenu = item;
}
menu.addSeparator();
{
JMenuItem item = new JMenuItem("Export Source...");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (m_exportSourceFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
- m_controller.exportSource(m_exportSourceFileChooser.getSelectedFile());
- }
+ item.addActionListener(event -> {
+ if (m_exportSourceFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
+ m_controller.exportSource(m_exportSourceFileChooser.getSelectedFile());
}
});
m_exportSourceMenu = item;
@@ -580,12 +498,9 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Export Jar...");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (m_exportJarFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
- m_controller.exportJar(m_exportJarFileChooser.getSelectedFile());
- }
+ item.addActionListener(event -> {
+ if (m_exportJarFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) {
+ m_controller.exportJar(m_exportJarFileChooser.getSelectedFile());
}
});
m_exportJarMenu = item;
@@ -594,12 +509,7 @@ public class Gui {
{
JMenuItem item = new JMenuItem("Exit");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- close();
- }
- });
+ item.addActionListener(event -> close());
}
}
{
@@ -608,12 +518,7 @@ public class Gui {
{
JMenuItem item = new JMenuItem("About");
menu.add(item);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- AboutDialog.show(m_frame);
- }
- });
+ item.addActionListener(event -> AboutDialog.show(m_frame));
}
}
@@ -654,7 +559,7 @@ public class Gui {
public void onFinishOpenJar(String jarName) {
// update gui
- m_frame.setTitle(Constants.Name + " - " + jarName);
+ m_frame.setTitle(Constants.NAME + " - " + jarName);
m_classesPanel.removeAll();
m_classesPanel.add(m_splitClasses);
setSource(null);
@@ -674,7 +579,7 @@ public class Gui {
public void onCloseJar() {
// update gui
- m_frame.setTitle(Constants.Name);
+ m_frame.setTitle(Constants.NAME);
setObfClasses(null);
setDeobfClasses(null);
setSource(null);
@@ -720,14 +625,14 @@ public class Gui {
}
public void showTokens(Collection tokens) {
- Vector sortedTokens = new Vector(tokens);
+ Vector sortedTokens = new Vector<>(tokens);
Collections.sort(sortedTokens);
if (sortedTokens.size() > 1) {
// sort the tokens and update the tokens panel
m_tokens.setListData(sortedTokens);
m_tokens.setSelectedIndex(0);
} else {
- m_tokens.setListData(new Vector());
+ m_tokens.setListData(new Vector<>());
}
// show the first token
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java
index a6a2ec5..868e0d4 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -24,162 +24,138 @@ import java.util.List;
import java.util.jar.JarFile;
import cuchaz.enigma.Deobfuscator;
-import cuchaz.enigma.Deobfuscator.ProgressListener;
import cuchaz.enigma.analysis.*;
-import cuchaz.enigma.gui.ProgressDialog.ProgressRunnable;
import cuchaz.enigma.mapping.*;
public class GuiController {
- private Deobfuscator m_deobfuscator;
- private Gui m_gui;
- private SourceIndex m_index;
- private ClassEntry m_currentObfClass;
- private boolean m_isDirty;
- private Deque> m_referenceStack;
+ private Deobfuscator deobfuscator;
+ private Gui gui;
+ private SourceIndex index;
+ private ClassEntry currentObfClass;
+ private boolean isDirty;
+ private Deque> referenceStack;
public GuiController(Gui gui) {
- m_gui = gui;
- m_deobfuscator = null;
- m_index = null;
- m_currentObfClass = null;
- m_isDirty = false;
- m_referenceStack = Queues.newArrayDeque();
+ this.gui = gui;
+ this.deobfuscator = null;
+ this.index = null;
+ this.currentObfClass = null;
+ this.isDirty = false;
+ this.referenceStack = Queues.newArrayDeque();
}
public boolean isDirty() {
- return m_isDirty;
+ return this.isDirty;
}
public void openJar(final JarFile jar) throws IOException {
- m_gui.onStartOpenJar();
- m_deobfuscator = new Deobfuscator(jar);
- m_gui.onFinishOpenJar(m_deobfuscator.getJarName());
+ this.gui.onStartOpenJar();
+ this.deobfuscator = new Deobfuscator(jar);
+ this.gui.onFinishOpenJar(this.deobfuscator.getJarName());
refreshClasses();
}
public void closeJar() {
- m_deobfuscator = null;
- m_gui.onCloseJar();
+ this.deobfuscator = null;
+ this.gui.onCloseJar();
}
public void openOldMappings(File file) throws IOException, MappingParseException {
FileReader in = new FileReader(file);
- m_deobfuscator.setMappings(new MappingsReaderOld().read(in));
+ this.deobfuscator.setMappings(new MappingsReaderOld().read(in));
in.close();
- m_isDirty = false;
- m_gui.setMappingsFile(file);
+ this.isDirty = false;
+ this.gui.setMappingsFile(file);
refreshClasses();
refreshCurrentClass();
}
public void openMappings(File file) throws IOException, MappingParseException {
- m_deobfuscator.setMappings(new MappingsReader().read(file));
- m_isDirty = false;
- m_gui.setMappingsFile(file);
+ this.deobfuscator.setMappings(new MappingsReader().read(file));
+ this.isDirty = false;
+ this.gui.setMappingsFile(file);
refreshClasses();
refreshCurrentClass();
}
public void saveMappings(File file) throws IOException {
- new MappingsWriter().write(file, m_deobfuscator.getMappings());
- m_isDirty = false;
+ new MappingsWriter().write(file, this.deobfuscator.getMappings());
+ this.isDirty = false;
}
public void closeMappings() {
- m_deobfuscator.setMappings(null);
- m_gui.setMappingsFile(null);
+ this.deobfuscator.setMappings(null);
+ this.gui.setMappingsFile(null);
refreshClasses();
refreshCurrentClass();
}
public void exportSource(final File dirOut) {
- ProgressDialog.runInThread(m_gui.getFrame(), new ProgressRunnable() {
- @Override
- public void run(ProgressListener progress) throws Exception {
- m_deobfuscator.writeSources(dirOut, progress);
- }
- });
+ ProgressDialog.runInThread(this.gui.getFrame(), progress -> this.deobfuscator.writeSources(dirOut, progress));
}
public void exportJar(final File fileOut) {
- ProgressDialog.runInThread(m_gui.getFrame(), new ProgressRunnable() {
- @Override
- public void run(ProgressListener progress) {
- m_deobfuscator.writeJar(fileOut, progress);
- }
- });
+ ProgressDialog.runInThread(this.gui.getFrame(), progress -> this.deobfuscator.writeJar(fileOut, progress));
}
public Token getToken(int pos) {
- if (m_index == null) {
+ if (this.index == null) {
return null;
}
- return m_index.getReferenceToken(pos);
+ return this.index.getReferenceToken(pos);
}
public EntryReference getDeobfReference(Token token) {
- if (m_index == null) {
+ if (this.index == null) {
return null;
}
- return m_index.getDeobfReference(token);
+ return this.index.getDeobfReference(token);
}
public ReadableToken getReadableToken(Token token) {
- if (m_index == null) {
+ if (this.index == null) {
return null;
}
return new ReadableToken(
- m_index.getLineNumber(token.start),
- m_index.getColumnNumber(token.start),
- m_index.getColumnNumber(token.end)
+ this.index.getLineNumber(token.start),
+ this.index.getColumnNumber(token.start),
+ this.index.getColumnNumber(token.end)
);
}
public boolean entryHasDeobfuscatedName(Entry deobfEntry) {
- return m_deobfuscator.hasDeobfuscatedName(m_deobfuscator.obfuscateEntry(deobfEntry));
+ return this.deobfuscator.hasDeobfuscatedName(this.deobfuscator.obfuscateEntry(deobfEntry));
}
public boolean entryIsInJar(Entry deobfEntry) {
- return m_deobfuscator.isObfuscatedIdentifier(m_deobfuscator.obfuscateEntry(deobfEntry));
+ return this.deobfuscator.isObfuscatedIdentifier(this.deobfuscator.obfuscateEntry(deobfEntry));
}
public boolean referenceIsRenameable(EntryReference deobfReference) {
- return m_deobfuscator.isRenameable(m_deobfuscator.obfuscateReference(deobfReference));
+ return this.deobfuscator.isRenameable(this.deobfuscator.obfuscateReference(deobfReference));
}
public ClassInheritanceTreeNode getClassInheritance(ClassEntry deobfClassEntry) {
- ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry(deobfClassEntry);
- ClassInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getClassInheritance(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfClassEntry
- );
+ ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry);
+ ClassInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getClassInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry);
return ClassInheritanceTreeNode.findNode(rootNode, obfClassEntry);
}
public ClassImplementationsTreeNode getClassImplementations(ClassEntry deobfClassEntry) {
- ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry(deobfClassEntry);
- return m_deobfuscator.getJarIndex().getClassImplementations(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfClassEntry
- );
+ ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry);
+ return this.deobfuscator.getJarIndex().getClassImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry);
}
public MethodInheritanceTreeNode getMethodInheritance(MethodEntry deobfMethodEntry) {
- MethodEntry obfMethodEntry = m_deobfuscator.obfuscateEntry(deobfMethodEntry);
- MethodInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getMethodInheritance(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfMethodEntry
- );
+ MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
+ MethodInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getMethodInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry);
return MethodInheritanceTreeNode.findNode(rootNode, obfMethodEntry);
}
public MethodImplementationsTreeNode getMethodImplementations(MethodEntry deobfMethodEntry) {
- MethodEntry obfMethodEntry = m_deobfuscator.obfuscateEntry(deobfMethodEntry);
- List rootNodes = m_deobfuscator.getJarIndex().getMethodImplementations(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfMethodEntry
- );
+ MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
+ List rootNodes = this.deobfuscator.getJarIndex().getMethodImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry);
if (rootNodes.isEmpty()) {
return null;
}
@@ -190,45 +166,39 @@ public class GuiController {
}
public FieldReferenceTreeNode getFieldReferences(FieldEntry deobfFieldEntry) {
- FieldEntry obfFieldEntry = m_deobfuscator.obfuscateEntry(deobfFieldEntry);
- FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfFieldEntry
- );
- rootNode.load(m_deobfuscator.getJarIndex(), true);
+ FieldEntry obfFieldEntry = this.deobfuscator.obfuscateEntry(deobfFieldEntry);
+ FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfFieldEntry);
+ rootNode.load(this.deobfuscator.getJarIndex(), true);
return rootNode;
}
public BehaviorReferenceTreeNode getMethodReferences(BehaviorEntry deobfBehaviorEntry) {
- BehaviorEntry obfBehaviorEntry = m_deobfuscator.obfuscateEntry(deobfBehaviorEntry);
- BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode(
- m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating),
- obfBehaviorEntry
- );
- rootNode.load(m_deobfuscator.getJarIndex(), true);
+ BehaviorEntry obfBehaviorEntry = this.deobfuscator.obfuscateEntry(deobfBehaviorEntry);
+ BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfBehaviorEntry);
+ rootNode.load(this.deobfuscator.getJarIndex(), true);
return rootNode;
}
public void rename(EntryReference deobfReference, String newName) {
- EntryReference obfReference = m_deobfuscator.obfuscateReference(deobfReference);
- m_deobfuscator.rename(obfReference.getNameableEntry(), newName);
- m_isDirty = true;
+ EntryReference obfReference = this.deobfuscator.obfuscateReference(deobfReference);
+ this.deobfuscator.rename(obfReference.getNameableEntry(), newName);
+ this.isDirty = true;
refreshClasses();
refreshCurrentClass(obfReference);
}
public void removeMapping(EntryReference deobfReference) {
- EntryReference obfReference = m_deobfuscator.obfuscateReference(deobfReference);
- m_deobfuscator.removeMapping(obfReference.getNameableEntry());
- m_isDirty = true;
+ EntryReference obfReference = this.deobfuscator.obfuscateReference(deobfReference);
+ this.deobfuscator.removeMapping(obfReference.getNameableEntry());
+ this.isDirty = true;
refreshClasses();
refreshCurrentClass(obfReference);
}
public void markAsDeobfuscated(EntryReference deobfReference) {
- EntryReference obfReference = m_deobfuscator.obfuscateReference(deobfReference);
- m_deobfuscator.markAsDeobfuscated(obfReference.getNameableEntry());
- m_isDirty = true;
+ EntryReference obfReference = this.deobfuscator.obfuscateReference(deobfReference);
+ this.deobfuscator.markAsDeobfuscated(obfReference.getNameableEntry());
+ this.isDirty = true;
refreshClasses();
refreshCurrentClass(obfReference);
}
@@ -237,7 +207,7 @@ public class GuiController {
if (deobfEntry == null) {
throw new IllegalArgumentException("Entry cannot be null!");
}
- openReference(new EntryReference(deobfEntry, deobfEntry.getName()));
+ openReference(new EntryReference<>(deobfEntry, deobfEntry.getName()));
}
public void openReference(EntryReference deobfReference) {
@@ -246,51 +216,51 @@ public class GuiController {
}
// get the reference target class
- EntryReference obfReference = m_deobfuscator.obfuscateReference(deobfReference);
+ EntryReference obfReference = this.deobfuscator.obfuscateReference(deobfReference);
ClassEntry obfClassEntry = obfReference.getLocationClassEntry().getOutermostClassEntry();
- if (!m_deobfuscator.isObfuscatedIdentifier(obfClassEntry)) {
+ if (!this.deobfuscator.isObfuscatedIdentifier(obfClassEntry)) {
throw new IllegalArgumentException("Obfuscated class " + obfClassEntry + " was not found in the jar!");
}
- if (m_currentObfClass == null || !m_currentObfClass.equals(obfClassEntry)) {
+ if (this.currentObfClass == null || !this.currentObfClass.equals(obfClassEntry)) {
// deobfuscate the class, then navigate to the reference
- m_currentObfClass = obfClassEntry;
- deobfuscate(m_currentObfClass, obfReference);
+ this.currentObfClass = obfClassEntry;
+ deobfuscate(this.currentObfClass, obfReference);
} else {
showReference(obfReference);
}
}
private void showReference(EntryReference obfReference) {
- EntryReference deobfReference = m_deobfuscator.deobfuscateReference(obfReference);
- Collection tokens = m_index.getReferenceTokens(deobfReference);
+ EntryReference deobfReference = this.deobfuscator.deobfuscateReference(obfReference);
+ Collection tokens = this.index.getReferenceTokens(deobfReference);
if (tokens.isEmpty()) {
// DEBUG
- System.err.println(String.format("WARNING: no tokens found for %s in %s", deobfReference, m_currentObfClass));
+ System.err.println(String.format("WARNING: no tokens found for %s in %s", deobfReference, this.currentObfClass));
} else {
- m_gui.showTokens(tokens);
+ this.gui.showTokens(tokens);
}
}
public void savePreviousReference(EntryReference deobfReference) {
- m_referenceStack.push(m_deobfuscator.obfuscateReference(deobfReference));
+ this.referenceStack.push(this.deobfuscator.obfuscateReference(deobfReference));
}
public void openPreviousReference() {
if (hasPreviousLocation()) {
- openReference(m_deobfuscator.deobfuscateReference(m_referenceStack.pop()));
+ openReference(this.deobfuscator.deobfuscateReference(this.referenceStack.pop()));
}
}
public boolean hasPreviousLocation() {
- return !m_referenceStack.isEmpty();
+ return !this.referenceStack.isEmpty();
}
private void refreshClasses() {
List obfClasses = Lists.newArrayList();
List deobfClasses = Lists.newArrayList();
- m_deobfuscator.getSeparatedClasses(obfClasses, deobfClasses);
- m_gui.setObfClasses(obfClasses);
- m_gui.setDeobfClasses(deobfClasses);
+ this.deobfuscator.getSeparatedClasses(obfClasses, deobfClasses);
+ this.gui.setObfClasses(obfClasses);
+ this.gui.setDeobfClasses(deobfClasses);
}
private void refreshCurrentClass() {
@@ -298,29 +268,29 @@ public class GuiController {
}
private void refreshCurrentClass(EntryReference obfReference) {
- if (m_currentObfClass != null) {
- deobfuscate(m_currentObfClass, obfReference);
+ if (this.currentObfClass != null) {
+ deobfuscate(this.currentObfClass, obfReference);
}
}
private void deobfuscate(final ClassEntry classEntry, final EntryReference obfReference) {
- m_gui.setSource("(deobfuscating...)");
+ this.gui.setSource("(deobfuscating...)");
// run the deobfuscator in a separate thread so we don't block the GUI event queue
new Thread() {
@Override
public void run() {
// decompile,deobfuscate the bytecode
- CompilationUnit sourceTree = m_deobfuscator.getSourceTree(classEntry.getClassName());
+ CompilationUnit sourceTree = deobfuscator.getSourceTree(classEntry.getClassName());
if (sourceTree == null) {
// decompilation of this class is not supported
- m_gui.setSource("Unable to find class: " + classEntry);
+ gui.setSource("Unable to find class: " + classEntry);
return;
}
- String source = m_deobfuscator.getSource(sourceTree);
- m_index = m_deobfuscator.getSourceIndex(sourceTree, source);
- m_gui.setSource(m_index.getSource());
+ String source = deobfuscator.getSource(sourceTree);
+ index = deobfuscator.getSourceIndex(sourceTree, source);
+ gui.setSource(index.getSource());
if (obfReference != null) {
showReference(obfReference);
}
@@ -329,8 +299,8 @@ public class GuiController {
List obfuscatedTokens = Lists.newArrayList();
List deobfuscatedTokens = Lists.newArrayList();
List otherTokens = Lists.newArrayList();
- for (Token token : m_index.referenceTokens()) {
- EntryReference reference = m_index.getDeobfReference(token);
+ for (Token token : index.referenceTokens()) {
+ EntryReference reference = index.getDeobfReference(token);
if (referenceIsRenameable(reference)) {
if (entryHasDeobfuscatedName(reference.getNameableEntry())) {
deobfuscatedTokens.add(token);
@@ -341,7 +311,7 @@ public class GuiController {
otherTokens.add(token);
}
}
- m_gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens);
+ gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens);
}
}.start();
}
diff --git a/src/main/java/cuchaz/enigma/gui/GuiTricks.java b/src/main/java/cuchaz/enigma/gui/GuiTricks.java
index da2ec74..ffacfec 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiTricks.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiTricks.java
@@ -40,17 +40,13 @@ public class GuiTricks {
public static void deactivateButton(JButton button) {
button.setEnabled(false);
button.setText("");
- for (ActionListener listener : Arrays.asList(button.getActionListeners())) {
- button.removeActionListener(listener);
- }
+ Arrays.asList(button.getActionListeners()).forEach(button::removeActionListener);
}
public static void activateButton(JButton button, String text, ActionListener newListener) {
button.setText(text);
button.setEnabled(true);
- for (ActionListener listener : Arrays.asList(button.getActionListeners())) {
- button.removeActionListener(listener);
- }
+ Arrays.asList(button.getActionListeners()).forEach(button::removeActionListener);
button.addActionListener(newListener);
}
}
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;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
@@ -30,12 +29,10 @@ import javax.swing.text.Highlighter.HighlightPainter;
import cuchaz.enigma.Constants;
import cuchaz.enigma.Deobfuscator;
-import cuchaz.enigma.analysis.EntryReference;
import cuchaz.enigma.analysis.SourceIndex;
import cuchaz.enigma.analysis.Token;
import cuchaz.enigma.convert.ClassMatches;
import cuchaz.enigma.convert.MemberMatches;
-import cuchaz.enigma.gui.ClassSelector.ClassSelectionListener;
import cuchaz.enigma.mapping.ClassEntry;
import cuchaz.enigma.mapping.Entry;
import de.sciss.syntaxpane.DefaultSyntaxKit;
@@ -108,7 +105,7 @@ public class MemberMatchingGui {
m_destDeobfuscator = destDeobfuscator;
// init frame
- m_frame = new JFrame(Constants.Name + " - Member Matcher");
+ m_frame = new JFrame(Constants.NAME + " - Member Matcher");
final Container pane = m_frame.getContentPane();
pane.setLayout(new BorderLayout());
@@ -123,12 +120,7 @@ public class MemberMatchingGui {
JPanel sourceTypePanel = new JPanel();
classesPanel.add(sourceTypePanel);
sourceTypePanel.setLayout(new BoxLayout(sourceTypePanel, BoxLayout.PAGE_AXIS));
- ActionListener sourceTypeListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- setSourceType(SourceType.valueOf(event.getActionCommand()));
- }
- };
+ ActionListener sourceTypeListener = event -> setSourceType(SourceType.valueOf(event.getActionCommand()));
ButtonGroup sourceTypeButtons = new ButtonGroup();
m_sourceTypeButtons = Maps.newHashMap();
for (SourceType sourceType : SourceType.values()) {
@@ -138,37 +130,26 @@ public class MemberMatchingGui {
}
m_sourceClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator);
- m_sourceClasses.setListener(new ClassSelectionListener() {
- @Override
- public void onSelectClass(ClassEntry classEntry) {
- setSourceClass(classEntry);
- }
- });
+ m_sourceClasses.setListener(this::setSourceClass);
JScrollPane sourceScroller = new JScrollPane(m_sourceClasses);
classesPanel.add(sourceScroller);
// init readers
DefaultSyntaxKit.initKit();
m_sourceReader = new CodeReader();
- m_sourceReader.setSelectionListener(new CodeReader.SelectionListener() {
- @Override
- public void onSelect(EntryReference reference) {
- if (reference != null) {
- onSelectSource(reference.entry);
- } else {
- onSelectSource(null);
- }
+ m_sourceReader.setSelectionListener(reference -> {
+ if (reference != null) {
+ onSelectSource(reference.entry);
+ } else {
+ onSelectSource(null);
}
});
m_destReader = new CodeReader();
- m_destReader.setSelectionListener(new CodeReader.SelectionListener() {
- @Override
- public void onSelect(EntryReference reference) {
- if (reference != null) {
- onSelectDest(reference.entry);
- } else {
- onSelectDest(null);
- }
+ m_destReader.setSelectionListener(reference -> {
+ if (reference != null) {
+ onSelectDest(reference.entry);
+ } else {
+ onSelectDest(null);
}
});
@@ -267,18 +248,8 @@ public class MemberMatchingGui {
throw new Error("No matching dest class for source class: " + m_obfSourceClass);
}
- m_sourceReader.decompileClass(m_obfSourceClass, m_sourceDeobfuscator, false, new Runnable() {
- @Override
- public void run() {
- updateSourceHighlights();
- }
- });
- m_destReader.decompileClass(m_obfDestClass, m_destDeobfuscator, false, new Runnable() {
- @Override
- public void run() {
- updateDestHighlights();
- }
- });
+ m_sourceReader.decompileClass(m_obfSourceClass, m_sourceDeobfuscator, false, this::updateSourceHighlights);
+ m_destReader.decompileClass(m_obfDestClass, m_destDeobfuscator, false, this::updateDestHighlights);
}
protected void updateSourceHighlights() {
@@ -382,21 +353,19 @@ public class MemberMatchingGui {
}
private void setSource(T obfEntry) {
+ m_obfSourceEntry = obfEntry;
if (obfEntry == null) {
- m_obfSourceEntry = obfEntry;
m_sourceLabel.setText("");
} else {
- m_obfSourceEntry = obfEntry;
m_sourceLabel.setText(getEntryLabel(obfEntry, m_sourceDeobfuscator));
}
}
private void setDest(T obfEntry) {
+ m_obfDestEntry = obfEntry;
if (obfEntry == null) {
- m_obfDestEntry = obfEntry;
m_destLabel.setText("");
} else {
- m_obfDestEntry = obfEntry;
m_destLabel.setText(getEntryLabel(obfEntry, m_destDeobfuscator));
}
}
@@ -414,27 +383,12 @@ public class MemberMatchingGui {
if (m_obfSourceEntry != null && m_obfDestEntry != null) {
if (m_memberMatches.isMatched(m_obfSourceEntry, m_obfDestEntry)) {
- GuiTricks.activateButton(m_matchButton, "Unmatch", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- unmatch();
- }
- });
+ GuiTricks.activateButton(m_matchButton, "Unmatch", event -> unmatch());
} else if (!m_memberMatches.isMatchedSourceEntry(m_obfSourceEntry) && !m_memberMatches.isMatchedDestEntry(m_obfDestEntry)) {
- GuiTricks.activateButton(m_matchButton, "Match", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- match();
- }
- });
+ GuiTricks.activateButton(m_matchButton, "Match", event -> match());
}
} else if (m_obfSourceEntry != null) {
- GuiTricks.activateButton(m_unmatchableButton, "Set Unmatchable", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- unmatchable();
- }
- });
+ GuiTricks.activateButton(m_unmatchableButton, "Set Unmatchable", event -> unmatchable());
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/ObfuscatedHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/ObfuscatedHighlightPainter.java
index caaf99c..5afc767 100644
--- a/src/main/java/cuchaz/enigma/gui/ObfuscatedHighlightPainter.java
+++ b/src/main/java/cuchaz/enigma/gui/ObfuscatedHighlightPainter.java
@@ -15,7 +15,6 @@ import java.awt.Color;
public class ObfuscatedHighlightPainter extends BoxHighlightPainter {
public ObfuscatedHighlightPainter() {
- // red ish
super(new Color(255, 220, 220), new Color(160, 80, 80));
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/OtherHighlightPainter.java b/src/main/java/cuchaz/enigma/gui/OtherHighlightPainter.java
index d2a2f02..256f69e 100644
--- a/src/main/java/cuchaz/enigma/gui/OtherHighlightPainter.java
+++ b/src/main/java/cuchaz/enigma/gui/OtherHighlightPainter.java
@@ -15,7 +15,6 @@ import java.awt.Color;
public class OtherHighlightPainter extends BoxHighlightPainter {
public OtherHighlightPainter() {
- // grey
super(null, new Color(180, 180, 180));
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/ProgressDialog.java b/src/main/java/cuchaz/enigma/gui/ProgressDialog.java
index 087d843..70bca15 100644
--- a/src/main/java/cuchaz/enigma/gui/ProgressDialog.java
+++ b/src/main/java/cuchaz/enigma/gui/ProgressDialog.java
@@ -22,63 +22,63 @@ import cuchaz.enigma.Deobfuscator.ProgressListener;
public class ProgressDialog implements ProgressListener, AutoCloseable {
- private JFrame m_frame;
- private JLabel m_title;
- private JLabel m_text;
- private JProgressBar m_progress;
+ private JFrame frame;
+ private JLabel labelTitle;
+ private JLabel labelText;
+ private JProgressBar progress;
public ProgressDialog(JFrame parent) {
// init frame
- m_frame = new JFrame(Constants.Name + " - Operation in progress");
- final Container pane = m_frame.getContentPane();
+ this.frame = new JFrame(Constants.NAME + " - Operation in progress");
+ final Container pane = this.frame.getContentPane();
FlowLayout layout = new FlowLayout();
layout.setAlignment(FlowLayout.LEFT);
pane.setLayout(layout);
- m_title = new JLabel();
- pane.add(m_title);
+ this.labelTitle = new JLabel();
+ pane.add(this.labelTitle);
// set up the progress bar
JPanel panel = new JPanel();
pane.add(panel);
panel.setLayout(new BorderLayout());
- m_text = GuiTricks.unboldLabel(new JLabel());
- m_progress = new JProgressBar();
- m_text.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
- panel.add(m_text, BorderLayout.NORTH);
- panel.add(m_progress, BorderLayout.CENTER);
+ this.labelText = GuiTricks.unboldLabel(new JLabel());
+ this.progress = new JProgressBar();
+ this.labelText.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
+ panel.add(this.labelText, BorderLayout.NORTH);
+ panel.add(this.progress, BorderLayout.CENTER);
panel.setPreferredSize(new Dimension(360, 50));
// show the frame
pane.doLayout();
- m_frame.setSize(400, 120);
- m_frame.setResizable(false);
- m_frame.setLocationRelativeTo(parent);
- m_frame.setVisible(true);
- m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
+ this.frame.setSize(400, 120);
+ this.frame.setResizable(false);
+ this.frame.setLocationRelativeTo(parent);
+ this.frame.setVisible(true);
+ this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
public void close() {
- m_frame.dispose();
+ this.frame.dispose();
}
@Override
public void init(int totalWork, String title) {
- m_title.setText(title);
- m_progress.setMinimum(0);
- m_progress.setMaximum(totalWork);
- m_progress.setValue(0);
+ this.labelTitle.setText(title);
+ this.progress.setMinimum(0);
+ this.progress.setMaximum(totalWork);
+ this.progress.setValue(0);
}
@Override
public void onProgress(int numDone, String message) {
- m_text.setText(message);
- m_progress.setValue(numDone);
+ this.labelText.setText(message);
+ this.progress.setValue(numDone);
// update the frame
- m_frame.validate();
- m_frame.repaint();
+ this.frame.validate();
+ this.frame.repaint();
}
public interface ProgressRunnable {
diff --git a/src/main/java/cuchaz/enigma/gui/RenameListener.java b/src/main/java/cuchaz/enigma/gui/RenameListener.java
deleted file mode 100644
index f0f9dcc..0000000
--- a/src/main/java/cuchaz/enigma/gui/RenameListener.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Jeff Martin.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser General Public
- * License v3.0 which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl.html
- *
- * Contributors:
- * Jeff Martin - initial API and implementation
- ******************************************************************************/
-package cuchaz.enigma.gui;
-
-import cuchaz.enigma.mapping.Entry;
-
-public interface RenameListener {
- void rename(Entry obfEntry, String newName);
-}
diff --git a/src/main/java/cuchaz/enigma/gui/ScoredClassEntry.java b/src/main/java/cuchaz/enigma/gui/ScoredClassEntry.java
index d1e2de0..359ec7a 100644
--- a/src/main/java/cuchaz/enigma/gui/ScoredClassEntry.java
+++ b/src/main/java/cuchaz/enigma/gui/ScoredClassEntry.java
@@ -12,19 +12,18 @@ package cuchaz.enigma.gui;
import cuchaz.enigma.mapping.ClassEntry;
-
public class ScoredClassEntry extends ClassEntry {
private static final long serialVersionUID = -8798725308554217105L;
- private float m_score;
+ private float score;
public ScoredClassEntry(ClassEntry other, float score) {
super(other);
- m_score = score;
+ this.score = score;
}
public float getScore() {
- return m_score;
+ return this.score;
}
}
diff --git a/src/main/java/cuchaz/enigma/gui/TokenListCellRenderer.java b/src/main/java/cuchaz/enigma/gui/TokenListCellRenderer.java
index efc8df8..518055f 100644
--- a/src/main/java/cuchaz/enigma/gui/TokenListCellRenderer.java
+++ b/src/main/java/cuchaz/enigma/gui/TokenListCellRenderer.java
@@ -21,18 +21,18 @@ import cuchaz.enigma.analysis.Token;
public class TokenListCellRenderer implements ListCellRenderer {
- private GuiController m_controller;
- private DefaultListCellRenderer m_defaultRenderer;
+ private GuiController controller;
+ private DefaultListCellRenderer defaultRenderer;
public TokenListCellRenderer(GuiController controller) {
- m_controller = controller;
- m_defaultRenderer = new DefaultListCellRenderer();
+ this.controller = controller;
+ this.defaultRenderer = new DefaultListCellRenderer();
}
@Override
public Component getListCellRendererComponent(JList extends Token> list, Token token, int index, boolean isSelected, boolean hasFocus) {
- JLabel label = (JLabel) m_defaultRenderer.getListCellRendererComponent(list, token, index, isSelected, hasFocus);
- label.setText(m_controller.getReadableToken(token).toString());
+ JLabel label = (JLabel) this.defaultRenderer.getListCellRendererComponent(list, token, index, isSelected, hasFocus);
+ label.setText(this.controller.getReadableToken(token).toString());
return label;
}
}
--
cgit v1.2.3