diff options
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index d448dc2..3f46b6e 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -20,6 +20,7 @@ import java.awt.event.ActionEvent; | |||
| 20 | import java.awt.event.ActionListener; | 20 | import java.awt.event.ActionListener; |
| 21 | import java.awt.event.MouseAdapter; | 21 | import java.awt.event.MouseAdapter; |
| 22 | import java.awt.event.MouseEvent; | 22 | import java.awt.event.MouseEvent; |
| 23 | import java.io.File; | ||
| 23 | import java.io.IOException; | 24 | import java.io.IOException; |
| 24 | import java.util.Collections; | 25 | import java.util.Collections; |
| 25 | import java.util.Comparator; | 26 | import java.util.Comparator; |
| @@ -54,6 +55,7 @@ import cuchaz.enigma.Constants; | |||
| 54 | import cuchaz.enigma.analysis.SourceIndex; | 55 | import cuchaz.enigma.analysis.SourceIndex; |
| 55 | import cuchaz.enigma.mapping.ArgumentEntry; | 56 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 56 | import cuchaz.enigma.mapping.ClassEntry; | 57 | import cuchaz.enigma.mapping.ClassEntry; |
| 58 | import cuchaz.enigma.mapping.Entry; | ||
| 57 | import cuchaz.enigma.mapping.EntryPair; | 59 | import cuchaz.enigma.mapping.EntryPair; |
| 58 | import cuchaz.enigma.mapping.FieldEntry; | 60 | import cuchaz.enigma.mapping.FieldEntry; |
| 59 | import cuchaz.enigma.mapping.MethodEntry; | 61 | import cuchaz.enigma.mapping.MethodEntry; |
| @@ -101,9 +103,9 @@ public class Gui | |||
| 101 | private JMenuItem m_closeMappingsMenu; | 103 | private JMenuItem m_closeMappingsMenu; |
| 102 | 104 | ||
| 103 | // state | 105 | // state |
| 104 | private EntryPair m_selectedEntryPair; | 106 | private EntryPair<Entry> m_selectedEntryPair; |
| 105 | private JFileChooser m_jarFileChooser; | 107 | private JFileChooser m_jarFileChooser; |
| 106 | private JFileChooser m_mappingFileChooser; | 108 | private JFileChooser m_mappingsFileChooser; |
| 107 | 109 | ||
| 108 | public Gui( ) | 110 | public Gui( ) |
| 109 | { | 111 | { |
| @@ -111,7 +113,7 @@ public class Gui | |||
| 111 | 113 | ||
| 112 | // init file choosers | 114 | // init file choosers |
| 113 | m_jarFileChooser = new JFileChooser(); | 115 | m_jarFileChooser = new JFileChooser(); |
| 114 | m_mappingFileChooser = new JFileChooser(); | 116 | m_mappingsFileChooser = new JFileChooser(); |
| 115 | 117 | ||
| 116 | // init frame | 118 | // init frame |
| 117 | m_frame = new JFrame( Constants.Name ); | 119 | m_frame = new JFrame( Constants.Name ); |
| @@ -279,11 +281,11 @@ public class Gui | |||
| 279 | @Override | 281 | @Override |
| 280 | public void actionPerformed( ActionEvent event ) | 282 | public void actionPerformed( ActionEvent event ) |
| 281 | { | 283 | { |
| 282 | if( m_mappingFileChooser.showOpenDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 284 | if( m_mappingsFileChooser.showOpenDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) |
| 283 | { | 285 | { |
| 284 | try | 286 | try |
| 285 | { | 287 | { |
| 286 | m_controller.openMappings( m_mappingFileChooser.getSelectedFile() ); | 288 | m_controller.openMappings( m_mappingsFileChooser.getSelectedFile() ); |
| 287 | } | 289 | } |
| 288 | catch( IOException ex ) | 290 | catch( IOException ex ) |
| 289 | { | 291 | { |
| @@ -304,7 +306,7 @@ public class Gui | |||
| 304 | { | 306 | { |
| 305 | try | 307 | try |
| 306 | { | 308 | { |
| 307 | m_controller.saveMappings( m_mappingFileChooser.getSelectedFile() ); | 309 | m_controller.saveMappings( m_mappingsFileChooser.getSelectedFile() ); |
| 308 | } | 310 | } |
| 309 | catch( IOException ex ) | 311 | catch( IOException ex ) |
| 310 | { | 312 | { |
| @@ -322,11 +324,11 @@ public class Gui | |||
| 322 | @Override | 324 | @Override |
| 323 | public void actionPerformed( ActionEvent event ) | 325 | public void actionPerformed( ActionEvent event ) |
| 324 | { | 326 | { |
| 325 | if( m_mappingFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 327 | if( m_mappingsFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) |
| 326 | { | 328 | { |
| 327 | try | 329 | try |
| 328 | { | 330 | { |
| 329 | m_controller.saveMappings( m_mappingFileChooser.getSelectedFile() ); | 331 | m_controller.saveMappings( m_mappingsFileChooser.getSelectedFile() ); |
| 330 | m_saveMappingsMenu.setEnabled( true ); | 332 | m_saveMappingsMenu.setEnabled( true ); |
| 331 | } | 333 | } |
| 332 | catch( IOException ex ) | 334 | catch( IOException ex ) |
| @@ -440,9 +442,10 @@ public class Gui | |||
| 440 | } | 442 | } |
| 441 | } | 443 | } |
| 442 | 444 | ||
| 443 | public void setMappingsLoaded( boolean isLoaded ) | 445 | public void setMappingsFile( File file ) |
| 444 | { | 446 | { |
| 445 | m_saveMappingsMenu.setEnabled( isLoaded ); | 447 | m_mappingsFileChooser.setSelectedFile( file ); |
| 448 | m_saveMappingsMenu.setEnabled( file != null ); | ||
| 446 | } | 449 | } |
| 447 | 450 | ||
| 448 | public void setSource( String source ) | 451 | public void setSource( String source ) |
| @@ -493,7 +496,8 @@ public class Gui | |||
| 493 | redraw(); | 496 | redraw(); |
| 494 | } | 497 | } |
| 495 | 498 | ||
| 496 | private void showEntryPair( EntryPair pair ) | 499 | @SuppressWarnings( "unchecked" ) |
| 500 | private void showEntryPair( EntryPair<Entry> pair ) | ||
| 497 | { | 501 | { |
| 498 | if( pair == null ) | 502 | if( pair == null ) |
| 499 | { | 503 | { |
| @@ -514,19 +518,19 @@ public class Gui | |||
| 514 | m_actionPanel.add( dynamicPanel ); | 518 | m_actionPanel.add( dynamicPanel ); |
| 515 | if( pair.deobf instanceof ClassEntry ) | 519 | if( pair.deobf instanceof ClassEntry ) |
| 516 | { | 520 | { |
| 517 | showEntry( (ClassEntry)pair.deobf, dynamicPanel ); | 521 | showClassEntryPair( (EntryPair<? extends ClassEntry>)pair, dynamicPanel ); |
| 518 | } | 522 | } |
| 519 | else if( pair.deobf instanceof FieldEntry ) | 523 | else if( pair.deobf instanceof FieldEntry ) |
| 520 | { | 524 | { |
| 521 | showEntry( (FieldEntry)pair.deobf, dynamicPanel ); | 525 | showFieldEntryPair( (EntryPair<? extends FieldEntry>)pair, dynamicPanel ); |
| 522 | } | 526 | } |
| 523 | else if( pair.deobf instanceof MethodEntry ) | 527 | else if( pair.deobf instanceof MethodEntry ) |
| 524 | { | 528 | { |
| 525 | showEntry( (MethodEntry)pair.deobf, dynamicPanel ); | 529 | showMethodEntryPair( (EntryPair<? extends MethodEntry>)pair, dynamicPanel ); |
| 526 | } | 530 | } |
| 527 | else if( pair.deobf instanceof ArgumentEntry ) | 531 | else if( pair.deobf instanceof ArgumentEntry ) |
| 528 | { | 532 | { |
| 529 | showEntry( (ArgumentEntry)pair.deobf, dynamicPanel ); | 533 | showArgumentEntryPair( (EntryPair<? extends ArgumentEntry>)pair, dynamicPanel ); |
| 530 | } | 534 | } |
| 531 | else | 535 | else |
| 532 | { | 536 | { |
| @@ -536,30 +540,30 @@ public class Gui | |||
| 536 | redraw(); | 540 | redraw(); |
| 537 | } | 541 | } |
| 538 | 542 | ||
| 539 | private void showEntry( ClassEntry entry, JPanel panel ) | 543 | private void showClassEntryPair( EntryPair<? extends ClassEntry> pair, JPanel panel ) |
| 540 | { | 544 | { |
| 541 | m_typeLabel.setText( "Class: " ); | 545 | m_typeLabel.setText( "Class: " ); |
| 542 | } | 546 | } |
| 543 | 547 | ||
| 544 | private void showEntry( FieldEntry entry, JPanel panel ) | 548 | private void showFieldEntryPair( EntryPair<? extends FieldEntry> pair, JPanel panel ) |
| 545 | { | 549 | { |
| 546 | m_typeLabel.setText( "Field: " ); | 550 | m_typeLabel.setText( "Field: " ); |
| 547 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); | 551 | addNameValue( panel, "Class", pair.obf.getClassEntry().getName() + " <-> " + pair.deobf.getClassEntry().getName() ); |
| 548 | } | 552 | } |
| 549 | 553 | ||
| 550 | private void showEntry( MethodEntry entry, JPanel panel ) | 554 | private void showMethodEntryPair( EntryPair<? extends MethodEntry> pair, JPanel panel ) |
| 551 | { | 555 | { |
| 552 | m_typeLabel.setText( "Method: " ); | 556 | m_typeLabel.setText( "Method: " ); |
| 553 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); | 557 | addNameValue( panel, "Class", pair.obf.getClassEntry().getName() + " <-> " + pair.deobf.getClassEntry().getName() ); |
| 554 | addNameValue( panel, "Signature", entry.getSignature() ); | 558 | addNameValue( panel, "Signature", pair.obf.getSignature() + " <-> " + pair.deobf.getSignature() ); |
| 555 | } | 559 | } |
| 556 | 560 | ||
| 557 | private void showEntry( ArgumentEntry entry, JPanel panel ) | 561 | private void showArgumentEntryPair( EntryPair<? extends ArgumentEntry> pair, JPanel panel ) |
| 558 | { | 562 | { |
| 559 | m_typeLabel.setText( "Argument: " ); | 563 | m_typeLabel.setText( "Argument: " ); |
| 560 | addNameValue( panel, "Class", entry.getMethodEntry().getClassEntry().getName() ); | 564 | addNameValue( panel, "Class", pair.obf.getClassEntry().getName() + " <-> " + pair.deobf.getClassEntry().getName() ); |
| 561 | addNameValue( panel, "Method", entry.getMethodEntry().getName() ); | 565 | addNameValue( panel, "Method", pair.obf.getMethodEntry().getName() + " <-> " + pair.deobf.getMethodEntry().getName() ); |
| 562 | addNameValue( panel, "Index", Integer.toString( entry.getIndex() ) ); | 566 | addNameValue( panel, "Index", Integer.toString( pair.obf.getIndex() ) ); |
| 563 | } | 567 | } |
| 564 | 568 | ||
| 565 | private void addNameValue( JPanel container, String name, String value ) | 569 | private void addNameValue( JPanel container, String name, String value ) |