Changeset 17685 for release-kits/shared


Ignore:
Timestamp:
2008-11-05T14:03:24+13:00 (15 years ago)
Author:
oranfry
Message:

uninstaller now uses the unified language bundle strings, has the buttons in the right order, and repaints using a dialog box which will be replaced with a call to repaint() or similar

Location:
release-kits/shared/uninstaller
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release-kits/shared/uninstaller

    • Property svn:ignore
      •  

        old new  
        11startmenu
        22gsdl
        3 
         3resources
  • release-kits/shared/uninstaller/Uninstaller.java

    r17456 r17685  
    2727    public static int SCREEN_HEIGHT = 450;
    2828
    29     public static final ResourceBundle bundle = ResourceBundle.getBundle("Uninstaller");
     29    public static final ResourceBundle bundle = ResourceBundle.getBundle("resources.LanguagePack");
    3030
    3131    public static final File gs2InstallProps = new File("etc/installation.properties");
     
    3939    JCheckBox keepCollectionsCheckbox;
    4040    //JCheckBox keepModifiedFilesCheckbox;
     41
     42    //panels
    4143    JPanel progressPanel;
    4244    JPanel introPanel;
     45
     46    //toolbars 
     47    JPanel initialToolbar;
     48    JPanel finishToolbar;
     49
     50
    4351    JTextArea log;
    4452    JButton uninstallButton;
    45     JPanel initialToolbar;
    46     JPanel finishToolbar;
    4753   
    4854
     
    5763        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    5864        frame.setLocation(screenSize.width/2 - frame.getWidth()/2, screenSize.height/2 - frame.getHeight()/2);
     65
     66        //The panel to introduce and ask for options
     67        introPanel = new JPanel(new BorderLayout());
     68        JPanel innerPanel = new JPanel();
     69        innerPanel.setLayout( new BoxLayout(innerPanel,BoxLayout.Y_AXIS) );
     70        innerPanel.setBorder( new EmptyBorder(10, 10, 5, 10) );
     71        introPanel.add( BorderLayout.WEST, innerPanel );
    5972
    6073        //The panel to be displayed while the uninstall is happening
     
    6780        progressPanel.add( BorderLayout.CENTER, logPane );
    6881
    69         //The panel to introduce and ask for options
    70         introPanel = new JPanel(new BorderLayout());
    71         frame.getContentPane().add( BorderLayout.NORTH, introPanel );
    72 
    73         JPanel innerPanel = new JPanel();
    74         innerPanel.setLayout( new BoxLayout(innerPanel,BoxLayout.Y_AXIS) );
    75         innerPanel.setBorder( new EmptyBorder(10, 10, 5, 10) );
    76         introPanel.add( BorderLayout.WEST, innerPanel );
    77 
    7882        //initial toolbar
    7983        initialToolbar = new JPanel();
    80         JButton cancelButton = new JButton(bundle.getString("cancel"));
     84        uninstallButton = new JButton(bundle.getString("uninstaller.uninstall"));
     85        uninstallButton.addActionListener( new StartUninstallListener() );
     86        JButton cancelButton = new JButton(bundle.getString("uninstaller.cancel"));
    8187        cancelButton.addActionListener( new CancelListener() );
    82 
    83         uninstallButton = new JButton(bundle.getString("uninstall"));
    84         uninstallButton.addActionListener( new StartUninstallListener() );
    85 
     88        initialToolbar.add(uninstallButton);
    8689        initialToolbar.add(cancelButton);
    87         initialToolbar.add(uninstallButton);
    88         frame.getContentPane().add( BorderLayout.SOUTH, initialToolbar );
    8990
    9091        //finish toolbar
    9192        finishToolbar = new JPanel();
    92         JButton finishButton = new JButton(bundle.getString("finish"));
     93        JButton finishButton = new JButton(bundle.getString("uninstaller.finish"));
    9394        finishButton.addActionListener( new FinishListener() );
    9495        finishToolbar.add( finishButton );
     96
    9597
    9698        String pwd = (new File(".")).getAbsolutePath();
     
    101103        JLabel l;       
    102104
    103         l = new JLabel(bundle.getString("will.uninstall.from"));
     105        l = new JLabel(bundle.getString("uninstaller.will.uninstall.from"));
    104106        innerPanel.add( l );
    105107        innerPanel.add( Box.createRigidArea(new Dimension(5,5)) );
     
    110112        innerPanel.add( Box.createRigidArea(new Dimension(5,20)) );
    111113
    112         l = new JLabel(bundle.getString("uninstall.options"));
     114        l = new JLabel(bundle.getString("uninstaller.uninstall.options"));
    113115        innerPanel.add( l );
    114116
    115         keepCollectionsCheckbox = new JCheckBox(bundle.getString("keep.collections"));
     117        keepCollectionsCheckbox = new JCheckBox(bundle.getString("uninstaller.keep.collections"));
    116118        keepCollectionsCheckbox.setSelected(true);
    117119        innerPanel.add( keepCollectionsCheckbox );
     
    120122        //innerPanel.add( keepModifiedFilesCheckbox );
    121123
    122         frame.setTitle( bundle.getString("greenstone.uninstaller") );
     124        frame.setTitle( bundle.getString("uninstaller.greenstone.uninstaller") );
    123125        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     126
     127        //the initial screen
     128        frame.getContentPane().add( BorderLayout.NORTH, introPanel );
     129        frame.getContentPane().add( BorderLayout.SOUTH, initialToolbar );
     130
    124131        frame.setVisible(true);
    125132       
     
    147154
    148155            //The dialog to ask "are you sure"
    149             Object[] options = { bundle.getString("cancel"), bundle.getString("uninstall") };
     156            Object[] options = { bundle.getString("uninstaller.uninstall"), bundle.getString("uninstaller.cancel") };
    150157            int n = JOptionPane.showOptionDialog(
    151158                frame,
    152                 bundle.getString("are.you.sure"),
    153                 bundle.getString("confirmation"),
     159                bundle.getString("uninstaller.are.you.sure"),
     160                bundle.getString("uninstaller.confirmation"),
    154161                JOptionPane.YES_NO_CANCEL_OPTION,
    155162                JOptionPane.QUESTION_MESSAGE,
     
    158165                options[0]
    159166            );
    160             if ( n == 0 ) {
     167            if ( n == 1 ) {
    161168                return;
    162169            }
     
    167174            //confirm delete of collections
    168175            if ( !keepCollections ) {
    169                 options[0] = bundle.getString("cancel");
    170                 options[1] = bundle.getString("continue");
     176                options[0] = bundle.getString("uninstaller.continue");
     177                options[1] = bundle.getString("uninstaller.cancel");
    171178                n = JOptionPane.showOptionDialog(
    172179                    frame,
    173                     bundle.getString("are.you.sure.collections"),
    174                     bundle.getString("confirmation"),
     180                    bundle.getString("uninstaller.are.you.sure.collections"),
     181                    bundle.getString("uninstaller.confirmation"),
    175182                    JOptionPane.YES_NO_CANCEL_OPTION,
    176183                    JOptionPane.WARNING_MESSAGE,
     
    179186                    options[0]
    180187                );
    181                 if ( n == 0 ) {
     188                if ( n == 1 ) {
    182189                    return;
    183190                }
    184191            }
    185192
    186             //swap to the progress panel
    187             introPanel.setVisible(false);
     193           
     194            introPanel.setVisible( false );
    188195            frame.getContentPane().remove(introPanel);
    189             frame.getContentPane().add( BorderLayout.CENTER, progressPanel);
    190             frame.setVisible(true);
     196            frame.getContentPane().add( BorderLayout.CENTER, progressPanel );
    191197
    192198            //disable the uninstall button
    193199            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                );
    194212
    195213
     
    205223
    206224        if ( !gs2InstallProps.exists() && !gs3InstallProps.exists() ) {
    207             log.append( bundle.getString("error.couldnt.find.install.props") + "\n" );
    208             JOptionPane.showMessageDialog(frame, bundle.getString("error.couldnt.find.install.props"), bundle.getString("error"), 0);
     225            log.append( bundle.getString("uninstaller.error.couldnt.find.install.props") + "\n" );
     226            JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.error.couldnt.find.install.props"), bundle.getString("uninstaller.error"), 0);
    209227            return false;
    210228        }
     
    241259
    242260        if ( startMenuPath == null ) {
    243             log.append( bundle.getString("info.no.startmenu") + "\n" );
     261            log.append( bundle.getString("uninstaller.info.no.startmenu") + "\n" );
    244262        } else {
    245263            log.append( "StartMenu Path: " + startMenuPath.getAbsolutePath() + "\n" );
     
    247265                recursiveDelete( startMenuPath, null );
    248266            } catch ( CancelledException ce ) {
    249                 log.append( bundle.getString("cancelled") + "\n" );
     267                log.append( bundle.getString("uninstaller.cancelled") + "\n" );
    250268                changeToFinishToolbar();
    251                 JOptionPane.showMessageDialog(frame, bundle.getString("cancelled"), bundle.getString("complete"), 1);
     269                JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.cancelled"), bundle.getString("uninstaller.complete"), 1);
    252270                return;
    253271            }
     
    276294                cd = new File( new File(".").getCanonicalPath() );
    277295            } catch ( Exception e ) {
    278                 JOptionPane.showMessageDialog(frame, bundle.getString("failed.to.figure.cd"), bundle.getString("error") , 0);
     296                JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.failed.to.figure.cd"), bundle.getString("uninstaller.error") , 0);
    279297                System.exit(0);
    280298            }
     
    287305            recursiveDelete( cd , ex );
    288306        } catch ( CancelledException ce ) {
    289             log.append( bundle.getString("cancelled") + "\n" );
    290             JOptionPane.showMessageDialog(frame, bundle.getString("cancelled"), bundle.getString("complete"), 1);
     307            log.append( bundle.getString("uninstaller.cancelled") + "\n" );
     308            JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.cancelled"), bundle.getString("uninstaller.complete"), 1);
    291309            changeToFinishToolbar();
    292310            return;
     
    297315            (new File("uninst.flag")).createNewFile();
    298316        } catch (Exception e) {
    299             log.append( bundle.getString("couldnt-create-flagfile") + "\n" );
     317            log.append( bundle.getString("uninstaller.couldnt-create-flagfile") + "\n" );
    300318        }
    301319
    302320        changeToFinishToolbar();
    303         JOptionPane.showMessageDialog(frame, bundle.getString("finished"), bundle.getString("complete"), 1);
     321        JOptionPane.showMessageDialog(frame, bundle.getString("uninstaller.finished"), bundle.getString("uninstaller.complete"), 1);
    304322    }
    305323
     
    348366        // Make sure the file or directory exists
    349367        if (!f.exists()) {
    350             log.append( Strings.replaceAll( bundle.getString("warning.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
     368            log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
    351369            return;
    352370        }
     
    358376                try {
    359377                    if ( f.equals( exceptions[i] ) || f.getCanonicalPath().equals(exceptions[i].getCanonicalPath()) ) {
    360                         log.append( Strings.replaceAll( bundle.getString("info.skipping"), "{file}", f.getAbsolutePath() ) + "\n" );
     378                        log.append( Strings.replaceAll( bundle.getString("uninstaller.info.skipping"), "{file}", f.getAbsolutePath() ) + "\n" );
    361379                        return;
    362380                    }
     
    370388        //check existance
    371389        if ( !f.exists() ) {
    372             log.append( Strings.replaceAll( bundle.getString("error.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
     390            log.append( Strings.replaceAll( bundle.getString("uninstaller.error.nonexistent"), "{file}", f.getAbsolutePath() ) + "\n" );
    373391            return;
    374392        }
     
    397415        if ( doDelete ) {
    398416
    399             log.append( Strings.replaceAll( bundle.getString("deleting"), "{file}", f.getAbsolutePath() ) + "\n" );
     417            log.append( Strings.replaceAll( bundle.getString("uninstaller.deleting"), "{file}", f.getAbsolutePath() ) + "\n" );
    400418            while ( !f.delete() ) {
    401                 log.append( Strings.replaceAll( bundle.getString("warning.couldnt.delete"), "{file}", f.getAbsolutePath() ) + "\n" );
     419                log.append( Strings.replaceAll( bundle.getString("uninstaller.warning.couldnt.delete"), "{file}", f.getAbsolutePath() ) + "\n" );
    402420
    403421                if ( ignoreReadOnlys ) {
     
    405423                }
    406424
    407                 Object[] options = { bundle.getString("cancel"), bundle.getString("retry"), bundle.getString("skip"), bundle.getString("skip.all") };
     425                Object[] options = { bundle.getString("uninstaller.retry"), bundle.getString("uninstaller.skip"), bundle.getString("uninstaller.skip.all"), bundle.getString("uninstaller.cancel") };
    408426                int n = JOptionPane.showOptionDialog(
    409427                    frame,
    410                     Strings.replaceAll( bundle.getString("warning.readonly"), "{file}", f.getAbsolutePath() ),
    411                     bundle.getString("readonly"),
     428                    Strings.replaceAll( bundle.getString("uninstaller.warning.readonly"), "{file}", f.getAbsolutePath() ),
     429                    bundle.getString("uninstaller.readonly"),
    412430                    JOptionPane.YES_NO_CANCEL_OPTION,
    413431                    JOptionPane.QUESTION_MESSAGE,
     
    417435                );
    418436
    419                 if ( n == 0 ) {
     437                if ( n == 3 ) {
    420438                    throw new CancelledException();
     439                } else if ( n == 1 ) {
     440                    return;
    421441                } else if ( n == 2 ) {
    422                     return;
    423                 } else if ( n == 3 ) {
    424442                    ignoreReadOnlys = true;
    425443                    return;
  • release-kits/shared/uninstaller/compile.sh

    r17456 r17685  
    1 javac Uninstaller.java
    2 jar -cmf manifest.mf gsdl-template/uninst.jar *.class *.properties
     1rk_home=$1
     2if [ "$rk_home" = "" ]; then
     3    echo "usage: ./compile.sh <rk_home>"
     4    exit
     5fi
     6
     7#setup language string bundle
     8rm -rf resources
     9mkdir resources
     10cp $rk_home/language-strings/*.properties resources
     11
     12#java compile
     13javac Uninstaller.java -Xlint:unchecked
     14jar -cmf manifest.mf gsdl-template/uninst.jar *.class resources
     15
     16#setup a fake greenstone installation
    317cp Uninstall.bat gsdl-template
    418cp Uninstall.sh gsdl-template
Note: See TracChangeset for help on using the changeset viewer.