summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/Gui.java
diff options
context:
space:
mode:
authorGravatar jeff2014-08-26 00:27:44 -0400
committerGravatar jeff2014-08-26 00:27:44 -0400
commit5f44aac70f59898197c2a7625b74f901c3b31106 (patch)
tree7d2cc2e48201c92867786793966f356810b464fa /src/cuchaz/enigma/gui/Gui.java
parentwrote CheckCastIterator to try to do generic type inference. It's too hard to... (diff)
downloadenigma-fork-5f44aac70f59898197c2a7625b74f901c3b31106.tar.gz
enigma-fork-5f44aac70f59898197c2a7625b74f901c3b31106.tar.xz
enigma-fork-5f44aac70f59898197c2a7625b74f901c3b31106.zip
implemented proper support for interfaces
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
-rw-r--r--src/cuchaz/enigma/gui/Gui.java104
1 files changed, 103 insertions, 1 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java
index 4e63606..3dcb4e2 100644
--- a/src/cuchaz/enigma/gui/Gui.java
+++ b/src/cuchaz/enigma/gui/Gui.java
@@ -70,9 +70,11 @@ import com.google.common.collect.Lists;
70 70
71import cuchaz.enigma.Constants; 71import cuchaz.enigma.Constants;
72import cuchaz.enigma.analysis.BehaviorReferenceTreeNode; 72import cuchaz.enigma.analysis.BehaviorReferenceTreeNode;
73import cuchaz.enigma.analysis.ClassImplementationsTreeNode;
73import cuchaz.enigma.analysis.ClassInheritanceTreeNode; 74import cuchaz.enigma.analysis.ClassInheritanceTreeNode;
74import cuchaz.enigma.analysis.EntryReference; 75import cuchaz.enigma.analysis.EntryReference;
75import cuchaz.enigma.analysis.FieldReferenceTreeNode; 76import cuchaz.enigma.analysis.FieldReferenceTreeNode;
77import cuchaz.enigma.analysis.MethodImplementationsTreeNode;
76import cuchaz.enigma.analysis.MethodInheritanceTreeNode; 78import cuchaz.enigma.analysis.MethodInheritanceTreeNode;
77import cuchaz.enigma.analysis.ReferenceTreeNode; 79import cuchaz.enigma.analysis.ReferenceTreeNode;
78import cuchaz.enigma.analysis.Token; 80import cuchaz.enigma.analysis.Token;
@@ -148,6 +150,7 @@ public class Gui
148 private DeobfuscatedHighlightPainter m_deobfuscatedHighlightPainter; 150 private DeobfuscatedHighlightPainter m_deobfuscatedHighlightPainter;
149 private SelectionHighlightPainter m_selectionHighlightPainter; 151 private SelectionHighlightPainter m_selectionHighlightPainter;
150 private JTree m_inheritanceTree; 152 private JTree m_inheritanceTree;
153 private JTree m_implementationsTree;
151 private JTree m_callsTree; 154 private JTree m_callsTree;
152 private JList<Token> m_tokens; 155 private JList<Token> m_tokens;
153 private JTabbedPane m_tabs; 156 private JTabbedPane m_tabs;
@@ -163,6 +166,7 @@ public class Gui
163 private JMenuItem m_openEntryMenu; 166 private JMenuItem m_openEntryMenu;
164 private JMenuItem m_openPreviousMenu; 167 private JMenuItem m_openPreviousMenu;
165 private JMenuItem m_showCallsMenu; 168 private JMenuItem m_showCallsMenu;
169 private JMenuItem m_showImplementationsMenu;
166 170
167 // state 171 // state
168 private EntryReference<Entry,Entry> m_reference; 172 private EntryReference<Entry,Entry> m_reference;
@@ -285,6 +289,10 @@ public class Gui
285 showInheritance(); 289 showInheritance();
286 break; 290 break;
287 291
292 case KeyEvent.VK_M:
293 showImplementations();
294 break;
295
288 case KeyEvent.VK_N: 296 case KeyEvent.VK_N:
289 openDeclaration(); 297 openDeclaration();
290 break; 298 break;
@@ -338,6 +346,21 @@ public class Gui
338 m_showInheritanceMenu = menu; 346 m_showInheritanceMenu = menu;
339 } 347 }
340 { 348 {
349 JMenuItem menu = new JMenuItem( "Show Implementations" );
350 menu.addActionListener( new ActionListener( )
351 {
352 @Override
353 public void actionPerformed( ActionEvent event )
354 {
355 showImplementations();
356 }
357 } );
358 menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_M, 0 ) );
359 menu.setEnabled( false );
360 popupMenu.add( menu );
361 m_showImplementationsMenu = menu;
362 }
363 {
341 JMenuItem menu = new JMenuItem( "Show Calls" ); 364 JMenuItem menu = new JMenuItem( "Show Calls" );
342 menu.addActionListener( new ActionListener( ) 365 menu.addActionListener( new ActionListener( )
343 { 366 {
@@ -428,6 +451,41 @@ public class Gui
428 inheritancePanel.setLayout( new BorderLayout() ); 451 inheritancePanel.setLayout( new BorderLayout() );
429 inheritancePanel.add( new JScrollPane( m_inheritanceTree ) ); 452 inheritancePanel.add( new JScrollPane( m_inheritanceTree ) );
430 453
454 // init implementations panel
455 m_implementationsTree = new JTree();
456 m_implementationsTree.setModel( null );
457 m_implementationsTree.addMouseListener( new MouseAdapter( )
458 {
459 @Override
460 public void mouseClicked( MouseEvent event )
461 {
462 if( event.getClickCount() == 2 )
463 {
464 // get the selected node
465 TreePath path = m_implementationsTree.getSelectionPath();
466 if( path == null )
467 {
468 return;
469 }
470
471 Object node = path.getLastPathComponent();
472 if( node instanceof ClassImplementationsTreeNode )
473 {
474 ClassImplementationsTreeNode classNode = (ClassImplementationsTreeNode)node;
475 m_controller.openDeclaration( classNode.getClassEntry() );
476 }
477 else if( node instanceof MethodImplementationsTreeNode )
478 {
479 MethodImplementationsTreeNode methodNode = (MethodImplementationsTreeNode)node;
480 m_controller.openDeclaration( methodNode.getMethodEntry() );
481 }
482 }
483 }
484 } );
485 JPanel implementationsPanel = new JPanel();
486 implementationsPanel.setLayout( new BorderLayout() );
487 implementationsPanel.add( new JScrollPane( m_implementationsTree ) );
488
431 // init call panel 489 // init call panel
432 m_callsTree = new JTree(); 490 m_callsTree = new JTree();
433 m_callsTree.setModel( null ); 491 m_callsTree.setModel( null );
@@ -501,6 +559,7 @@ public class Gui
501 m_tabs = new JTabbedPane(); 559 m_tabs = new JTabbedPane();
502 m_tabs.setPreferredSize( new Dimension( 250, 0 ) ); 560 m_tabs.setPreferredSize( new Dimension( 250, 0 ) );
503 m_tabs.addTab( "Inheritance", inheritancePanel ); 561 m_tabs.addTab( "Inheritance", inheritancePanel );
562 m_tabs.addTab( "Implementations", implementationsPanel );
504 m_tabs.addTab( "Call Graph", callPanel ); 563 m_tabs.addTab( "Call Graph", callPanel );
505 JSplitPane splitRight = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs ); 564 JSplitPane splitRight = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs );
506 splitRight.setResizeWeight( 1 ); // let the left side take all the slack 565 splitRight.setResizeWeight( 1 ); // let the left side take all the slack
@@ -1023,6 +1082,7 @@ public class Gui
1023 1082
1024 m_renameMenu.setEnabled( isToken ); 1083 m_renameMenu.setEnabled( isToken );
1025 m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); 1084 m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry );
1085 m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry );
1026 m_showCallsMenu.setEnabled( isFieldEntry || isMethodEntry || isConstructorEntry ); 1086 m_showCallsMenu.setEnabled( isFieldEntry || isMethodEntry || isConstructorEntry );
1027 m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); 1087 m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry );
1028 m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); 1088 m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() );
@@ -1097,6 +1157,8 @@ public class Gui
1097 return; 1157 return;
1098 } 1158 }
1099 1159
1160 m_inheritanceTree.setModel( null );
1161
1100 if( m_reference.entry instanceof ClassEntry ) 1162 if( m_reference.entry instanceof ClassEntry )
1101 { 1163 {
1102 // get the class inheritance 1164 // get the class inheritance
@@ -1124,6 +1186,46 @@ public class Gui
1124 redraw(); 1186 redraw();
1125 } 1187 }
1126 1188
1189 private void showImplementations( )
1190 {
1191 if( m_reference == null )
1192 {
1193 return;
1194 }
1195
1196 m_implementationsTree.setModel( null );
1197
1198 if( m_reference.entry instanceof ClassEntry )
1199 {
1200 // get the class implementations
1201 ClassImplementationsTreeNode node = m_controller.getClassImplementations( (ClassEntry)m_reference.entry );
1202 if( node != null )
1203 {
1204 // show the tree at the root
1205 TreePath path = getPathToRoot( node );
1206 m_implementationsTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) );
1207 m_implementationsTree.expandPath( path );
1208 m_implementationsTree.setSelectionRow( m_implementationsTree.getRowForPath( path ) );
1209 }
1210 }
1211 else if( m_reference.entry instanceof MethodEntry )
1212 {
1213 // get the method implementations
1214 MethodImplementationsTreeNode node = m_controller.getMethodImplementations( (MethodEntry)m_reference.entry );
1215 if( node != null )
1216 {
1217 // show the tree at the root
1218 TreePath path = getPathToRoot( node );
1219 m_implementationsTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) );
1220 m_implementationsTree.expandPath( path );
1221 m_implementationsTree.setSelectionRow( m_implementationsTree.getRowForPath( path ) );
1222 }
1223 }
1224
1225 m_tabs.setSelectedIndex( 1 );
1226 redraw();
1227 }
1228
1127 private void showCalls( ) 1229 private void showCalls( )
1128 { 1230 {
1129 if( m_reference == null ) 1231 if( m_reference == null )
@@ -1147,7 +1249,7 @@ public class Gui
1147 m_callsTree.setModel( new DefaultTreeModel( node ) ); 1249 m_callsTree.setModel( new DefaultTreeModel( node ) );
1148 } 1250 }
1149 1251
1150 m_tabs.setSelectedIndex( 1 ); 1252 m_tabs.setSelectedIndex( 2 );
1151 redraw(); 1253 redraw();
1152 } 1254 }
1153 1255