diff options
Diffstat (limited to 'src/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 1265 |
1 files changed, 525 insertions, 740 deletions
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index faa9b7b..86ba93b 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -88,8 +88,8 @@ import cuchaz.enigma.mapping.IllegalNameException; | |||
| 88 | import cuchaz.enigma.mapping.MappingParseException; | 88 | import cuchaz.enigma.mapping.MappingParseException; |
| 89 | import cuchaz.enigma.mapping.MethodEntry; | 89 | import cuchaz.enigma.mapping.MethodEntry; |
| 90 | 90 | ||
| 91 | public class Gui | 91 | public class Gui { |
| 92 | { | 92 | |
| 93 | private GuiController m_controller; | 93 | private GuiController m_controller; |
| 94 | 94 | ||
| 95 | // controls | 95 | // controls |
| @@ -133,81 +133,74 @@ public class Gui | |||
| 133 | private JFileChooser m_exportSourceFileChooser; | 133 | private JFileChooser m_exportSourceFileChooser; |
| 134 | private JFileChooser m_exportJarFileChooser; | 134 | private JFileChooser m_exportJarFileChooser; |
| 135 | 135 | ||
| 136 | public Gui( ) | 136 | public Gui() { |
| 137 | { | 137 | |
| 138 | // init frame | 138 | // init frame |
| 139 | m_frame = new JFrame( Constants.Name ); | 139 | m_frame = new JFrame(Constants.Name); |
| 140 | final Container pane = m_frame.getContentPane(); | 140 | final Container pane = m_frame.getContentPane(); |
| 141 | pane.setLayout( new BorderLayout() ); | 141 | pane.setLayout(new BorderLayout()); |
| 142 | 142 | ||
| 143 | if( Boolean.parseBoolean( System.getProperty( "enigma.catchExceptions", "true" ) ) ) | 143 | if (Boolean.parseBoolean(System.getProperty("enigma.catchExceptions", "true"))) { |
| 144 | { | ||
| 145 | // install a global exception handler to the event thread | 144 | // install a global exception handler to the event thread |
| 146 | CrashDialog.init( m_frame ); | 145 | CrashDialog.init(m_frame); |
| 147 | Thread.setDefaultUncaughtExceptionHandler( new UncaughtExceptionHandler( ) | 146 | Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { |
| 148 | { | ||
| 149 | @Override | 147 | @Override |
| 150 | public void uncaughtException( Thread thread, Throwable ex ) | 148 | public void uncaughtException(Thread thread, Throwable ex) { |
| 151 | { | 149 | ex.printStackTrace(System.err); |
| 152 | ex.printStackTrace( System.err ); | 150 | CrashDialog.show(ex); |
| 153 | CrashDialog.show( ex ); | ||
| 154 | } | 151 | } |
| 155 | } ); | 152 | }); |
| 156 | } | 153 | } |
| 157 | 154 | ||
| 158 | m_controller = new GuiController( this ); | 155 | m_controller = new GuiController(this); |
| 159 | 156 | ||
| 160 | // init file choosers | 157 | // init file choosers |
| 161 | m_jarFileChooser = new JFileChooser(); | 158 | m_jarFileChooser = new JFileChooser(); |
| 162 | m_mappingsFileChooser = new JFileChooser(); | 159 | m_mappingsFileChooser = new JFileChooser(); |
| 163 | m_exportSourceFileChooser = new JFileChooser(); | 160 | m_exportSourceFileChooser = new JFileChooser(); |
| 164 | m_exportSourceFileChooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); | 161 | m_exportSourceFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 165 | m_exportJarFileChooser = new JFileChooser(); | 162 | m_exportJarFileChooser = new JFileChooser(); |
| 166 | 163 | ||
| 167 | // init obfuscated classes list | 164 | // init obfuscated classes list |
| 168 | m_obfClasses = new ClassSelector( ClassSelector.ObfuscatedClassEntryComparator ); | 165 | m_obfClasses = new ClassSelector(ClassSelector.ObfuscatedClassEntryComparator); |
| 169 | m_obfClasses.setListener( new ClassSelectionListener( ) | 166 | m_obfClasses.setListener(new ClassSelectionListener() { |
| 170 | { | ||
| 171 | @Override | 167 | @Override |
| 172 | public void onSelectClass( ClassEntry classEntry ) | 168 | public void onSelectClass(ClassEntry classEntry) { |
| 173 | { | 169 | navigateTo(classEntry); |
| 174 | navigateTo( classEntry ); | ||
| 175 | } | 170 | } |
| 176 | } ); | 171 | }); |
| 177 | JScrollPane obfScroller = new JScrollPane( m_obfClasses ); | 172 | JScrollPane obfScroller = new JScrollPane(m_obfClasses); |
| 178 | JPanel obfPanel = new JPanel(); | 173 | JPanel obfPanel = new JPanel(); |
| 179 | obfPanel.setLayout( new BorderLayout() ); | 174 | obfPanel.setLayout(new BorderLayout()); |
| 180 | obfPanel.add( new JLabel( "Obfuscated Classes" ), BorderLayout.NORTH ); | 175 | obfPanel.add(new JLabel("Obfuscated Classes"), BorderLayout.NORTH); |
| 181 | obfPanel.add( obfScroller, BorderLayout.CENTER ); | 176 | obfPanel.add(obfScroller, BorderLayout.CENTER); |
| 182 | 177 | ||
| 183 | // init deobfuscated classes list | 178 | // init deobfuscated classes list |
| 184 | m_deobfClasses = new ClassSelector( ClassSelector.DeobfuscatedClassEntryComparator ); | 179 | m_deobfClasses = new ClassSelector(ClassSelector.DeobfuscatedClassEntryComparator); |
| 185 | m_deobfClasses.setListener( new ClassSelectionListener( ) | 180 | m_deobfClasses.setListener(new ClassSelectionListener() { |
| 186 | { | ||
| 187 | @Override | 181 | @Override |
| 188 | public void onSelectClass( ClassEntry classEntry ) | 182 | public void onSelectClass(ClassEntry classEntry) { |
| 189 | { | 183 | navigateTo(classEntry); |
| 190 | navigateTo( classEntry ); | ||
| 191 | } | 184 | } |
| 192 | } ); | 185 | }); |
| 193 | JScrollPane deobfScroller = new JScrollPane( m_deobfClasses ); | 186 | JScrollPane deobfScroller = new JScrollPane(m_deobfClasses); |
| 194 | JPanel deobfPanel = new JPanel(); | 187 | JPanel deobfPanel = new JPanel(); |
| 195 | deobfPanel.setLayout( new BorderLayout() ); | 188 | deobfPanel.setLayout(new BorderLayout()); |
| 196 | deobfPanel.add( new JLabel( "De-obfuscated Classes" ), BorderLayout.NORTH ); | 189 | deobfPanel.add(new JLabel("De-obfuscated Classes"), BorderLayout.NORTH); |
| 197 | deobfPanel.add( deobfScroller, BorderLayout.CENTER ); | 190 | deobfPanel.add(deobfScroller, BorderLayout.CENTER); |
| 198 | 191 | ||
| 199 | // set up classes panel (don't add the splitter yet) | 192 | // set up classes panel (don't add the splitter yet) |
| 200 | m_splitClasses = new JSplitPane( JSplitPane.VERTICAL_SPLIT, true, obfPanel, deobfPanel ); | 193 | m_splitClasses = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, obfPanel, deobfPanel); |
| 201 | m_splitClasses.setResizeWeight( 0.3 ); | 194 | m_splitClasses.setResizeWeight(0.3); |
| 202 | m_classesPanel = new JPanel(); | 195 | m_classesPanel = new JPanel(); |
| 203 | m_classesPanel.setLayout( new BorderLayout() ); | 196 | m_classesPanel.setLayout(new BorderLayout()); |
| 204 | m_classesPanel.setPreferredSize( new Dimension( 250, 0 ) ); | 197 | m_classesPanel.setPreferredSize(new Dimension(250, 0)); |
| 205 | 198 | ||
| 206 | // init info panel | 199 | // init info panel |
| 207 | m_infoPanel = new JPanel(); | 200 | m_infoPanel = new JPanel(); |
| 208 | m_infoPanel.setLayout( new GridLayout( 4, 1, 0, 0 ) ); | 201 | m_infoPanel.setLayout(new GridLayout(4, 1, 0, 0)); |
| 209 | m_infoPanel.setPreferredSize( new Dimension( 0, 100 ) ); | 202 | m_infoPanel.setPreferredSize(new Dimension(0, 100)); |
| 210 | m_infoPanel.setBorder( BorderFactory.createTitledBorder( "Identifier Info" ) ); | 203 | m_infoPanel.setBorder(BorderFactory.createTitledBorder("Identifier Info")); |
| 211 | clearReference(); | 204 | clearReference(); |
| 212 | 205 | ||
| 213 | // init editor | 206 | // init editor |
| @@ -217,25 +210,20 @@ public class Gui | |||
| 217 | m_otherHighlightPainter = new OtherHighlightPainter(); | 210 | m_otherHighlightPainter = new OtherHighlightPainter(); |
| 218 | m_selectionHighlightPainter = new SelectionHighlightPainter(); | 211 | m_selectionHighlightPainter = new SelectionHighlightPainter(); |
| 219 | m_editor = new JEditorPane(); | 212 | m_editor = new JEditorPane(); |
| 220 | m_editor.setEditable( false ); | 213 | m_editor.setEditable(false); |
| 221 | m_editor.setCaret( new BrowserCaret() ); | 214 | m_editor.setCaret(new BrowserCaret()); |
| 222 | JScrollPane sourceScroller = new JScrollPane( m_editor ); | 215 | JScrollPane sourceScroller = new JScrollPane(m_editor); |
| 223 | m_editor.setContentType( "text/java" ); | 216 | m_editor.setContentType("text/java"); |
| 224 | m_editor.addCaretListener( new CaretListener( ) | 217 | m_editor.addCaretListener(new CaretListener() { |
| 225 | { | ||
| 226 | @Override | 218 | @Override |
| 227 | public void caretUpdate( CaretEvent event ) | 219 | public void caretUpdate(CaretEvent event) { |
| 228 | { | 220 | onCaretMove(event.getDot()); |
| 229 | onCaretMove( event.getDot() ); | ||
| 230 | } | 221 | } |
| 231 | } ); | 222 | }); |
| 232 | m_editor.addKeyListener( new KeyAdapter( ) | 223 | m_editor.addKeyListener(new KeyAdapter() { |
| 233 | { | ||
| 234 | @Override | 224 | @Override |
| 235 | public void keyPressed( KeyEvent event ) | 225 | public void keyPressed(KeyEvent event) { |
| 236 | { | 226 | switch (event.getKeyCode()) { |
| 237 | switch( event.getKeyCode() ) | ||
| 238 | { | ||
| 239 | case KeyEvent.VK_R: | 227 | case KeyEvent.VK_R: |
| 240 | m_renameMenu.doClick(); | 228 | m_renameMenu.doClick(); |
| 241 | break; | 229 | break; |
| @@ -265,713 +253,594 @@ public class Gui | |||
| 265 | break; | 253 | break; |
| 266 | } | 254 | } |
| 267 | } | 255 | } |
| 268 | } ); | 256 | }); |
| 269 | 257 | ||
| 270 | // turn off token highlighting (it's wrong most of the time anyway...) | 258 | // turn off token highlighting (it's wrong most of the time anyway...) |
| 271 | DefaultSyntaxKit kit = (DefaultSyntaxKit)m_editor.getEditorKit(); | 259 | DefaultSyntaxKit kit = (DefaultSyntaxKit)m_editor.getEditorKit(); |
| 272 | kit.toggleComponent( m_editor, "jsyntaxpane.components.TokenMarker" ); | 260 | kit.toggleComponent(m_editor, "jsyntaxpane.components.TokenMarker"); |
| 273 | 261 | ||
| 274 | // init editor popup menu | 262 | // init editor popup menu |
| 275 | JPopupMenu popupMenu = new JPopupMenu(); | 263 | JPopupMenu popupMenu = new JPopupMenu(); |
| 276 | m_editor.setComponentPopupMenu( popupMenu ); | 264 | m_editor.setComponentPopupMenu(popupMenu); |
| 277 | { | 265 | { |
| 278 | JMenuItem menu = new JMenuItem( "Rename" ); | 266 | JMenuItem menu = new JMenuItem("Rename"); |
| 279 | menu.addActionListener( new ActionListener( ) | 267 | menu.addActionListener(new ActionListener() { |
| 280 | { | ||
| 281 | @Override | 268 | @Override |
| 282 | public void actionPerformed( ActionEvent event ) | 269 | public void actionPerformed(ActionEvent event) { |
| 283 | { | ||
| 284 | startRename(); | 270 | startRename(); |
| 285 | } | 271 | } |
| 286 | } ); | 272 | }); |
| 287 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_R, 0 ) ); | 273 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0)); |
| 288 | menu.setEnabled( false ); | 274 | menu.setEnabled(false); |
| 289 | popupMenu.add( menu ); | 275 | popupMenu.add(menu); |
| 290 | m_renameMenu = menu; | 276 | m_renameMenu = menu; |
| 291 | } | 277 | } |
| 292 | { | 278 | { |
| 293 | JMenuItem menu = new JMenuItem( "Show Inheritance" ); | 279 | JMenuItem menu = new JMenuItem("Show Inheritance"); |
| 294 | menu.addActionListener( new ActionListener( ) | 280 | menu.addActionListener(new ActionListener() { |
| 295 | { | ||
| 296 | @Override | 281 | @Override |
| 297 | public void actionPerformed( ActionEvent event ) | 282 | public void actionPerformed(ActionEvent event) { |
| 298 | { | ||
| 299 | showInheritance(); | 283 | showInheritance(); |
| 300 | } | 284 | } |
| 301 | } ); | 285 | }); |
| 302 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_I, 0 ) ); | 286 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, 0)); |
| 303 | menu.setEnabled( false ); | 287 | menu.setEnabled(false); |
| 304 | popupMenu.add( menu ); | 288 | popupMenu.add(menu); |
| 305 | m_showInheritanceMenu = menu; | 289 | m_showInheritanceMenu = menu; |
| 306 | } | 290 | } |
| 307 | { | 291 | { |
| 308 | JMenuItem menu = new JMenuItem( "Show Implementations" ); | 292 | JMenuItem menu = new JMenuItem("Show Implementations"); |
| 309 | menu.addActionListener( new ActionListener( ) | 293 | menu.addActionListener(new ActionListener() { |
| 310 | { | ||
| 311 | @Override | 294 | @Override |
| 312 | public void actionPerformed( ActionEvent event ) | 295 | public void actionPerformed(ActionEvent event) { |
| 313 | { | ||
| 314 | showImplementations(); | 296 | showImplementations(); |
| 315 | } | 297 | } |
| 316 | } ); | 298 | }); |
| 317 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_M, 0 ) ); | 299 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0)); |
| 318 | menu.setEnabled( false ); | 300 | menu.setEnabled(false); |
| 319 | popupMenu.add( menu ); | 301 | popupMenu.add(menu); |
| 320 | m_showImplementationsMenu = menu; | 302 | m_showImplementationsMenu = menu; |
| 321 | } | 303 | } |
| 322 | { | 304 | { |
| 323 | JMenuItem menu = new JMenuItem( "Show Calls" ); | 305 | JMenuItem menu = new JMenuItem("Show Calls"); |
| 324 | menu.addActionListener( new ActionListener( ) | 306 | menu.addActionListener(new ActionListener() { |
| 325 | { | ||
| 326 | @Override | 307 | @Override |
| 327 | public void actionPerformed( ActionEvent event ) | 308 | public void actionPerformed(ActionEvent event) { |
| 328 | { | ||
| 329 | showCalls(); | 309 | showCalls(); |
| 330 | } | 310 | } |
| 331 | } ); | 311 | }); |
| 332 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C, 0 ) ); | 312 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, 0)); |
| 333 | menu.setEnabled( false ); | 313 | menu.setEnabled(false); |
| 334 | popupMenu.add( menu ); | 314 | popupMenu.add(menu); |
| 335 | m_showCallsMenu = menu; | 315 | m_showCallsMenu = menu; |
| 336 | } | 316 | } |
| 337 | { | 317 | { |
| 338 | JMenuItem menu = new JMenuItem( "Go to Declaration" ); | 318 | JMenuItem menu = new JMenuItem("Go to Declaration"); |
| 339 | menu.addActionListener( new ActionListener( ) | 319 | menu.addActionListener(new ActionListener() { |
| 340 | { | ||
| 341 | @Override | 320 | @Override |
| 342 | public void actionPerformed( ActionEvent event ) | 321 | public void actionPerformed(ActionEvent event) { |
| 343 | { | 322 | navigateTo(m_reference.entry); |
| 344 | navigateTo( m_reference.entry ); | ||
| 345 | } | 323 | } |
| 346 | } ); | 324 | }); |
| 347 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_N, 0 ) ); | 325 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, 0)); |
| 348 | menu.setEnabled( false ); | 326 | menu.setEnabled(false); |
| 349 | popupMenu.add( menu ); | 327 | popupMenu.add(menu); |
| 350 | m_openEntryMenu = menu; | 328 | m_openEntryMenu = menu; |
| 351 | } | 329 | } |
| 352 | { | 330 | { |
| 353 | JMenuItem menu = new JMenuItem( "Go to previous" ); | 331 | JMenuItem menu = new JMenuItem("Go to previous"); |
| 354 | menu.addActionListener( new ActionListener( ) | 332 | menu.addActionListener(new ActionListener() { |
| 355 | { | ||
| 356 | @Override | 333 | @Override |
| 357 | public void actionPerformed( ActionEvent event ) | 334 | public void actionPerformed(ActionEvent event) { |
| 358 | { | ||
| 359 | m_controller.openPreviousReference(); | 335 | m_controller.openPreviousReference(); |
| 360 | } | 336 | } |
| 361 | } ); | 337 | }); |
| 362 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_P, 0 ) ); | 338 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, 0)); |
| 363 | menu.setEnabled( false ); | 339 | menu.setEnabled(false); |
| 364 | popupMenu.add( menu ); | 340 | popupMenu.add(menu); |
| 365 | m_openPreviousMenu = menu; | 341 | m_openPreviousMenu = menu; |
| 366 | } | 342 | } |
| 367 | { | 343 | { |
| 368 | JMenuItem menu = new JMenuItem( "Mark as deobfuscated" ); | 344 | JMenuItem menu = new JMenuItem("Mark as deobfuscated"); |
| 369 | menu.addActionListener( new ActionListener( ) | 345 | menu.addActionListener(new ActionListener() { |
| 370 | { | ||
| 371 | @Override | 346 | @Override |
| 372 | public void actionPerformed( ActionEvent event ) | 347 | public void actionPerformed(ActionEvent event) { |
| 373 | { | ||
| 374 | toggleMapping(); | 348 | toggleMapping(); |
| 375 | } | 349 | } |
| 376 | } ); | 350 | }); |
| 377 | menu.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_T, 0 ) ); | 351 | menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, 0)); |
| 378 | menu.setEnabled( false ); | 352 | menu.setEnabled(false); |
| 379 | popupMenu.add( menu ); | 353 | popupMenu.add(menu); |
| 380 | m_toggleMappingMenu = menu; | 354 | m_toggleMappingMenu = menu; |
| 381 | } | 355 | } |
| 382 | 356 | ||
| 383 | // init inheritance panel | 357 | // init inheritance panel |
| 384 | m_inheritanceTree = new JTree(); | 358 | m_inheritanceTree = new JTree(); |
| 385 | m_inheritanceTree.setModel( null ); | 359 | m_inheritanceTree.setModel(null); |
| 386 | m_inheritanceTree.addMouseListener( new MouseAdapter( ) | 360 | m_inheritanceTree.addMouseListener(new MouseAdapter() { |
| 387 | { | ||
| 388 | @Override | 361 | @Override |
| 389 | public void mouseClicked( MouseEvent event ) | 362 | public void mouseClicked(MouseEvent event) { |
| 390 | { | 363 | if (event.getClickCount() == 2) { |
| 391 | if( event.getClickCount() == 2 ) | ||
| 392 | { | ||
| 393 | // get the selected node | 364 | // get the selected node |
| 394 | TreePath path = m_inheritanceTree.getSelectionPath(); | 365 | TreePath path = m_inheritanceTree.getSelectionPath(); |
| 395 | if( path == null ) | 366 | if (path == null) { |
| 396 | { | ||
| 397 | return; | 367 | return; |
| 398 | } | 368 | } |
| 399 | 369 | ||
| 400 | Object node = path.getLastPathComponent(); | 370 | Object node = path.getLastPathComponent(); |
| 401 | if( node instanceof ClassInheritanceTreeNode ) | 371 | if (node instanceof ClassInheritanceTreeNode) { |
| 402 | { | ||
| 403 | ClassInheritanceTreeNode classNode = (ClassInheritanceTreeNode)node; | 372 | ClassInheritanceTreeNode classNode = (ClassInheritanceTreeNode)node; |
| 404 | navigateTo( new ClassEntry( classNode.getObfClassName() ) ); | 373 | navigateTo(new ClassEntry(classNode.getObfClassName())); |
| 405 | } | 374 | } else if (node instanceof MethodInheritanceTreeNode) { |
| 406 | else if( node instanceof MethodInheritanceTreeNode ) | ||
| 407 | { | ||
| 408 | MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; | 375 | MethodInheritanceTreeNode methodNode = (MethodInheritanceTreeNode)node; |
| 409 | if( methodNode.isImplemented() ) | 376 | if (methodNode.isImplemented()) { |
| 410 | { | 377 | navigateTo(methodNode.getMethodEntry()); |
| 411 | navigateTo( methodNode.getMethodEntry() ); | ||
| 412 | } | 378 | } |
| 413 | } | 379 | } |
| 414 | } | 380 | } |
| 415 | } | 381 | } |
| 416 | } ); | 382 | }); |
| 417 | JPanel inheritancePanel = new JPanel(); | 383 | JPanel inheritancePanel = new JPanel(); |
| 418 | inheritancePanel.setLayout( new BorderLayout() ); | 384 | inheritancePanel.setLayout(new BorderLayout()); |
| 419 | inheritancePanel.add( new JScrollPane( m_inheritanceTree ) ); | 385 | inheritancePanel.add(new JScrollPane(m_inheritanceTree)); |
| 420 | 386 | ||
| 421 | // init implementations panel | 387 | // init implementations panel |
| 422 | m_implementationsTree = new JTree(); | 388 | m_implementationsTree = new JTree(); |
| 423 | m_implementationsTree.setModel( null ); | 389 | m_implementationsTree.setModel(null); |
| 424 | m_implementationsTree.addMouseListener( new MouseAdapter( ) | 390 | m_implementationsTree.addMouseListener(new MouseAdapter() { |
| 425 | { | ||
| 426 | @Override | 391 | @Override |
| 427 | public void mouseClicked( MouseEvent event ) | 392 | public void mouseClicked(MouseEvent event) { |
| 428 | { | 393 | if (event.getClickCount() == 2) { |
| 429 | if( event.getClickCount() == 2 ) | ||
| 430 | { | ||
| 431 | // get the selected node | 394 | // get the selected node |
| 432 | TreePath path = m_implementationsTree.getSelectionPath(); | 395 | TreePath path = m_implementationsTree.getSelectionPath(); |
| 433 | if( path == null ) | 396 | if (path == null) { |
| 434 | { | ||
| 435 | return; | 397 | return; |
| 436 | } | 398 | } |
| 437 | 399 | ||
| 438 | Object node = path.getLastPathComponent(); | 400 | Object node = path.getLastPathComponent(); |
| 439 | if( node instanceof ClassImplementationsTreeNode ) | 401 | if (node instanceof ClassImplementationsTreeNode) { |
| 440 | { | ||
| 441 | ClassImplementationsTreeNode classNode = (ClassImplementationsTreeNode)node; | 402 | ClassImplementationsTreeNode classNode = (ClassImplementationsTreeNode)node; |
| 442 | navigateTo( classNode.getClassEntry() ); | 403 | navigateTo(classNode.getClassEntry()); |
| 443 | } | 404 | } else if (node instanceof MethodImplementationsTreeNode) { |
| 444 | else if( node instanceof MethodImplementationsTreeNode ) | ||
| 445 | { | ||
| 446 | MethodImplementationsTreeNode methodNode = (MethodImplementationsTreeNode)node; | 405 | MethodImplementationsTreeNode methodNode = (MethodImplementationsTreeNode)node; |
| 447 | navigateTo( methodNode.getMethodEntry() ); | 406 | navigateTo(methodNode.getMethodEntry()); |
| 448 | } | 407 | } |
| 449 | } | 408 | } |
| 450 | } | 409 | } |
| 451 | } ); | 410 | }); |
| 452 | JPanel implementationsPanel = new JPanel(); | 411 | JPanel implementationsPanel = new JPanel(); |
| 453 | implementationsPanel.setLayout( new BorderLayout() ); | 412 | implementationsPanel.setLayout(new BorderLayout()); |
| 454 | implementationsPanel.add( new JScrollPane( m_implementationsTree ) ); | 413 | implementationsPanel.add(new JScrollPane(m_implementationsTree)); |
| 455 | 414 | ||
| 456 | // init call panel | 415 | // init call panel |
| 457 | m_callsTree = new JTree(); | 416 | m_callsTree = new JTree(); |
| 458 | m_callsTree.setModel( null ); | 417 | m_callsTree.setModel(null); |
| 459 | m_callsTree.addMouseListener( new MouseAdapter( ) | 418 | m_callsTree.addMouseListener(new MouseAdapter() { |
| 460 | { | 419 | @SuppressWarnings("unchecked") |
| 461 | @SuppressWarnings( "unchecked" ) | ||
| 462 | @Override | 420 | @Override |
| 463 | public void mouseClicked( MouseEvent event ) | 421 | public void mouseClicked(MouseEvent event) { |
| 464 | { | 422 | if (event.getClickCount() == 2) { |
| 465 | if( event.getClickCount() == 2 ) | ||
| 466 | { | ||
| 467 | // get the selected node | 423 | // get the selected node |
| 468 | TreePath path = m_callsTree.getSelectionPath(); | 424 | TreePath path = m_callsTree.getSelectionPath(); |
| 469 | if( path == null ) | 425 | if (path == null) { |
| 470 | { | ||
| 471 | return; | 426 | return; |
| 472 | } | 427 | } |
| 473 | 428 | ||
| 474 | Object node = path.getLastPathComponent(); | 429 | Object node = path.getLastPathComponent(); |
| 475 | if( node instanceof ReferenceTreeNode ) | 430 | if (node instanceof ReferenceTreeNode) { |
| 476 | { | ||
| 477 | ReferenceTreeNode<Entry,Entry> referenceNode = ((ReferenceTreeNode<Entry,Entry>)node); | 431 | ReferenceTreeNode<Entry,Entry> referenceNode = ((ReferenceTreeNode<Entry,Entry>)node); |
| 478 | if( referenceNode.getReference() != null ) | 432 | if (referenceNode.getReference() != null) { |
| 479 | { | 433 | navigateTo(referenceNode.getReference()); |
| 480 | navigateTo( referenceNode.getReference() ); | 434 | } else { |
| 481 | } | 435 | navigateTo(referenceNode.getEntry()); |
| 482 | else | ||
| 483 | { | ||
| 484 | navigateTo( referenceNode.getEntry() ); | ||
| 485 | } | 436 | } |
| 486 | } | 437 | } |
| 487 | } | 438 | } |
| 488 | } | 439 | } |
| 489 | } ); | 440 | }); |
| 490 | m_tokens = new JList<Token>(); | 441 | m_tokens = new JList<Token>(); |
| 491 | m_tokens.setCellRenderer( new TokenListCellRenderer( m_controller ) ); | 442 | m_tokens.setCellRenderer(new TokenListCellRenderer(m_controller)); |
| 492 | m_tokens.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); | 443 | m_tokens.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
| 493 | m_tokens.setLayoutOrientation( JList.VERTICAL ); | 444 | m_tokens.setLayoutOrientation(JList.VERTICAL); |
| 494 | m_tokens.addMouseListener( new MouseAdapter() | 445 | m_tokens.addMouseListener(new MouseAdapter() { |
| 495 | { | ||
| 496 | @Override | 446 | @Override |
| 497 | public void mouseClicked( MouseEvent event ) | 447 | public void mouseClicked(MouseEvent event) { |
| 498 | { | 448 | if (event.getClickCount() == 2) { |
| 499 | if( event.getClickCount() == 2 ) | ||
| 500 | { | ||
| 501 | Token selected = m_tokens.getSelectedValue(); | 449 | Token selected = m_tokens.getSelectedValue(); |
| 502 | if( selected != null ) | 450 | if (selected != null) { |
| 503 | { | 451 | showToken(selected); |
| 504 | showToken( selected ); | ||
| 505 | } | 452 | } |
| 506 | } | 453 | } |
| 507 | } | 454 | } |
| 508 | } ); | 455 | }); |
| 509 | m_tokens.setPreferredSize( new Dimension( 0, 200 ) ); | 456 | m_tokens.setPreferredSize(new Dimension(0, 200)); |
| 510 | m_tokens.setMinimumSize( new Dimension( 0, 200 ) ); | 457 | m_tokens.setMinimumSize(new Dimension(0, 200)); |
| 511 | JSplitPane callPanel = new JSplitPane( JSplitPane.VERTICAL_SPLIT, true, new JScrollPane( m_callsTree ), new JScrollPane( m_tokens ) ); | 458 | JSplitPane callPanel = new JSplitPane( |
| 512 | callPanel.setResizeWeight( 1 ); // let the top side take all the slack | 459 | JSplitPane.VERTICAL_SPLIT, |
| 460 | true, | ||
| 461 | new JScrollPane(m_callsTree), | ||
| 462 | new JScrollPane(m_tokens) | ||
| 463 | ); | ||
| 464 | callPanel.setResizeWeight(1); // let the top side take all the slack | ||
| 513 | callPanel.resetToPreferredSizes(); | 465 | callPanel.resetToPreferredSizes(); |
| 514 | 466 | ||
| 515 | // layout controls | 467 | // layout controls |
| 516 | JPanel centerPanel = new JPanel(); | 468 | JPanel centerPanel = new JPanel(); |
| 517 | centerPanel.setLayout( new BorderLayout() ); | 469 | centerPanel.setLayout(new BorderLayout()); |
| 518 | centerPanel.add( m_infoPanel, BorderLayout.NORTH ); | 470 | centerPanel.add(m_infoPanel, BorderLayout.NORTH); |
| 519 | centerPanel.add( sourceScroller, BorderLayout.CENTER ); | 471 | centerPanel.add(sourceScroller, BorderLayout.CENTER); |
| 520 | m_tabs = new JTabbedPane(); | 472 | m_tabs = new JTabbedPane(); |
| 521 | m_tabs.setPreferredSize( new Dimension( 250, 0 ) ); | 473 | m_tabs.setPreferredSize(new Dimension(250, 0)); |
| 522 | m_tabs.addTab( "Inheritance", inheritancePanel ); | 474 | m_tabs.addTab("Inheritance", inheritancePanel); |
| 523 | m_tabs.addTab( "Implementations", implementationsPanel ); | 475 | m_tabs.addTab("Implementations", implementationsPanel); |
| 524 | m_tabs.addTab( "Call Graph", callPanel ); | 476 | m_tabs.addTab("Call Graph", callPanel); |
| 525 | JSplitPane splitRight = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs ); | 477 | JSplitPane splitRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, centerPanel, m_tabs); |
| 526 | splitRight.setResizeWeight( 1 ); // let the left side take all the slack | 478 | splitRight.setResizeWeight(1); // let the left side take all the slack |
| 527 | splitRight.resetToPreferredSizes(); | 479 | splitRight.resetToPreferredSizes(); |
| 528 | JSplitPane splitCenter = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, true, m_classesPanel, splitRight ); | 480 | JSplitPane splitCenter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, m_classesPanel, splitRight); |
| 529 | splitCenter.setResizeWeight( 0 ); // let the right side take all the slack | 481 | splitCenter.setResizeWeight(0); // let the right side take all the slack |
| 530 | pane.add( splitCenter, BorderLayout.CENTER ); | 482 | pane.add(splitCenter, BorderLayout.CENTER); |
| 531 | 483 | ||
| 532 | // init menus | 484 | // init menus |
| 533 | JMenuBar menuBar = new JMenuBar(); | 485 | JMenuBar menuBar = new JMenuBar(); |
| 534 | m_frame.setJMenuBar( menuBar ); | 486 | m_frame.setJMenuBar(menuBar); |
| 535 | { | 487 | { |
| 536 | JMenu menu = new JMenu( "File" ); | 488 | JMenu menu = new JMenu("File"); |
| 537 | menuBar.add( menu ); | 489 | menuBar.add(menu); |
| 538 | { | 490 | { |
| 539 | JMenuItem item = new JMenuItem( "Open Jar..." ); | 491 | JMenuItem item = new JMenuItem("Open Jar..."); |
| 540 | menu.add( item ); | 492 | menu.add(item); |
| 541 | item.addActionListener( new ActionListener( ) | 493 | item.addActionListener(new ActionListener() { |
| 542 | { | ||
| 543 | @Override | 494 | @Override |
| 544 | public void actionPerformed( ActionEvent event ) | 495 | public void actionPerformed(ActionEvent event) { |
| 545 | { | 496 | if (m_jarFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 546 | if( m_jarFileChooser.showOpenDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | ||
| 547 | { | ||
| 548 | // load the jar in a separate thread | 497 | // load the jar in a separate thread |
| 549 | new Thread( ) | 498 | new Thread() { |
| 550 | { | ||
| 551 | @Override | 499 | @Override |
| 552 | public void run( ) | 500 | public void run() { |
| 553 | { | 501 | try { |
| 554 | try | 502 | m_controller.openJar(m_jarFileChooser.getSelectedFile()); |
| 555 | { | 503 | } catch (IOException ex) { |
| 556 | m_controller.openJar( m_jarFileChooser.getSelectedFile() ); | 504 | throw new Error(ex); |
| 557 | } | ||
| 558 | catch( IOException ex ) | ||
| 559 | { | ||
| 560 | throw new Error( ex ); | ||
| 561 | } | 505 | } |
| 562 | } | 506 | } |
| 563 | }.start(); | 507 | }.start(); |
| 564 | } | 508 | } |
| 565 | } | 509 | } |
| 566 | } ); | 510 | }); |
| 567 | } | 511 | } |
| 568 | { | 512 | { |
| 569 | JMenuItem item = new JMenuItem( "Close Jar" ); | 513 | JMenuItem item = new JMenuItem("Close Jar"); |
| 570 | menu.add( item ); | 514 | menu.add(item); |
| 571 | item.addActionListener( new ActionListener( ) | 515 | item.addActionListener(new ActionListener() { |
| 572 | { | ||
| 573 | @Override | 516 | @Override |
| 574 | public void actionPerformed( ActionEvent event ) | 517 | public void actionPerformed(ActionEvent event) { |
| 575 | { | ||
| 576 | m_controller.closeJar(); | 518 | m_controller.closeJar(); |
| 577 | } | 519 | } |
| 578 | } ); | 520 | }); |
| 579 | m_closeJarMenu = item; | 521 | m_closeJarMenu = item; |
| 580 | } | 522 | } |
| 581 | menu.addSeparator(); | 523 | menu.addSeparator(); |
| 582 | { | 524 | { |
| 583 | JMenuItem item = new JMenuItem( "Open Mappings..." ); | 525 | JMenuItem item = new JMenuItem("Open Mappings..."); |
| 584 | menu.add( item ); | 526 | menu.add(item); |
| 585 | item.addActionListener( new ActionListener( ) | 527 | item.addActionListener(new ActionListener() { |
| 586 | { | ||
| 587 | @Override | 528 | @Override |
| 588 | public void actionPerformed( ActionEvent event ) | 529 | public void actionPerformed(ActionEvent event) { |
| 589 | { | 530 | if (m_mappingsFileChooser.showOpenDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 590 | if( m_mappingsFileChooser.showOpenDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 531 | try { |
| 591 | { | 532 | m_controller.openMappings(m_mappingsFileChooser.getSelectedFile()); |
| 592 | try | 533 | } catch (IOException ex) { |
| 593 | { | 534 | throw new Error(ex); |
| 594 | m_controller.openMappings( m_mappingsFileChooser.getSelectedFile() ); | 535 | } catch (MappingParseException ex) { |
| 595 | } | 536 | JOptionPane.showMessageDialog(m_frame, ex.getMessage()); |
| 596 | catch( IOException ex ) | ||
| 597 | { | ||
| 598 | throw new Error( ex ); | ||
| 599 | } | ||
| 600 | catch( MappingParseException ex ) | ||
| 601 | { | ||
| 602 | JOptionPane.showMessageDialog( m_frame, ex.getMessage() ); | ||
| 603 | } | 537 | } |
| 604 | } | 538 | } |
| 605 | } | 539 | } |
| 606 | } ); | 540 | }); |
| 607 | m_openMappingsMenu = item; | 541 | m_openMappingsMenu = item; |
| 608 | } | 542 | } |
| 609 | { | 543 | { |
| 610 | JMenuItem item = new JMenuItem( "Save Mappings" ); | 544 | JMenuItem item = new JMenuItem("Save Mappings"); |
| 611 | menu.add( item ); | 545 | menu.add(item); |
| 612 | item.addActionListener( new ActionListener( ) | 546 | item.addActionListener(new ActionListener() { |
| 613 | { | ||
| 614 | @Override | 547 | @Override |
| 615 | public void actionPerformed( ActionEvent event ) | 548 | public void actionPerformed(ActionEvent event) { |
| 616 | { | 549 | try { |
| 617 | try | 550 | m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile()); |
| 618 | { | 551 | } catch (IOException ex) { |
| 619 | m_controller.saveMappings( m_mappingsFileChooser.getSelectedFile() ); | 552 | throw new Error(ex); |
| 620 | } | ||
| 621 | catch( IOException ex ) | ||
| 622 | { | ||
| 623 | throw new Error( ex ); | ||
| 624 | } | 553 | } |
| 625 | } | 554 | } |
| 626 | } ); | 555 | }); |
| 627 | item.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK ) ); | 556 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); |
| 628 | m_saveMappingsMenu = item; | 557 | m_saveMappingsMenu = item; |
| 629 | } | 558 | } |
| 630 | { | 559 | { |
| 631 | JMenuItem item = new JMenuItem( "Save Mappings As..." ); | 560 | JMenuItem item = new JMenuItem("Save Mappings As..."); |
| 632 | menu.add( item ); | 561 | menu.add(item); |
| 633 | item.addActionListener( new ActionListener( ) | 562 | item.addActionListener(new ActionListener() { |
| 634 | { | ||
| 635 | @Override | 563 | @Override |
| 636 | public void actionPerformed( ActionEvent event ) | 564 | public void actionPerformed(ActionEvent event) { |
| 637 | { | 565 | if (m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 638 | if( m_mappingsFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 566 | try { |
| 639 | { | 567 | m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile()); |
| 640 | try | 568 | m_saveMappingsMenu.setEnabled(true); |
| 641 | { | 569 | } catch (IOException ex) { |
| 642 | m_controller.saveMappings( m_mappingsFileChooser.getSelectedFile() ); | 570 | throw new Error(ex); |
| 643 | m_saveMappingsMenu.setEnabled( true ); | ||
| 644 | } | ||
| 645 | catch( IOException ex ) | ||
| 646 | { | ||
| 647 | throw new Error( ex ); | ||
| 648 | } | 571 | } |
| 649 | } | 572 | } |
| 650 | } | 573 | } |
| 651 | } ); | 574 | }); |
| 652 | item.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK ) ); | 575 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); |
| 653 | m_saveMappingsAsMenu = item; | 576 | m_saveMappingsAsMenu = item; |
| 654 | } | 577 | } |
| 655 | { | 578 | { |
| 656 | JMenuItem item = new JMenuItem( "Close Mappings" ); | 579 | JMenuItem item = new JMenuItem("Close Mappings"); |
| 657 | menu.add( item ); | 580 | menu.add(item); |
| 658 | item.addActionListener( new ActionListener( ) | 581 | item.addActionListener(new ActionListener() { |
| 659 | { | ||
| 660 | @Override | 582 | @Override |
| 661 | public void actionPerformed( ActionEvent event ) | 583 | public void actionPerformed(ActionEvent event) { |
| 662 | { | ||
| 663 | m_controller.closeMappings(); | 584 | m_controller.closeMappings(); |
| 664 | } | 585 | } |
| 665 | } ); | 586 | }); |
| 666 | m_closeMappingsMenu = item; | 587 | m_closeMappingsMenu = item; |
| 667 | } | 588 | } |
| 668 | menu.addSeparator(); | 589 | menu.addSeparator(); |
| 669 | { | 590 | { |
| 670 | JMenuItem item = new JMenuItem( "Export Source..." ); | 591 | JMenuItem item = new JMenuItem("Export Source..."); |
| 671 | menu.add( item ); | 592 | menu.add(item); |
| 672 | item.addActionListener( new ActionListener( ) | 593 | item.addActionListener(new ActionListener() { |
| 673 | { | ||
| 674 | @Override | 594 | @Override |
| 675 | public void actionPerformed( ActionEvent event ) | 595 | public void actionPerformed(ActionEvent event) { |
| 676 | { | 596 | if (m_exportSourceFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 677 | if( m_exportSourceFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 597 | m_controller.exportSource(m_exportSourceFileChooser.getSelectedFile()); |
| 678 | { | ||
| 679 | m_controller.exportSource( m_exportSourceFileChooser.getSelectedFile() ); | ||
| 680 | } | 598 | } |
| 681 | } | 599 | } |
| 682 | } ); | 600 | }); |
| 683 | m_exportSourceMenu = item; | 601 | m_exportSourceMenu = item; |
| 684 | } | 602 | } |
| 685 | { | 603 | { |
| 686 | JMenuItem item = new JMenuItem( "Export Jar..." ); | 604 | JMenuItem item = new JMenuItem("Export Jar..."); |
| 687 | menu.add( item ); | 605 | menu.add(item); |
| 688 | item.addActionListener( new ActionListener( ) | 606 | item.addActionListener(new ActionListener() { |
| 689 | { | ||
| 690 | @Override | 607 | @Override |
| 691 | public void actionPerformed( ActionEvent event ) | 608 | public void actionPerformed(ActionEvent event) { |
| 692 | { | 609 | if (m_exportJarFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 693 | if( m_exportJarFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 610 | m_controller.exportJar(m_exportJarFileChooser.getSelectedFile()); |
| 694 | { | ||
| 695 | m_controller.exportJar( m_exportJarFileChooser.getSelectedFile() ); | ||
| 696 | } | 611 | } |
| 697 | } | 612 | } |
| 698 | } ); | 613 | }); |
| 699 | m_exportJarMenu = item; | 614 | m_exportJarMenu = item; |
| 700 | } | 615 | } |
| 701 | menu.addSeparator(); | 616 | menu.addSeparator(); |
| 702 | { | 617 | { |
| 703 | JMenuItem item = new JMenuItem( "Exit" ); | 618 | JMenuItem item = new JMenuItem("Exit"); |
| 704 | menu.add( item ); | 619 | menu.add(item); |
| 705 | item.addActionListener( new ActionListener( ) | 620 | item.addActionListener(new ActionListener() { |
| 706 | { | ||
| 707 | @Override | 621 | @Override |
| 708 | public void actionPerformed( ActionEvent event ) | 622 | public void actionPerformed(ActionEvent event) { |
| 709 | { | ||
| 710 | close(); | 623 | close(); |
| 711 | } | 624 | } |
| 712 | } ); | 625 | }); |
| 713 | } | 626 | } |
| 714 | } | 627 | } |
| 715 | { | 628 | { |
| 716 | JMenu menu = new JMenu( "Help" ); | 629 | JMenu menu = new JMenu("Help"); |
| 717 | menuBar.add( menu ); | 630 | menuBar.add(menu); |
| 718 | { | 631 | { |
| 719 | JMenuItem item = new JMenuItem( "About" ); | 632 | JMenuItem item = new JMenuItem("About"); |
| 720 | menu.add( item ); | 633 | menu.add(item); |
| 721 | item.addActionListener( new ActionListener( ) | 634 | item.addActionListener(new ActionListener() { |
| 722 | { | ||
| 723 | @Override | 635 | @Override |
| 724 | public void actionPerformed( ActionEvent event ) | 636 | public void actionPerformed(ActionEvent event) { |
| 725 | { | 637 | AboutDialog.show(m_frame); |
| 726 | AboutDialog.show( m_frame ); | ||
| 727 | } | 638 | } |
| 728 | } ); | 639 | }); |
| 729 | } | 640 | } |
| 730 | } | 641 | } |
| 731 | 642 | ||
| 732 | // init state | 643 | // init state |
| 733 | onCloseJar(); | 644 | onCloseJar(); |
| 734 | 645 | ||
| 735 | m_frame.addWindowListener( new WindowAdapter( ) | 646 | m_frame.addWindowListener(new WindowAdapter() { |
| 736 | { | ||
| 737 | @Override | 647 | @Override |
| 738 | public void windowClosing( WindowEvent event ) | 648 | public void windowClosing(WindowEvent event) { |
| 739 | { | ||
| 740 | close(); | 649 | close(); |
| 741 | } | 650 | } |
| 742 | } ); | 651 | }); |
| 743 | 652 | ||
| 744 | // show the frame | 653 | // show the frame |
| 745 | pane.doLayout(); | 654 | pane.doLayout(); |
| 746 | m_frame.setSize( 1024, 576 ); | 655 | m_frame.setSize(1024, 576); |
| 747 | m_frame.setMinimumSize( new Dimension( 640, 480 ) ); | 656 | m_frame.setMinimumSize(new Dimension(640, 480)); |
| 748 | m_frame.setVisible( true ); | 657 | m_frame.setVisible(true); |
| 749 | m_frame.setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE ); | 658 | m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
| 750 | } | 659 | } |
| 751 | 660 | ||
| 752 | public JFrame getFrame( ) | 661 | public JFrame getFrame() { |
| 753 | { | ||
| 754 | return m_frame; | 662 | return m_frame; |
| 755 | } | 663 | } |
| 756 | 664 | ||
| 757 | public GuiController getController( ) | 665 | public GuiController getController() { |
| 758 | { | ||
| 759 | return m_controller; | 666 | return m_controller; |
| 760 | } | 667 | } |
| 761 | 668 | ||
| 762 | public void onStartOpenJar( ) | 669 | public void onStartOpenJar() { |
| 763 | { | ||
| 764 | m_classesPanel.removeAll(); | 670 | m_classesPanel.removeAll(); |
| 765 | JPanel panel = new JPanel(); | 671 | JPanel panel = new JPanel(); |
| 766 | panel.setLayout( new FlowLayout() ); | 672 | panel.setLayout(new FlowLayout()); |
| 767 | panel.add( new JLabel( "Loading..." ) ); | 673 | panel.add(new JLabel("Loading...")); |
| 768 | m_classesPanel.add( panel ); | 674 | m_classesPanel.add(panel); |
| 769 | redraw(); | 675 | redraw(); |
| 770 | } | 676 | } |
| 771 | 677 | ||
| 772 | public void onFinishOpenJar( String jarName ) | 678 | public void onFinishOpenJar(String jarName) { |
| 773 | { | ||
| 774 | // update gui | 679 | // update gui |
| 775 | m_frame.setTitle( Constants.Name + " - " + jarName ); | 680 | m_frame.setTitle(Constants.Name + " - " + jarName); |
| 776 | m_classesPanel.removeAll(); | 681 | m_classesPanel.removeAll(); |
| 777 | m_classesPanel.add( m_splitClasses ); | 682 | m_classesPanel.add(m_splitClasses); |
| 778 | setSource( null ); | 683 | setSource(null); |
| 779 | 684 | ||
| 780 | // update menu | 685 | // update menu |
| 781 | m_closeJarMenu.setEnabled( true ); | 686 | m_closeJarMenu.setEnabled(true); |
| 782 | m_openMappingsMenu.setEnabled( true ); | 687 | m_openMappingsMenu.setEnabled(true); |
| 783 | m_saveMappingsMenu.setEnabled( false ); | 688 | m_saveMappingsMenu.setEnabled(false); |
| 784 | m_saveMappingsAsMenu.setEnabled( true ); | 689 | m_saveMappingsAsMenu.setEnabled(true); |
| 785 | m_closeMappingsMenu.setEnabled( true ); | 690 | m_closeMappingsMenu.setEnabled(true); |
| 786 | m_exportSourceMenu.setEnabled( true ); | 691 | m_exportSourceMenu.setEnabled(true); |
| 787 | m_exportJarMenu.setEnabled( true ); | 692 | m_exportJarMenu.setEnabled(true); |
| 788 | 693 | ||
| 789 | redraw(); | 694 | redraw(); |
| 790 | } | 695 | } |
| 791 | 696 | ||
| 792 | public void onCloseJar( ) | 697 | public void onCloseJar() { |
| 793 | { | ||
| 794 | // update gui | 698 | // update gui |
| 795 | m_frame.setTitle( Constants.Name ); | 699 | m_frame.setTitle(Constants.Name); |
| 796 | setObfClasses( null ); | 700 | setObfClasses(null); |
| 797 | setDeobfClasses( null ); | 701 | setDeobfClasses(null); |
| 798 | setSource( null ); | 702 | setSource(null); |
| 799 | m_classesPanel.removeAll(); | 703 | m_classesPanel.removeAll(); |
| 800 | 704 | ||
| 801 | // update menu | 705 | // update menu |
| 802 | m_closeJarMenu.setEnabled( false ); | 706 | m_closeJarMenu.setEnabled(false); |
| 803 | m_openMappingsMenu.setEnabled( false ); | 707 | m_openMappingsMenu.setEnabled(false); |
| 804 | m_saveMappingsMenu.setEnabled( false ); | 708 | m_saveMappingsMenu.setEnabled(false); |
| 805 | m_saveMappingsAsMenu.setEnabled( false ); | 709 | m_saveMappingsAsMenu.setEnabled(false); |
| 806 | m_closeMappingsMenu.setEnabled( false ); | 710 | m_closeMappingsMenu.setEnabled(false); |
| 807 | m_exportSourceMenu.setEnabled( false ); | 711 | m_exportSourceMenu.setEnabled(false); |
| 808 | m_exportJarMenu.setEnabled( false ); | 712 | m_exportJarMenu.setEnabled(false); |
| 809 | 713 | ||
| 810 | redraw(); | 714 | redraw(); |
| 811 | } | 715 | } |
| 812 | 716 | ||
| 813 | public void setObfClasses( Collection<ClassEntry> obfClasses ) | 717 | public void setObfClasses(Collection<ClassEntry> obfClasses) { |
| 814 | { | 718 | m_obfClasses.setClasses(obfClasses); |
| 815 | m_obfClasses.setClasses( obfClasses ); | ||
| 816 | } | 719 | } |
| 817 | 720 | ||
| 818 | public void setDeobfClasses( Collection<ClassEntry> deobfClasses ) | 721 | public void setDeobfClasses(Collection<ClassEntry> deobfClasses) { |
| 819 | { | 722 | m_deobfClasses.setClasses(deobfClasses); |
| 820 | m_deobfClasses.setClasses( deobfClasses ); | ||
| 821 | } | 723 | } |
| 822 | 724 | ||
| 823 | public void setMappingsFile( File file ) | 725 | public void setMappingsFile(File file) { |
| 824 | { | 726 | m_mappingsFileChooser.setSelectedFile(file); |
| 825 | m_mappingsFileChooser.setSelectedFile( file ); | 727 | m_saveMappingsMenu.setEnabled(file != null); |
| 826 | m_saveMappingsMenu.setEnabled( file != null ); | ||
| 827 | } | 728 | } |
| 828 | 729 | ||
| 829 | public void setSource( String source ) | 730 | public void setSource(String source) { |
| 830 | { | ||
| 831 | m_editor.getHighlighter().removeAllHighlights(); | 731 | m_editor.getHighlighter().removeAllHighlights(); |
| 832 | m_editor.setText( source ); | 732 | m_editor.setText(source); |
| 833 | } | 733 | } |
| 834 | 734 | ||
| 835 | public void showToken( final Token token ) | 735 | public void showToken(final Token token) { |
| 836 | { | 736 | if (token == null) { |
| 837 | if( token == null ) | 737 | throw new IllegalArgumentException("Token cannot be null!"); |
| 838 | { | ||
| 839 | throw new IllegalArgumentException( "Token cannot be null!" ); | ||
| 840 | } | 738 | } |
| 841 | 739 | ||
| 842 | // set the caret position to the token | 740 | // set the caret position to the token |
| 843 | m_editor.setCaretPosition( token.start ); | 741 | m_editor.setCaretPosition(token.start); |
| 844 | m_editor.grabFocus(); | 742 | m_editor.grabFocus(); |
| 845 | 743 | ||
| 846 | try | 744 | try { |
| 847 | { | ||
| 848 | // make sure the token is visible in the scroll window | 745 | // make sure the token is visible in the scroll window |
| 849 | Rectangle start = m_editor.modelToView( token.start ); | 746 | Rectangle start = m_editor.modelToView(token.start); |
| 850 | Rectangle end = m_editor.modelToView( token.end ); | 747 | Rectangle end = m_editor.modelToView(token.end); |
| 851 | final Rectangle show = start.union( end ); | 748 | final Rectangle show = start.union(end); |
| 852 | show.grow( start.width*10, start.height*6 ); | 749 | show.grow(start.width * 10, start.height * 6); |
| 853 | SwingUtilities.invokeLater( new Runnable( ) | 750 | SwingUtilities.invokeLater(new Runnable() { |
| 854 | { | ||
| 855 | @Override | 751 | @Override |
| 856 | public void run( ) | 752 | public void run() { |
| 857 | { | 753 | m_editor.scrollRectToVisible(show); |
| 858 | m_editor.scrollRectToVisible( show ); | ||
| 859 | } | 754 | } |
| 860 | } ); | 755 | }); |
| 861 | } | 756 | } catch (BadLocationException ex) { |
| 862 | catch( BadLocationException ex ) | 757 | throw new Error(ex); |
| 863 | { | ||
| 864 | throw new Error( ex ); | ||
| 865 | } | 758 | } |
| 866 | 759 | ||
| 867 | // highlight the token momentarily | 760 | // highlight the token momentarily |
| 868 | final Timer timer = new Timer( 200, new ActionListener( ) | 761 | final Timer timer = new Timer(200, new ActionListener() { |
| 869 | { | ||
| 870 | private int m_counter = 0; | 762 | private int m_counter = 0; |
| 871 | private Object m_highlight = null; | 763 | private Object m_highlight = null; |
| 872 | 764 | ||
| 873 | @Override | 765 | @Override |
| 874 | public void actionPerformed( ActionEvent event ) | 766 | public void actionPerformed(ActionEvent event) { |
| 875 | { | 767 | if (m_counter % 2 == 0) { |
| 876 | if( m_counter % 2 == 0 ) | 768 | try { |
| 877 | { | 769 | m_highlight = m_editor.getHighlighter().addHighlight(token.start, token.end, m_selectionHighlightPainter); |
| 878 | try | 770 | } catch (BadLocationException ex) { |
| 879 | { | ||
| 880 | m_highlight = m_editor.getHighlighter().addHighlight( token.start, token.end, m_selectionHighlightPainter ); | ||
| 881 | } | ||
| 882 | catch( BadLocationException ex ) | ||
| 883 | { | ||
| 884 | // don't care | 771 | // don't care |
| 885 | } | 772 | } |
| 886 | } | 773 | } else if (m_highlight != null) { |
| 887 | else if( m_highlight != null ) | 774 | m_editor.getHighlighter().removeHighlight(m_highlight); |
| 888 | { | ||
| 889 | m_editor.getHighlighter().removeHighlight( m_highlight ); | ||
| 890 | } | 775 | } |
| 891 | 776 | ||
| 892 | if( m_counter++ > 6 ) | 777 | if (m_counter++ > 6) { |
| 893 | { | ||
| 894 | Timer timer = (Timer)event.getSource(); | 778 | Timer timer = (Timer)event.getSource(); |
| 895 | timer.stop(); | 779 | timer.stop(); |
| 896 | } | 780 | } |
| 897 | } | 781 | } |
| 898 | } ); | 782 | }); |
| 899 | timer.start(); | 783 | timer.start(); |
| 900 | 784 | ||
| 901 | redraw(); | 785 | redraw(); |
| 902 | } | 786 | } |
| 903 | 787 | ||
| 904 | public void showTokens( Collection<Token> tokens ) | 788 | public void showTokens(Collection<Token> tokens) { |
| 905 | { | 789 | Vector<Token> sortedTokens = new Vector<Token>(tokens); |
| 906 | Vector<Token> sortedTokens = new Vector<Token>( tokens ); | 790 | Collections.sort(sortedTokens); |
| 907 | Collections.sort( sortedTokens ); | 791 | if (sortedTokens.size() > 1) { |
| 908 | if( sortedTokens.size() > 1 ) | ||
| 909 | { | ||
| 910 | // sort the tokens and update the tokens panel | 792 | // sort the tokens and update the tokens panel |
| 911 | m_tokens.setListData( sortedTokens ); | 793 | m_tokens.setListData(sortedTokens); |
| 912 | m_tokens.setSelectedIndex( 0 ); | 794 | m_tokens.setSelectedIndex(0); |
| 913 | } | 795 | } else { |
| 914 | else | 796 | m_tokens.setListData(new Vector<Token>()); |
| 915 | { | ||
| 916 | m_tokens.setListData( new Vector<Token>() ); | ||
| 917 | } | 797 | } |
| 918 | 798 | ||
| 919 | // show the first token | 799 | // show the first token |
| 920 | showToken( sortedTokens.get( 0 ) ); | 800 | showToken(sortedTokens.get(0)); |
| 921 | } | 801 | } |
| 922 | 802 | ||
| 923 | public void setHighlightedTokens( Iterable<Token> obfuscatedTokens, Iterable<Token> deobfuscatedTokens, Iterable<Token> otherTokens ) | 803 | public void setHighlightedTokens(Iterable<Token> obfuscatedTokens, Iterable<Token> deobfuscatedTokens, Iterable<Token> otherTokens) { |
| 924 | { | 804 | |
| 925 | // remove any old highlighters | 805 | // remove any old highlighters |
| 926 | m_editor.getHighlighter().removeAllHighlights(); | 806 | m_editor.getHighlighter().removeAllHighlights(); |
| 927 | 807 | ||
| 928 | // color things based on the index | 808 | // color things based on the index |
| 929 | if( obfuscatedTokens != null ) | 809 | if (obfuscatedTokens != null) { |
| 930 | { | 810 | setHighlightedTokens(obfuscatedTokens, m_obfuscatedHighlightPainter); |
| 931 | setHighlightedTokens( obfuscatedTokens, m_obfuscatedHighlightPainter ); | ||
| 932 | } | 811 | } |
| 933 | if( deobfuscatedTokens != null ) | 812 | if (deobfuscatedTokens != null) { |
| 934 | { | 813 | setHighlightedTokens(deobfuscatedTokens, m_deobfuscatedHighlightPainter); |
| 935 | setHighlightedTokens( deobfuscatedTokens, m_deobfuscatedHighlightPainter ); | ||
| 936 | } | 814 | } |
| 937 | if( otherTokens != null ) | 815 | if (otherTokens != null) { |
| 938 | { | 816 | setHighlightedTokens(otherTokens, m_otherHighlightPainter); |
| 939 | setHighlightedTokens( otherTokens, m_otherHighlightPainter ); | ||
| 940 | } | 817 | } |
| 941 | 818 | ||
| 942 | redraw(); | 819 | redraw(); |
| 943 | } | 820 | } |
| 944 | 821 | ||
| 945 | private void setHighlightedTokens( Iterable<Token> tokens, Highlighter.HighlightPainter painter ) | 822 | private void setHighlightedTokens(Iterable<Token> tokens, Highlighter.HighlightPainter painter) { |
| 946 | { | 823 | for (Token token : tokens) { |
| 947 | for( Token token : tokens ) | 824 | try { |
| 948 | { | 825 | m_editor.getHighlighter().addHighlight(token.start, token.end, painter); |
| 949 | try | 826 | } catch (BadLocationException ex) { |
| 950 | { | 827 | throw new IllegalArgumentException(ex); |
| 951 | m_editor.getHighlighter().addHighlight( token.start, token.end, painter ); | ||
| 952 | } | ||
| 953 | catch( BadLocationException ex ) | ||
| 954 | { | ||
| 955 | throw new IllegalArgumentException( ex ); | ||
| 956 | } | 828 | } |
| 957 | } | 829 | } |
| 958 | } | 830 | } |
| 959 | 831 | ||
| 960 | private void clearReference( ) | 832 | private void clearReference() { |
| 961 | { | ||
| 962 | m_infoPanel.removeAll(); | 833 | m_infoPanel.removeAll(); |
| 963 | JLabel label = new JLabel( "No identifier selected" ); | 834 | JLabel label = new JLabel("No identifier selected"); |
| 964 | GuiTricks.unboldLabel( label ); | 835 | GuiTricks.unboldLabel(label); |
| 965 | label.setHorizontalAlignment( JLabel.CENTER ); | 836 | label.setHorizontalAlignment(JLabel.CENTER); |
| 966 | m_infoPanel.add( label ); | 837 | m_infoPanel.add(label); |
| 967 | 838 | ||
| 968 | redraw(); | 839 | redraw(); |
| 969 | } | 840 | } |
| 970 | 841 | ||
| 971 | private void showReference( EntryReference<Entry,Entry> reference ) | 842 | private void showReference(EntryReference<Entry,Entry> reference) { |
| 972 | { | 843 | if (reference == null) { |
| 973 | if( reference == null ) | ||
| 974 | { | ||
| 975 | clearReference(); | 844 | clearReference(); |
| 976 | return; | 845 | return; |
| 977 | } | 846 | } |
| @@ -979,383 +848,300 @@ public class Gui | |||
| 979 | m_reference = reference; | 848 | m_reference = reference; |
| 980 | 849 | ||
| 981 | m_infoPanel.removeAll(); | 850 | m_infoPanel.removeAll(); |
| 982 | if( reference.entry instanceof ClassEntry ) | 851 | if (reference.entry instanceof ClassEntry) { |
| 983 | { | 852 | showClassEntry((ClassEntry)m_reference.entry); |
| 984 | showClassEntry( (ClassEntry)m_reference.entry ); | 853 | } else if (m_reference.entry instanceof FieldEntry) { |
| 985 | } | 854 | showFieldEntry((FieldEntry)m_reference.entry); |
| 986 | else if( m_reference.entry instanceof FieldEntry ) | 855 | } else if (m_reference.entry instanceof MethodEntry) { |
| 987 | { | 856 | showMethodEntry((MethodEntry)m_reference.entry); |
| 988 | showFieldEntry( (FieldEntry)m_reference.entry ); | 857 | } else if (m_reference.entry instanceof ConstructorEntry) { |
| 989 | } | 858 | showConstructorEntry((ConstructorEntry)m_reference.entry); |
| 990 | else if( m_reference.entry instanceof MethodEntry ) | 859 | } else if (m_reference.entry instanceof ArgumentEntry) { |
| 991 | { | 860 | showArgumentEntry((ArgumentEntry)m_reference.entry); |
| 992 | showMethodEntry( (MethodEntry)m_reference.entry ); | 861 | } else { |
| 993 | } | 862 | throw new Error("Unknown entry type: " + m_reference.entry.getClass().getName()); |
| 994 | else if( m_reference.entry instanceof ConstructorEntry ) | ||
| 995 | { | ||
| 996 | showConstructorEntry( (ConstructorEntry)m_reference.entry ); | ||
| 997 | } | ||
| 998 | else if( m_reference.entry instanceof ArgumentEntry ) | ||
| 999 | { | ||
| 1000 | showArgumentEntry( (ArgumentEntry)m_reference.entry ); | ||
| 1001 | } | ||
| 1002 | else | ||
| 1003 | { | ||
| 1004 | throw new Error( "Unknown entry type: " + m_reference.entry.getClass().getName() ); | ||
| 1005 | } | 863 | } |
| 1006 | 864 | ||
| 1007 | redraw(); | 865 | redraw(); |
| 1008 | } | 866 | } |
| 1009 | 867 | ||
| 1010 | private void showClassEntry( ClassEntry entry ) | 868 | private void showClassEntry(ClassEntry entry) { |
| 1011 | { | 869 | addNameValue(m_infoPanel, "Class", entry.getName()); |
| 1012 | addNameValue( m_infoPanel, "Class", entry.getName() ); | ||
| 1013 | } | 870 | } |
| 1014 | 871 | ||
| 1015 | private void showFieldEntry( FieldEntry entry ) | 872 | private void showFieldEntry(FieldEntry entry) { |
| 1016 | { | 873 | addNameValue(m_infoPanel, "Field", entry.getName()); |
| 1017 | addNameValue( m_infoPanel, "Field", entry.getName() ); | 874 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); |
| 1018 | addNameValue( m_infoPanel, "Class", entry.getClassEntry().getName() ); | ||
| 1019 | } | 875 | } |
| 1020 | 876 | ||
| 1021 | private void showMethodEntry( MethodEntry entry ) | 877 | private void showMethodEntry(MethodEntry entry) { |
| 1022 | { | 878 | addNameValue(m_infoPanel, "Method", entry.getName()); |
| 1023 | addNameValue( m_infoPanel, "Method", entry.getName() ); | 879 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); |
| 1024 | addNameValue( m_infoPanel, "Class", entry.getClassEntry().getName() ); | 880 | addNameValue(m_infoPanel, "Signature", entry.getSignature()); |
| 1025 | addNameValue( m_infoPanel, "Signature", entry.getSignature() ); | ||
| 1026 | } | 881 | } |
| 1027 | 882 | ||
| 1028 | private void showConstructorEntry( ConstructorEntry entry ) | 883 | private void showConstructorEntry(ConstructorEntry entry) { |
| 1029 | { | 884 | addNameValue(m_infoPanel, "Constructor", entry.getClassEntry().getName()); |
| 1030 | addNameValue( m_infoPanel, "Constructor", entry.getClassEntry().getName() ); | 885 | addNameValue(m_infoPanel, "Signature", entry.getSignature()); |
| 1031 | addNameValue( m_infoPanel, "Signature", entry.getSignature() ); | ||
| 1032 | } | 886 | } |
| 1033 | 887 | ||
| 1034 | private void showArgumentEntry( ArgumentEntry entry ) | 888 | private void showArgumentEntry(ArgumentEntry entry) { |
| 1035 | { | 889 | addNameValue(m_infoPanel, "Argument", entry.getName()); |
| 1036 | addNameValue( m_infoPanel, "Argument", entry.getName() ); | 890 | addNameValue(m_infoPanel, "Class", entry.getClassEntry().getName()); |
| 1037 | addNameValue( m_infoPanel, "Class", entry.getClassEntry().getName() ); | 891 | addNameValue(m_infoPanel, "Method", entry.getBehaviorEntry().getName()); |
| 1038 | addNameValue( m_infoPanel, "Method", entry.getBehaviorEntry().getName() ); | 892 | addNameValue(m_infoPanel, "Index", Integer.toString(entry.getIndex())); |
| 1039 | addNameValue( m_infoPanel, "Index", Integer.toString( entry.getIndex() ) ); | ||
| 1040 | } | 893 | } |
| 1041 | 894 | ||
| 1042 | private void addNameValue( JPanel container, String name, String value ) | 895 | private void addNameValue(JPanel container, String name, String value) { |
| 1043 | { | ||
| 1044 | JPanel panel = new JPanel(); | 896 | JPanel panel = new JPanel(); |
| 1045 | panel.setLayout( new FlowLayout( FlowLayout.LEFT, 6, 0 ) ); | 897 | panel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0)); |
| 1046 | container.add( panel ); | 898 | container.add(panel); |
| 1047 | 899 | ||
| 1048 | JLabel label = new JLabel( name + ":", JLabel.RIGHT ); | 900 | JLabel label = new JLabel(name + ":", JLabel.RIGHT); |
| 1049 | label.setPreferredSize( new Dimension( 100, label.getPreferredSize().height ) ); | 901 | label.setPreferredSize(new Dimension(100, label.getPreferredSize().height)); |
| 1050 | panel.add( label ); | 902 | panel.add(label); |
| 1051 | 903 | ||
| 1052 | panel.add( GuiTricks.unboldLabel( new JLabel( value, JLabel.LEFT ) ) ); | 904 | panel.add(GuiTricks.unboldLabel(new JLabel(value, JLabel.LEFT))); |
| 1053 | } | 905 | } |
| 1054 | 906 | ||
| 1055 | private void onCaretMove( int pos ) | 907 | private void onCaretMove(int pos) { |
| 1056 | { | 908 | |
| 1057 | Token token = m_controller.getToken( pos ); | 909 | Token token = m_controller.getToken(pos); |
| 1058 | boolean isToken = token != null; | 910 | boolean isToken = token != null; |
| 1059 | 911 | ||
| 1060 | m_reference = m_controller.getDeobfReference( token ); | 912 | m_reference = m_controller.getDeobfReference(token); |
| 1061 | boolean isClassEntry = isToken && m_reference.entry instanceof ClassEntry; | 913 | boolean isClassEntry = isToken && m_reference.entry instanceof ClassEntry; |
| 1062 | boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; | 914 | boolean isFieldEntry = isToken && m_reference.entry instanceof FieldEntry; |
| 1063 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; | 915 | boolean isMethodEntry = isToken && m_reference.entry instanceof MethodEntry; |
| 1064 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; | 916 | boolean isConstructorEntry = isToken && m_reference.entry instanceof ConstructorEntry; |
| 1065 | boolean isInJar = isToken && m_controller.entryIsInJar( m_reference.entry ); | 917 | boolean isInJar = isToken && m_controller.entryIsInJar(m_reference.entry); |
| 1066 | boolean isRenameable = isToken && m_controller.referenceIsRenameable( m_reference ); | 918 | boolean isRenameable = isToken && m_controller.referenceIsRenameable(m_reference); |
| 1067 | 919 | ||
| 1068 | if( isToken ) | 920 | if (isToken) { |
| 1069 | { | 921 | showReference(m_reference); |
| 1070 | showReference( m_reference ); | 922 | } else { |
| 1071 | } | ||
| 1072 | else | ||
| 1073 | { | ||
| 1074 | clearReference(); | 923 | clearReference(); |
| 1075 | } | 924 | } |
| 1076 | 925 | ||
| 1077 | m_renameMenu.setEnabled( isRenameable && isToken ); | 926 | m_renameMenu.setEnabled(isRenameable && isToken); |
| 1078 | m_showInheritanceMenu.setEnabled( isClassEntry || isMethodEntry || isConstructorEntry ); | 927 | m_showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); |
| 1079 | m_showImplementationsMenu.setEnabled( isClassEntry || isMethodEntry ); | 928 | m_showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); |
| 1080 | m_showCallsMenu.setEnabled( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ); | 929 | m_showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); |
| 1081 | m_openEntryMenu.setEnabled( isInJar && ( isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry ) ); | 930 | m_openEntryMenu.setEnabled(isInJar && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); |
| 1082 | m_openPreviousMenu.setEnabled( m_controller.hasPreviousLocation() ); | 931 | m_openPreviousMenu.setEnabled(m_controller.hasPreviousLocation()); |
| 1083 | m_toggleMappingMenu.setEnabled( isRenameable && isToken ); | 932 | m_toggleMappingMenu.setEnabled(isRenameable && isToken); |
| 1084 | 933 | ||
| 1085 | if( isToken && m_controller.entryHasDeobfuscatedName( m_reference.entry ) ) | 934 | if (isToken && m_controller.entryHasDeobfuscatedName(m_reference.entry)) { |
| 1086 | { | 935 | m_toggleMappingMenu.setText("Reset to obfuscated"); |
| 1087 | m_toggleMappingMenu.setText( "Reset to obfuscated" ); | 936 | } else { |
| 1088 | } | 937 | m_toggleMappingMenu.setText("Mark as deobfuscated"); |
| 1089 | else | ||
| 1090 | { | ||
| 1091 | m_toggleMappingMenu.setText( "Mark as deobfuscated" ); | ||
| 1092 | } | 938 | } |
| 1093 | } | 939 | } |
| 1094 | 940 | ||
| 1095 | private void navigateTo( Entry entry ) | 941 | private void navigateTo(Entry entry) { |
| 1096 | { | 942 | if (!m_controller.entryIsInJar(entry)) { |
| 1097 | if( !m_controller.entryIsInJar( entry ) ) | ||
| 1098 | { | ||
| 1099 | // entry is not in the jar. Ignore it | 943 | // entry is not in the jar. Ignore it |
| 1100 | return; | 944 | return; |
| 1101 | } | 945 | } |
| 1102 | if( m_reference != null ) | 946 | if (m_reference != null) { |
| 1103 | { | 947 | m_controller.savePreviousReference(m_reference); |
| 1104 | m_controller.savePreviousReference( m_reference ); | ||
| 1105 | } | 948 | } |
| 1106 | m_controller.openDeclaration( entry ); | 949 | m_controller.openDeclaration(entry); |
| 1107 | } | 950 | } |
| 1108 | 951 | ||
| 1109 | private void navigateTo( EntryReference<Entry,Entry> reference ) | 952 | private void navigateTo(EntryReference<Entry,Entry> reference) { |
| 1110 | { | 953 | if (!m_controller.entryIsInJar(reference.getLocationClassEntry())) { |
| 1111 | if( !m_controller.entryIsInJar( reference.getLocationClassEntry() ) ) | ||
| 1112 | { | ||
| 1113 | // reference is not in the jar. Ignore it | 954 | // reference is not in the jar. Ignore it |
| 1114 | return; | 955 | return; |
| 1115 | } | 956 | } |
| 1116 | if( m_reference != null ) | 957 | if (m_reference != null) { |
| 1117 | { | 958 | m_controller.savePreviousReference(m_reference); |
| 1118 | m_controller.savePreviousReference( m_reference ); | ||
| 1119 | } | 959 | } |
| 1120 | m_controller.openReference( reference ); | 960 | m_controller.openReference(reference); |
| 1121 | } | 961 | } |
| 1122 | 962 | ||
| 1123 | private void startRename( ) | 963 | private void startRename() { |
| 1124 | { | 964 | |
| 1125 | // init the text box | 965 | // init the text box |
| 1126 | final JTextField text = new JTextField(); | 966 | final JTextField text = new JTextField(); |
| 1127 | text.setText( m_reference.getNamableName() ); | 967 | text.setText(m_reference.getNamableName()); |
| 1128 | text.setPreferredSize( new Dimension( 360, text.getPreferredSize().height ) ); | 968 | text.setPreferredSize(new Dimension(360, text.getPreferredSize().height)); |
| 1129 | text.addKeyListener( new KeyAdapter( ) | 969 | text.addKeyListener(new KeyAdapter() { |
| 1130 | { | ||
| 1131 | @Override | 970 | @Override |
| 1132 | public void keyPressed( KeyEvent event ) | 971 | public void keyPressed(KeyEvent event) { |
| 1133 | { | 972 | switch (event.getKeyCode()) { |
| 1134 | switch( event.getKeyCode() ) | ||
| 1135 | { | ||
| 1136 | case KeyEvent.VK_ENTER: | 973 | case KeyEvent.VK_ENTER: |
| 1137 | finishRename( text, true ); | 974 | finishRename(text, true); |
| 1138 | break; | 975 | break; |
| 1139 | 976 | ||
| 1140 | case KeyEvent.VK_ESCAPE: | 977 | case KeyEvent.VK_ESCAPE: |
| 1141 | finishRename( text, false ); | 978 | finishRename(text, false); |
| 1142 | break; | 979 | break; |
| 1143 | } | 980 | } |
| 1144 | } | 981 | } |
| 1145 | } ); | 982 | }); |
| 1146 | 983 | ||
| 1147 | // find the label with the name and replace it with the text box | 984 | // find the label with the name and replace it with the text box |
| 1148 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); | 985 | JPanel panel = (JPanel)m_infoPanel.getComponent(0); |
| 1149 | panel.remove( panel.getComponentCount() - 1 ); | 986 | panel.remove(panel.getComponentCount() - 1); |
| 1150 | panel.add( text ); | 987 | panel.add(text); |
| 1151 | text.grabFocus(); | 988 | text.grabFocus(); |
| 1152 | text.selectAll(); | 989 | text.selectAll(); |
| 1153 | 990 | ||
| 1154 | redraw(); | 991 | redraw(); |
| 1155 | } | 992 | } |
| 1156 | 993 | ||
| 1157 | private void finishRename( JTextField text, boolean saveName ) | 994 | private void finishRename(JTextField text, boolean saveName) { |
| 1158 | { | ||
| 1159 | String newName = text.getText(); | 995 | String newName = text.getText(); |
| 1160 | if( saveName && newName != null && newName.length() > 0 ) | 996 | if (saveName && newName != null && newName.length() > 0) { |
| 1161 | { | 997 | try { |
| 1162 | try | 998 | m_controller.rename(m_reference, newName); |
| 1163 | { | 999 | } catch (IllegalNameException ex) { |
| 1164 | m_controller.rename( m_reference, newName ); | 1000 | text.setBorder(BorderFactory.createLineBorder(Color.red, 1)); |
| 1165 | } | 1001 | text.setToolTipText(ex.getReason()); |
| 1166 | catch( IllegalNameException ex ) | 1002 | GuiTricks.showToolTipNow(text); |
| 1167 | { | ||
| 1168 | text.setBorder( BorderFactory.createLineBorder( Color.red, 1 ) ); | ||
| 1169 | text.setToolTipText( ex.getReason() ); | ||
| 1170 | GuiTricks.showToolTipNow( text ); | ||
| 1171 | } | 1003 | } |
| 1172 | return; | 1004 | return; |
| 1173 | } | 1005 | } |
| 1174 | 1006 | ||
| 1175 | // abort the rename | 1007 | // abort the rename |
| 1176 | JPanel panel = (JPanel)m_infoPanel.getComponent( 0 ); | 1008 | JPanel panel = (JPanel)m_infoPanel.getComponent(0); |
| 1177 | panel.remove( panel.getComponentCount() - 1 ); | 1009 | panel.remove(panel.getComponentCount() - 1); |
| 1178 | panel.add( GuiTricks.unboldLabel( new JLabel( m_reference.getNamableName(), JLabel.LEFT ) ) ); | 1010 | panel.add(GuiTricks.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT))); |
| 1179 | 1011 | ||
| 1180 | m_editor.grabFocus(); | 1012 | m_editor.grabFocus(); |
| 1181 | 1013 | ||
| 1182 | redraw(); | 1014 | redraw(); |
| 1183 | } | 1015 | } |
| 1184 | 1016 | ||
| 1185 | private void showInheritance( ) | 1017 | private void showInheritance() { |
| 1186 | { | 1018 | |
| 1187 | if( m_reference == null ) | 1019 | if (m_reference == null) { |
| 1188 | { | ||
| 1189 | return; | 1020 | return; |
| 1190 | } | 1021 | } |
| 1191 | 1022 | ||
| 1192 | m_inheritanceTree.setModel( null ); | 1023 | m_inheritanceTree.setModel(null); |
| 1193 | 1024 | ||
| 1194 | if( m_reference.entry instanceof ClassEntry ) | 1025 | if (m_reference.entry instanceof ClassEntry) { |
| 1195 | { | ||
| 1196 | // get the class inheritance | 1026 | // get the class inheritance |
| 1197 | ClassInheritanceTreeNode classNode = m_controller.getClassInheritance( (ClassEntry)m_reference.entry ); | 1027 | ClassInheritanceTreeNode classNode = m_controller.getClassInheritance((ClassEntry)m_reference.entry); |
| 1198 | 1028 | ||
| 1199 | // show the tree at the root | 1029 | // show the tree at the root |
| 1200 | TreePath path = getPathToRoot( classNode ); | 1030 | TreePath path = getPathToRoot(classNode); |
| 1201 | m_inheritanceTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); | 1031 | m_inheritanceTree.setModel(new DefaultTreeModel((TreeNode)path.getPathComponent(0))); |
| 1202 | m_inheritanceTree.expandPath( path ); | 1032 | m_inheritanceTree.expandPath(path); |
| 1203 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); | 1033 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); |
| 1204 | } | 1034 | } else if (m_reference.entry instanceof MethodEntry) { |
| 1205 | else if( m_reference.entry instanceof MethodEntry ) | ||
| 1206 | { | ||
| 1207 | // get the method inheritance | 1035 | // get the method inheritance |
| 1208 | MethodInheritanceTreeNode classNode = m_controller.getMethodInheritance( (MethodEntry)m_reference.entry ); | 1036 | MethodInheritanceTreeNode classNode = m_controller.getMethodInheritance((MethodEntry)m_reference.entry); |
| 1209 | 1037 | ||
| 1210 | // show the tree at the root | 1038 | // show the tree at the root |
| 1211 | TreePath path = getPathToRoot( classNode ); | 1039 | TreePath path = getPathToRoot(classNode); |
| 1212 | m_inheritanceTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); | 1040 | m_inheritanceTree.setModel(new DefaultTreeModel((TreeNode)path.getPathComponent(0))); |
| 1213 | m_inheritanceTree.expandPath( path ); | 1041 | m_inheritanceTree.expandPath(path); |
| 1214 | m_inheritanceTree.setSelectionRow( m_inheritanceTree.getRowForPath( path ) ); | 1042 | m_inheritanceTree.setSelectionRow(m_inheritanceTree.getRowForPath(path)); |
| 1215 | } | 1043 | } |
| 1216 | 1044 | ||
| 1217 | m_tabs.setSelectedIndex( 0 ); | 1045 | m_tabs.setSelectedIndex(0); |
| 1218 | redraw(); | 1046 | redraw(); |
| 1219 | } | 1047 | } |
| 1220 | 1048 | ||
| 1221 | private void showImplementations( ) | 1049 | private void showImplementations() { |
| 1222 | { | 1050 | |
| 1223 | if( m_reference == null ) | 1051 | if (m_reference == null) { |
| 1224 | { | ||
| 1225 | return; | 1052 | return; |
| 1226 | } | 1053 | } |
| 1227 | 1054 | ||
| 1228 | m_implementationsTree.setModel( null ); | 1055 | m_implementationsTree.setModel(null); |
| 1229 | 1056 | ||
| 1230 | if( m_reference.entry instanceof ClassEntry ) | 1057 | if (m_reference.entry instanceof ClassEntry) { |
| 1231 | { | ||
| 1232 | // get the class implementations | 1058 | // get the class implementations |
| 1233 | ClassImplementationsTreeNode node = m_controller.getClassImplementations( (ClassEntry)m_reference.entry ); | 1059 | ClassImplementationsTreeNode node = m_controller.getClassImplementations((ClassEntry)m_reference.entry); |
| 1234 | if( node != null ) | 1060 | if (node != null) { |
| 1235 | { | ||
| 1236 | // show the tree at the root | 1061 | // show the tree at the root |
| 1237 | TreePath path = getPathToRoot( node ); | 1062 | TreePath path = getPathToRoot(node); |
| 1238 | m_implementationsTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); | 1063 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode)path.getPathComponent(0))); |
| 1239 | m_implementationsTree.expandPath( path ); | 1064 | m_implementationsTree.expandPath(path); |
| 1240 | m_implementationsTree.setSelectionRow( m_implementationsTree.getRowForPath( path ) ); | 1065 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); |
| 1241 | } | 1066 | } |
| 1242 | } | 1067 | } else if (m_reference.entry instanceof MethodEntry) { |
| 1243 | else if( m_reference.entry instanceof MethodEntry ) | ||
| 1244 | { | ||
| 1245 | // get the method implementations | 1068 | // get the method implementations |
| 1246 | MethodImplementationsTreeNode node = m_controller.getMethodImplementations( (MethodEntry)m_reference.entry ); | 1069 | MethodImplementationsTreeNode node = m_controller.getMethodImplementations((MethodEntry)m_reference.entry); |
| 1247 | if( node != null ) | 1070 | if (node != null) { |
| 1248 | { | ||
| 1249 | // show the tree at the root | 1071 | // show the tree at the root |
| 1250 | TreePath path = getPathToRoot( node ); | 1072 | TreePath path = getPathToRoot(node); |
| 1251 | m_implementationsTree.setModel( new DefaultTreeModel( (TreeNode)path.getPathComponent( 0 ) ) ); | 1073 | m_implementationsTree.setModel(new DefaultTreeModel((TreeNode)path.getPathComponent(0))); |
| 1252 | m_implementationsTree.expandPath( path ); | 1074 | m_implementationsTree.expandPath(path); |
| 1253 | m_implementationsTree.setSelectionRow( m_implementationsTree.getRowForPath( path ) ); | 1075 | m_implementationsTree.setSelectionRow(m_implementationsTree.getRowForPath(path)); |
| 1254 | } | 1076 | } |
| 1255 | } | 1077 | } |
| 1256 | 1078 | ||
| 1257 | m_tabs.setSelectedIndex( 1 ); | 1079 | m_tabs.setSelectedIndex(1); |
| 1258 | redraw(); | 1080 | redraw(); |
| 1259 | } | 1081 | } |
| 1260 | 1082 | ||
| 1261 | private void showCalls( ) | 1083 | private void showCalls() { |
| 1262 | { | 1084 | |
| 1263 | if( m_reference == null ) | 1085 | if (m_reference == null) { |
| 1264 | { | ||
| 1265 | return; | 1086 | return; |
| 1266 | } | 1087 | } |
| 1267 | 1088 | ||
| 1268 | if( m_reference.entry instanceof ClassEntry ) | 1089 | if (m_reference.entry instanceof ClassEntry) { |
| 1269 | { | ||
| 1270 | // look for calls to the default constructor | 1090 | // look for calls to the default constructor |
| 1271 | // TODO: get a list of all the constructors and find calls to all of them | 1091 | // TODO: get a list of all the constructors and find calls to all of them |
| 1272 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences( new ConstructorEntry( (ClassEntry)m_reference.entry, "()V" ) ); | 1092 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences(new ConstructorEntry((ClassEntry)m_reference.entry, "()V")); |
| 1273 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | 1093 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 1274 | } | 1094 | } else if (m_reference.entry instanceof FieldEntry) { |
| 1275 | else if( m_reference.entry instanceof FieldEntry ) | 1095 | FieldReferenceTreeNode node = m_controller.getFieldReferences((FieldEntry)m_reference.entry); |
| 1276 | { | 1096 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 1277 | FieldReferenceTreeNode node = m_controller.getFieldReferences( (FieldEntry)m_reference.entry ); | 1097 | } else if (m_reference.entry instanceof MethodEntry) { |
| 1278 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | 1098 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences((MethodEntry)m_reference.entry); |
| 1279 | } | 1099 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 1280 | else if( m_reference.entry instanceof MethodEntry ) | 1100 | } else if (m_reference.entry instanceof ConstructorEntry) { |
| 1281 | { | 1101 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences((ConstructorEntry)m_reference.entry); |
| 1282 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences( (MethodEntry)m_reference.entry ); | 1102 | m_callsTree.setModel(new DefaultTreeModel(node)); |
| 1283 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | ||
| 1284 | } | ||
| 1285 | else if( m_reference.entry instanceof ConstructorEntry ) | ||
| 1286 | { | ||
| 1287 | BehaviorReferenceTreeNode node = m_controller.getMethodReferences( (ConstructorEntry)m_reference.entry ); | ||
| 1288 | m_callsTree.setModel( new DefaultTreeModel( node ) ); | ||
| 1289 | } | 1103 | } |
| 1290 | 1104 | ||
| 1291 | m_tabs.setSelectedIndex( 2 ); | 1105 | m_tabs.setSelectedIndex(2); |
| 1292 | redraw(); | 1106 | redraw(); |
| 1293 | } | 1107 | } |
| 1294 | 1108 | ||
| 1295 | private void toggleMapping() | 1109 | private void toggleMapping() { |
| 1296 | { | 1110 | if (m_controller.entryHasDeobfuscatedName(m_reference.entry)) { |
| 1297 | if( m_controller.entryHasDeobfuscatedName( m_reference.entry ) ) | 1111 | m_controller.removeMapping(m_reference); |
| 1298 | { | 1112 | } else { |
| 1299 | m_controller.removeMapping( m_reference ); | 1113 | m_controller.markAsDeobfuscated(m_reference); |
| 1300 | } | ||
| 1301 | else | ||
| 1302 | { | ||
| 1303 | m_controller.markAsDeobfuscated( m_reference ); | ||
| 1304 | } | 1114 | } |
| 1305 | } | 1115 | } |
| 1306 | 1116 | ||
| 1307 | private TreePath getPathToRoot( TreeNode node ) | 1117 | private TreePath getPathToRoot(TreeNode node) { |
| 1308 | { | ||
| 1309 | List<TreeNode> nodes = Lists.newArrayList(); | 1118 | List<TreeNode> nodes = Lists.newArrayList(); |
| 1310 | TreeNode n = node; | 1119 | TreeNode n = node; |
| 1311 | do | 1120 | do { |
| 1312 | { | 1121 | nodes.add(n); |
| 1313 | nodes.add( n ); | ||
| 1314 | n = n.getParent(); | 1122 | n = n.getParent(); |
| 1315 | } | 1123 | } while (n != null); |
| 1316 | while( n != null ); | 1124 | Collections.reverse(nodes); |
| 1317 | Collections.reverse( nodes ); | 1125 | return new TreePath(nodes.toArray()); |
| 1318 | return new TreePath( nodes.toArray() ); | ||
| 1319 | } | 1126 | } |
| 1320 | 1127 | ||
| 1321 | private void close( ) | 1128 | private void close() { |
| 1322 | { | 1129 | if (!m_controller.isDirty()) { |
| 1323 | if( !m_controller.isDirty() ) | ||
| 1324 | { | ||
| 1325 | // everything is saved, we can exit safely | 1130 | // everything is saved, we can exit safely |
| 1326 | m_frame.dispose(); | 1131 | m_frame.dispose(); |
| 1327 | } | 1132 | } else { |
| 1328 | else | ||
| 1329 | { | ||
| 1330 | // ask to save before closing | 1133 | // ask to save before closing |
| 1331 | String[] options = { | 1134 | String[] options = { "Save and exit", "Discard changes", "Cancel" }; |
| 1332 | "Save and exit", | 1135 | 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, |
| 1333 | "Discard changes", | 1136 | JOptionPane.QUESTION_MESSAGE, null, options, options[2]); |
| 1334 | "Cancel" | 1137 | switch (response) { |
| 1335 | }; | ||
| 1336 | int response = JOptionPane.showOptionDialog( | ||
| 1337 | m_frame, | ||
| 1338 | "Your mappings have not been saved yet. Do you want to save?", | ||
| 1339 | "Save your changes?", | ||
| 1340 | JOptionPane.YES_NO_CANCEL_OPTION, | ||
| 1341 | JOptionPane.QUESTION_MESSAGE, | ||
| 1342 | null, | ||
| 1343 | options, | ||
| 1344 | options[2] | ||
| 1345 | ); | ||
| 1346 | switch( response ) | ||
| 1347 | { | ||
| 1348 | case JOptionPane.YES_OPTION: // save and exit | 1138 | case JOptionPane.YES_OPTION: // save and exit |
| 1349 | if( m_mappingsFileChooser.getSelectedFile() != null || m_mappingsFileChooser.showSaveDialog( m_frame ) == JFileChooser.APPROVE_OPTION ) | 1139 | if (m_mappingsFileChooser.getSelectedFile() != null || m_mappingsFileChooser.showSaveDialog(m_frame) == JFileChooser.APPROVE_OPTION) { |
| 1350 | { | 1140 | try { |
| 1351 | try | 1141 | m_controller.saveMappings(m_mappingsFileChooser.getSelectedFile()); |
| 1352 | { | ||
| 1353 | m_controller.saveMappings( m_mappingsFileChooser.getSelectedFile() ); | ||
| 1354 | m_frame.dispose(); | 1142 | m_frame.dispose(); |
| 1355 | } | 1143 | } catch (IOException ex) { |
| 1356 | catch( IOException ex ) | 1144 | throw new Error(ex); |
| 1357 | { | ||
| 1358 | throw new Error( ex ); | ||
| 1359 | } | 1145 | } |
| 1360 | } | 1146 | } |
| 1361 | break; | 1147 | break; |
| @@ -1364,14 +1150,13 @@ public class Gui | |||
| 1364 | // don't save, exit | 1150 | // don't save, exit |
| 1365 | m_frame.dispose(); | 1151 | m_frame.dispose(); |
| 1366 | break; | 1152 | break; |
| 1367 | 1153 | ||
| 1368 | // cancel means do nothing | 1154 | // cancel means do nothing |
| 1369 | } | 1155 | } |
| 1370 | } | 1156 | } |
| 1371 | } | 1157 | } |
| 1372 | 1158 | ||
| 1373 | private void redraw( ) | 1159 | private void redraw() { |
| 1374 | { | ||
| 1375 | m_frame.validate(); | 1160 | m_frame.validate(); |
| 1376 | m_frame.repaint(); | 1161 | m_frame.repaint(); |
| 1377 | } | 1162 | } |