diff options
| author | 2014-07-27 22:33:21 -0400 | |
|---|---|---|
| committer | 2014-07-27 22:33:21 -0400 | |
| commit | d7321b5b0d38c575e54c770f7aa18dacbacab3c8 (patch) | |
| tree | ef4b3e0f83b1fe89125c2674fec023871e70c0d8 /src/cuchaz/enigma/gui/Gui.java | |
| parent | made gui responsive to caret position and show identifier info (diff) | |
| download | enigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.tar.gz enigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.tar.xz enigma-fork-d7321b5b0d38c575e54c770f7aa18dacbacab3c8.zip | |
added identifier renaming capability
copied some code over from M3L to handle the heavy bytecode magic.
It's ok... M3L will eventually depend on Enigma.
Completely restructured the mappings though. This way is better. =)
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index d1a3cb2..2a539a3 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -45,7 +45,7 @@ import cuchaz.enigma.ClassFile; | |||
| 45 | import cuchaz.enigma.analysis.SourceIndex; | 45 | import cuchaz.enigma.analysis.SourceIndex; |
| 46 | import cuchaz.enigma.mapping.ArgumentEntry; | 46 | import cuchaz.enigma.mapping.ArgumentEntry; |
| 47 | import cuchaz.enigma.mapping.ClassEntry; | 47 | import cuchaz.enigma.mapping.ClassEntry; |
| 48 | import cuchaz.enigma.mapping.Entry; | 48 | import cuchaz.enigma.mapping.EntryPair; |
| 49 | import cuchaz.enigma.mapping.FieldEntry; | 49 | import cuchaz.enigma.mapping.FieldEntry; |
| 50 | import cuchaz.enigma.mapping.MethodEntry; | 50 | import cuchaz.enigma.mapping.MethodEntry; |
| 51 | 51 | ||
| @@ -69,7 +69,7 @@ public class Gui | |||
| 69 | private RenameListener m_renameListener; | 69 | private RenameListener m_renameListener; |
| 70 | 70 | ||
| 71 | private BoxHighlightPainter m_highlightPainter; | 71 | private BoxHighlightPainter m_highlightPainter; |
| 72 | private Entry m_selectedEntry; | 72 | private EntryPair m_selectedEntryPair; |
| 73 | 73 | ||
| 74 | public Gui( ) | 74 | public Gui( ) |
| 75 | { | 75 | { |
| @@ -128,9 +128,9 @@ public class Gui | |||
| 128 | @Override | 128 | @Override |
| 129 | public void actionPerformed( ActionEvent event ) | 129 | public void actionPerformed( ActionEvent event ) |
| 130 | { | 130 | { |
| 131 | if( m_renameListener != null && m_selectedEntry != null ) | 131 | if( m_renameListener != null && m_selectedEntryPair != null ) |
| 132 | { | 132 | { |
| 133 | m_renameListener.rename( m_selectedEntry, m_nameField.getText() ); | 133 | m_renameListener.rename( m_selectedEntryPair.obf, m_nameField.getText() ); |
| 134 | } | 134 | } |
| 135 | } | 135 | } |
| 136 | } ); | 136 | } ); |
| @@ -142,7 +142,7 @@ public class Gui | |||
| 142 | m_renamePanel.add( m_typeLabel ); | 142 | m_renamePanel.add( m_typeLabel ); |
| 143 | m_renamePanel.add( m_nameField ); | 143 | m_renamePanel.add( m_nameField ); |
| 144 | m_renamePanel.add( m_renameButton ); | 144 | m_renamePanel.add( m_renameButton ); |
| 145 | clearEntry(); | 145 | clearEntryPair(); |
| 146 | 146 | ||
| 147 | // init editor | 147 | // init editor |
| 148 | DefaultSyntaxKit.initKit(); | 148 | DefaultSyntaxKit.initKit(); |
| @@ -241,7 +241,7 @@ public class Gui | |||
| 241 | m_editor.addCaretListener( listener ); | 241 | m_editor.addCaretListener( listener ); |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | public void clearEntry( ) | 244 | public void clearEntryPair( ) |
| 245 | { | 245 | { |
| 246 | m_actionPanel.removeAll(); | 246 | m_actionPanel.removeAll(); |
| 247 | JLabel label = new JLabel( "No identifier selected" ); | 247 | JLabel label = new JLabel( "No identifier selected" ); |
| @@ -251,67 +251,72 @@ public class Gui | |||
| 251 | 251 | ||
| 252 | redraw(); | 252 | redraw(); |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | public void showEntry( Entry entry ) | 255 | public void showEntryPair( EntryPair pair ) |
| 256 | { | 256 | { |
| 257 | if( entry == null ) | 257 | if( pair == null ) |
| 258 | { | 258 | { |
| 259 | clearEntry(); | 259 | clearEntryPair(); |
| 260 | return; | 260 | return; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | // TEMP | ||
| 264 | System.out.println( "Pair:\n" + pair.obf + "\n" + pair.deobf ); | ||
| 265 | |||
| 266 | m_selectedEntryPair = pair; | ||
| 267 | |||
| 263 | // layout the action panel | 268 | // layout the action panel |
| 264 | m_actionPanel.removeAll(); | 269 | m_actionPanel.removeAll(); |
| 265 | m_actionPanel.add( m_renamePanel ); | 270 | m_actionPanel.add( m_renamePanel ); |
| 266 | m_nameField.setText( entry.getName() ); | 271 | m_nameField.setText( pair.deobf.getName() ); |
| 267 | 272 | ||
| 268 | // layout the dynamic section | 273 | // layout the dynamic section |
| 269 | JPanel dynamicPanel = new JPanel(); | 274 | JPanel dynamicPanel = new JPanel(); |
| 270 | dynamicPanel.setLayout( new GridLayout( 3, 1, 0, 0 ) ); | 275 | dynamicPanel.setLayout( new GridLayout( 3, 1, 0, 0 ) ); |
| 271 | m_actionPanel.add( dynamicPanel ); | 276 | m_actionPanel.add( dynamicPanel ); |
| 272 | if( entry instanceof ClassEntry ) | 277 | if( pair.deobf instanceof ClassEntry ) |
| 273 | { | 278 | { |
| 274 | showEntry( (ClassEntry)entry, dynamicPanel ); | 279 | showEntry( (ClassEntry)pair.deobf, dynamicPanel ); |
| 275 | } | 280 | } |
| 276 | else if( entry instanceof FieldEntry ) | 281 | else if( pair.deobf instanceof FieldEntry ) |
| 277 | { | 282 | { |
| 278 | showEntry( (FieldEntry)entry, dynamicPanel ); | 283 | showEntry( (FieldEntry)pair.deobf, dynamicPanel ); |
| 279 | } | 284 | } |
| 280 | else if( entry instanceof MethodEntry ) | 285 | else if( pair.deobf instanceof MethodEntry ) |
| 281 | { | 286 | { |
| 282 | showEntry( (MethodEntry)entry, dynamicPanel ); | 287 | showEntry( (MethodEntry)pair.deobf, dynamicPanel ); |
| 283 | } | 288 | } |
| 284 | else if( entry instanceof ArgumentEntry ) | 289 | else if( pair.deobf instanceof ArgumentEntry ) |
| 285 | { | 290 | { |
| 286 | showEntry( (ArgumentEntry)entry, dynamicPanel ); | 291 | showEntry( (ArgumentEntry)pair.deobf, dynamicPanel ); |
| 287 | } | 292 | } |
| 288 | else | 293 | else |
| 289 | { | 294 | { |
| 290 | throw new Error( "Unknown entry type: " + entry.getClass().getName() ); | 295 | throw new Error( "Unknown entry type: " + pair.deobf.getClass().getName() ); |
| 291 | } | 296 | } |
| 292 | 297 | ||
| 293 | redraw(); | 298 | redraw(); |
| 294 | } | 299 | } |
| 295 | 300 | ||
| 296 | public void showEntry( ClassEntry entry, JPanel panel ) | 301 | private void showEntry( ClassEntry entry, JPanel panel ) |
| 297 | { | 302 | { |
| 298 | m_typeLabel.setText( "Class: " ); | 303 | m_typeLabel.setText( "Class: " ); |
| 299 | } | 304 | } |
| 300 | 305 | ||
| 301 | public void showEntry( FieldEntry entry, JPanel panel ) | 306 | private void showEntry( FieldEntry entry, JPanel panel ) |
| 302 | { | 307 | { |
| 303 | m_typeLabel.setText( "Field: " ); | 308 | m_typeLabel.setText( "Field: " ); |
| 304 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); | 309 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); |
| 305 | } | 310 | } |
| 306 | 311 | ||
| 307 | public void showEntry( MethodEntry entry, JPanel panel ) | 312 | private void showEntry( MethodEntry entry, JPanel panel ) |
| 308 | { | 313 | { |
| 309 | m_typeLabel.setText( "Method: " ); | 314 | m_typeLabel.setText( "Method: " ); |
| 310 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); | 315 | addNameValue( panel, "Class", entry.getClassEntry().getName() ); |
| 311 | addNameValue( panel, "Signature", entry.getSignature() ); | 316 | addNameValue( panel, "Signature", entry.getSignature() ); |
| 312 | } | 317 | } |
| 313 | 318 | ||
| 314 | public void showEntry( ArgumentEntry entry, JPanel panel ) | 319 | private void showEntry( ArgumentEntry entry, JPanel panel ) |
| 315 | { | 320 | { |
| 316 | m_typeLabel.setText( "Argument: " ); | 321 | m_typeLabel.setText( "Argument: " ); |
| 317 | addNameValue( panel, "Class", entry.getMethodEntry().getClassEntry().getName() ); | 322 | addNameValue( panel, "Class", entry.getMethodEntry().getClassEntry().getName() ); |