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