diff options
| author | 2014-08-10 22:39:18 -0400 | |
|---|---|---|
| committer | 2014-08-10 22:39:18 -0400 | |
| commit | dc7c8847ab69e946a20a45c955b4a0273e262d48 (patch) | |
| tree | 13c20f8b9eef74e0557d8621d099db686eb54764 /src/cuchaz/enigma/gui/GuiController.java | |
| parent | refactored to remove ClassFile class to prep for upcoming stack navigation. I... (diff) | |
| download | enigma-fork-dc7c8847ab69e946a20a45c955b4a0273e262d48.tar.gz enigma-fork-dc7c8847ab69e946a20a45c955b4a0273e262d48.tar.xz enigma-fork-dc7c8847ab69e946a20a45c955b4a0273e262d48.zip | |
added backwards navigation
Diffstat (limited to 'src/cuchaz/enigma/gui/GuiController.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index 6a7a7da..a4228c7 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -15,6 +15,7 @@ import java.io.FileReader; | |||
| 15 | import java.io.FileWriter; | 15 | import java.io.FileWriter; |
| 16 | import java.io.IOException; | 16 | import java.io.IOException; |
| 17 | import java.util.List; | 17 | import java.util.List; |
| 18 | import java.util.Stack; | ||
| 18 | 19 | ||
| 19 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
| 20 | 21 | ||
| @@ -36,6 +37,7 @@ public class GuiController | |||
| 36 | private SourceIndex m_index; | 37 | private SourceIndex m_index; |
| 37 | private ClassEntry m_currentClass; | 38 | private ClassEntry m_currentClass; |
| 38 | private boolean m_isDirty; | 39 | private boolean m_isDirty; |
| 40 | private Stack<Entry> m_entryStack; | ||
| 39 | 41 | ||
| 40 | public GuiController( Gui gui ) | 42 | public GuiController( Gui gui ) |
| 41 | { | 43 | { |
| @@ -44,6 +46,7 @@ public class GuiController | |||
| 44 | m_index = null; | 46 | m_index = null; |
| 45 | m_currentClass = null; | 47 | m_currentClass = null; |
| 46 | m_isDirty = false; | 48 | m_isDirty = false; |
| 49 | m_entryStack = new Stack<Entry>(); | ||
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | public boolean isDirty( ) | 52 | public boolean isDirty( ) |
| @@ -153,21 +156,42 @@ public class GuiController | |||
| 153 | m_deobfuscator.rename( obfEntry, newName ); | 156 | m_deobfuscator.rename( obfEntry, newName ); |
| 154 | m_isDirty = true; | 157 | m_isDirty = true; |
| 155 | refreshClasses(); | 158 | refreshClasses(); |
| 156 | refreshCurrentClass( m_deobfuscator.deobfuscateEntry( obfEntry ) ); | 159 | refreshCurrentClass( obfEntry ); |
| 157 | } | 160 | } |
| 158 | 161 | ||
| 159 | public void openEntry( Entry obfEntry ) | 162 | public void openEntry( Entry entry ) |
| 160 | { | 163 | { |
| 161 | Entry deobfEntry = m_deobfuscator.deobfuscateEntry( obfEntry ); | 164 | // go to the entry |
| 162 | if( m_currentClass == null || !m_currentClass.equals( deobfEntry.getClassEntry() ) ) | 165 | Entry obfEntry = m_deobfuscator.obfuscateEntry( entry ); |
| 166 | if( m_currentClass == null || !m_currentClass.equals( obfEntry.getClassEntry() ) ) | ||
| 163 | { | 167 | { |
| 164 | m_currentClass = new ClassEntry( obfEntry.getClassEntry() ); | 168 | m_currentClass = new ClassEntry( obfEntry.getClassEntry() ); |
| 165 | deobfuscate( m_currentClass, deobfEntry ); | 169 | deobfuscate( m_currentClass, obfEntry ); |
| 166 | } | 170 | } |
| 167 | else | 171 | else |
| 168 | { | 172 | { |
| 169 | m_gui.showToken( m_index.getDeclarationToken( deobfEntry ) ); | 173 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntry ) ) ); |
| 170 | } | 174 | } |
| 175 | |||
| 176 | if( m_entryStack.isEmpty() || !m_entryStack.peek().equals( obfEntry ) ) | ||
| 177 | { | ||
| 178 | // update the stack | ||
| 179 | m_entryStack.push( obfEntry ); | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | public void openPreviousEntry( ) | ||
| 184 | { | ||
| 185 | if( hasPreviousEntry() ) | ||
| 186 | { | ||
| 187 | m_entryStack.pop(); | ||
| 188 | openEntry( m_entryStack.peek() ); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | public boolean hasPreviousEntry( ) | ||
| 193 | { | ||
| 194 | return m_entryStack.size() > 1; | ||
| 171 | } | 195 | } |
| 172 | 196 | ||
| 173 | private void refreshClasses( ) | 197 | private void refreshClasses( ) |
| @@ -184,15 +208,15 @@ public class GuiController | |||
| 184 | refreshCurrentClass( null ); | 208 | refreshCurrentClass( null ); |
| 185 | } | 209 | } |
| 186 | 210 | ||
| 187 | private void refreshCurrentClass( Entry entryToShow ) | 211 | private void refreshCurrentClass( Entry obfEntryToShow ) |
| 188 | { | 212 | { |
| 189 | if( m_currentClass != null ) | 213 | if( m_currentClass != null ) |
| 190 | { | 214 | { |
| 191 | deobfuscate( m_currentClass, entryToShow ); | 215 | deobfuscate( m_currentClass, obfEntryToShow ); |
| 192 | } | 216 | } |
| 193 | } | 217 | } |
| 194 | 218 | ||
| 195 | private void deobfuscate( final ClassEntry classEntry, final Entry entryToShow ) | 219 | private void deobfuscate( final ClassEntry classEntry, final Entry obfEntryToShow ) |
| 196 | { | 220 | { |
| 197 | m_gui.setSource( "(deobfuscating...)" ); | 221 | m_gui.setSource( "(deobfuscating...)" ); |
| 198 | 222 | ||
| @@ -205,9 +229,9 @@ public class GuiController | |||
| 205 | // decompile,deobfuscate the bytecode | 229 | // decompile,deobfuscate the bytecode |
| 206 | m_index = m_deobfuscator.getSource( classEntry.getClassName() ); | 230 | m_index = m_deobfuscator.getSource( classEntry.getClassName() ); |
| 207 | m_gui.setSource( m_index.getSource() ); | 231 | m_gui.setSource( m_index.getSource() ); |
| 208 | if( entryToShow != null ) | 232 | if( obfEntryToShow != null ) |
| 209 | { | 233 | { |
| 210 | m_gui.showToken( m_index.getDeclarationToken( entryToShow ) ); | 234 | m_gui.showToken( m_index.getDeclarationToken( m_deobfuscator.deobfuscateEntry( obfEntryToShow ) ) ); |
| 211 | } | 235 | } |
| 212 | 236 | ||
| 213 | // set the highlighted tokens | 237 | // set the highlighted tokens |