diff options
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 93 |
1 files changed, 83 insertions, 10 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 3e8a18c..072fb3a 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -67,6 +67,7 @@ import com.google.common.collect.Lists; | |||
| 67 | 67 | ||
| 68 | import cuchaz.enigma.Constants; | 68 | import cuchaz.enigma.Constants; |
| 69 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | 69 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; |
| 70 | import cuchaz.enigma.analysis.MethodCallsTreeNode; | ||
| 70 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | 71 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; |
| 71 | import cuchaz.enigma.analysis.Token; | 72 | import cuchaz.enigma.analysis.Token; |
| 72 | import cuchaz.enigma.mapping.ArgumentEntry; | 73 | import cuchaz.enigma.mapping.ArgumentEntry; |
| @@ -139,6 +140,8 @@ public class Gui | |||
| 139 | private BoxHighlightPainter m_obfuscatedHighlightPainter; | 140 | private BoxHighlightPainter m_obfuscatedHighlightPainter; |
| 140 | private BoxHighlightPainter m_deobfuscatedHighlightPainter; | 141 | private BoxHighlightPainter m_deobfuscatedHighlightPainter; |
| 141 | private JTree m_inheritanceTree; | 142 | private JTree m_inheritanceTree; |
| 143 | private JTree m_callsTree; | ||
| 144 | private JTabbedPane m_tabs; | ||
| 142 | 145 | ||
| 143 | // dynamic menu items | 146 | // dynamic menu items |
| 144 | private JMenuItem m_closeJarMenu; | 147 | private JMenuItem m_closeJarMenu; |
| @@ -147,9 +150,10 @@ public class Gui | |||
| 147 | private JMenuItem m_saveMappingsAsMenu; | 150 | private JMenuItem m_saveMappingsAsMenu; |
| 148 | private JMenuItem m_closeMappingsMenu; | 151 | private JMenuItem m_closeMappingsMenu; |
| 149 | private JMenuItem m_renameMenu; | 152 | private JMenuItem m_renameMenu; |
| 150 | private JMenuItem m_inheritanceMenu; | 153 | private JMenuItem m_showInheritanceMenu; |
| 151 | private JMenuItem m_openEntryMenu; | 154 | private JMenuItem m_openEntryMenu; |
| 152 | private JMenuItem m_openPreviousMenu; | 155 | private JMenuItem m_openPreviousMenu; |
| 156 | private JMenuItem m_showCallsMenu; | ||
| 153 | 157 | ||
| 154 | // state | 158 | // state |
| 155 | private EntryPair<Entry> m_selectedEntryPair; | 159 | private EntryPair<Entry> m_selectedEntryPair; |
| @@ -267,6 +271,10 @@ public class Gui | |||
| 267 | case KeyEvent.VK_P: | 271 | case KeyEvent.VK_P: |
| 268 | m_controller.openPreviousEntry(); | 272 | m_controller.openPreviousEntry(); |
| 269 | break; | 273 | break; |
| 274 | |||
| 275 | case KeyEvent.VK_C: | ||
| 276 | showCalls(); | ||
| 277 | break; | ||
| 270 | } | 278 | } |
| 271 | } | 279 | } |
| 272 | } ); | 280 | } ); |
| @@ -306,7 +314,22 @@ public class Gui | |||
| 306 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_I, 0 ) ); | 314 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_I, 0 ) ); |
| 307 | menu.setEnabled( false ); | 315 | menu.setEnabled( false ); |
| 308 | popupMenu.add( menu ); | 316 | popupMenu.add( menu ); |
| 309 | m_inheritanceMenu = menu; | 317 | m_showInheritanceMenu = menu; |
| 318 | } | ||
| 319 | { | ||
| 320 | JMenuItem menu = new JMenuItem( "Show Calls" ); | ||
| 321 | menu.addActionListener( new ActionListener( ) | ||
| 322 | { | ||
| 323 | @Override | ||
| 324 | public void actionPerformed( ActionEvent event ) | ||
| 325 | { | ||
| 326 | showCalls(); | ||
| 327 | } | ||
| 328 | } ); | ||
| 329 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C, 0 ) ); | ||
| 330 | menu.setEnabled( false ); | ||
| 331 | popupMenu.add( menu ); | ||
| 332 | m_showCallsMenu = menu; | ||
| 310 | } | 333 | } |
| 311 | { | 334 | { |
| 312 | JMenuItem menu = new JMenuItem( "Go to Declaration" ); | 335 | JMenuItem menu = new JMenuItem( "Go to Declaration" ); |
| @@ -350,12 +373,13 @@ public class Gui | |||
| 350 | if( event.getClickCount() == 2 ) | 373 | if( event.getClickCount() == 2 ) |
| 351 | { | 374 | { |
| 352 | // get the selected node | 375 | // get the selected node |
| 353 | Object node = m_inheritanceTree.getSelectionPath().getLastPathComponent(); | 376 | TreePath path = m_inheritanceTree.getSelectionPath(); |
| 354 | if( node == null ) | 377 | if( path == null ) |
| 355 | { | 378 | { |
| 356 | return; | 379 | return; |
| 357 | } | 380 | } |
| 358 | 381 | ||
| 382 | Object node = path.getLastPathComponent(); | ||
| 359 | if( node instanceof ClassInheritanceTreeNode ) | 383 | if( node instanceof ClassInheritanceTreeNode ) |
| 360 | { | 384 | { |
| 361 | m_controller.openEntry( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) ); | 385 | m_controller.openEntry( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) ); |
| @@ -375,17 +399,47 @@ public class Gui | |||
| 375 | inheritancePanel.setLayout( new BorderLayout() ); | 399 | inheritancePanel.setLayout( new BorderLayout() ); |
| 376 | inheritancePanel.add( new JScrollPane( m_inheritanceTree ) ); | 400 | inheritancePanel.add( new JScrollPane( m_inheritanceTree ) ); |
| 377 | 401 | ||
| 402 | // init call panel | ||
| 403 | m_callsTree = new JTree(); | ||
| 404 | m_callsTree.setModel( null ); | ||
| 405 | m_callsTree.addMouseListener( new MouseAdapter( ) | ||
| 406 | { | ||
| 407 | @Override | ||
| 408 | public void mouseClicked( MouseEvent event ) | ||
| 409 | { | ||
| 410 | if( event.getClickCount() == 2 ) | ||
| 411 | { | ||
| 412 | // get the selected node | ||
| 413 | TreePath path = m_callsTree.getSelectionPath(); | ||
| 414 | if( path == null ) | ||
| 415 | { | ||
| 416 | return; | ||
| 417 | } | ||
| 418 | |||
| 419 | Object node = path.getLastPathComponent(); | ||
| 420 | if( node instanceof MethodCallsTreeNode ) | ||
| 421 | { | ||
| 422 | m_controller.openEntry( ((MethodCallsTreeNode)node).getMethodEntry() ); | ||
| 423 | } | ||
| 424 | } | ||
| 425 | } | ||
| 426 | } ); | ||
| 427 | JPanel callPanel = new JPanel(); | ||
| 428 | callPanel.setLayout( new BorderLayout() ); | ||
| 429 | callPanel.add( new JScrollPane( m_callsTree ) ); | ||
| 430 | |||
| 378 | // layout controls | 431 | // layout controls |
| 379 | JSplitPane splitLeft = new JSplitPane( JSplitPane.VERTICAL_SPLIT, true, obfPanel, deobfPanel ); | 432 | JSplitPane splitLeft = new JSplitPane( JSplitPane.VERTICAL_SPLIT, true, obfPanel, deobfPanel ); |
| 380 | splitLeft.setPreferredSize( new Dimension( 200, 0 ) ); | 433 | splitLeft.setPreferredSize( new Dimension( 250, 0 ) ); |
| 381 | JPanel centerPanel = new JPanel(); | 434 | JPanel centerPanel = new JPanel(); |
| 382 | centerPanel.setLayout( new BorderLayout() ); | 435 | centerPanel.setLayout( new BorderLayout() ); |
| 383 | centerPanel.add( m_infoPanel, BorderLayout.NORTH ); | 436 | centerPanel.add( m_infoPanel, BorderLayout.NORTH ); |
| 384 | centerPanel.add( sourceScroller, BorderLayout.CENTER ); | 437 | centerPanel.add( sourceScroller, BorderLayout.CENTER ); |
| 385 | JTabbedPane tabbedPane = new JTabbedPane(); | 438 | m_tabs = new JTabbedPane(); |
| 386 | tabbedPane.setPreferredSize( new Dimension( 200, 0 ) ); | 439 | m_tabs.setPreferredSize( new Dimension( 250, 0 ) ); |
| 387 | tabbedPane.addTab( "Inheritance", inheritancePanel ); | 440 | m_tabs.addTab( "Inheritance", inheritancePanel ); |
| 388 | JSplitPane splitRight = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, tabbedPane ); | 441 | m_tabs.addTab( "Method Calls", callPanel ); |
| 442 | JSplitPane splitRight = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs ); | ||
| 389 | splitRight.setResizeWeight( 1 ); // let the left side take all the slack | 443 | splitRight.setResizeWeight( 1 ); // let the left side take all the slack |
| 390 | splitRight.resetToPreferredSizes(); | 444 | splitRight.resetToPreferredSizes(); |
| 391 | JSplitPane splitCenter = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, splitLeft, splitRight ); | 445 | JSplitPane splitCenter = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, splitLeft, splitRight ); |
| @@ -784,7 +838,8 @@ public class Gui | |||
| 784 | 838 | ||
| 785 | showEntryPair( m_selectedEntryPair ); | 839 | showEntryPair( m_selectedEntryPair ); |
| 786 | 840 | ||
| 787 | m_inheritanceMenu.setEnabled( isClassEntry || isMethodEntry ); | 841 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry ); |
| 842 | m_showCallsMenu.setEnabled( isMethodEntry ); | ||
| 788 | m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry ); | 843 | m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry ); |
| 789 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousEntry() ); | 844 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousEntry() ); |
| 790 | } | 845 | } |
| @@ -879,6 +934,24 @@ public class Gui | |||
| 879 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); | 934 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); |
| 880 | } | 935 | } |
| 881 | 936 | ||
| 937 | m_tabs.setSelectedIndex( 0 ); | ||
| 938 | redraw(); | ||
| 939 | } | ||
| 940 | |||
| 941 | private void showCalls( ) | ||
| 942 | { | ||
| 943 | if( m_selectedEntryPair == null ) | ||
| 944 | { | ||
| 945 | return; | ||
| 946 | } | ||
| 947 | |||
| 948 | if( m_selectedEntryPair.obf instanceof MethodEntry ) | ||
| 949 | { | ||
| 950 | MethodCallsTreeNode node = m_controller.getMethodCalls( (MethodEntry)m_selectedEntryPair.obf ); | ||
| 951 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | ||
| 952 | } | ||
| 953 | |||
| 954 | m_tabs.setSelectedIndex( 1 ); | ||
| 882 | redraw(); | 955 | redraw(); |
| 883 | } | 956 | } |
| 884 | 957 | ||