diff options
| author | 2014-08-19 00:25:32 -0400 | |
|---|---|---|
| committer | 2014-08-19 00:25:32 -0400 | |
| commit | c4e35f2d516ade27e8e1a863b4bc356f182f43c2 (patch) | |
| tree | 6711cde39dcfaea30520b8ccabb6236872e0d756 /src/cuchaz/enigma/gui | |
| parent | fixed type caching after rename (diff) | |
| download | enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.tar.gz enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.tar.xz enigma-fork-c4e35f2d516ade27e8e1a863b4bc356f182f43c2.zip | |
started new reference navigation system
Diffstat (limited to 'src/cuchaz/enigma/gui')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 46 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 65 |
2 files changed, 57 insertions, 54 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index 9ed6dd8..43a0cda 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -66,10 +66,11 @@ 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.BehaviorReferenceTreeNode; | ||
| 69 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | 70 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; |
| 70 | import cuchaz.enigma.analysis.FieldCallsTreeNode; | 71 | import cuchaz.enigma.analysis.FieldReferenceTreeNode; |
| 71 | import cuchaz.enigma.analysis.MethodCallsTreeNode; | ||
| 72 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | 72 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; |
| 73 | import cuchaz.enigma.analysis.ReferenceTreeNode; | ||
| 73 | import cuchaz.enigma.analysis.Token; | 74 | import cuchaz.enigma.analysis.Token; |
| 74 | import cuchaz.enigma.mapping.ArgumentEntry; | 75 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 75 | import cuchaz.enigma.mapping.ClassEntry; | 76 | import cuchaz.enigma.mapping.ClassEntry; |
| @@ -191,7 +192,7 @@ public class Gui | |||
| 191 | String selected = m_obfClasses.getSelectedValue(); | 192 | String selected = m_obfClasses.getSelectedValue(); |
| 192 | if( selected != null ) | 193 | if( selected != null ) |
| 193 | { | 194 | { |
| 194 | m_controller.openEntry( new ClassEntry( selected ) ); | 195 | m_controller.openDeclaration( new ClassEntry( selected ) ); |
| 195 | } | 196 | } |
| 196 | } | 197 | } |
| 197 | } | 198 | } |
| @@ -217,7 +218,7 @@ public class Gui | |||
| 217 | String selected = m_deobfClasses.getSelectedValue(); | 218 | String selected = m_deobfClasses.getSelectedValue(); |
| 218 | if( selected != null ) | 219 | if( selected != null ) |
| 219 | { | 220 | { |
| 220 | m_controller.openEntry( new ClassEntry( selected ) ); | 221 | m_controller.openDeclaration( new ClassEntry( selected ) ); |
| 221 | } | 222 | } |
| 222 | } | 223 | } |
| 223 | } | 224 | } |
| @@ -268,11 +269,11 @@ public class Gui | |||
| 268 | break; | 269 | break; |
| 269 | 270 | ||
| 270 | case KeyEvent.VK_N: | 271 | case KeyEvent.VK_N: |
| 271 | openEntry(); | 272 | openDeclaration(); |
| 272 | break; | 273 | break; |
| 273 | 274 | ||
| 274 | case KeyEvent.VK_P: | 275 | case KeyEvent.VK_P: |
| 275 | m_controller.openPreviousEntry(); | 276 | m_controller.openPreviousLocation(); |
| 276 | break; | 277 | break; |
| 277 | 278 | ||
| 278 | case KeyEvent.VK_C: | 279 | case KeyEvent.VK_C: |
| @@ -341,7 +342,7 @@ public class Gui | |||
| 341 | @Override | 342 | @Override |
| 342 | public void actionPerformed( ActionEvent event ) | 343 | public void actionPerformed( ActionEvent event ) |
| 343 | { | 344 | { |
| 344 | openEntry(); | 345 | openDeclaration(); |
| 345 | } | 346 | } |
| 346 | } ); | 347 | } ); |
| 347 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, 0 ) ); | 348 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, 0 ) ); |
| @@ -356,7 +357,7 @@ public class Gui | |||
| 356 | @Override | 357 | @Override |
| 357 | public void actionPerformed( ActionEvent event ) | 358 | public void actionPerformed( ActionEvent event ) |
| 358 | { | 359 | { |
| 359 | m_controller.openPreviousEntry(); | 360 | m_controller.openPreviousLocation(); |
| 360 | } | 361 | } |
| 361 | } ); | 362 | } ); |
| 362 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_P, 0 ) ); | 363 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_P, 0 ) ); |
| @@ -385,14 +386,14 @@ public class Gui | |||
| 385 | Object node = path.getLastPathComponent(); | 386 | Object node = path.getLastPathComponent(); |
| 386 | if( node instanceof ClassInheritanceTreeNode ) | 387 | if( node instanceof ClassInheritanceTreeNode ) |
| 387 | { | 388 | { |
| 388 | m_controller.openEntry( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) ); | 389 | m_controller.openDeclaration( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) ); |
| 389 | } | 390 | } |
| 390 | else if( node instanceof MethodInheritanceTreeNode ) | 391 | else if( node instanceof MethodInheritanceTreeNode ) |
| 391 | { | 392 | { |
| 392 | MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; | 393 | MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; |
| 393 | if( methodNode.isImplemented() ) | 394 | if( methodNode.isImplemented() ) |
| 394 | { | 395 | { |
| 395 | m_controller.openEntry( methodNode.getMethodEntry() ); | 396 | m_controller.openDeclaration( methodNode.getMethodEntry() ); |
| 396 | } | 397 | } |
| 397 | } | 398 | } |
| 398 | } | 399 | } |
| @@ -407,6 +408,7 @@ public class Gui | |||
| 407 | m_callsTree.setModel( null ); | 408 | m_callsTree.setModel( null ); |
| 408 | m_callsTree.addMouseListener( new MouseAdapter( ) | 409 | m_callsTree.addMouseListener( new MouseAdapter( ) |
| 409 | { | 410 | { |
| 411 | @SuppressWarnings( "unchecked" ) | ||
| 410 | @Override | 412 | @Override |
| 411 | public void mouseClicked( MouseEvent event ) | 413 | public void mouseClicked( MouseEvent event ) |
| 412 | { | 414 | { |
| @@ -420,9 +422,17 @@ public class Gui | |||
| 420 | } | 422 | } |
| 421 | 423 | ||
| 422 | Object node = path.getLastPathComponent(); | 424 | Object node = path.getLastPathComponent(); |
| 423 | if( node instanceof MethodCallsTreeNode ) | 425 | if( node instanceof ReferenceTreeNode ) |
| 424 | { | 426 | { |
| 425 | m_controller.openEntry( ((MethodCallsTreeNode)node).getEntry() ); | 427 | ReferenceTreeNode<Entry> referenceNode = ((ReferenceTreeNode<Entry>)node); |
| 428 | if( referenceNode.getReference() != null ) | ||
| 429 | { | ||
| 430 | m_controller.openReference( referenceNode.getReference() ); | ||
| 431 | } | ||
| 432 | else | ||
| 433 | { | ||
| 434 | m_controller.openDeclaration( referenceNode.getEntry() ); | ||
| 435 | } | ||
| 426 | } | 436 | } |
| 427 | } | 437 | } |
| 428 | } | 438 | } |
| @@ -862,7 +872,7 @@ public class Gui | |||
| 862 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); | 872 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); |
| 863 | m_showCallsMenu.setEnabled( isFieldEntry || isMethodEntry || isConstructorEntry ); | 873 | m_showCallsMenu.setEnabled( isFieldEntry || isMethodEntry || isConstructorEntry ); |
| 864 | m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); | 874 | m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); |
| 865 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousEntry() ); | 875 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); |
| 866 | } | 876 | } |
| 867 | 877 | ||
| 868 | private void startRename( ) | 878 | private void startRename( ) |
| @@ -977,17 +987,17 @@ public class Gui | |||
| 977 | 987 | ||
| 978 | if( m_selectedEntryPair.obf instanceof FieldEntry ) | 988 | if( m_selectedEntryPair.obf instanceof FieldEntry ) |
| 979 | { | 989 | { |
| 980 | FieldCallsTreeNode node = m_controller.getFieldCalls( (FieldEntry)m_selectedEntryPair.obf ); | 990 | FieldReferenceTreeNode node = m_controller.getFieldReferences( (FieldEntry)m_selectedEntryPair.obf ); |
| 981 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | 991 | m_callsTree.setModel( new DefaultTreeModel( node ) ); |
| 982 | } | 992 | } |
| 983 | else if( m_selectedEntryPair.obf instanceof MethodEntry ) | 993 | else if( m_selectedEntryPair.obf instanceof MethodEntry ) |
| 984 | { | 994 | { |
| 985 | MethodCallsTreeNode node = m_controller.getMethodCalls( (MethodEntry)m_selectedEntryPair.obf ); | 995 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences( (MethodEntry)m_selectedEntryPair.obf ); |
| 986 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | 996 | m_callsTree.setModel( new DefaultTreeModel( node ) ); |
| 987 | } | 997 | } |
| 988 | else if( m_selectedEntryPair.obf instanceof ConstructorEntry ) | 998 | else if( m_selectedEntryPair.obf instanceof ConstructorEntry ) |
| 989 | { | 999 | { |
| 990 | MethodCallsTreeNode node = m_controller.getMethodCalls( (ConstructorEntry)m_selectedEntryPair.obf ); | 1000 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences( (ConstructorEntry)m_selectedEntryPair.obf ); |
| 991 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | 1001 | m_callsTree.setModel( new DefaultTreeModel( node ) ); |
| 992 | } | 1002 | } |
| 993 | 1003 | ||
| @@ -1009,13 +1019,13 @@ public class Gui | |||
| 1009 | return new TreePath( nodes.toArray() ); | 1019 | return new TreePath( nodes.toArray() ); |
| 1010 | } | 1020 | } |
| 1011 | 1021 | ||
| 1012 | private void openEntry( ) | 1022 | private void openDeclaration( ) |
| 1013 | { | 1023 | { |
| 1014 | if( m_selectedEntryPair == null ) | 1024 | if( m_selectedEntryPair == null ) |
| 1015 | { | 1025 | { |
| 1016 | return; | 1026 | return; |
| 1017 | } | 1027 | } |
| 1018 | m_controller.openEntry( m_selectedEntryPair.obf ); | 1028 | m_controller.openDeclaration( m_selectedEntryPair.obf ); |
| 1019 | } | 1029 | } |
| 1020 | 1030 | ||
| 1021 | private void close( ) | 1031 | private void close( ) |
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index f305e34..f80bec7 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -20,14 +20,15 @@ import java.util.Stack; | |||
| 20 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
| 21 | 21 | ||
| 22 | import cuchaz.enigma.Deobfuscator; | 22 | import cuchaz.enigma.Deobfuscator; |
| 23 | import cuchaz.enigma.analysis.BehaviorReferenceTreeNode; | ||
| 23 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; | 24 | import cuchaz.enigma.analysis.ClassInheritanceTreeNode; |
| 24 | import cuchaz.enigma.analysis.FieldCallsTreeNode; | 25 | import cuchaz.enigma.analysis.EntryReference; |
| 25 | import cuchaz.enigma.analysis.MethodCallsTreeNode; | 26 | import cuchaz.enigma.analysis.FieldReferenceTreeNode; |
| 26 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | 27 | import cuchaz.enigma.analysis.MethodInheritanceTreeNode; |
| 27 | import cuchaz.enigma.analysis.SourceIndex; | 28 | import cuchaz.enigma.analysis.SourceIndex; |
| 28 | import cuchaz.enigma.analysis.Token; | 29 | import cuchaz.enigma.analysis.Token; |
| 30 | import cuchaz.enigma.mapping.BehaviorEntry; | ||
| 29 | import cuchaz.enigma.mapping.ClassEntry; | 31 | import cuchaz.enigma.mapping.ClassEntry; |
| 30 | import cuchaz.enigma.mapping.ConstructorEntry; | ||
| 31 | import cuchaz.enigma.mapping.Entry; | 32 | import cuchaz.enigma.mapping.Entry; |
| 32 | import cuchaz.enigma.mapping.EntryPair; | 33 | import cuchaz.enigma.mapping.EntryPair; |
| 33 | import cuchaz.enigma.mapping.FieldEntry; | 34 | import cuchaz.enigma.mapping.FieldEntry; |
| @@ -44,7 +45,7 @@ public class GuiController | |||
| 44 | private SourceIndex m_index; | 45 | private SourceIndex m_index; |
| 45 | private ClassEntry m_currentClass; | 46 | private ClassEntry m_currentClass; |
| 46 | private boolean m_isDirty; | 47 | private boolean m_isDirty; |
| 47 | private Stack<Entry> m_entryStack; | 48 | private Stack<Entry> m_locationStack; // TODO: make a location class, can be either Entry or EntryReference |
| 48 | 49 | ||
| 49 | public GuiController( Gui gui ) | 50 | public GuiController( Gui gui ) |
| 50 | { | 51 | { |
| @@ -53,7 +54,7 @@ public class GuiController | |||
| 53 | m_index = null; | 54 | m_index = null; |
| 54 | m_currentClass = null; | 55 | m_currentClass = null; |
| 55 | m_isDirty = false; | 56 | m_isDirty = false; |
| 56 | m_entryStack = new Stack<Entry>(); | 57 | m_locationStack = new Stack<Entry>(); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | public boolean isDirty( ) | 60 | public boolean isDirty( ) |
| @@ -157,9 +158,9 @@ public class GuiController | |||
| 157 | return MethodInheritanceTreeNode.findNode( rootNode, obfMethodEntry ); | 158 | return MethodInheritanceTreeNode.findNode( rootNode, obfMethodEntry ); |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | public FieldCallsTreeNode getFieldCalls( FieldEntry obfFieldEntry ) | 161 | public FieldReferenceTreeNode getFieldReferences( FieldEntry obfFieldEntry ) |
| 161 | { | 162 | { |
| 162 | FieldCallsTreeNode rootNode = new FieldCallsTreeNode( | 163 | FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode( |
| 163 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | 164 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 164 | obfFieldEntry | 165 | obfFieldEntry |
| 165 | ); | 166 | ); |
| @@ -167,27 +168,12 @@ public class GuiController | |||
| 167 | return rootNode; | 168 | return rootNode; |
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | public MethodCallsTreeNode getMethodCalls( Entry obfEntry ) | 171 | public BehaviorReferenceTreeNode getMethodReferences( BehaviorEntry obfEntry ) |
| 171 | { | 172 | { |
| 172 | MethodCallsTreeNode rootNode; | 173 | BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode( |
| 173 | if( obfEntry instanceof MethodEntry ) | 174 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), |
| 174 | { | 175 | obfEntry |
| 175 | rootNode = new MethodCallsTreeNode( | 176 | ); |
| 176 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | ||
| 177 | (MethodEntry)obfEntry | ||
| 178 | ); | ||
| 179 | } | ||
| 180 | else if( obfEntry instanceof ConstructorEntry ) | ||
| 181 | { | ||
| 182 | rootNode = new MethodCallsTreeNode( | ||
| 183 | m_deobfuscator.getTranslator( TranslationDirection.Deobfuscating ), | ||
| 184 | (ConstructorEntry)obfEntry | ||
| 185 | ); | ||
| 186 | } | ||
| 187 | else | ||
| 188 | { | ||
| 189 | throw new IllegalArgumentException( "entry must be a MethodEntry or a ConstructorEntry!" ); | ||
| 190 | } | ||
| 191 | rootNode.load( m_deobfuscator.getJarIndex(), true ); | 177 | rootNode.load( m_deobfuscator.getJarIndex(), true ); |
| 192 | return rootNode; | 178 | return rootNode; |
| 193 | } | 179 | } |
| @@ -200,7 +186,7 @@ public class GuiController | |||
| 200 | refreshCurrentClass( obfEntry ); | 186 | refreshCurrentClass( obfEntry ); |
| 201 | } | 187 | } |
| 202 | 188 | ||
| 203 | public void openEntry( Entry entry ) | 189 | public void openDeclaration( Entry entry ) |
| 204 | { | 190 | { |
| 205 | // go to the entry | 191 | // go to the entry |
| 206 | Entry obfEntry = m_deobfuscator.obfuscateEntry( entry ); | 192 | Entry obfEntry = m_deobfuscator.obfuscateEntry( entry ); |
| @@ -214,25 +200,32 @@ public class GuiController | |||
| 214 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntry ) ) ); | 200 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntry ) ) ); |
| 215 | } | 201 | } |
| 216 | 202 | ||
| 217 | if( m_entryStack.isEmpty() || !m_entryStack.peek().equals( obfEntry ) ) | 203 | if( m_locationStack.isEmpty() || !m_locationStack.peek().equals( obfEntry ) ) |
| 218 | { | 204 | { |
| 219 | // update the stack | 205 | // update the stack |
| 220 | m_entryStack.push( obfEntry ); | 206 | m_locationStack.push( obfEntry ); |
| 221 | } | 207 | } |
| 222 | } | 208 | } |
| 223 | 209 | ||
| 224 | public void openPreviousEntry( ) | 210 | public void openReference( EntryReference<Entry> reference ) |
| 211 | { | ||
| 212 | // TODO: find out how to load the n-th reference in a caller | ||
| 213 | // TEMP: just go to the caller for now | ||
| 214 | openDeclaration( reference.caller ); | ||
| 215 | } | ||
| 216 | |||
| 217 | public void openPreviousLocation( ) | ||
| 225 | { | 218 | { |
| 226 | if( hasPreviousEntry() ) | 219 | if( hasPreviousLocation() ) |
| 227 | { | 220 | { |
| 228 | m_entryStack.pop(); | 221 | m_locationStack.pop(); |
| 229 | openEntry( m_entryStack.peek() ); | 222 | openDeclaration( m_locationStack.peek() ); |
| 230 | } | 223 | } |
| 231 | } | 224 | } |
| 232 | 225 | ||
| 233 | public boolean hasPreviousEntry( ) | 226 | public boolean hasPreviousLocation( ) |
| 234 | { | 227 | { |
| 235 | return m_entryStack.size() > 1; | 228 | return m_locationStack.size() > 1; |
| 236 | } | 229 | } |
| 237 | 230 | ||
| 238 | private void refreshClasses( ) | 231 | private void refreshClasses( ) |