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