Changeset 17792
- Timestamp:
- 2008-11-07T17:02:21+13:00 (15 years ago)
- Location:
- release-kits/shared/uninstaller
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
release-kits/shared/uninstaller/Uninstall.sh
r17784 r17792 13 13 rmdir packages 14 14 15 rm - f bin15 rm -rf bin 16 16 17 17 rm uninst.jar -
release-kits/shared/uninstaller/Uninstaller.java
r17685 r17792 1 import java.util.ResourceBundle;1 import java.util.ResourceBundle; 2 2 import java.awt.*; 3 3 import java.awt.event.*; … … 22 22 import java.util.ArrayList; 23 23 24 import java.awt.event.ActionEvent; 25 import java.awt.event.ActionListener; 26 import java.awt.event.MouseAdapter; 27 import java.awt.event.MouseEvent; 28 import java.io.FileNotFoundException; 29 import java.io.FileWriter; 30 import java.io.IOException; 31 import javax.swing.JMenuItem; 32 import javax.swing.JPopupMenu; 33 import javax.swing.JTextArea; 34 24 35 public class Uninstaller { 25 36 … … 49 60 50 61 62 JScrollPane logPane; 51 63 JTextArea log; 52 64 JButton uninstallButton; … … 73 85 //The panel to be displayed while the uninstall is happening 74 86 progressPanel = new JPanel(new BorderLayout()); 75 log = new JTextArea(); 76 JScrollPane logPane = new JScrollPane(log); 87 log = new FollowingJTextArea(); 88 log.setEditable(false); 89 logPane = new JScrollPane(log); 77 90 logPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); 78 91 logPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 79 92 progressPanel.add( BorderLayout.NORTH, new JLabel("Progress") ); 80 progressPanel.add( BorderLayout.CENTER, log Pane);93 progressPanel.add( BorderLayout.CENTER, log ); 81 94 82 95 //initial toolbar … … 126 139 127 140 //the initial screen 128 frame.getContentPane().add( BorderLayout. NORTH, introPanel );141 frame.getContentPane().add( BorderLayout.CENTER, introPanel ); 129 142 frame.getContentPane().add( BorderLayout.SOUTH, initialToolbar ); 130 143 … … 195 208 frame.getContentPane().remove(introPanel); 196 209 frame.getContentPane().add( BorderLayout.CENTER, progressPanel ); 197 198 //disable the uninstall button 199 uninstallButton.setEnabled( false ); 200 options = new Object[1]; 201 options[0] = "OK"; 202 n = JOptionPane.showOptionDialog( 203 frame, 204 "repainting", 205 "repainting", 206 JOptionPane.OK_OPTION, 207 JOptionPane.INFORMATION_MESSAGE, 208 null, 209 options, 210 options[0] 211 ); 212 210 progressPanel.setVisible( true ); 213 211 214 212 //start the unstinall … … 260 258 if ( startMenuPath == null ) { 261 259 log.append( bundle.getString("uninstaller.info.no.startmenu") + "\n" ); 260 log.repaint(); 262 261 } else { 263 262 log.append( "StartMenu Path: " + startMenuPath.getAbsolutePath() + "\n" ); 263 log.repaint(); 264 264 try { 265 265 recursiveDelete( startMenuPath, null ); … … 279 279 exceptions.add( new File("bin/search4j.exe") ); 280 280 exceptions.add( new File("bin/search4j") ); 281 282 exceptions.add( new File("bin/windows/search4j.exe") ); 283 exceptions.add( new File("bin/linux/search4j") ); 284 exceptions.add( new File("bin/darwin/search4j") ); 285 281 286 exceptions.add( new File("packages/jre") ); 282 287 exceptions.add( new File("uninst.jar") ); … … 306 311 } catch ( CancelledException ce ) { 307 312 log.append( bundle.getString("uninstaller.cancelled") + "\n" ); 313 log.repaint(); 308 314 JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.cancelled"), bundle.getString("uninstaller.complete"), 1); 309 315 changeToFinishToolbar(); … … 316 322 } catch (Exception e) { 317 323 log.append( bundle.getString("uninstaller.couldnt-create-flagfile") + "\n" ); 324 log.repaint(); 318 325 } 319 326 … … 367 374 if (!f.exists()) { 368 375 log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" ); 376 log.repaint(); 369 377 return; 370 378 } … … 389 397 if ( !f.exists() ) { 390 398 log.append( Strings.replaceAll( bundle.getString("uninstaller.error.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" ); 399 log.repaint(); 391 400 return; 392 401 } … … 415 424 if ( doDelete ) { 416 425 426 Object[] options = null; 427 int n = 0; 417 428 log.append( Strings.replaceAll( bundle.getString("uninstaller.deleting"), "{file}", f.getAbsolutePath() ) + "\n" ); 429 log.repaint(); 430 try{ Thread.sleep( 50 ); } catch( Exception e ) {} 431 /* 432 //disable the uninstall button 433 434 options = new Object[1]; 435 options = new Object[1]; 436 options[0] = "OK"; 437 n = JOptionPane.showOptionDialog( 438 frame, 439 "repainting", 440 "repainting", 441 JOptionPane.OK_OPTION, 442 JOptionPane.INFORMATION_MESSAGE, 443 null, 444 options, 445 options[0] 446 ); 447 */ 448 418 449 while ( !f.delete() ) { 419 450 log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.couldnt.delete"), "{file}", f.getAbsolutePath() ) + "\n" ); 451 log.repaint(); 420 452 421 453 if ( ignoreReadOnlys ) { … … 423 455 } 424 456 425 Object[] options = { bundle.getString("uninstaller.retry"), bundle.getString("uninstaller.skip"), bundle.getString("uninstaller.skip.all"), bundle.getString("uninstaller.cancel") }; 426 int n = JOptionPane.showOptionDialog( 457 options[0] = bundle.getString("uninstaller.retry"); 458 options[1] = bundle.getString("uninstaller.skip"); 459 options[2] = bundle.getString("uninstaller.skip.all"); 460 options[3] = bundle.getString("uninstaller.cancel"); 461 n = JOptionPane.showOptionDialog( 427 462 frame, 428 463 Strings.replaceAll( bundle.getString("uninstaller.warning.readonly"), "{file}", f.getAbsolutePath() ), … … 476 511 } 477 512 513 514 515 516 class FollowingJTextArea extends JTextArea{ 517 518 private boolean follow = true; 519 520 public FollowingJTextArea() { 521 jInit(); 522 } 523 524 525 private void jInit(){ 526 final JPopupMenu popUp = getPopupMenu(); 527 this.add(popUp); 528 this.addMouseListener(new MouseAdapter(){ 529 public void mouseClicked(MouseEvent e) { 530 if (e.getButton() == e.BUTTON3) { 531 popUp.show(FollowingJTextArea.this,e.getX(),e.getY()); 532 } 533 } 534 }); 535 } 536 537 public boolean isFollow() { 538 return follow; 539 } 540 public void setFollow(boolean follow) { 541 this.follow = follow; 542 } 543 544 private void scrollToEnd(){ 545 setCaretPosition(getDocument().getLength()); 546 } 547 private void toggleFollow(){ 548 setFollow(!isFollow()); 549 } 550 551 /** 552 * Appends the given text to the end of the document. 553 * 554 * @param str the text to insert 555 * @todo Implement this javax.swing.JTextArea method 556 */ 557 public void append(String str) { 558 super.append(str); 559 if(follow)scrollToEnd(); 560 } 561 private JPopupMenu getPopupMenu() { 562 JPopupMenu contextMenu = new JPopupMenu("Options"); 563 JMenuItem saveMenu = new JMenuItem("Save Text"); 564 /* 565 saveMenu.addActionListener(new ActionListener() { 566 public void actionPerformed(ActionEvent e) { 567 SelectFileAction action = new SelectFileAction("Save Output", null, null); 568 try { 569 action.actionPerformed(new ActionEvent(this, 0, "Save Output")); 570 if (action.selectedFile != null) { 571 FileWriter fos = new FileWriter(action.selectedFile); 572 fos.write(getText()); 573 fos.close(); 574 } 575 576 } 577 catch (FileNotFoundException ex) { 578 System.err.println("FileNotFoundException"); 579 } 580 catch (IOException ex) { 581 System.err.println("IOException"); 582 } 583 } 584 }); 585 contextMenu.add(saveMenu); 586 */ 587 588 JMenuItem toggleFollowMenu = new JMenuItem("Toggle Follow"); 589 toggleFollowMenu.addActionListener(new ActionListener() { 590 public void actionPerformed(ActionEvent e) { 591 toggleFollow(); 592 } 593 }); 594 contextMenu.add(toggleFollowMenu); 595 596 JMenuItem jumpToEndMenu = new JMenuItem("Jump To End"); 597 jumpToEndMenu.addActionListener(new ActionListener() { 598 public void actionPerformed(ActionEvent e) { 599 setCaretPosition(getDocument().getLength()); 600 } 601 }); 602 contextMenu.add(toggleFollowMenu); 603 604 JMenuItem clearTextMenu = new JMenuItem("Clear Text"); 605 clearTextMenu.addActionListener(new ActionListener() { 606 public void actionPerformed(ActionEvent e) { 607 setText(""); 608 } 609 }); 610 contextMenu.add(clearTextMenu); 611 return contextMenu; 612 } 613 }
Note:
See TracChangeset
for help on using the changeset viewer.