diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 318 |
1 files changed, 159 insertions, 159 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index ed18777..7cb494f 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -62,23 +62,23 @@ public class Gui { | |||
| 62 | private final MenuBar menuBar; | 62 | private final MenuBar menuBar; |
| 63 | public final PopupMenuBar popupMenu; | 63 | public final PopupMenuBar popupMenu; |
| 64 | 64 | ||
| 65 | private JFrame frame; | 65 | private JFrame frame; |
| 66 | private PanelEditor editor; | 66 | private PanelEditor editor; |
| 67 | private JPanel classesPanel; | 67 | private JPanel classesPanel; |
| 68 | private JSplitPane m_splitClasses; | 68 | private JSplitPane splitClasses; |
| 69 | private PanelIdentifier m_infoPanel; | 69 | private PanelIdentifier infoPanel; |
| 70 | private ObfuscatedHighlightPainter m_obfuscatedHighlightPainter; | 70 | private ObfuscatedHighlightPainter obfuscatedHighlightPainter; |
| 71 | private DeobfuscatedHighlightPainter m_deobfuscatedHighlightPainter; | 71 | private DeobfuscatedHighlightPainter deobfuscatedHighlightPainter; |
| 72 | private OtherHighlightPainter m_otherHighlightPainter; | 72 | private OtherHighlightPainter otherHighlightPainter; |
| 73 | private SelectionHighlightPainter m_selectionHighlightPainter; | 73 | private SelectionHighlightPainter selectionHighlightPainter; |
| 74 | private JTree m_inheritanceTree; | 74 | private JTree inheritanceTree; |
| 75 | private JTree m_implementationsTree; | 75 | private JTree implementationsTree; |
| 76 | private JTree m_callsTree; | 76 | private JTree callsTree; |
| 77 | private JList<Token> m_tokens; | 77 | private JList<Token> tokens; |
| 78 | private JTabbedPane m_tabs; | 78 | private JTabbedPane tabs; |
| 79 | 79 | ||
| 80 | // state | 80 | // state |
| 81 | public EntryReference<Entry, Entry> m_reference; | 81 | public EntryReference<Entry, Entry> reference; |
| 82 | 82 | ||
| 83 | public JFileChooser jarFileChooser; | 83 | public JFileChooser jarFileChooser; |
| 84 | public JFileChooser enigmaMappingsFileChooser; | 84 | public JFileChooser enigmaMappingsFileChooser; |
| @@ -118,22 +118,22 @@ public class Gui { | |||
| 118 | this.deobfPanel = new PanelDeobf(this); | 118 | this.deobfPanel = new PanelDeobf(this); |
| 119 | 119 | ||
| 120 | // set up classes panel (don't add the splitter yet) | 120 | // set up classes panel (don't add the splitter yet) |
| 121 | m_splitClasses = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, this.obfPanel, this.deobfPanel); | 121 | splitClasses = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, this.obfPanel, this.deobfPanel); |
| 122 | m_splitClasses.setResizeWeight(0.3); | 122 | splitClasses.setResizeWeight(0.3); |
| 123 | this.classesPanel = new JPanel(); | 123 | this.classesPanel = new JPanel(); |
| 124 | this.classesPanel.setLayout(new BorderLayout()); | 124 | this.classesPanel.setLayout(new BorderLayout()); |
| 125 | this.classesPanel.setPreferredSize(new Dimension(250, 0)); | 125 | this.classesPanel.setPreferredSize(new Dimension(250, 0)); |
| 126 | 126 | ||
| 127 | // init info panel | 127 | // init info panel |
| 128 | m_infoPanel = new PanelIdentifier(this); | 128 | infoPanel = new PanelIdentifier(this); |
| 129 | m_infoPanel.clearReference(); | 129 | infoPanel.clearReference(); |
| 130 | 130 | ||
| 131 | // init editor | 131 | // init editor |
| 132 | DefaultSyntaxKit.initKit(); | 132 | DefaultSyntaxKit.initKit(); |
| 133 | m_obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); | 133 | obfuscatedHighlightPainter = new ObfuscatedHighlightPainter(); |
| 134 | m_deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | 134 | deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); |
| 135 | m_otherHighlightPainter = new OtherHighlightPainter(); | 135 | otherHighlightPainter = new OtherHighlightPainter(); |
| 136 | m_selectionHighlightPainter = new SelectionHighlightPainter(); | 136 | selectionHighlightPainter = new SelectionHighlightPainter(); |
| 137 | this.editor = new PanelEditor(this); | 137 | this.editor = new PanelEditor(this); |
| 138 | JScrollPane sourceScroller = new JScrollPane(this.editor); | 138 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| 139 | this.editor.setContentType("text/java"); | 139 | this.editor.setContentType("text/java"); |
| @@ -145,14 +145,14 @@ public class Gui { | |||
| 145 | this.editor.setComponentPopupMenu(this.popupMenu); | 145 | this.editor.setComponentPopupMenu(this.popupMenu); |
| 146 | 146 | ||
| 147 | // init inheritance panel | 147 | // init inheritance panel |
| 148 | m_inheritanceTree = new JTree(); | 148 | inheritanceTree = new JTree(); |
| 149 | m_inheritanceTree.setModel(null); | 149 | inheritanceTree.setModel(null); |
| 150 | m_inheritanceTree.addMouseListener(new MouseAdapter() { | 150 | inheritanceTree.addMouseListener(new MouseAdapter() { |
| 151 | @Override | 151 | @Override |
| 152 | public void mouseClicked(MouseEvent event) { | 152 | public void mouseClicked(MouseEvent event) { |
| 153 | if (event.getClickCount() == 2) { | 153 | if (event.getClickCount() == 2) { |
| 154 | // get the selected node | 154 | // get the selected node |
| 155 | TreePath path = m_inheritanceTree.getSelectionPath(); | 155 | TreePath path = inheritanceTree.getSelectionPath(); |
| 156 | if (path == null) { | 156 | if (path == null) { |
| 157 | return; | 157 | return; |
| 158 | } | 158 | } |
| @@ -172,17 +172,17 @@ public class Gui { | |||
| 172 | }); | 172 | }); |
| 173 | JPanel inheritancePanel = new JPanel(); | 173 | JPanel inheritancePanel = new JPanel(); |
| 174 | inheritancePanel.setLayout(new BorderLayout()); | 174 | inheritancePanel.setLayout(new BorderLayout()); |
| 175 | inheritancePanel.add(new JScrollPane(m_inheritanceTree)); | 175 | inheritancePanel.add(new JScrollPane(inheritanceTree)); |
| 176 | 176 | ||
| 177 | // init implementations panel | 177 | // init implementations panel |
| 178 | m_implementationsTree = new JTree(); | 178 | implementationsTree = new JTree(); |
| 179 | m_implementationsTree.setModel(null); | 179 | implementationsTree.setModel(null); |
| 180 | m_implementationsTree.addMouseListener(new MouseAdapter() { | 180 | implementationsTree.addMouseListener(new MouseAdapter() { |
| 181 | @Override | 181 | @Override |
| 182 | public void mouseClicked(MouseEvent event) { | 182 | public void mouseClicked(MouseEvent event) { |
| 183 | if (event.getClickCount() == 2) { | 183 | if (event.getClickCount() == 2) { |
| 184 | // get the selected node | 184 | // get the selected node |
| 185 | TreePath path = m_implementationsTree.getSelectionPath(); | 185 | TreePath path = implementationsTree.getSelectionPath(); |
| 186 | if (path == null) { | 186 | if (path == null) { |
| 187 | return; | 187 | return; |
| 188 | } | 188 | } |
| @@ -200,18 +200,18 @@ public class Gui { | |||
| 200 | }); | 200 | }); |
| 201 | JPanel implementationsPanel = new JPanel(); | 201 | JPanel implementationsPanel = new JPanel(); |
| 202 | implementationsPanel.setLayout(new BorderLayout()); | 202 | implementationsPanel.setLayout(new BorderLayout()); |
| 203 | implementationsPanel.add(new JScrollPane(m_implementationsTree)); | 203 | implementationsPanel.add(new JScrollPane(implementationsTree)); |
| 204 | 204 | ||
| 205 | // init call panel | 205 | // init call panel |
| 206 | m_callsTree = new JTree(); | 206 | callsTree = new JTree(); |
| 207 | m_callsTree.setModel(null); | 207 | callsTree.setModel(null); |
| 208 | m_callsTree.addMouseListener(new MouseAdapter() { | 208 | callsTree.addMouseListener(new MouseAdapter() { |
| 209 | @SuppressWarnings("unchecked") | 209 | @SuppressWarnings("unchecked") |
| 210 | @Override | 210 | @Override |
| 211 | public void mouseClicked(MouseEvent event) { | 211 | public void mouseClicked(MouseEvent event) { |
| 212 | if (event.getClickCount() == 2) { | 212 | if (event.getClickCount() == 2) { |
| 213 | // get the selected node | 213 | // get the selected node |
| 214 | TreePath path = m_callsTree.getSelectionPath(); | 214 | TreePath path = callsTree.getSelectionPath(); |
| 215 | if (path == null) { | 215 | if (path == null) { |
| 216 | return; | 216 | return; |
| 217 | } | 217 | } |
| @@ -228,28 +228,28 @@ public class Gui { | |||
| 228 | } | 228 | } |
| 229 | } | 229 | } |
| 230 | }); | 230 | }); |
| 231 | m_tokens = new JList<>(); | 231 | tokens = new JList<>(); |
| 232 | m_tokens.setCellRenderer(new TokenListCellRenderer(this.controller)); | 232 | tokens.setCellRenderer(new TokenListCellRenderer(this.controller)); |
| 233 | m_tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | 233 | tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 234 | m_tokens.setLayoutOrientation(JList.VERTICAL); | 234 | tokens.setLayoutOrientation(JList.VERTICAL); |
| 235 | m_tokens.addMouseListener(new MouseAdapter() { | 235 | tokens.addMouseListener(new MouseAdapter() { |
| 236 | @Override | 236 | @Override |
| 237 | public void mouseClicked(MouseEvent event) { | 237 | public void mouseClicked(MouseEvent event) { |
| 238 | if (event.getClickCount() == 2) { | 238 | if (event.getClickCount() == 2) { |
| 239 | Token selected = m_tokens.getSelectedValue(); | 239 | Token selected = tokens.getSelectedValue(); |
| 240 | if (selected != null) { | 240 | if (selected != null) { |
| 241 | showToken(selected); | 241 | showToken(selected); |
| 242 | } | 242 | } |
| 243 | } | 243 | } |
| 244 | } | 244 | } |
| 245 | }); | 245 | }); |
| 246 | m_tokens.setPreferredSize(new Dimension(0, 200)); | 246 | tokens.setPreferredSize(new Dimension(0, 200)); |
| 247 | m_tokens.setMinimumSize(new Dimension(0, 200)); | 247 | tokens.setMinimumSize(new Dimension(0, 200)); |
| 248 | JSplitPane callPanel = new JSplitPane( | 248 | JSplitPane callPanel = new JSplitPane( |
| 249 | JSplitPane.VERTICAL_SPLIT, | 249 | JSplitPane.VERTICAL_SPLIT, |
| 250 | true, | 250 | true, |
| 251 | new JScrollPane(m_callsTree), | 251 | new JScrollPane(callsTree), |
| 252 | new JScrollPane(m_tokens) | 252 | new JScrollPane(tokens) |
| 253 | ); | 253 | ); |
| 254 | callPanel.setResizeWeight(1); // let the top side take all the slack | 254 | callPanel.setResizeWeight(1); // let the top side take all the slack |
| 255 | callPanel.resetToPreferredSizes(); | 255 | callPanel.resetToPreferredSizes(); |
| @@ -257,14 +257,14 @@ public class Gui { | |||
| 257 | // layout controls | 257 | // layout controls |
| 258 | JPanel centerPanel = new JPanel(); | 258 | JPanel centerPanel = new JPanel(); |
| 259 | centerPanel.setLayout(new BorderLayout()); | 259 | centerPanel.setLayout(new BorderLayout()); |
| 260 | centerPanel.add(m_infoPanel, BorderLayout.NORTH); | 260 | centerPanel.add(infoPanel, BorderLayout.NORTH); |
| 261 | centerPanel.add(sourceScroller, BorderLayout.CENTER); | 261 | centerPanel.add(sourceScroller, BorderLayout.CENTER); |
| 262 | m_tabs = new JTabbedPane(); | 262 | tabs = new JTabbedPane(); |
| 263 | m_tabs.setPreferredSize(new Dimension(250, 0)); | 263 | tabs.setPreferredSize(new Dimension(250, 0)); |
| 264 | m_tabs.addTab("Inheritance", inheritancePanel); | 264 | tabs.addTab("Inheritance", inheritancePanel); |
| 265 | m_tabs.addTab("Implementations", implementationsPanel); | 265 | tabs.addTab("Implementations", implementationsPanel); |
| 266 | m_tabs.addTab("Call Graph", callPanel); | 266 | tabs.addTab("Call Graph", callPanel); |
| 267 | JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs); | 267 | JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, tabs); |
| 268 | splitRight.setResizeWeight(1); // let the left side take all the slack | 268 | splitRight.setResizeWeight(1); // let the left side take all the slack |
| 269 | splitRight.resetToPreferredSizes(); | 269 | splitRight.resetToPreferredSizes(); |
| 270 | JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, this.classesPanel, splitRight); | 270 | JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, this.classesPanel, splitRight); |
| @@ -314,7 +314,7 @@ public class Gui { | |||
| 314 | // update gui | 314 | // update gui |
| 315 | this.frame.setTitle(Constants.NAME + " - " + jarName); | 315 | this.frame.setTitle(Constants.NAME + " - " + jarName); |
| 316 | this.classesPanel.removeAll(); | 316 | this.classesPanel.removeAll(); |
| 317 | this.classesPanel.add(m_splitClasses); | 317 | this.classesPanel.add(splitClasses); |
| 318 | setSource(null); | 318 | setSource(null); |
| 319 | 319 | ||
| 320 | // update menu | 320 | // update menu |
| @@ -375,7 +375,7 @@ public class Gui { | |||
| 375 | if (token == null) { | 375 | if (token == null) { |
| 376 | throw new IllegalArgumentException("Token cannot be null!"); | 376 | throw new IllegalArgumentException("Token cannot be null!"); |
| 377 | } | 377 | } |
| 378 | CodeReader.navigateToToken(this.editor, token, m_selectionHighlightPainter); | 378 | CodeReader.navigateToToken(this.editor, token, selectionHighlightPainter); |
| 379 | redraw(); | 379 | redraw(); |
| 380 | } | 380 | } |
| 381 | 381 | ||
| @@ -384,10 +384,10 @@ public class Gui { | |||
| 384 | Collections.sort(sortedTokens); | 384 | Collections.sort(sortedTokens); |
| 385 | if (sortedTokens.size() > 1) { | 385 | if (sortedTokens.size() > 1) { |
| 386 | // sort the tokens and update the tokens panel | 386 | // sort the tokens and update the tokens panel |
| 387 | m_tokens.setListData(sortedTokens); | 387 | this.tokens.setListData(sortedTokens); |
| 388 | m_tokens.setSelectedIndex(0); | 388 | this.tokens.setSelectedIndex(0); |
| 389 | } else { | 389 | } else { |
| 390 | m_tokens.setListData(new Vector<>()); | 390 | this.tokens.setListData(new Vector<>()); |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | // show the first token | 393 | // show the first token |
| @@ -401,13 +401,13 @@ public class Gui { | |||
| 401 | 401 | ||
| 402 | // color things based on the index | 402 | // color things based on the index |
| 403 | if (obfuscatedTokens != null) { | 403 | if (obfuscatedTokens != null) { |
| 404 | setHighlightedTokens(obfuscatedTokens, m_obfuscatedHighlightPainter); | 404 | setHighlightedTokens(obfuscatedTokens, obfuscatedHighlightPainter); |
| 405 | } | 405 | } |
| 406 | if (deobfuscatedTokens != null) { | 406 | if (deobfuscatedTokens != null) { |
| 407 | setHighlightedTokens(deobfuscatedTokens, m_deobfuscatedHighlightPainter); | 407 | setHighlightedTokens(deobfuscatedTokens, deobfuscatedHighlightPainter); |
| 408 | } | 408 | } |
| 409 | if (otherTokens != null) { | 409 | if (otherTokens != null) { |
| 410 | setHighlightedTokens(otherTokens, m_otherHighlightPainter); | 410 | setHighlightedTokens(otherTokens, otherHighlightPainter); |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | redraw(); | 413 | redraw(); |
| @@ -425,73 +425,73 @@ public class Gui { | |||
| 425 | 425 | ||
| 426 | private void showReference(EntryReference<Entry, Entry> reference) { | 426 | private void showReference(EntryReference<Entry, Entry> reference) { |
| 427 | if (reference == null) { | 427 | if (reference == null) { |
| 428 | m_infoPanel.clearReference(); | 428 | infoPanel.clearReference(); |
| 429 | return; | 429 | return; |
| 430 | } | 430 | } |
| 431 | 431 | ||
| 432 | m_reference = reference; | 432 | this.reference = reference; |
| 433 | 433 | ||
| 434 | m_infoPanel.removeAll(); | 434 | infoPanel.removeAll(); |
| 435 | if (reference.entry instanceof ClassEntry) { | 435 | if (reference.entry instanceof ClassEntry) { |
| 436 | showClassEntry((ClassEntry) m_reference.entry); | 436 | showClassEntry((ClassEntry) this.reference.entry); |
| 437 | } else if (m_reference.entry instanceof FieldEntry) { | 437 | } else if (this.reference.entry instanceof FieldEntry) { |
| 438 | showFieldEntry((FieldEntry) m_reference.entry); | 438 | showFieldEntry((FieldEntry) this.reference.entry); |
| 439 | } else if (m_reference.entry instanceof MethodEntry) { | 439 | } else if (this.reference.entry instanceof MethodEntry) { |
| 440 | showMethodEntry((MethodEntry) m_reference.entry); | 440 | showMethodEntry((MethodEntry) this.reference.entry); |
| 441 | } else if (m_reference.entry instanceof ConstructorEntry) { | 441 | } else if (this.reference.entry instanceof ConstructorEntry) { |
| 442 | showConstructorEntry((ConstructorEntry) m_reference.entry); | 442 | showConstructorEntry((ConstructorEntry) this.reference.entry); |
| 443 | } else if (m_reference.entry instanceof ArgumentEntry) { | 443 | } else if (this.reference.entry instanceof ArgumentEntry) { |
| 444 | showArgumentEntry((ArgumentEntry) m_reference.entry); | 444 | showArgumentEntry((ArgumentEntry) this.reference.entry); |
| 445 | } else if (m_reference.entry instanceof LocalVariableEntry) { | 445 | } else if (this.reference.entry instanceof LocalVariableEntry) { |
| 446 | showLocalVariableEntry((LocalVariableEntry) m_reference.entry); | 446 | showLocalVariableEntry((LocalVariableEntry) this.reference.entry); |
| 447 | } else { | 447 | } else { |
| 448 | throw new Error("Unknown entry type: " + m_reference.entry.getClass().getName()); | 448 | throw new Error("Unknown entry type: " + this.reference.entry.getClass().getName()); |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | redraw(); | 451 | redraw(); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | private void showLocalVariableEntry(LocalVariableEntry entry) { | 454 | private void showLocalVariableEntry(LocalVariableEntry entry) { |
| 455 | addNameValue(m_infoPanel, "Variable", entry.getName()); | 455 | addNameValue(infoPanel, "Variable", entry.getName()); |
| 456 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); | 456 | addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); |
| 457 | addNameValue(m_infoPanel, "Method", entry.getBehaviorEntry().getName()); | 457 | addNameValue(infoPanel, "Method", entry.getBehaviorEntry().getName()); |
| 458 | addNameValue(m_infoPanel, "Index", Integer.toString(entry.getIndex())); | 458 | addNameValue(infoPanel, "Index", Integer.toString(entry.getIndex())); |
| 459 | addNameValue(m_infoPanel, "Type", entry.getType().toString()); | 459 | addNameValue(infoPanel, "Type", entry.getType().toString()); |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | private void showClassEntry(ClassEntry entry) { | 462 | private void showClassEntry(ClassEntry entry) { |
| 463 | addNameValue(m_infoPanel, "Class", entry.getName()); | 463 | addNameValue(infoPanel, "Class", entry.getName()); |
| 464 | addModifierComboBox(m_infoPanel, "Modifier", entry); | 464 | addModifierComboBox(infoPanel, "Modifier", entry); |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | private void showFieldEntry(FieldEntry entry) { | 467 | private void showFieldEntry(FieldEntry entry) { |
| 468 | addNameValue(m_infoPanel, "Field", entry.getName()); | 468 | addNameValue(infoPanel, "Field", entry.getName()); |
| 469 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); | 469 | addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); |
| 470 | addNameValue(m_infoPanel, "Type", entry.getType().toString()); | 470 | addNameValue(infoPanel, "Type", entry.getType().toString()); |
| 471 | addModifierComboBox(m_infoPanel, "Modifier", entry); | 471 | addModifierComboBox(infoPanel, "Modifier", entry); |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | private void showMethodEntry(MethodEntry entry) { | 474 | private void showMethodEntry(MethodEntry entry) { |
| 475 | addNameValue(m_infoPanel, "Method", entry.getName()); | 475 | addNameValue(infoPanel, "Method", entry.getName()); |
| 476 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); | 476 | addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); |
| 477 | addNameValue(m_infoPanel, "Signature", entry.getSignature().toString()); | 477 | addNameValue(infoPanel, "Signature", entry.getSignature().toString()); |
| 478 | addModifierComboBox(m_infoPanel, "Modifier", entry); | 478 | addModifierComboBox(infoPanel, "Modifier", entry); |
| 479 | 479 | ||
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | private void showConstructorEntry(ConstructorEntry entry) { | 482 | private void showConstructorEntry(ConstructorEntry entry) { |
| 483 | addNameValue(m_infoPanel, "Constructor", entry.getClassEntry().getName()); | 483 | addNameValue(infoPanel, "Constructor", entry.getClassEntry().getName()); |
| 484 | if (!entry.isStatic()) { | 484 | if (!entry.isStatic()) { |
| 485 | addNameValue(m_infoPanel, "Signature", entry.getSignature().toString()); | 485 | addNameValue(infoPanel, "Signature", entry.getSignature().toString()); |
| 486 | addModifierComboBox(m_infoPanel, "Modifier", entry); | 486 | addModifierComboBox(infoPanel, "Modifier", entry); |
| 487 | } | 487 | } |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | private void showArgumentEntry(ArgumentEntry entry) { | 490 | private void showArgumentEntry(ArgumentEntry entry) { |
| 491 | addNameValue(m_infoPanel, "Argument", entry.getName()); | 491 | addNameValue(infoPanel, "Argument", entry.getName()); |
| 492 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); | 492 | addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); |
| 493 | addNameValue(m_infoPanel, "Method", entry.getBehaviorEntry().getName()); | 493 | addNameValue(infoPanel, "Method", entry.getBehaviorEntry().getName()); |
| 494 | addNameValue(m_infoPanel, "Index", Integer.toString(entry.getIndex())); | 494 | addNameValue(infoPanel, "Index", Integer.toString(entry.getIndex())); |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | private void addNameValue(JPanel container, String name, String value) { | 497 | private void addNameValue(JPanel container, String name, String value) { |
| @@ -530,18 +530,18 @@ public class Gui { | |||
| 530 | Token token = this.controller.getToken(pos); | 530 | Token token = this.controller.getToken(pos); |
| 531 | boolean isToken = token != null; | 531 | boolean isToken = token != null; |
| 532 | 532 | ||
| 533 | m_reference = this.controller.getDeobfReference(token); | 533 | reference = this.controller.getDeobfReference(token); |
| 534 | boolean isClassEntry = isToken && m_reference.entry instanceof ClassEntry; | 534 | boolean isClassEntry = isToken && reference.entry instanceof ClassEntry; |
| 535 | boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; | 535 | boolean isFieldEntry = isToken && reference.entry instanceof FieldEntry; |
| 536 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; | 536 | boolean isMethodEntry = isToken && reference.entry instanceof MethodEntry; |
| 537 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; | 537 | boolean isConstructorEntry = isToken && reference.entry instanceof ConstructorEntry; |
| 538 | boolean isInJar = isToken && this.controller.entryIsInJar(m_reference.entry); | 538 | boolean isInJar = isToken && this.controller.entryIsInJar(reference.entry); |
| 539 | boolean isRenameable = isToken && this.controller.referenceIsRenameable(m_reference); | 539 | boolean isRenameable = isToken && this.controller.referenceIsRenameable(reference); |
| 540 | 540 | ||
| 541 | if (isToken) { | 541 | if (isToken) { |
| 542 | showReference(m_reference); | 542 | showReference(reference); |
| 543 | } else { | 543 | } else { |
| 544 | m_infoPanel.clearReference(); | 544 | infoPanel.clearReference(); |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | this.popupMenu.renameMenu.setEnabled(isRenameable); | 547 | this.popupMenu.renameMenu.setEnabled(isRenameable); |
| @@ -552,7 +552,7 @@ public class Gui { | |||
| 552 | this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousLocation()); | 552 | this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousLocation()); |
| 553 | this.popupMenu.toggleMappingMenu.setEnabled(isRenameable); | 553 | this.popupMenu.toggleMappingMenu.setEnabled(isRenameable); |
| 554 | 554 | ||
| 555 | if (isToken && this.controller.entryHasDeobfuscatedName(m_reference.entry)) { | 555 | if (isToken && this.controller.entryHasDeobfuscatedName(reference.entry)) { |
| 556 | this.popupMenu.toggleMappingMenu.setText("Reset to obfuscated"); | 556 | this.popupMenu.toggleMappingMenu.setText("Reset to obfuscated"); |
| 557 | } else { | 557 | } else { |
| 558 | this.popupMenu.toggleMappingMenu.setText("Mark as deobfuscated"); | 558 | this.popupMenu.toggleMappingMenu.setText("Mark as deobfuscated"); |
| @@ -564,8 +564,8 @@ public class Gui { | |||
| 564 | // entry is not in the jar. Ignore it | 564 | // entry is not in the jar. Ignore it |
| 565 | return; | 565 | return; |
| 566 | } | 566 | } |
| 567 | if (m_reference != null) { | 567 | if (reference != null) { |
| 568 | this.controller.savePreviousReference(m_reference); | 568 | this.controller.savePreviousReference(reference); |
| 569 | } | 569 | } |
| 570 | this.controller.openDeclaration(entry); | 570 | this.controller.openDeclaration(entry); |
| 571 | } | 571 | } |
| @@ -574,8 +574,8 @@ public class Gui { | |||
| 574 | if (!this.controller.entryIsInJar(reference.getLocationClassEntry())) { | 574 | if (!this.controller.entryIsInJar(reference.getLocationClassEntry())) { |
| 575 | return; | 575 | return; |
| 576 | } | 576 | } |
| 577 | if (m_reference != null) { | 577 | if (this.reference != null) { |
| 578 | this.controller.savePreviousReference(m_reference); | 578 | this.controller.savePreviousReference(this.reference); |
| 579 | } | 579 | } |
| 580 | this.controller.openReference(reference); | 580 | this.controller.openReference(reference); |
| 581 | } | 581 | } |
| @@ -584,7 +584,7 @@ public class Gui { | |||
| 584 | 584 | ||
| 585 | // init the text box | 585 | // init the text box |
| 586 | final JTextField text = new JTextField(); | 586 | final JTextField text = new JTextField(); |
| 587 | text.setText(m_reference.getNamableName()); | 587 | text.setText(reference.getNamableName()); |
| 588 | text.setPreferredSize(new Dimension(360, text.getPreferredSize().height)); | 588 | text.setPreferredSize(new Dimension(360, text.getPreferredSize().height)); |
| 589 | text.addKeyListener(new KeyAdapter() { | 589 | text.addKeyListener(new KeyAdapter() { |
| 590 | @Override | 590 | @Override |
| @@ -604,14 +604,14 @@ public class Gui { | |||
| 604 | }); | 604 | }); |
| 605 | 605 | ||
| 606 | // find the label with the name and replace it with the text box | 606 | // find the label with the name and replace it with the text box |
| 607 | JPanel panel = (JPanel) m_infoPanel.getComponent(0); | 607 | JPanel panel = (JPanel) infoPanel.getComponent(0); |
| 608 | panel.remove(panel.getComponentCount() - 1); | 608 | panel.remove(panel.getComponentCount() - 1); |
| 609 | panel.add(text); | 609 | panel.add(text); |
| 610 | text.grabFocus(); | 610 | text.grabFocus(); |
| 611 | 611 | ||
| 612 | int offset = text.getText().lastIndexOf('/') + 1; | 612 | int offset = text.getText().lastIndexOf('/') + 1; |
| 613 | // If it's a class and isn't in the default package, assume that it's deobfuscated. | 613 | // If it's a class and isn't in the default package, assume that it's deobfuscated. |
| 614 | if (m_reference.getNameableEntry() instanceof ClassEntry && text.getText().contains("/") && offset != 0) | 614 | if (reference.getNameableEntry() instanceof ClassEntry && text.getText().contains("/") && offset != 0) |
| 615 | text.select(offset, text.getText().length()); | 615 | text.select(offset, text.getText().length()); |
| 616 | else | 616 | else |
| 617 | text.selectAll(); | 617 | text.selectAll(); |
| @@ -623,7 +623,7 @@ public class Gui { | |||
| 623 | String newName = text.getText(); | 623 | String newName = text.getText(); |
| 624 | if (saveName && newName != null && newName.length() > 0) { | 624 | if (saveName && newName != null && newName.length() > 0) { |
| 625 | try { | 625 | try { |
| 626 | this.controller.rename(m_reference, newName); | 626 | this.controller.rename(reference, newName); |
| 627 | } catch (IllegalNameException ex) { | 627 | } catch (IllegalNameException ex) { |
| 628 | text.setBorder(BorderFactory.createLineBorder(Color.red, 1)); | 628 | text.setBorder(BorderFactory.createLineBorder(Color.red, 1)); |
| 629 | text.setToolTipText(ex.getReason()); | 629 | text.setToolTipText(ex.getReason()); |
| @@ -633,9 +633,9 @@ public class Gui { | |||
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | // abort the rename | 635 | // abort the rename |
| 636 | JPanel panel = (JPanel) m_infoPanel.getComponent(0); | 636 | JPanel panel = (JPanel) infoPanel.getComponent(0); |
| 637 | panel.remove(panel.getComponentCount() - 1); | 637 | panel.remove(panel.getComponentCount() - 1); |
| 638 | panel.add(Utils.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT))); | 638 | panel.add(Utils.unboldLabel(new JLabel(reference.getNamableName(), JLabel.LEFT))); |
| 639 | 639 | ||
| 640 | this.editor.grabFocus(); | 640 | this.editor.grabFocus(); |
| 641 | 641 | ||
| @@ -644,95 +644,95 @@ public class Gui { | |||
| 644 | 644 | ||
| 645 | public void showInheritance() { | 645 | public void showInheritance() { |
| 646 | 646 | ||
| 647 | if (m_reference == null) { | 647 | if (reference == null) { |
| 648 | return; | 648 | return; |
| 649 | } | 649 | } |
| 650 | 650 | ||
| 651 | m_inheritanceTree.setModel(null); | 651 | inheritanceTree.setModel(null); |
| 652 | 652 | ||
| 653 | if (m_reference.entry instanceof ClassEntry) { | 653 | if (reference.entry instanceof ClassEntry) { |
| 654 | // get the class inheritance | 654 | // get the class inheritance |
| 655 | ClassInheritanceTreeNode classNode = this.controller.getClassInheritance((ClassEntry) m_reference.entry); | 655 | ClassInheritanceTreeNode classNode = this.controller.getClassInheritance((ClassEntry) reference.entry); |
| 656 | 656 | ||
| 657 | // show the tree at the root | 657 | // show the tree at the root |
| 658 | TreePath path = getPathToRoot(classNode); | 658 | TreePath path = getPathToRoot(classNode); |
| 659 | m_inheritanceTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); | 659 | inheritanceTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); |
| 660 | m_inheritanceTree.expandPath(path); | 660 | inheritanceTree.expandPath(path); |
| 661 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); | 661 | inheritanceTree.setSelectionRow(inheritanceTree.getRowForPath(path)); |
| 662 | } else if (m_reference.entry instanceof MethodEntry) { | 662 | } else if (reference.entry instanceof MethodEntry) { |
| 663 | // get the method inheritance | 663 | // get the method inheritance |
| 664 | MethodInheritanceTreeNode classNode = this.controller.getMethodInheritance((MethodEntry) m_reference.entry); | 664 | MethodInheritanceTreeNode classNode = this.controller.getMethodInheritance((MethodEntry) reference.entry); |
| 665 | 665 | ||
| 666 | // show the tree at the root | 666 | // show the tree at the root |
| 667 | TreePath path = getPathToRoot(classNode); | 667 | TreePath path = getPathToRoot(classNode); |
| 668 | m_inheritanceTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); | 668 | inheritanceTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); |
| 669 | m_inheritanceTree.expandPath(path); | 669 | inheritanceTree.expandPath(path); |
| 670 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); | 670 | inheritanceTree.setSelectionRow(inheritanceTree.getRowForPath(path)); |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | m_tabs.setSelectedIndex(0); | 673 | tabs.setSelectedIndex(0); |
| 674 | redraw(); | 674 | redraw(); |
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | public void showImplementations() { | 677 | public void showImplementations() { |
| 678 | 678 | ||
| 679 | if (m_reference == null) { | 679 | if (reference == null) { |
| 680 | return; | 680 | return; |
| 681 | } | 681 | } |
| 682 | 682 | ||
| 683 | m_implementationsTree.setModel(null); | 683 | implementationsTree.setModel(null); |
| 684 | 684 | ||
| 685 | DefaultMutableTreeNode node = null; | 685 | DefaultMutableTreeNode node = null; |
| 686 | 686 | ||
| 687 | // get the class implementations | 687 | // get the class implementations |
| 688 | if (m_reference.entry instanceof ClassEntry) | 688 | if (reference.entry instanceof ClassEntry) |
| 689 | node = this.controller.getClassImplementations((ClassEntry) m_reference.entry); | 689 | node = this.controller.getClassImplementations((ClassEntry) reference.entry); |
| 690 | else // get the method implementations | 690 | else // get the method implementations |
| 691 | if (m_reference.entry instanceof MethodEntry) | 691 | if (reference.entry instanceof MethodEntry) |
| 692 | node = this.controller.getMethodImplementations((MethodEntry) m_reference.entry); | 692 | node = this.controller.getMethodImplementations((MethodEntry) reference.entry); |
| 693 | 693 | ||
| 694 | if (node != null) { | 694 | if (node != null) { |
| 695 | // show the tree at the root | 695 | // show the tree at the root |
| 696 | TreePath path = getPathToRoot(node); | 696 | TreePath path = getPathToRoot(node); |
| 697 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); | 697 | implementationsTree.setModel(new DefaultTreeModel((TreeNode) path.getPathComponent(0))); |
| 698 | m_implementationsTree.expandPath(path); | 698 | implementationsTree.expandPath(path); |
| 699 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); | 699 | implementationsTree.setSelectionRow(implementationsTree.getRowForPath(path)); |
| 700 | } | 700 | } |
| 701 | 701 | ||
| 702 | m_tabs.setSelectedIndex(1); | 702 | tabs.setSelectedIndex(1); |
| 703 | redraw(); | 703 | redraw(); |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | public void showCalls() { | 706 | public void showCalls() { |
| 707 | if (m_reference == null) { | 707 | if (reference == null) { |
| 708 | return; | 708 | return; |
| 709 | } | 709 | } |
| 710 | 710 | ||
| 711 | if (m_reference.entry instanceof ClassEntry) { | 711 | if (reference.entry instanceof ClassEntry) { |
| 712 | // look for calls to the default constructor | 712 | // look for calls to the default constructor |
| 713 | // TODO: get a list of all the constructors and find calls to all of them | 713 | // TODO: get a list of all the constructors and find calls to all of them |
| 714 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences(new ConstructorEntry((ClassEntry) m_reference.entry, new Signature("()V"))); | 714 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences(new ConstructorEntry((ClassEntry) reference.entry, new Signature("()V"))); |
| 715 | m_callsTree.setModel(new DefaultTreeModel(node)); | 715 | callsTree.setModel(new DefaultTreeModel(node)); |
| 716 | } else if (m_reference.entry instanceof FieldEntry) { | 716 | } else if (reference.entry instanceof FieldEntry) { |
| 717 | FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) m_reference.entry); | 717 | FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) reference.entry); |
| 718 | m_callsTree.setModel(new DefaultTreeModel(node)); | 718 | callsTree.setModel(new DefaultTreeModel(node)); |
| 719 | } else if (m_reference.entry instanceof MethodEntry) { | 719 | } else if (reference.entry instanceof MethodEntry) { |
| 720 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) m_reference.entry); | 720 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) reference.entry); |
| 721 | m_callsTree.setModel(new DefaultTreeModel(node)); | 721 | callsTree.setModel(new DefaultTreeModel(node)); |
| 722 | } else if (m_reference.entry instanceof ConstructorEntry) { | 722 | } else if (reference.entry instanceof ConstructorEntry) { |
| 723 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((ConstructorEntry) m_reference.entry); | 723 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((ConstructorEntry) reference.entry); |
| 724 | m_callsTree.setModel(new DefaultTreeModel(node)); | 724 | callsTree.setModel(new DefaultTreeModel(node)); |
| 725 | } | 725 | } |
| 726 | 726 | ||
| 727 | m_tabs.setSelectedIndex(2); | 727 | tabs.setSelectedIndex(2); |
| 728 | redraw(); | 728 | redraw(); |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | public void toggleMapping() { | 731 | public void toggleMapping() { |
| 732 | if (this.controller.entryHasDeobfuscatedName(m_reference.entry)) { | 732 | if (this.controller.entryHasDeobfuscatedName(reference.entry)) { |
| 733 | this.controller.removeMapping(m_reference); | 733 | this.controller.removeMapping(reference); |
| 734 | } else { | 734 | } else { |
| 735 | this.controller.markAsDeobfuscated(m_reference); | 735 | this.controller.markAsDeobfuscated(reference); |
| 736 | } | 736 | } |
| 737 | } | 737 | } |
| 738 | 738 | ||