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.java52
1 files changed, 43 insertions, 9 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java
index e2ccb7d..57c6ef7 100644
--- a/src/cuchaz/enigma/gui/Gui.java
+++ b/src/cuchaz/enigma/gui/Gui.java
@@ -116,6 +116,7 @@ public class Gui
116 private JMenuItem m_closeMappingsMenu; 116 private JMenuItem m_closeMappingsMenu;
117 private JMenuItem m_renameMenu; 117 private JMenuItem m_renameMenu;
118 private JMenuItem m_inheritanceMenu; 118 private JMenuItem m_inheritanceMenu;
119 private JMenuItem m_openEntryMenu;
119 120
120 // state 121 // state
121 private EntryPair<Entry> m_selectedEntryPair; 122 private EntryPair<Entry> m_selectedEntryPair;
@@ -258,6 +259,19 @@ public class Gui
258 popupMenu.add( menu ); 259 popupMenu.add( menu );
259 m_inheritanceMenu = menu; 260 m_inheritanceMenu = menu;
260 } 261 }
262 {
263 JMenuItem menu = new JMenuItem( "Open Class" );
264 menu.addActionListener( new ActionListener( )
265 {
266 @Override
267 public void actionPerformed( ActionEvent event )
268 {
269 openEntry();
270 }
271 } );
272 popupMenu.add( menu );
273 m_openEntryMenu = menu;
274 }
261 275
262 // init inheritance panel 276 // init inheritance panel
263 m_inheritanceTree = new JTree(); 277 m_inheritanceTree = new JTree();
@@ -693,22 +707,23 @@ public class Gui
693 private void onCaretMove( int pos ) 707 private void onCaretMove( int pos )
694 { 708 {
695 m_selectedEntryPair = m_controller.getEntryPair( pos ); 709 m_selectedEntryPair = m_controller.getEntryPair( pos );
696 if( m_selectedEntryPair != null ) 710
711 boolean isEntry = m_selectedEntryPair != null;
712 boolean isClassEntry = isEntry && m_selectedEntryPair.obf instanceof ClassEntry;
713 boolean isMethodEntry = isEntry && m_selectedEntryPair.obf instanceof MethodEntry;
714
715 if( isEntry )
697 { 716 {
698 showEntryPair( m_selectedEntryPair ); 717 showEntryPair( m_selectedEntryPair );
699
700 boolean isClassEntry = m_selectedEntryPair.obf instanceof ClassEntry;
701 boolean isMethodEntry = m_selectedEntryPair.obf instanceof MethodEntry;
702
703 m_renameMenu.setEnabled( true );
704 m_inheritanceMenu.setEnabled( isClassEntry || isMethodEntry );
705 } 718 }
706 else 719 else
707 { 720 {
708 clearEntryPair(); 721 clearEntryPair();
709 m_renameMenu.setEnabled( false );
710 m_inheritanceMenu.setEnabled( false );
711 } 722 }
723
724 m_renameMenu.setEnabled( isEntry );
725 m_inheritanceMenu.setEnabled( isClassEntry || isMethodEntry );
726 m_openEntryMenu.setEnabled( isClassEntry );
712 } 727 }
713 728
714 private void startRename( ) 729 private void startRename( )
@@ -775,6 +790,11 @@ public class Gui
775 790
776 private void showInheritance( ) 791 private void showInheritance( )
777 { 792 {
793 if( m_selectedEntryPair == null )
794 {
795 return;
796 }
797
778 // get the current class 798 // get the current class
779 if( m_selectedEntryPair.obf instanceof ClassEntry ) 799 if( m_selectedEntryPair.obf instanceof ClassEntry )
780 { 800 {
@@ -800,6 +820,20 @@ public class Gui
800 redraw(); 820 redraw();
801 } 821 }
802 822
823 private void openEntry( )
824 {
825 if( m_selectedEntryPair == null )
826 {
827 return;
828 }
829
830 // get the current class
831 if( m_selectedEntryPair.obf instanceof ClassEntry )
832 {
833 m_controller.deobfuscateClass( new ClassFile( m_selectedEntryPair.obf.getName() ) );
834 }
835 }
836
803 private void close( ) 837 private void close( )
804 { 838 {
805 if( !m_controller.isDirty() ) 839 if( !m_controller.isDirty() )