1*cdf0e10cSrcweir package installer; 2*cdf0e10cSrcweir 3*cdf0e10cSrcweir /* 4*cdf0e10cSrcweir * Welcome.java 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * Created on 04 July 2002, 15:43 7*cdf0e10cSrcweir */ 8*cdf0e10cSrcweir 9*cdf0e10cSrcweir /** 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * @author mike 12*cdf0e10cSrcweir */ 13*cdf0e10cSrcweir import java.awt.event.*; 14*cdf0e10cSrcweir import javax.swing.*; 15*cdf0e10cSrcweir import java.io.*; 16*cdf0e10cSrcweir import java.net.*; 17*cdf0e10cSrcweir import java.util.Properties; 18*cdf0e10cSrcweir 19*cdf0e10cSrcweir public class Welcome extends javax.swing.JPanel implements ActionListener { 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir /** Creates new form Welcome */ 22*cdf0e10cSrcweir public Welcome(InstallWizard wizard) { 23*cdf0e10cSrcweir this.wizard = wizard; 24*cdf0e10cSrcweir setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED)); 25*cdf0e10cSrcweir initComponents(); 26*cdf0e10cSrcweir } 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir /** This method is called from within the constructor to 29*cdf0e10cSrcweir * initialize the form. 30*cdf0e10cSrcweir * WARNING: Do NOT modify this code. The content of this method is 31*cdf0e10cSrcweir * always regenerated by the Form Editor. 32*cdf0e10cSrcweir */ 33*cdf0e10cSrcweir private void initComponents() {//GEN-BEGIN:initComponents 34*cdf0e10cSrcweir welcomePanel = new javax.swing.JPanel(); 35*cdf0e10cSrcweir area = new javax.swing.JTextArea(); 36*cdf0e10cSrcweir nextButtonEnable = true; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir setLayout(new java.awt.BorderLayout()); 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir welcomePanel.setLayout(new java.awt.BorderLayout()); 41*cdf0e10cSrcweir area.setEditable(false); 42*cdf0e10cSrcweir area.setLineWrap(true); 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir String message = "\n\tOffice Scripting Framework Version 0.3" + 45*cdf0e10cSrcweir "\n\n\n\tPlease ensure that you have exited from Office"; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir /* String userDir = (String) System.getProperty( "user.dir" ); 48*cdf0e10cSrcweir boolean isValid = validateCurrentUserDir(userDir); 49*cdf0e10cSrcweir if( !isValid ) { 50*cdf0e10cSrcweir nextButtonEnable = false; 51*cdf0e10cSrcweir message = "Please run Installer from the program directory in a valid Office installation"; 52*cdf0e10cSrcweir setUpWelcomePanel(message); 53*cdf0e10cSrcweir return; 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir int programPosition = userDir.lastIndexOf("program"); 57*cdf0e10cSrcweir String offInstallPth = null; 58*cdf0e10cSrcweir offInstallPth = userDir.substring( 0, programPosition ); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir wizard.storeLocation(offInstallPth); */ 61*cdf0e10cSrcweir setUpWelcomePanel(message); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir }//GEN-END:initComponents 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir private void setUpWelcomePanel(String message){ 66*cdf0e10cSrcweir area.setText( message ); 67*cdf0e10cSrcweir welcomePanel.add(area, java.awt.BorderLayout.CENTER); 68*cdf0e10cSrcweir add(welcomePanel, java.awt.BorderLayout.CENTER); 69*cdf0e10cSrcweir NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", InstallWizard.VERSIONS); 70*cdf0e10cSrcweir nav.setNextListener(this); 71*cdf0e10cSrcweir add(nav, java.awt.BorderLayout.SOUTH); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir //Banner br = new Banner(); 74*cdf0e10cSrcweir //add(br, java.awt.BorderLayout.WEST); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir private boolean validateCurrentUserDir(String userDir){ 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir Properties props = null; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir File fileVersions = null; 85*cdf0e10cSrcweir try 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir fileVersions = InstUtil.buildSversionLocation(); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir catch(IOException eFnF) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir System.err.println("Cannot find sversion.ini/.sversionrc"); 92*cdf0e10cSrcweir JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found", JOptionPane.ERROR_MESSAGE); 93*cdf0e10cSrcweir wizard.exitForm(null); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir try { 97*cdf0e10cSrcweir props = InstUtil.getOfficeVersions(fileVersions); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir catch (IOException eIO) { 100*cdf0e10cSrcweir //Message about no installed versions found 101*cdf0e10cSrcweir System.err.println("Failed to parse SVERSION"); 102*cdf0e10cSrcweir JOptionPane.showMessageDialog(this, "There was a problem reading from the Office settings file.", "Parse Error", JOptionPane.ERROR_MESSAGE); 103*cdf0e10cSrcweir wizard.exitForm(null); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir boolean versionMatch = false; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir for( int i = 0; i < versions.length; i++ ) { 110*cdf0e10cSrcweir String key = versions[i]; 111*cdf0e10cSrcweir String progPath = ( String )props.getProperty( key ); 112*cdf0e10cSrcweir if ( progPath != null ){ 113*cdf0e10cSrcweir progPath = progPath + File.separator + "program"; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir File tmpFile = new File(progPath + File.separator + "oostubversion.txt"); 116*cdf0e10cSrcweir try{ 117*cdf0e10cSrcweir tmpFile.createNewFile(); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if( new File(userDir + File.separator + "oostubversion.txt").exists()) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir versionMatch = true; 122*cdf0e10cSrcweir break; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir catch( IOException e) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir // Fail silently 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir tmpFile.delete(); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir return versionMatch; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir public java.awt.Dimension getPreferredSize() { 138*cdf0e10cSrcweir return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir public void actionPerformed(ActionEvent ev) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir //Perform next actions here... 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // Variables declaration - do not modify//GEN-BEGIN:variables 148*cdf0e10cSrcweir private javax.swing.JPanel welcomePanel; 149*cdf0e10cSrcweir private javax.swing.JTextArea area; 150*cdf0e10cSrcweir private InstallWizard wizard; 151*cdf0e10cSrcweir //private static final String [] versions = {"OpenOffice.org 643", "StarOffice 6.1"}; 152*cdf0e10cSrcweir private static final String [] versions = { "StarOffice 6.1" }; 153*cdf0e10cSrcweir private boolean nextButtonEnable = true; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir // End of variables declaration//GEN-END:variables 156*cdf0e10cSrcweir } 157