merge the formfield patch from ooo-build
[ooovba.git] / scripting / workben / installer / Welcome.java
blob20b42566b186f85e1263e5e99810c46cacc247e4
1 package installer;
3 /*
4 * Welcome.java
6 * Created on 04 July 2002, 15:43
7 */
9 /**
11 * @author mike
13 import java.awt.event.*;
14 import javax.swing.*;
15 import java.io.*;
16 import java.net.*;
17 import java.util.Properties;
19 public class Welcome extends javax.swing.JPanel implements ActionListener {
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();
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.
33 private void initComponents() {//GEN-BEGIN:initComponents
34 welcomePanel = new javax.swing.JPanel();
35 area = new javax.swing.JTextArea();
36 nextButtonEnable = true;
38 setLayout(new java.awt.BorderLayout());
40 welcomePanel.setLayout(new java.awt.BorderLayout());
41 area.setEditable(false);
42 area.setLineWrap(true);
44 String message = "\n\tOffice Scripting Framework Version 0.3" +
45 "\n\n\n\tPlease ensure that you have exited from Office";
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;
56 int programPosition = userDir.lastIndexOf("program");
57 String offInstallPth = null;
58 offInstallPth = userDir.substring( 0, programPosition );
60 wizard.storeLocation(offInstallPth); */
61 setUpWelcomePanel(message);
63 }//GEN-END:initComponents
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);
73 //Banner br = new Banner();
74 //add(br, java.awt.BorderLayout.WEST);
78 private boolean validateCurrentUserDir(String userDir){
82 Properties props = null;
84 File fileVersions = null;
85 try
87 fileVersions = InstUtil.buildSversionLocation();
89 catch(IOException eFnF)
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);
96 try {
97 props = InstUtil.getOfficeVersions(fileVersions);
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);
107 boolean versionMatch = false;
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";
115 File tmpFile = new File(progPath + File.separator + "oostubversion.txt");
116 try{
117 tmpFile.createNewFile();
119 if( new File(userDir + File.separator + "oostubversion.txt").exists())
121 versionMatch = true;
122 break;
125 catch( IOException e)
127 // Fail silently
129 tmpFile.delete();
132 return versionMatch;
137 public java.awt.Dimension getPreferredSize() {
138 return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT);
141 public void actionPerformed(ActionEvent ev)
143 //Perform next actions here...
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;
155 // End of variables declaration//GEN-END:variables