diff options
| author | 2014-08-11 00:02:00 -0400 | |
|---|---|---|
| committer | 2014-08-11 00:02:00 -0400 | |
| commit | bba7c6a19c15bc82946176c79a4eba3612b25f17 (patch) | |
| tree | f0b55befaa6e7e532e9728dfa6b1c9cb36660594 /src/cuchaz/enigma/gui/Gui.java | |
| parent | added backwards navigation (diff) | |
| download | enigma-fork-bba7c6a19c15bc82946176c79a4eba3612b25f17.tar.gz enigma-fork-bba7c6a19c15bc82946176c79a4eba3612b25f17.tar.xz enigma-fork-bba7c6a19c15bc82946176c79a4eba3612b25f17.zip | |
added method inheritance browsing
also finally fixed method renamer to rename all method implementations in the inheritance hierarchy.
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 62f2391..db67677 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -66,6 +66,8 @@ import jsyntaxpane.DefaultSyntaxKit; | |||
| 66 | import com.google.common.collect.Lists; | 66 | import com.google.common.collect.Lists; |
| 67 | 67 | ||
| 68 | import cuchaz.enigma.Constants; | 68 | import cuchaz.enigma.Constants; |
| 69 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | ||
| 70 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | ||
| 69 | import cuchaz.enigma.analysis.Token; | 71 | import cuchaz.enigma.analysis.Token; |
| 70 | import cuchaz.enigma.mapping.ArgumentEntry; | 72 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 71 | import cuchaz.enigma.mapping.ClassEntry; | 73 | import cuchaz.enigma.mapping.ClassEntry; |
| @@ -343,10 +345,24 @@ public class Gui | |||
| 343 | { | 345 | { |
| 344 | if( event.getClickCount() == 2 ) | 346 | if( event.getClickCount() == 2 ) |
| 345 | { | 347 | { |
| 346 | ClassInheritanceTreeNode node = (ClassInheritanceTreeNode)m_inheritanceTree.getSelectionPath().getLastPathComponent(); | 348 | // get the selected node |
| 347 | if( node != null ) | 349 | Object node = m_inheritanceTree.getSelectionPath().getLastPathComponent(); |
| 350 | if( node == null ) | ||
| 348 | { | 351 | { |
| 349 | m_controller.openEntry( new ClassEntry( node.getObfClassName() ) ); | 352 | return; |
| 353 | } | ||
| 354 | |||
| 355 | if( node instanceof ClassInheritanceTreeNode ) | ||
| 356 | { | ||
| 357 | m_controller.openEntry( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) ); | ||
| 358 | } | ||
| 359 | else if( node instanceof MethodInheritanceTreeNode ) | ||
| 360 | { | ||
| 361 | MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; | ||
| 362 | if( methodNode.isImplemented() ) | ||
| 363 | { | ||
| 364 | m_controller.openEntry( methodNode.getMethodEntry() ); | ||
| 365 | } | ||
| 350 | } | 366 | } |
| 351 | } | 367 | } |
| 352 | } | 368 | } |
| @@ -836,31 +852,46 @@ public class Gui | |||
| 836 | return; | 852 | return; |
| 837 | } | 853 | } |
| 838 | 854 | ||
| 839 | // get the current class | ||
| 840 | if( m_selectedEntryPair.obf instanceof ClassEntry ) | 855 | if( m_selectedEntryPair.obf instanceof ClassEntry ) |
| 841 | { | 856 | { |
| 857 | // get the class inheritance | ||
| 842 | ClassInheritanceTreeNode classNode = m_controller.getClassInheritance( (ClassEntry)m_selectedEntryPair.obf ); | 858 | ClassInheritanceTreeNode classNode = m_controller.getClassInheritance( (ClassEntry)m_selectedEntryPair.obf ); |
| 843 | 859 | ||
| 844 | // build the path from the root to the class node | 860 | // show the tree at the root |
| 845 | List<TreeNode> nodes = Lists.newArrayList(); | 861 | TreePath path = getPathToRoot( classNode ); |
| 846 | TreeNode node = classNode; | 862 | m_inheritanceTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); |
| 847 | do | 863 | m_inheritanceTree.expandPath( path ); |
| 848 | { | 864 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); |
| 849 | nodes.add( node ); | 865 | } |
| 850 | node = node.getParent(); | 866 | else if( m_selectedEntryPair.obf instanceof MethodEntry ) |
| 851 | } | 867 | { |
| 852 | while( node != null ); | 868 | // get the method inheritance |
| 853 | Collections.reverse( nodes ); | 869 | MethodInheritanceTreeNode classNode = m_controller.getMethodInheritance( (MethodEntry)m_selectedEntryPair.obf ); |
| 854 | TreePath path = new TreePath( nodes.toArray() ); | ||
| 855 | 870 | ||
| 856 | // show the tree at the root | 871 | // show the tree at the root |
| 872 | TreePath path = getPathToRoot( classNode ); | ||
| 857 | m_inheritanceTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); | 873 | m_inheritanceTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); |
| 858 | m_inheritanceTree.expandPath( path ); | 874 | m_inheritanceTree.expandPath( path ); |
| 859 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); | 875 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); |
| 860 | } | 876 | } |
| 877 | |||
| 861 | redraw(); | 878 | redraw(); |
| 862 | } | 879 | } |
| 863 | 880 | ||
| 881 | private TreePath getPathToRoot( TreeNode node ) | ||
| 882 | { | ||
| 883 | List<TreeNode> nodes = Lists.newArrayList(); | ||
| 884 | TreeNode n = node; | ||
| 885 | do | ||
| 886 | { | ||
| 887 | nodes.add( n ); | ||
| 888 | n = n.getParent(); | ||
| 889 | } | ||
| 890 | while( n != null ); | ||
| 891 | Collections.reverse( nodes ); | ||
| 892 | return new TreePath( nodes.toArray() ); | ||
| 893 | } | ||
| 894 | |||
| 864 | private void openEntry( ) | 895 | private void openEntry( ) |
| 865 | { | 896 | { |
| 866 | if( m_selectedEntryPair == null ) | 897 | if( m_selectedEntryPair == null ) |