Ignore:
Timestamp:
2008-11-07T17:02:21+13:00 (15 years ago)
Author:
oranfry
Message:

little fix to unistall sh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/uninstaller/Uninstaller.java

    r17685 r17792  
    1 import java.util.ResourceBundle;
     1    import java.util.ResourceBundle;
    22import java.awt.*;
    33import java.awt.event.*;
     
    2222import java.util.ArrayList;
    2323
     24import java.awt.event.ActionEvent;
     25import java.awt.event.ActionListener;
     26import java.awt.event.MouseAdapter;
     27import java.awt.event.MouseEvent;
     28import java.io.FileNotFoundException;
     29import java.io.FileWriter;
     30import java.io.IOException;
     31import javax.swing.JMenuItem;
     32import javax.swing.JPopupMenu;
     33import javax.swing.JTextArea;
     34
    2435public class Uninstaller {
    2536
     
    4960
    5061
     62    JScrollPane logPane;
    5163    JTextArea log;
    5264    JButton uninstallButton;
     
    7385        //The panel to be displayed while the uninstall is happening
    7486        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);
    7790        logPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    7891        logPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    7992        progressPanel.add( BorderLayout.NORTH, new JLabel("Progress") );
    80         progressPanel.add( BorderLayout.CENTER, logPane );
     93        progressPanel.add( BorderLayout.CENTER, log );
    8194
    8295        //initial toolbar
     
    126139
    127140        //the initial screen
    128         frame.getContentPane().add( BorderLayout.NORTH, introPanel );
     141        frame.getContentPane().add( BorderLayout.CENTER, introPanel );
    129142        frame.getContentPane().add( BorderLayout.SOUTH, initialToolbar );
    130143
     
    195208            frame.getContentPane().remove(introPanel);
    196209            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 );
    213211
    214212            //start the unstinall
     
    260258        if ( startMenuPath == null ) {
    261259            log.append( bundle.getString("uninstaller.info.no.startmenu") + "\n" );
     260            log.repaint();
    262261        } else {
    263262            log.append( "StartMenu Path: " + startMenuPath.getAbsolutePath() + "\n" );
     263            log.repaint();
    264264            try {
    265265                recursiveDelete( startMenuPath, null );
     
    279279            exceptions.add( new File("bin/search4j.exe") );
    280280            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
    281286            exceptions.add( new File("packages/jre") );
    282287            exceptions.add( new File("uninst.jar") );
     
    306311        } catch ( CancelledException ce ) {
    307312            log.append( bundle.getString("uninstaller.cancelled") + "\n" );
     313            log.repaint();
    308314            JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.cancelled"), bundle.getString("uninstaller.complete"), 1);
    309315            changeToFinishToolbar();
     
    316322        } catch (Exception e) {
    317323            log.append( bundle.getString("uninstaller.couldnt-create-flagfile") + "\n" );
     324            log.repaint();
    318325        }
    319326
     
    367374        if (!f.exists()) {
    368375            log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
     376            log.repaint();
    369377            return;
    370378        }
     
    389397        if ( !f.exists() ) {
    390398            log.append( Strings.replaceAll( bundle.getString("uninstaller.error.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
     399            log.repaint();
    391400            return;
    392401        }
     
    415424        if ( doDelete ) {
    416425
     426            Object[] options = null;
     427            int n = 0;
    417428            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
    418449            while ( !f.delete() ) {
    419450                log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.couldnt.delete"), "{file}", f.getAbsolutePath() ) + "\n" );
     451                log.repaint();
    420452
    421453                if ( ignoreReadOnlys ) {
     
    423455                }
    424456
    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(
    427462                    frame,
    428463                    Strings.replaceAll( bundle.getString("uninstaller.warning.readonly"), "{file}", f.getAbsolutePath() ),
     
    476511}
    477512
     513
     514
     515
     516class 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.