diff options
| author | 2016-07-03 00:05:04 +1000 | |
|---|---|---|
| committer | 2016-07-03 00:05:04 +1000 | |
| commit | 9a3e5a9d132735f818c379ba72c554362650690d (patch) | |
| tree | 2a454f96d99bdcfc5bdf0f6814a2ea7857698d1b /src/main/java/cuchaz/enigma/gui/Gui.java | |
| parent | Fixed #4 (diff) | |
| download | enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.tar.gz enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.tar.xz enigma-fork-9a3e5a9d132735f818c379ba72c554362650690d.zip | |
Started Gui Refactor
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 561 |
1 files changed, 147 insertions, 414 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index fee9c9f..623e12e 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -20,7 +20,6 @@ import java.util.Collection; | |||
| 20 | import java.util.Collections; | 20 | import java.util.Collections; |
| 21 | import java.util.List; | 21 | import java.util.List; |
| 22 | import java.util.Vector; | 22 | import java.util.Vector; |
| 23 | import java.util.jar.JarFile; | ||
| 24 | 23 | ||
| 25 | import javax.swing.*; | 24 | import javax.swing.*; |
| 26 | import javax.swing.text.BadLocationException; | 25 | import javax.swing.text.BadLocationException; |
| @@ -32,21 +31,33 @@ import javax.swing.tree.TreePath; | |||
| 32 | import cuchaz.enigma.Constants; | 31 | import cuchaz.enigma.Constants; |
| 33 | import cuchaz.enigma.ExceptionIgnorer; | 32 | import cuchaz.enigma.ExceptionIgnorer; |
| 34 | import cuchaz.enigma.analysis.*; | 33 | import cuchaz.enigma.analysis.*; |
| 34 | import cuchaz.enigma.gui.dialog.CrashDialog; | ||
| 35 | import cuchaz.enigma.gui.elements.MenuBar; | ||
| 36 | import cuchaz.enigma.gui.elements.PopupMenuBar; | ||
| 37 | import cuchaz.enigma.gui.filechooser.FileChooserFile; | ||
| 38 | import cuchaz.enigma.gui.filechooser.FileChooserFolder; | ||
| 39 | import cuchaz.enigma.gui.panels.PanelDeobf; | ||
| 40 | import cuchaz.enigma.gui.panels.PanelEditor; | ||
| 41 | import cuchaz.enigma.gui.panels.PanelIdentifier; | ||
| 42 | import cuchaz.enigma.gui.panels.PanelObf; | ||
| 35 | import cuchaz.enigma.mapping.*; | 43 | import cuchaz.enigma.mapping.*; |
| 36 | import de.sciss.syntaxpane.DefaultSyntaxKit; | 44 | import de.sciss.syntaxpane.DefaultSyntaxKit; |
| 37 | 45 | ||
| 38 | public class Gui { | 46 | public class Gui { |
| 39 | 47 | ||
| 40 | private GuiController m_controller; | 48 | private GuiController controller; |
| 41 | 49 | ||
| 42 | // controls | 50 | private final PanelObf obfPanel; |
| 43 | private JFrame m_frame; | 51 | private final PanelDeobf deobfPanel; |
| 44 | private ClassSelector m_obfClasses; | 52 | |
| 45 | private ClassSelector m_deobfClasses; | 53 | private final MenuBar menuBar; |
| 46 | private JEditorPane m_editor; | 54 | public final PopupMenuBar popupMenu; |
| 47 | private JPanel m_classesPanel; | 55 | |
| 56 | private JFrame frame; | ||
| 57 | private PanelEditor editor; | ||
| 58 | private JPanel classesPanel; | ||
| 48 | private JSplitPane m_splitClasses; | 59 | private JSplitPane m_splitClasses; |
| 49 | private JPanel m_infoPanel; | 60 | private PanelIdentifier m_infoPanel; |
| 50 | private ObfuscatedHighlightPainter m_obfuscatedHighlightPainter; | 61 | private ObfuscatedHighlightPainter m_obfuscatedHighlightPainter; |
| 51 | private DeobfuscatedHighlightPainter m_deobfuscatedHighlightPainter; | 62 | private DeobfuscatedHighlightPainter m_deobfuscatedHighlightPainter; |
| 52 | private OtherHighlightPainter m_otherHighlightPainter; | 63 | private OtherHighlightPainter m_otherHighlightPainter; |
| @@ -57,42 +68,26 @@ public class Gui { | |||
| 57 | private JList<Token> m_tokens; | 68 | private JList<Token> m_tokens; |
| 58 | private JTabbedPane m_tabs; | 69 | private JTabbedPane m_tabs; |
| 59 | 70 | ||
| 60 | // dynamic menu items | ||
| 61 | private JMenuItem m_closeJarMenu; | ||
| 62 | private JMenuItem m_openMappingsMenu; | ||
| 63 | private JMenuItem m_openOldMappingsMenu; | ||
| 64 | private JMenuItem m_saveMappingsMenu; | ||
| 65 | private JMenuItem m_saveMappingsAsMenu; | ||
| 66 | private JMenuItem m_closeMappingsMenu; | ||
| 67 | private JMenuItem m_renameMenu; | ||
| 68 | private JMenuItem m_showInheritanceMenu; | ||
| 69 | private JMenuItem m_openEntryMenu; | ||
| 70 | private JMenuItem m_openPreviousMenu; | ||
| 71 | private JMenuItem m_showCallsMenu; | ||
| 72 | private JMenuItem m_showImplementationsMenu; | ||
| 73 | private JMenuItem m_toggleMappingMenu; | ||
| 74 | private JMenuItem m_exportSourceMenu; | ||
| 75 | private JMenuItem m_exportJarMenu; | ||
| 76 | |||
| 77 | // state | 71 | // state |
| 78 | private EntryReference<Entry, Entry> m_reference; | 72 | public EntryReference<Entry, Entry> m_reference; |
| 79 | private JFileChooser m_jarFileChooser; | ||
| 80 | private JFileChooser m_mappingsFileChooser; | ||
| 81 | private JFileChooser m_oldMappingsFileChooser; | ||
| 82 | 73 | ||
| 83 | private JFileChooser m_exportSourceFileChooser; | 74 | public JFileChooser jarFileChooser; |
| 84 | private JFileChooser m_exportJarFileChooser; | 75 | public JFileChooser mappingsFileChooser; |
| 76 | public JFileChooser oldMappingsFileChooser; | ||
| 77 | |||
| 78 | public JFileChooser exportSourceFileChooser; | ||
| 79 | public JFileChooser exportJarFileChooser; | ||
| 85 | 80 | ||
| 86 | public Gui() { | 81 | public Gui() { |
| 87 | 82 | ||
| 88 | // init frame | 83 | // init frame |
| 89 | m_frame = new JFrame(Constants.NAME); | 84 | this.frame = new JFrame(Constants.NAME); |
| 90 | final Container pane = m_frame.getContentPane(); | 85 | final Container pane = this.frame.getContentPane(); |
| 91 | pane.setLayout(new BorderLayout()); | 86 | pane.setLayout(new BorderLayout()); |
| 92 | 87 | ||
| 93 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { | 88 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { |
| 94 | // install a global exception handler to the event thread | 89 | // install a global exception handler to the event thread |
| 95 | CrashDialog.init(m_frame); | 90 | CrashDialog.init(this.frame); |
| 96 | Thread.setDefaultUncaughtExceptionHandler((thread, t) -> { | 91 | Thread.setDefaultUncaughtExceptionHandler((thread, t) -> { |
| 97 | t.printStackTrace(System.err); | 92 | t.printStackTrace(System.err); |
| 98 | if (!ExceptionIgnorer.shouldIgnore(t)) { | 93 | if (!ExceptionIgnorer.shouldIgnore(t)) { |
| @@ -101,50 +96,30 @@ public class Gui { | |||
| 101 | }); | 96 | }); |
| 102 | } | 97 | } |
| 103 | 98 | ||
| 104 | m_controller = new GuiController(this); | 99 | this.controller = new GuiController(this); |
| 105 | 100 | ||
| 106 | // init file choosers | 101 | // init file choosers |
| 107 | m_jarFileChooser = new JFileChooser(); | 102 | this.jarFileChooser = new FileChooserFile(); |
| 108 | m_mappingsFileChooser = new JFileChooser(); | 103 | this.mappingsFileChooser = new FileChooserFolder(); |
| 109 | m_mappingsFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | 104 | |
| 110 | m_mappingsFileChooser.setAcceptAllFileFilterUsed(false); | 105 | |
| 111 | 106 | this.oldMappingsFileChooser = new FileChooserFile(); | |
| 112 | m_oldMappingsFileChooser = new JFileChooser(); | 107 | this.exportSourceFileChooser = new FileChooserFolder(); |
| 113 | m_exportSourceFileChooser = new JFileChooser(); | 108 | this.exportJarFileChooser = new FileChooserFile(); |
| 114 | m_exportSourceFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); | 109 | |
| 115 | m_exportJarFileChooser = new JFileChooser(); | 110 | this.obfPanel = new PanelObf(this); |
| 116 | 111 | this.deobfPanel = new PanelDeobf(this); | |
| 117 | // init obfuscated classes list | ||
| 118 | m_obfClasses = new ClassSelector(ClassSelector.ObfuscatedClassEntryComparator); | ||
| 119 | m_obfClasses.setListener(this::navigateTo); | ||
| 120 | JScrollPane obfScroller = new JScrollPane(m_obfClasses); | ||
| 121 | JPanel obfPanel = new JPanel(); | ||
| 122 | obfPanel.setLayout(new BorderLayout()); | ||
| 123 | obfPanel.add(new JLabel("Obfuscated Classes"), BorderLayout.NORTH); | ||
| 124 | obfPanel.add(obfScroller, BorderLayout.CENTER); | ||
| 125 | |||
| 126 | // init deobfuscated classes list | ||
| 127 | m_deobfClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); | ||
| 128 | m_deobfClasses.setListener(this::navigateTo); | ||
| 129 | JScrollPane deobfScroller = new JScrollPane(m_deobfClasses); | ||
| 130 | JPanel deobfPanel = new JPanel(); | ||
| 131 | deobfPanel.setLayout(new BorderLayout()); | ||
| 132 | deobfPanel.add(new JLabel("De-obfuscated Classes"), BorderLayout.NORTH); | ||
| 133 | deobfPanel.add(deobfScroller, BorderLayout.CENTER); | ||
| 134 | 112 | ||
| 135 | // set up classes panel (don't add the splitter yet) | 113 | // set up classes panel (don't add the splitter yet) |
| 136 | m_splitClasses = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, obfPanel, deobfPanel); | 114 | m_splitClasses = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, this.obfPanel, this.deobfPanel); |
| 137 | m_splitClasses.setResizeWeight(0.3); | 115 | m_splitClasses.setResizeWeight(0.3); |
| 138 | m_classesPanel = new JPanel(); | 116 | this.classesPanel = new JPanel(); |
| 139 | m_classesPanel.setLayout(new BorderLayout()); | 117 | this.classesPanel.setLayout(new BorderLayout()); |
| 140 | m_classesPanel.setPreferredSize(new Dimension(250, 0)); | 118 | this.classesPanel.setPreferredSize(new Dimension(250, 0)); |
| 141 | 119 | ||
| 142 | // init info panel | 120 | // init info panel |
| 143 | m_infoPanel = new JPanel(); | 121 | m_infoPanel = new PanelIdentifier(this); |
| 144 | m_infoPanel.setLayout(new GridLayout(4, 1, 0, 0)); | 122 | m_infoPanel.clearReference(); |
| 145 | m_infoPanel.setPreferredSize(new Dimension(0, 100)); | ||
| 146 | m_infoPanel.setBorder(BorderFactory.createTitledBorder("Identifier Info")); | ||
| 147 | clearReference(); | ||
| 148 | 123 | ||
| 149 | // init editor | 124 | // init editor |
| 150 | DefaultSyntaxKit.initKit(); | 125 | DefaultSyntaxKit.initKit(); |
| @@ -152,110 +127,12 @@ public class Gui { | |||
| 152 | m_deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); | 127 | m_deobfuscatedHighlightPainter = new DeobfuscatedHighlightPainter(); |
| 153 | m_otherHighlightPainter = new OtherHighlightPainter(); | 128 | m_otherHighlightPainter = new OtherHighlightPainter(); |
| 154 | m_selectionHighlightPainter = new SelectionHighlightPainter(); | 129 | m_selectionHighlightPainter = new SelectionHighlightPainter(); |
| 155 | m_editor = new JEditorPane(); | 130 | this.editor = new PanelEditor(this); |
| 156 | m_editor.setEditable(false); | 131 | JScrollPane sourceScroller = new JScrollPane(this.editor); |
| 157 | m_editor.setCaret(new BrowserCaret()); | ||
| 158 | JScrollPane sourceScroller = new JScrollPane(m_editor); | ||
| 159 | m_editor.setContentType("text/java"); | ||
| 160 | m_editor.addCaretListener(event -> onCaretMove(event.getDot())); | ||
| 161 | m_editor.addKeyListener(new KeyAdapter() { | ||
| 162 | @Override | ||
| 163 | public void keyPressed(KeyEvent event) { | ||
| 164 | switch (event.getKeyCode()) { | ||
| 165 | case KeyEvent.VK_R: | ||
| 166 | m_renameMenu.doClick(); | ||
| 167 | break; | ||
| 168 | |||
| 169 | case KeyEvent.VK_I: | ||
| 170 | m_showInheritanceMenu.doClick(); | ||
| 171 | break; | ||
| 172 | |||
| 173 | case KeyEvent.VK_M: | ||
| 174 | m_showImplementationsMenu.doClick(); | ||
| 175 | break; | ||
| 176 | |||
| 177 | case KeyEvent.VK_N: | ||
| 178 | m_openEntryMenu.doClick(); | ||
| 179 | break; | ||
| 180 | |||
| 181 | case KeyEvent.VK_P: | ||
| 182 | m_openPreviousMenu.doClick(); | ||
| 183 | break; | ||
| 184 | |||
| 185 | case KeyEvent.VK_C: | ||
| 186 | m_showCallsMenu.doClick(); | ||
| 187 | break; | ||
| 188 | |||
| 189 | case KeyEvent.VK_T: | ||
| 190 | m_toggleMappingMenu.doClick(); | ||
| 191 | break; | ||
| 192 | } | ||
| 193 | } | ||
| 194 | }); | ||
| 195 | |||
| 196 | // turn off token highlighting (it's wrong most of the time anyway...) | ||
| 197 | DefaultSyntaxKit kit = (DefaultSyntaxKit) m_editor.getEditorKit(); | ||
| 198 | kit.toggleComponent(m_editor, "de.sciss.syntaxpane.components.TokenMarker"); | ||
| 199 | 132 | ||
| 200 | // init editor popup menu | 133 | // init editor popup menu |
| 201 | JPopupMenu popupMenu = new JPopupMenu(); | 134 | this.popupMenu = new PopupMenuBar(this); |
| 202 | m_editor.setComponentPopupMenu(popupMenu); | 135 | this.editor.setComponentPopupMenu(this.popupMenu); |
| 203 | { | ||
| 204 | JMenuItem menu = new JMenuItem("Rename"); | ||
| 205 | menu.addActionListener(event -> startRename()); | ||
| 206 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0)); | ||
| 207 | menu.setEnabled(false); | ||
| 208 | popupMenu.add(menu); | ||
| 209 | m_renameMenu = menu; | ||
| 210 | } | ||
| 211 | { | ||
| 212 | JMenuItem menu = new JMenuItem("Show Inheritance"); | ||
| 213 | menu.addActionListener(event -> showInheritance()); | ||
| 214 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, 0)); | ||
| 215 | menu.setEnabled(false); | ||
| 216 | popupMenu.add(menu); | ||
| 217 | m_showInheritanceMenu = menu; | ||
| 218 | } | ||
| 219 | { | ||
| 220 | JMenuItem menu = new JMenuItem("Show Implementations"); | ||
| 221 | menu.addActionListener(event -> showImplementations()); | ||
| 222 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0)); | ||
| 223 | menu.setEnabled(false); | ||
| 224 | popupMenu.add(menu); | ||
| 225 | m_showImplementationsMenu = menu; | ||
| 226 | } | ||
| 227 | { | ||
| 228 | JMenuItem menu = new JMenuItem("Show Calls"); | ||
| 229 | menu.addActionListener(event -> showCalls()); | ||
| 230 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, 0)); | ||
| 231 | menu.setEnabled(false); | ||
| 232 | popupMenu.add(menu); | ||
| 233 | m_showCallsMenu = menu; | ||
| 234 | } | ||
| 235 | { | ||
| 236 | JMenuItem menu = new JMenuItem("Go to Declaration"); | ||
| 237 | menu.addActionListener(event -> navigateTo(m_reference.entry)); | ||
| 238 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, 0)); | ||
| 239 | menu.setEnabled(false); | ||
| 240 | popupMenu.add(menu); | ||
| 241 | m_openEntryMenu = menu; | ||
| 242 | } | ||
| 243 | { | ||
| 244 | JMenuItem menu = new JMenuItem("Go to previous"); | ||
| 245 | menu.addActionListener(event -> m_controller.openPreviousReference()); | ||
| 246 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, 0)); | ||
| 247 | menu.setEnabled(false); | ||
| 248 | popupMenu.add(menu); | ||
| 249 | m_openPreviousMenu = menu; | ||
| 250 | } | ||
| 251 | { | ||
| 252 | JMenuItem menu = new JMenuItem("Mark as deobfuscated"); | ||
| 253 | menu.addActionListener(event -> toggleMapping()); | ||
| 254 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, 0)); | ||
| 255 | menu.setEnabled(false); | ||
| 256 | popupMenu.add(menu); | ||
| 257 | m_toggleMappingMenu = menu; | ||
| 258 | } | ||
| 259 | 136 | ||
| 260 | // init inheritance panel | 137 | // init inheritance panel |
| 261 | m_inheritanceTree = new JTree(); | 138 | m_inheritanceTree = new JTree(); |
| @@ -342,7 +219,7 @@ public class Gui { | |||
| 342 | } | 219 | } |
| 343 | }); | 220 | }); |
| 344 | m_tokens = new JList<>(); | 221 | m_tokens = new JList<>(); |
| 345 | m_tokens.setCellRenderer(new TokenListCellRenderer(m_controller)); | 222 | m_tokens.setCellRenderer(new TokenListCellRenderer(this.controller)); |
| 346 | m_tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); | 223 | m_tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 347 | m_tokens.setLayoutOrientation(JList.VERTICAL); | 224 | m_tokens.setLayoutOrientation(JList.VERTICAL); |
| 348 | m_tokens.addMouseListener(new MouseAdapter() { | 225 | m_tokens.addMouseListener(new MouseAdapter() { |
| @@ -380,152 +257,18 @@ public class Gui { | |||
| 380 | JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs); | 257 | JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs); |
| 381 | splitRight.setResizeWeight(1); // let the left side take all the slack | 258 | splitRight.setResizeWeight(1); // let the left side take all the slack |
| 382 | splitRight.resetToPreferredSizes(); | 259 | splitRight.resetToPreferredSizes(); |
| 383 | JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, m_classesPanel, splitRight); | 260 | JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, this.classesPanel, splitRight); |
| 384 | splitCenter.setResizeWeight(0); // let the right side take all the slack | 261 | splitCenter.setResizeWeight(0); // let the right side take all the slack |
| 385 | pane.add(splitCenter, BorderLayout.CENTER); | 262 | pane.add(splitCenter, BorderLayout.CENTER); |
| 386 | 263 | ||
| 387 | // init menus | 264 | // init menus |
| 388 | JMenuBar menuBar = new JMenuBar(); | 265 | this.menuBar = new MenuBar(this); |
| 389 | m_frame.setJMenuBar(menuBar); | 266 | this.frame.setJMenuBar(this.menuBar); |
| 390 | { | ||
| 391 | JMenu menu = new JMenu("File"); | ||
| 392 | menuBar.add(menu); | ||
| 393 | { | ||
| 394 | JMenuItem item = new JMenuItem("Open Jar..."); | ||
| 395 | menu.add(item); | ||
| 396 | item.addActionListener(event -> { | ||
| 397 | if (m_jarFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 398 | // load the jar in a separate thread | ||
| 399 | new Thread() { | ||
| 400 | @Override | ||
| 401 | public void run() { | ||
| 402 | try { | ||
| 403 | m_controller.openJar(new JarFile(m_jarFileChooser.getSelectedFile())); | ||
| 404 | } catch (IOException ex) { | ||
| 405 | throw new Error(ex); | ||
| 406 | } | ||
| 407 | } | ||
| 408 | }.start(); | ||
| 409 | } | ||
| 410 | }); | ||
| 411 | } | ||
| 412 | { | ||
| 413 | JMenuItem item = new JMenuItem("Close Jar"); | ||
| 414 | menu.add(item); | ||
| 415 | item.addActionListener(event -> m_controller.closeJar()); | ||
| 416 | m_closeJarMenu = item; | ||
| 417 | } | ||
| 418 | menu.addSeparator(); | ||
| 419 | { | ||
| 420 | JMenuItem item = new JMenuItem("Open Mappings..."); | ||
| 421 | menu.add(item); | ||
| 422 | item.addActionListener(event -> { | ||
| 423 | if (m_mappingsFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 424 | try { | ||
| 425 | m_controller.openMappings(m_mappingsFileChooser.getSelectedFile()); | ||
| 426 | } catch (IOException ex) { | ||
| 427 | throw new Error(ex); | ||
| 428 | } catch (MappingParseException ex) { | ||
| 429 | JOptionPane.showMessageDialog(m_frame, ex.getMessage()); | ||
| 430 | } | ||
| 431 | } | ||
| 432 | }); | ||
| 433 | m_openMappingsMenu = item; | ||
| 434 | } | ||
| 435 | { | ||
| 436 | JMenuItem item = new JMenuItem("Open Old Mappings..."); | ||
| 437 | menu.add(item); | ||
| 438 | item.addActionListener(event -> { | ||
| 439 | if (m_oldMappingsFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 440 | try { | ||
| 441 | m_controller.openOldMappings(m_oldMappingsFileChooser.getSelectedFile()); | ||
| 442 | } catch (IOException ex) { | ||
| 443 | throw new Error(ex); | ||
| 444 | } catch (MappingParseException ex) { | ||
| 445 | JOptionPane.showMessageDialog(m_frame, ex.getMessage()); | ||
| 446 | } | ||
| 447 | } | ||
| 448 | }); | ||
| 449 | m_openOldMappingsMenu = item; | ||
| 450 | } | ||
| 451 | menu.addSeparator(); | ||
| 452 | { | ||
| 453 | JMenuItem item = new JMenuItem("Save Mappings"); | ||
| 454 | menu.add(item); | ||
| 455 | item.addActionListener(event -> { | ||
| 456 | try { | ||
| 457 | m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile()); | ||
| 458 | } catch (IOException ex) { | ||
| 459 | throw new Error(ex); | ||
| 460 | } | ||
| 461 | }); | ||
| 462 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); | ||
| 463 | m_saveMappingsMenu = item; | ||
| 464 | } | ||
| 465 | { | ||
| 466 | JMenuItem item = new JMenuItem("Save Mappings As..."); | ||
| 467 | menu.add(item); | ||
| 468 | item.addActionListener(event -> { | ||
| 469 | if (m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 470 | try { | ||
| 471 | m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile()); | ||
| 472 | m_saveMappingsMenu.setEnabled(true); | ||
| 473 | } catch (IOException ex) { | ||
| 474 | throw new Error(ex); | ||
| 475 | } | ||
| 476 | } | ||
| 477 | }); | ||
| 478 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); | ||
| 479 | m_saveMappingsAsMenu = item; | ||
| 480 | } | ||
| 481 | { | ||
| 482 | JMenuItem item = new JMenuItem("Close Mappings"); | ||
| 483 | menu.add(item); | ||
| 484 | item.addActionListener(event -> m_controller.closeMappings()); | ||
| 485 | m_closeMappingsMenu = item; | ||
| 486 | } | ||
| 487 | menu.addSeparator(); | ||
| 488 | { | ||
| 489 | JMenuItem item = new JMenuItem("Export Source..."); | ||
| 490 | menu.add(item); | ||
| 491 | item.addActionListener(event -> { | ||
| 492 | if (m_exportSourceFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 493 | m_controller.exportSource(m_exportSourceFileChooser.getSelectedFile()); | ||
| 494 | } | ||
| 495 | }); | ||
| 496 | m_exportSourceMenu = item; | ||
| 497 | } | ||
| 498 | { | ||
| 499 | JMenuItem item = new JMenuItem("Export Jar..."); | ||
| 500 | menu.add(item); | ||
| 501 | item.addActionListener(event -> { | ||
| 502 | if (m_exportJarFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | ||
| 503 | m_controller.exportJar(m_exportJarFileChooser.getSelectedFile()); | ||
| 504 | } | ||
| 505 | }); | ||
| 506 | m_exportJarMenu = item; | ||
| 507 | } | ||
| 508 | menu.addSeparator(); | ||
| 509 | { | ||
| 510 | JMenuItem item = new JMenuItem("Exit"); | ||
| 511 | menu.add(item); | ||
| 512 | item.addActionListener(event -> close()); | ||
| 513 | } | ||
| 514 | } | ||
| 515 | { | ||
| 516 | JMenu menu = new JMenu("Help"); | ||
| 517 | menuBar.add(menu); | ||
| 518 | { | ||
| 519 | JMenuItem item = new JMenuItem("About"); | ||
| 520 | menu.add(item); | ||
| 521 | item.addActionListener(event -> AboutDialog.show(m_frame)); | ||
| 522 | } | ||
| 523 | } | ||
| 524 | 267 | ||
| 525 | // init state | 268 | // init state |
| 526 | onCloseJar(); | 269 | onCloseJar(); |
| 527 | 270 | ||
| 528 | m_frame.addWindowListener(new WindowAdapter() { | 271 | this.frame.addWindowListener(new WindowAdapter() { |
| 529 | @Override | 272 | @Override |
| 530 | public void windowClosing(WindowEvent event) { | 273 | public void windowClosing(WindowEvent event) { |
| 531 | close(); | 274 | close(); |
| @@ -534,93 +277,93 @@ public class Gui { | |||
| 534 | 277 | ||
| 535 | // show the frame | 278 | // show the frame |
| 536 | pane.doLayout(); | 279 | pane.doLayout(); |
| 537 | m_frame.setSize(1024, 576); | 280 | this.frame.setSize(1024, 576); |
| 538 | m_frame.setMinimumSize(new Dimension(640, 480)); | 281 | this.frame.setMinimumSize(new Dimension(640, 480)); |
| 539 | m_frame.setVisible(true); | 282 | this.frame.setVisible(true); |
| 540 | m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); | 283 | this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
| 541 | } | 284 | } |
| 542 | 285 | ||
| 543 | public JFrame getFrame() { | 286 | public JFrame getFrame() { |
| 544 | return m_frame; | 287 | return this.frame; |
| 545 | } | 288 | } |
| 546 | 289 | ||
| 547 | public GuiController getController() { | 290 | public GuiController getController() { |
| 548 | return m_controller; | 291 | return this.controller; |
| 549 | } | 292 | } |
| 550 | 293 | ||
| 551 | public void onStartOpenJar() { | 294 | public void onStartOpenJar() { |
| 552 | m_classesPanel.removeAll(); | 295 | this.classesPanel.removeAll(); |
| 553 | JPanel panel = new JPanel(); | 296 | JPanel panel = new JPanel(); |
| 554 | panel.setLayout(new FlowLayout()); | 297 | panel.setLayout(new FlowLayout()); |
| 555 | panel.add(new JLabel("Loading...")); | 298 | panel.add(new JLabel("Loading...")); |
| 556 | m_classesPanel.add(panel); | 299 | this.classesPanel.add(panel); |
| 557 | redraw(); | 300 | redraw(); |
| 558 | } | 301 | } |
| 559 | 302 | ||
| 560 | public void onFinishOpenJar(String jarName) { | 303 | public void onFinishOpenJar(String jarName) { |
| 561 | // update gui | 304 | // update gui |
| 562 | m_frame.setTitle(Constants.NAME + " - " + jarName); | 305 | this.frame.setTitle(Constants.NAME + " - " + jarName); |
| 563 | m_classesPanel.removeAll(); | 306 | this.classesPanel.removeAll(); |
| 564 | m_classesPanel.add(m_splitClasses); | 307 | this.classesPanel.add(m_splitClasses); |
| 565 | setSource(null); | 308 | setSource(null); |
| 566 | 309 | ||
| 567 | // update menu | 310 | // update menu |
| 568 | m_closeJarMenu.setEnabled(true); | 311 | this.menuBar.closeJarMenu.setEnabled(true); |
| 569 | m_openOldMappingsMenu.setEnabled(true); | 312 | this.menuBar.openOldMappingsMenu.setEnabled(true); |
| 570 | m_openMappingsMenu.setEnabled(true); | 313 | this.menuBar.openMappingsMenu.setEnabled(true); |
| 571 | m_saveMappingsMenu.setEnabled(false); | 314 | this.menuBar.saveMappingsMenu.setEnabled(false); |
| 572 | m_saveMappingsAsMenu.setEnabled(true); | 315 | this.menuBar.saveMappingsAsMenu.setEnabled(true); |
| 573 | m_closeMappingsMenu.setEnabled(true); | 316 | this.menuBar.closeMappingsMenu.setEnabled(true); |
| 574 | m_exportSourceMenu.setEnabled(true); | 317 | this.menuBar.exportSourceMenu.setEnabled(true); |
| 575 | m_exportJarMenu.setEnabled(true); | 318 | this.menuBar.exportJarMenu.setEnabled(true); |
| 576 | 319 | ||
| 577 | redraw(); | 320 | redraw(); |
| 578 | } | 321 | } |
| 579 | 322 | ||
| 580 | public void onCloseJar() { | 323 | public void onCloseJar() { |
| 581 | // update gui | 324 | // update gui |
| 582 | m_frame.setTitle(Constants.NAME); | 325 | this.frame.setTitle(Constants.NAME); |
| 583 | setObfClasses(null); | 326 | setObfClasses(null); |
| 584 | setDeobfClasses(null); | 327 | setDeobfClasses(null); |
| 585 | setSource(null); | 328 | setSource(null); |
| 586 | m_classesPanel.removeAll(); | 329 | this.classesPanel.removeAll(); |
| 587 | 330 | ||
| 588 | // update menu | 331 | // update menu |
| 589 | m_closeJarMenu.setEnabled(false); | 332 | this.menuBar.closeJarMenu.setEnabled(false); |
| 590 | m_openOldMappingsMenu.setEnabled(false); | 333 | this.menuBar.openOldMappingsMenu.setEnabled(false); |
| 591 | m_openMappingsMenu.setEnabled(false); | 334 | this.menuBar.openMappingsMenu.setEnabled(false); |
| 592 | m_saveMappingsMenu.setEnabled(false); | 335 | this.menuBar.saveMappingsMenu.setEnabled(false); |
| 593 | m_saveMappingsAsMenu.setEnabled(false); | 336 | this.menuBar.saveMappingsAsMenu.setEnabled(false); |
| 594 | m_closeMappingsMenu.setEnabled(false); | 337 | this.menuBar.closeMappingsMenu.setEnabled(false); |
| 595 | m_exportSourceMenu.setEnabled(false); | 338 | this.menuBar.exportSourceMenu.setEnabled(false); |
| 596 | m_exportJarMenu.setEnabled(false); | 339 | this.menuBar.exportJarMenu.setEnabled(false); |
| 597 | 340 | ||
| 598 | redraw(); | 341 | redraw(); |
| 599 | } | 342 | } |
| 600 | 343 | ||
| 601 | public void setObfClasses(Collection<ClassEntry> obfClasses) { | 344 | public void setObfClasses(Collection<ClassEntry> obfClasses) { |
| 602 | m_obfClasses.setClasses(obfClasses); | 345 | this.obfPanel.obfClasses.setClasses(obfClasses); |
| 603 | } | 346 | } |
| 604 | 347 | ||
| 605 | public void setDeobfClasses(Collection<ClassEntry> deobfClasses) { | 348 | public void setDeobfClasses(Collection<ClassEntry> deobfClasses) { |
| 606 | m_deobfClasses.setClasses(deobfClasses); | 349 | this.deobfPanel.deobfClasses.setClasses(deobfClasses); |
| 607 | } | 350 | } |
| 608 | 351 | ||
| 609 | public void setMappingsFile(File file) { | 352 | public void setMappingsFile(File file) { |
| 610 | m_mappingsFileChooser.setSelectedFile(file); | 353 | this.mappingsFileChooser.setSelectedFile(file); |
| 611 | m_saveMappingsMenu.setEnabled(file != null); | 354 | this.menuBar.saveMappingsMenu.setEnabled(file != null); |
| 612 | } | 355 | } |
| 613 | 356 | ||
| 614 | public void setSource(String source) { | 357 | public void setSource(String source) { |
| 615 | m_editor.getHighlighter().removeAllHighlights(); | 358 | this.editor.getHighlighter().removeAllHighlights(); |
| 616 | m_editor.setText(source); | 359 | this.editor.setText(source); |
| 617 | } | 360 | } |
| 618 | 361 | ||
| 619 | public void showToken(final Token token) { | 362 | public void showToken(final Token token) { |
| 620 | if (token == null) { | 363 | if (token == null) { |
| 621 | throw new IllegalArgumentException("Token cannot be null!"); | 364 | throw new IllegalArgumentException("Token cannot be null!"); |
| 622 | } | 365 | } |
| 623 | CodeReader.navigateToToken(m_editor, token, m_selectionHighlightPainter); | 366 | CodeReader.navigateToToken(this.editor, token, m_selectionHighlightPainter); |
| 624 | redraw(); | 367 | redraw(); |
| 625 | } | 368 | } |
| 626 | 369 | ||
| @@ -642,7 +385,7 @@ public class Gui { | |||
| 642 | public void setHighlightedTokens(Iterable<Token> obfuscatedTokens, Iterable<Token> deobfuscatedTokens, Iterable<Token> otherTokens) { | 385 | public void setHighlightedTokens(Iterable<Token> obfuscatedTokens, Iterable<Token> deobfuscatedTokens, Iterable<Token> otherTokens) { |
| 643 | 386 | ||
| 644 | // remove any old highlighters | 387 | // remove any old highlighters |
| 645 | m_editor.getHighlighter().removeAllHighlights(); | 388 | this.editor.getHighlighter().removeAllHighlights(); |
| 646 | 389 | ||
| 647 | // color things based on the index | 390 | // color things based on the index |
| 648 | if (obfuscatedTokens != null) { | 391 | if (obfuscatedTokens != null) { |
| @@ -661,26 +404,16 @@ public class Gui { | |||
| 661 | private void setHighlightedTokens(Iterable<Token> tokens, Highlighter.HighlightPainter painter) { | 404 | private void setHighlightedTokens(Iterable<Token> tokens, Highlighter.HighlightPainter painter) { |
| 662 | for (Token token : tokens) { | 405 | for (Token token : tokens) { |
| 663 | try { | 406 | try { |
| 664 | m_editor.getHighlighter().addHighlight(token.start, token.end, painter); | 407 | this.editor.getHighlighter().addHighlight(token.start, token.end, painter); |
| 665 | } catch (BadLocationException ex) { | 408 | } catch (BadLocationException ex) { |
| 666 | throw new IllegalArgumentException(ex); | 409 | throw new IllegalArgumentException(ex); |
| 667 | } | 410 | } |
| 668 | } | 411 | } |
| 669 | } | 412 | } |
| 670 | 413 | ||
| 671 | private void clearReference() { | ||
| 672 | m_infoPanel.removeAll(); | ||
| 673 | JLabel label = new JLabel("No identifier selected"); | ||
| 674 | GuiTricks.unboldLabel(label); | ||
| 675 | label.setHorizontalAlignment(JLabel.CENTER); | ||
| 676 | m_infoPanel.add(label); | ||
| 677 | |||
| 678 | redraw(); | ||
| 679 | } | ||
| 680 | |||
| 681 | private void showReference(EntryReference<Entry, Entry> reference) { | 414 | private void showReference(EntryReference<Entry, Entry> reference) { |
| 682 | if (reference == null) { | 415 | if (reference == null) { |
| 683 | clearReference(); | 416 | m_infoPanel.clearReference(); |
| 684 | return; | 417 | return; |
| 685 | } | 418 | } |
| 686 | 419 | ||
| @@ -746,63 +479,63 @@ public class Gui { | |||
| 746 | panel.add(GuiTricks.unboldLabel(new JLabel(value, JLabel.LEFT))); | 479 | panel.add(GuiTricks.unboldLabel(new JLabel(value, JLabel.LEFT))); |
| 747 | } | 480 | } |
| 748 | 481 | ||
| 749 | private void onCaretMove(int pos) { | 482 | public void onCaretMove(int pos) { |
| 750 | 483 | ||
| 751 | Token token = m_controller.getToken(pos); | 484 | Token token = this.controller.getToken(pos); |
| 752 | boolean isToken = token != null; | 485 | boolean isToken = token != null; |
| 753 | 486 | ||
| 754 | m_reference = m_controller.getDeobfReference(token); | 487 | m_reference = this.controller.getDeobfReference(token); |
| 755 | boolean isClassEntry = isToken && m_reference.entry instanceof ClassEntry; | 488 | boolean isClassEntry = isToken && m_reference.entry instanceof ClassEntry; |
| 756 | boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; | 489 | boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; |
| 757 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; | 490 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; |
| 758 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; | 491 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; |
| 759 | boolean isInJar = isToken && m_controller.entryIsInJar(m_reference.entry); | 492 | boolean isInJar = isToken && this.controller.entryIsInJar(m_reference.entry); |
| 760 | boolean isRenameable = isToken && m_controller.referenceIsRenameable(m_reference); | 493 | boolean isRenameable = isToken && this.controller.referenceIsRenameable(m_reference); |
| 761 | 494 | ||
| 762 | if (isToken) { | 495 | if (isToken) { |
| 763 | showReference(m_reference); | 496 | showReference(m_reference); |
| 764 | } else { | 497 | } else { |
| 765 | clearReference(); | 498 | m_infoPanel.clearReference(); |
| 766 | } | 499 | } |
| 767 | 500 | ||
| 768 | m_renameMenu.setEnabled(isRenameable && isToken); | 501 | this.popupMenu.renameMenu.setEnabled(isRenameable && isToken); |
| 769 | m_showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); | 502 | this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); |
| 770 | m_showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); | 503 | this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); |
| 771 | m_showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); | 504 | this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); |
| 772 | m_openEntryMenu.setEnabled(isInJar && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); | 505 | this.popupMenu.openEntryMenu.setEnabled(isInJar && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); |
| 773 | m_openPreviousMenu.setEnabled(m_controller.hasPreviousLocation()); | 506 | this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousLocation()); |
| 774 | m_toggleMappingMenu.setEnabled(isRenameable && isToken); | 507 | this.popupMenu.toggleMappingMenu.setEnabled(isRenameable && isToken); |
| 775 | 508 | ||
| 776 | if (isToken && m_controller.entryHasDeobfuscatedName(m_reference.entry)) { | 509 | if (isToken && this.controller.entryHasDeobfuscatedName(m_reference.entry)) { |
| 777 | m_toggleMappingMenu.setText("Reset to obfuscated"); | 510 | this.popupMenu.toggleMappingMenu.setText("Reset to obfuscated"); |
| 778 | } else { | 511 | } else { |
| 779 | m_toggleMappingMenu.setText("Mark as deobfuscated"); | 512 | this.popupMenu.toggleMappingMenu.setText("Mark as deobfuscated"); |
| 780 | } | 513 | } |
| 781 | } | 514 | } |
| 782 | 515 | ||
| 783 | private void navigateTo(Entry entry) { | 516 | public void navigateTo(Entry entry) { |
| 784 | if (!m_controller.entryIsInJar(entry)) { | 517 | if (!this.controller.entryIsInJar(entry)) { |
| 785 | // entry is not in the jar. Ignore it | 518 | // entry is not in the jar. Ignore it |
| 786 | return; | 519 | return; |
| 787 | } | 520 | } |
| 788 | if (m_reference != null) { | 521 | if (m_reference != null) { |
| 789 | m_controller.savePreviousReference(m_reference); | 522 | this.controller.savePreviousReference(m_reference); |
| 790 | } | 523 | } |
| 791 | m_controller.openDeclaration(entry); | 524 | this.controller.openDeclaration(entry); |
| 792 | } | 525 | } |
| 793 | 526 | ||
| 794 | private void navigateTo(EntryReference<Entry, Entry> reference) { | 527 | private void navigateTo(EntryReference<Entry, Entry> reference) { |
| 795 | if (!m_controller.entryIsInJar(reference.getLocationClassEntry())) { | 528 | if (!this.controller.entryIsInJar(reference.getLocationClassEntry())) { |
| 796 | // reference is not in the jar. Ignore it | 529 | // reference is not in the jar. Ignore it |
| 797 | return; | 530 | return; |
| 798 | } | 531 | } |
| 799 | if (m_reference != null) { | 532 | if (m_reference != null) { |
| 800 | m_controller.savePreviousReference(m_reference); | 533 | this.controller.savePreviousReference(m_reference); |
| 801 | } | 534 | } |
| 802 | m_controller.openReference(reference); | 535 | this.controller.openReference(reference); |
| 803 | } | 536 | } |
| 804 | 537 | ||
| 805 | private void startRename() { | 538 | public void startRename() { |
| 806 | 539 | ||
| 807 | // init the text box | 540 | // init the text box |
| 808 | final JTextField text = new JTextField(); | 541 | final JTextField text = new JTextField(); |
| @@ -837,7 +570,7 @@ public class Gui { | |||
| 837 | String newName = text.getText(); | 570 | String newName = text.getText(); |
| 838 | if (saveName && newName != null && newName.length() > 0) { | 571 | if (saveName && newName != null && newName.length() > 0) { |
| 839 | try { | 572 | try { |
| 840 | m_controller.rename(m_reference, newName); | 573 | this.controller.rename(m_reference, newName); |
| 841 | } catch (IllegalNameException ex) { | 574 | } catch (IllegalNameException ex) { |
| 842 | text.setBorder(BorderFactory.createLineBorder(Color.red, 1)); | 575 | text.setBorder(BorderFactory.createLineBorder(Color.red, 1)); |
| 843 | text.setToolTipText(ex.getReason()); | 576 | text.setToolTipText(ex.getReason()); |
| @@ -851,12 +584,12 @@ public class Gui { | |||
| 851 | panel.remove(panel.getComponentCount() - 1); | 584 | panel.remove(panel.getComponentCount() - 1); |
| 852 | panel.add(GuiTricks.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT))); | 585 | panel.add(GuiTricks.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT))); |
| 853 | 586 | ||
| 854 | m_editor.grabFocus(); | 587 | this.editor.grabFocus(); |
| 855 | 588 | ||
| 856 | redraw(); | 589 | redraw(); |
| 857 | } | 590 | } |
| 858 | 591 | ||
| 859 | private void showInheritance() { | 592 | public void showInheritance() { |
| 860 | 593 | ||
| 861 | if (m_reference == null) { | 594 | if (m_reference == null) { |
| 862 | return; | 595 | return; |
| @@ -866,7 +599,7 @@ public class Gui { | |||
| 866 | 599 | ||
| 867 | if (m_reference.entry instanceof ClassEntry) { | 600 | if (m_reference.entry instanceof ClassEntry) { |
| 868 | // get the class inheritance | 601 | // get the class inheritance |
| 869 | ClassInheritanceTreeNode classNode = m_controller.getClassInheritance((ClassEntry) m_reference.entry); | 602 | ClassInheritanceTreeNode classNode = this.controller.getClassInheritance((ClassEntry) m_reference.entry); |
| 870 | 603 | ||
| 871 | // show the tree at the root | 604 | // show the tree at the root |
| 872 | TreePath path = getPathToRoot(classNode); | 605 | TreePath path = getPathToRoot(classNode); |
| @@ -875,7 +608,7 @@ public class Gui { | |||
| 875 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); | 608 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); |
| 876 | } else if (m_reference.entry instanceof MethodEntry) { | 609 | } else if (m_reference.entry instanceof MethodEntry) { |
| 877 | // get the method inheritance | 610 | // get the method inheritance |
| 878 | MethodInheritanceTreeNode classNode = m_controller.getMethodInheritance((MethodEntry) m_reference.entry); | 611 | MethodInheritanceTreeNode classNode = this.controller.getMethodInheritance((MethodEntry) m_reference.entry); |
| 879 | 612 | ||
| 880 | // show the tree at the root | 613 | // show the tree at the root |
| 881 | TreePath path = getPathToRoot(classNode); | 614 | TreePath path = getPathToRoot(classNode); |
| @@ -888,7 +621,7 @@ public class Gui { | |||
| 888 | redraw(); | 621 | redraw(); |
| 889 | } | 622 | } |
| 890 | 623 | ||
| 891 | private void showImplementations() { | 624 | public void showImplementations() { |
| 892 | 625 | ||
| 893 | if (m_reference == null) { | 626 | if (m_reference == null) { |
| 894 | return; | 627 | return; |
| @@ -898,7 +631,7 @@ public class Gui { | |||
| 898 | 631 | ||
| 899 | if (m_reference.entry instanceof ClassEntry) { | 632 | if (m_reference.entry instanceof ClassEntry) { |
| 900 | // get the class implementations | 633 | // get the class implementations |
| 901 | ClassImplementationsTreeNode node = m_controller.getClassImplementations((ClassEntry) m_reference.entry); | 634 | ClassImplementationsTreeNode node = this.controller.getClassImplementations((ClassEntry) m_reference.entry); |
| 902 | if (node != null) { | 635 | if (node != null) { |
| 903 | // show the tree at the root | 636 | // show the tree at the root |
| 904 | TreePath path = getPathToRoot(node); | 637 | TreePath path = getPathToRoot(node); |
| @@ -908,7 +641,7 @@ public class Gui { | |||
| 908 | } | 641 | } |
| 909 | } else if (m_reference.entry instanceof MethodEntry) { | 642 | } else if (m_reference.entry instanceof MethodEntry) { |
| 910 | // get the method implementations | 643 | // get the method implementations |
| 911 | MethodImplementationsTreeNode node = m_controller.getMethodImplementations((MethodEntry) m_reference.entry); | 644 | MethodImplementationsTreeNode node = this.controller.getMethodImplementations((MethodEntry) m_reference.entry); |
| 912 | if (node != null) { | 645 | if (node != null) { |
| 913 | // show the tree at the root | 646 | // show the tree at the root |
| 914 | TreePath path = getPathToRoot(node); | 647 | TreePath path = getPathToRoot(node); |
| @@ -922,7 +655,7 @@ public class Gui { | |||
| 922 | redraw(); | 655 | redraw(); |
| 923 | } | 656 | } |
| 924 | 657 | ||
| 925 | private void showCalls() { | 658 | public void showCalls() { |
| 926 | 659 | ||
| 927 | if (m_reference == null) { | 660 | if (m_reference == null) { |
| 928 | return; | 661 | return; |
| @@ -931,16 +664,16 @@ public class Gui { | |||
| 931 | if (m_reference.entry instanceof ClassEntry) { | 664 | if (m_reference.entry instanceof ClassEntry) { |
| 932 | // look for calls to the default constructor | 665 | // look for calls to the default constructor |
| 933 | // TODO: get a list of all the constructors and find calls to all of them | 666 | // TODO: get a list of all the constructors and find calls to all of them |
| 934 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences(new ConstructorEntry((ClassEntry) m_reference.entry, new Signature("()V"))); | 667 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences(new ConstructorEntry((ClassEntry) m_reference.entry, new Signature("()V"))); |
| 935 | m_callsTree.setModel(new DefaultTreeModel(node)); | 668 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 936 | } else if (m_reference.entry instanceof FieldEntry) { | 669 | } else if (m_reference.entry instanceof FieldEntry) { |
| 937 | FieldReferenceTreeNode node = m_controller.getFieldReferences((FieldEntry) m_reference.entry); | 670 | FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) m_reference.entry); |
| 938 | m_callsTree.setModel(new DefaultTreeModel(node)); | 671 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 939 | } else if (m_reference.entry instanceof MethodEntry) { | 672 | } else if (m_reference.entry instanceof MethodEntry) { |
| 940 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences((MethodEntry) m_reference.entry); | 673 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) m_reference.entry); |
| 941 | m_callsTree.setModel(new DefaultTreeModel(node)); | 674 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 942 | } else if (m_reference.entry instanceof ConstructorEntry) { | 675 | } else if (m_reference.entry instanceof ConstructorEntry) { |
| 943 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences((ConstructorEntry) m_reference.entry); | 676 | BehaviorReferenceTreeNode node = this.controller.getMethodReferences((ConstructorEntry) m_reference.entry); |
| 944 | m_callsTree.setModel(new DefaultTreeModel(node)); | 677 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 945 | } | 678 | } |
| 946 | 679 | ||
| @@ -948,11 +681,11 @@ public class Gui { | |||
| 948 | redraw(); | 681 | redraw(); |
| 949 | } | 682 | } |
| 950 | 683 | ||
| 951 | private void toggleMapping() { | 684 | public void toggleMapping() { |
| 952 | if (m_controller.entryHasDeobfuscatedName(m_reference.entry)) { | 685 | if (this.controller.entryHasDeobfuscatedName(m_reference.entry)) { |
| 953 | m_controller.removeMapping(m_reference); | 686 | this.controller.removeMapping(m_reference); |
| 954 | } else { | 687 | } else { |
| 955 | m_controller.markAsDeobfuscated(m_reference); | 688 | this.controller.markAsDeobfuscated(m_reference); |
| 956 | } | 689 | } |
| 957 | } | 690 | } |
| 958 | 691 | ||
| @@ -967,21 +700,21 @@ public class Gui { | |||
| 967 | return new TreePath(nodes.toArray()); | 700 | return new TreePath(nodes.toArray()); |
| 968 | } | 701 | } |
| 969 | 702 | ||
| 970 | private void close() { | 703 | public void close() { |
| 971 | if (!m_controller.isDirty()) { | 704 | if (!this.controller.isDirty()) { |
| 972 | // everything is saved, we can exit safely | 705 | // everything is saved, we can exit safely |
| 973 | m_frame.dispose(); | 706 | this.frame.dispose(); |
| 974 | } else { | 707 | } else { |
| 975 | // ask to save before closing | 708 | // ask to save before closing |
| 976 | String[] options = {"Save and exit", "Discard changes", "Cancel"}; | 709 | String[] options = {"Save and exit", "Discard changes", "Cancel"}; |
| 977 | int response = JOptionPane.showOptionDialog(m_frame, "Your mappings have not been saved yet. Do you want to save?", "Save your changes?", JOptionPane.YES_NO_CANCEL_OPTION, | 710 | int response = JOptionPane.showOptionDialog(this.frame, "Your mappings have not been saved yet. Do you want to save?", "Save your changes?", JOptionPane.YES_NO_CANCEL_OPTION, |
| 978 | JOptionPane.QUESTION_MESSAGE, null, options, options[2]); | 711 | JOptionPane.QUESTION_MESSAGE, null, options, options[2]); |
| 979 | switch (response) { | 712 | switch (response) { |
| 980 | case JOptionPane.YES_OPTION: // save and exit | 713 | case JOptionPane.YES_OPTION: // save and exit |
| 981 | if (m_mappingsFileChooser.getSelectedFile() != null || m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { | 714 | if (this.mappingsFileChooser.getSelectedFile() != null || this.mappingsFileChooser.showSaveDialog(this.frame) == JFileChooser.APPROVE_OPTION) { |
| 982 | try { | 715 | try { |
| 983 | m_controller.saveMappings(m_mappingsFileChooser.getCurrentDirectory()); | 716 | this.controller.saveMappings(this.mappingsFileChooser.getCurrentDirectory()); |
| 984 | m_frame.dispose(); | 717 | this.frame.dispose(); |
| 985 | } catch (IOException ex) { | 718 | } catch (IOException ex) { |
| 986 | throw new Error(ex); | 719 | throw new Error(ex); |
| 987 | } | 720 | } |
| @@ -990,7 +723,7 @@ public class Gui { | |||
| 990 | 723 | ||
| 991 | case JOptionPane.NO_OPTION: | 724 | case JOptionPane.NO_OPTION: |
| 992 | // don't save, exit | 725 | // don't save, exit |
| 993 | m_frame.dispose(); | 726 | this.frame.dispose(); |
| 994 | break; | 727 | break; |
| 995 | 728 | ||
| 996 | // cancel means do nothing | 729 | // cancel means do nothing |
| @@ -998,8 +731,8 @@ public class Gui { | |||
| 998 | } | 731 | } |
| 999 | } | 732 | } |
| 1000 | 733 | ||
| 1001 | private void redraw() { | 734 | public void redraw() { |
| 1002 | m_frame.validate(); | 735 | this.frame.validate(); |
| 1003 | m_frame.repaint(); | 736 | this.frame.repaint(); |
| 1004 | } | 737 | } |
| 1005 | } | 738 | } |