summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/Gui.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
-rw-r--r--src/cuchaz/enigma/gui/Gui.java84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java
index 7fac02d..1995cb8 100644
--- a/src/cuchaz/enigma/gui/Gui.java
+++ b/src/cuchaz/enigma/gui/Gui.java
@@ -162,11 +162,7 @@ public class Gui
162 @Override 162 @Override
163 public void onSelectClass( ClassEntry classEntry ) 163 public void onSelectClass( ClassEntry classEntry )
164 { 164 {
165 if( m_reference != null ) 165 navigateTo( classEntry );
166 {
167 m_controller.savePreviousReference( m_reference );
168 }
169 m_controller.openDeclaration( classEntry );
170 } 166 }
171 } ); 167 } );
172 JScrollPane obfScroller = new JScrollPane( m_obfClasses ); 168 JScrollPane obfScroller = new JScrollPane( m_obfClasses );
@@ -182,11 +178,7 @@ public class Gui
182 @Override 178 @Override
183 public void onSelectClass( ClassEntry classEntry ) 179 public void onSelectClass( ClassEntry classEntry )
184 { 180 {
185 if( m_reference != null ) 181 navigateTo( classEntry );
186 {
187 m_controller.savePreviousReference( m_reference );
188 }
189 m_controller.openDeclaration( classEntry );
190 } 182 }
191 } ); 183 } );
192 JScrollPane deobfScroller = new JScrollPane( m_deobfClasses ); 184 JScrollPane deobfScroller = new JScrollPane( m_deobfClasses );
@@ -247,7 +239,7 @@ public class Gui
247 break; 239 break;
248 240
249 case KeyEvent.VK_N: 241 case KeyEvent.VK_N:
250 openDeclaration(); 242 navigateTo( m_reference.entry );
251 break; 243 break;
252 244
253 case KeyEvent.VK_P: 245 case KeyEvent.VK_P:
@@ -335,7 +327,7 @@ public class Gui
335 @Override 327 @Override
336 public void actionPerformed( ActionEvent event ) 328 public void actionPerformed( ActionEvent event )
337 { 329 {
338 openDeclaration(); 330 navigateTo( m_reference.entry );
339 } 331 }
340 } ); 332 } );
341 menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, 0 ) ); 333 menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, 0 ) );
@@ -379,22 +371,15 @@ public class Gui
379 Object node = path.getLastPathComponent(); 371 Object node = path.getLastPathComponent();
380 if( node instanceof ClassInheritanceTreeNode ) 372 if( node instanceof ClassInheritanceTreeNode )
381 { 373 {
382 if( m_reference != null ) 374 ClassInheritanceTreeNode classNode = (ClassInheritanceTreeNode)node;
383 { 375 navigateTo( new ClassEntry( classNode.getObfClassName() ) );
384 m_controller.savePreviousReference( m_reference );
385 }
386 m_controller.openDeclaration( new ClassEntry( ((ClassInheritanceTreeNode)node).getObfClassName() ) );
387 } 376 }
388 else if( node instanceof MethodInheritanceTreeNode ) 377 else if( node instanceof MethodInheritanceTreeNode )
389 { 378 {
390 MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; 379 MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node;
391 if( methodNode.isImplemented() ) 380 if( methodNode.isImplemented() )
392 { 381 {
393 if( m_reference != null ) 382 navigateTo( methodNode.getMethodEntry() );
394 {
395 m_controller.savePreviousReference( m_reference );
396 }
397 m_controller.openDeclaration( methodNode.getMethodEntry() );
398 } 383 }
399 } 384 }
400 } 385 }
@@ -425,12 +410,12 @@ public class Gui
425 if( node instanceof ClassImplementationsTreeNode ) 410 if( node instanceof ClassImplementationsTreeNode )
426 { 411 {
427 ClassImplementationsTreeNode classNode = (ClassImplementationsTreeNode)node; 412 ClassImplementationsTreeNode classNode = (ClassImplementationsTreeNode)node;
428 m_controller.openDeclaration( classNode.getClassEntry() ); 413 navigateTo( classNode.getClassEntry() );
429 } 414 }
430 else if( node instanceof MethodImplementationsTreeNode ) 415 else if( node instanceof MethodImplementationsTreeNode )
431 { 416 {
432 MethodImplementationsTreeNode methodNode = (MethodImplementationsTreeNode)node; 417 MethodImplementationsTreeNode methodNode = (MethodImplementationsTreeNode)node;
433 m_controller.openDeclaration( methodNode.getMethodEntry() ); 418 navigateTo( methodNode.getMethodEntry() );
434 } 419 }
435 } 420 }
436 } 421 }
@@ -460,18 +445,14 @@ public class Gui
460 Object node = path.getLastPathComponent(); 445 Object node = path.getLastPathComponent();
461 if( node instanceof ReferenceTreeNode ) 446 if( node instanceof ReferenceTreeNode )
462 { 447 {
463 if( m_reference != null )
464 {
465 m_controller.savePreviousReference( m_reference );
466 }
467 ReferenceTreeNode<Entry,Entry> referenceNode = ((ReferenceTreeNode<Entry,Entry>)node); 448 ReferenceTreeNode<Entry,Entry> referenceNode = ((ReferenceTreeNode<Entry,Entry>)node);
468 if( referenceNode.getReference() != null ) 449 if( referenceNode.getReference() != null )
469 { 450 {
470 m_controller.openReference( referenceNode.getReference() ); 451 navigateTo( referenceNode.getReference() );
471 } 452 }
472 else 453 else
473 { 454 {
474 m_controller.openDeclaration( referenceNode.getEntry() ); 455 navigateTo( referenceNode.getEntry() );
475 } 456 }
476 } 457 }
477 } 458 }
@@ -1028,6 +1009,7 @@ public class Gui
1028 boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; 1009 boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry;
1029 boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; 1010 boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry;
1030 boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; 1011 boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry;
1012 boolean isInJar = isToken && m_controller.entryIsInJar( m_reference.entry.getClassEntry() );
1031 1013
1032 if( isToken ) 1014 if( isToken )
1033 { 1015 {
@@ -1038,14 +1020,42 @@ public class Gui
1038 clearReference(); 1020 clearReference();
1039 } 1021 }
1040 1022
1041 m_renameMenu.setEnabled( isToken ); 1023 m_renameMenu.setEnabled( isInJar && isToken );
1042 m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); 1024 m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry );
1043 m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry ); 1025 m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry );
1044 m_showCallsMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); 1026 m_showCallsMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry );
1045 m_openEntryMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); 1027 m_openEntryMenu.setEnabled( isInJar && ( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ) );
1046 m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); 1028 m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() );
1047 } 1029 }
1048 1030
1031 private void navigateTo( Entry entry )
1032 {
1033 if( !m_controller.entryIsInJar( entry ) )
1034 {
1035 // entry is not in the jar. Ignore it
1036 return;
1037 }
1038 if( m_reference != null )
1039 {
1040 m_controller.savePreviousReference( m_reference );
1041 }
1042 m_controller.openDeclaration( entry );
1043 }
1044
1045 private void navigateTo( EntryReference<Entry,Entry> reference )
1046 {
1047 if( !m_controller.entryIsInJar( reference.getClassEntry() ) )
1048 {
1049 // reference is not in the jar. Ignore it
1050 return;
1051 }
1052 if( m_reference != null )
1053 {
1054 m_controller.savePreviousReference( m_reference );
1055 }
1056 m_controller.openReference( reference );
1057 }
1058
1049 private void startRename( ) 1059 private void startRename( )
1050 { 1060 {
1051 // init the text box 1061 // init the text box
@@ -1232,16 +1242,6 @@ public class Gui
1232 return new TreePath( nodes.toArray() ); 1242 return new TreePath( nodes.toArray() );
1233 } 1243 }
1234 1244
1235 private void openDeclaration( )
1236 {
1237 if( m_reference == null )
1238 {
1239 return;
1240 }
1241 m_controller.savePreviousReference( m_reference );
1242 m_controller.openDeclaration( m_reference.entry );
1243 }
1244
1245 private void close( ) 1245 private void close( )
1246 { 1246 {
1247 if( !m_controller.isDirty() ) 1247 if( !m_controller.isDirty() )