1*cdf0e10cSrcweir package installer; 2*cdf0e10cSrcweir 3*cdf0e10cSrcweir /* 4*cdf0e10cSrcweir * InstallWizard.java 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * Created on 04 July 2002, 15:09 7*cdf0e10cSrcweir */ 8*cdf0e10cSrcweir 9*cdf0e10cSrcweir /** 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * @author mike 12*cdf0e10cSrcweir */ 13*cdf0e10cSrcweir 14*cdf0e10cSrcweir import javax.swing.*; 15*cdf0e10cSrcweir import java.awt.*; 16*cdf0e10cSrcweir import java.awt.event.*; 17*cdf0e10cSrcweir import java.util.*; 18*cdf0e10cSrcweir import java.net.*; 19*cdf0e10cSrcweir import java.io.*; 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir public class InstallWizard extends javax.swing.JFrame implements ActionListener { 22*cdf0e10cSrcweir /* 23*cdf0e10cSrcweir private static class ShutdownHook extends Thread { 24*cdf0e10cSrcweir public void run() 25*cdf0e10cSrcweir { 26*cdf0e10cSrcweir if (InstallWizard.isInstallStarted()) 27*cdf0e10cSrcweir { 28*cdf0e10cSrcweir // Check for and backup any config.xml files 29*cdf0e10cSrcweir // Check for and backup any StarBasic macro files 30*cdf0e10cSrcweir // Check for and backup ProtocolHandler 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir if (!InstallWizard.isPatchedTypes()) 33*cdf0e10cSrcweir { 34*cdf0e10cSrcweir File backup = new File(InstUtil.getTmpDir(), "TypeDetection.xml"); 35*cdf0e10cSrcweir File destination = new File(InstallWizard.getTypesPath()); 36*cdf0e10cSrcweir InstUtil.copy(backup, destination); //Restore typedetection.xml 37*cdf0e10cSrcweir } 38*cdf0e10cSrcweir if (!InstallWizard.isPatchedJava()) 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir File backup = new File(InstUtil.getTmpDir(), "Java.xml"); 41*cdf0e10cSrcweir File destination = new File(InstallWizard.getJavaPath()); 42*cdf0e10cSrcweir InstUtil.copy(backup, destination); //Restore typedetection.xml 43*cdf0e10cSrcweir } 44*cdf0e10cSrcweir if (!InstallWizard.isPatchedRDB()) 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir File backup = new File(InstUtil.getTmpDir(), "applicat.rdb"); 47*cdf0e10cSrcweir File destination = new File(InstallWizard.getJavaPath()); 48*cdf0e10cSrcweir //InstUtil.copy(backup, destination); //Restore typedetection.xml 49*cdf0e10cSrcweir } 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir System.out.println( "ShutdownHook" ); 52*cdf0e10cSrcweir } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir InstUtil.removeTmpDir(); 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir }// class ShutdownHook 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir static { 59*cdf0e10cSrcweir Runtime rt=Runtime.getRuntime(); 60*cdf0e10cSrcweir rt.addShutdownHook(new ShutdownHook()); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir */ 63*cdf0e10cSrcweir /** Creates new form InstallWizard */ 64*cdf0e10cSrcweir public InstallWizard() { 65*cdf0e10cSrcweir super("Office Scripting Framework Installer - Early Developer Release"); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir try { 68*cdf0e10cSrcweir System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n"); 69*cdf0e10cSrcweir System.out.print("Location: "+ System.getProperty( "user.dir" ) + 70*cdf0e10cSrcweir File.separator + "SFrameworkInstall.log\n"); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir LogStream log = new LogStream( "SFrameworkInstall.log" ); 73*cdf0e10cSrcweir System.setErr(log); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir System.setOut(log); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir catch( FileNotFoundException fnfe ) { 78*cdf0e10cSrcweir System.err.println("Office Scripting Framework Installer - Error: "); 79*cdf0e10cSrcweir System.err.println("Unable to create log file for installation."); 80*cdf0e10cSrcweir exitForm(null); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir //setBackground(Color.WHITE); 84*cdf0e10cSrcweir setBackground(new Color(0,0,0)); 85*cdf0e10cSrcweir locations = new ArrayList(); 86*cdf0e10cSrcweir //Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); 87*cdf0e10cSrcweir Point center = new Point( 400, 400 ); 88*cdf0e10cSrcweir int windowWidth=200; 89*cdf0e10cSrcweir int windowHeight=300; 90*cdf0e10cSrcweir setSize(windowWidth,windowHeight); 91*cdf0e10cSrcweir setBounds((center.x-windowWidth/2)-115,(center.y-windowWidth/2)-100, windowWidth,windowHeight); 92*cdf0e10cSrcweir initComponents(); 93*cdf0e10cSrcweir setResizable(false); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir /** This method is called from within the constructor to 97*cdf0e10cSrcweir * initialize the form. 98*cdf0e10cSrcweir */ 99*cdf0e10cSrcweir private void initComponents() { 100*cdf0e10cSrcweir navigation = new javax.swing.JPanel(); 101*cdf0e10cSrcweir navBack = new javax.swing.JButton(); 102*cdf0e10cSrcweir navNext = new javax.swing.JButton(); 103*cdf0e10cSrcweir navCancel = new javax.swing.JButton(); 104*cdf0e10cSrcweir screens = new javax.swing.JPanel(); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir addWindowListener(new java.awt.event.WindowAdapter() { 107*cdf0e10cSrcweir public void windowClosing(java.awt.event.WindowEvent evt) { 108*cdf0e10cSrcweir exitForm(evt); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir }); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir navigation.setLayout(new java.awt.GridBagLayout()); 113*cdf0e10cSrcweir java.awt.GridBagConstraints gridBagConstraints1; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir navBack.setText("<< Back"); 116*cdf0e10cSrcweir gridBagConstraints1 = new java.awt.GridBagConstraints(); 117*cdf0e10cSrcweir gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir navNext.setText("Next >>"); 120*cdf0e10cSrcweir gridBagConstraints1 = new java.awt.GridBagConstraints(); 121*cdf0e10cSrcweir gridBagConstraints1.gridx = 2; 122*cdf0e10cSrcweir gridBagConstraints1.gridy = 0; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir navCancel.setText("Cancel"); 125*cdf0e10cSrcweir gridBagConstraints1 = new java.awt.GridBagConstraints(); 126*cdf0e10cSrcweir gridBagConstraints1.gridx = 6; 127*cdf0e10cSrcweir gridBagConstraints1.gridy = 0; 128*cdf0e10cSrcweir //navigation.add(navNext, gridBagConstraints1); 129*cdf0e10cSrcweir //navigation.add(navBack, gridBagConstraints1); 130*cdf0e10cSrcweir //navigation.add(navCancel, gridBagConstraints1); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir getContentPane().add(navigation, java.awt.BorderLayout.SOUTH); 133*cdf0e10cSrcweir screens.setLayout(new java.awt.CardLayout()); 134*cdf0e10cSrcweir screens.add(WELCOME, new Welcome(this)); 135*cdf0e10cSrcweir version = new Version(this); 136*cdf0e10cSrcweir screens.add(VERSIONS, version); 137*cdf0e10cSrcweir _final = new Final(this); 138*cdf0e10cSrcweir screens.add(FINAL, _final); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir //boolean hasIDEInstallation = (InstUtil.hasNetbeansInstallation() || InstUtil.hasJeditInstallation()) ; 141*cdf0e10cSrcweir boolean hasIDEInstallation = ( InstUtil.hasNetbeansInstallation() ) ; 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if( hasIDEInstallation ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir idewelcome = new IdeWelcome(this); 146*cdf0e10cSrcweir screens.add(IDEWELCOME, idewelcome); 147*cdf0e10cSrcweir ideversion = new IdeVersion(this); 148*cdf0e10cSrcweir screens.add(IDEVERSIONS, ideversion); 149*cdf0e10cSrcweir idefinal = new IdeFinal(this); 150*cdf0e10cSrcweir screens.add(IDEFINAL, idefinal); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir getContentPane().add(screens, java.awt.BorderLayout.CENTER); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir navNext.addActionListener(this); 155*cdf0e10cSrcweir navNext.addActionListener(version); 156*cdf0e10cSrcweir navNext.addActionListener(_final); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir if( hasIDEInstallation ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir navNext.addActionListener(ideversion); 161*cdf0e10cSrcweir navNext.addActionListener(idefinal); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir navCancel.addActionListener(this); 165*cdf0e10cSrcweir navBack.addActionListener(this); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir URL url = this.getClass().getResource("sidebar.jpg"); 169*cdf0e10cSrcweir JLabel sideBar = new JLabel(); 170*cdf0e10cSrcweir sideBar.setIcon(new ImageIcon(url)); 171*cdf0e10cSrcweir getContentPane().add (sideBar, java.awt.BorderLayout.WEST); 172*cdf0e10cSrcweir pack(); 173*cdf0e10cSrcweir }// initComponents 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir /** Exit the Application */ 176*cdf0e10cSrcweir public void exitForm(java.awt.event.WindowEvent evt) { 177*cdf0e10cSrcweir System.exit(0); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir public void actionPerformed(ActionEvent e) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir if (e.getSource() == navNext) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir ((CardLayout)screens.getLayout()).next(screens); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir if (e.getSource() == navCancel) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir exitForm(null); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if (e.getSource() == navBack) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir ((CardLayout)screens.getLayout()).previous(screens); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir }// actionPerformed 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir public static void storeLocation(String path) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir locations.add(path); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir public static ArrayList getLocations() 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir return locations; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir public static void clearLocations() 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir locations.clear(); 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir public void show(String cardName) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir ((CardLayout)screens.getLayout()).show(screens, cardName); 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir /** 220*cdf0e10cSrcweir * @param args the command line arguments 221*cdf0e10cSrcweir */ 222*cdf0e10cSrcweir public static void main(String args[]) { 223*cdf0e10cSrcweir String officePath = null; 224*cdf0e10cSrcweir String netbeansPath = null; 225*cdf0e10cSrcweir //String jeditPath = null; 226*cdf0e10cSrcweir int i = 0; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir while (i < args.length) { 229*cdf0e10cSrcweir if (args[i].equals("-help")) { 230*cdf0e10cSrcweir printUsage(); 231*cdf0e10cSrcweir System.exit(0); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir if (args[i].equals("-office")) 234*cdf0e10cSrcweir officePath = args[++i]; 235*cdf0e10cSrcweir if (args[i].equals("-netbeans")) 236*cdf0e10cSrcweir netbeansPath = args[++i]; 237*cdf0e10cSrcweir if (args[i].equals("-net")) 238*cdf0e10cSrcweir bNetworkInstall = true; 239*cdf0e10cSrcweir if (args[i].equals("-bindings")) 240*cdf0e10cSrcweir bBindingsInstall = true; 241*cdf0e10cSrcweir //if (args[i].equals("-jedit")) 242*cdf0e10cSrcweir // jeditPath = args[++i]; 243*cdf0e10cSrcweir i++; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir //if (officePath == null && netbeansPath == null && jeditPath == null) 247*cdf0e10cSrcweir if (officePath == null && netbeansPath == null) 248*cdf0e10cSrcweir new InstallWizard().show(); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir JLabel label = new JLabel(); 251*cdf0e10cSrcweir JProgressBar progressbar = new JProgressBar(); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir try { 254*cdf0e10cSrcweir System.out.println("Log file is: " + 255*cdf0e10cSrcweir System.getProperty("user.dir") + 256*cdf0e10cSrcweir File.separator + "SFrameworkInstall.log"); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir LogStream log = new LogStream( "SFrameworkInstall.log" ); 259*cdf0e10cSrcweir System.setErr(log); 260*cdf0e10cSrcweir System.setOut(log); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir catch( FileNotFoundException fnfe ) { 263*cdf0e10cSrcweir System.err.println("Error: Unable to create log file: " 264*cdf0e10cSrcweir + fnfe.getMessage()); 265*cdf0e10cSrcweir System.exit(-1); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir if (officePath != null) { 269*cdf0e10cSrcweir XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall, bBindingsInstall ); 270*cdf0e10cSrcweir xud.run(); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir if (netbeansPath != null) { 274*cdf0e10cSrcweir IdeUpdater ideup = new IdeUpdater(netbeansPath, label, progressbar); 275*cdf0e10cSrcweir ideup.run(); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir //if (jeditPath != null) { 279*cdf0e10cSrcweir // IdeUpdater ideup = new IdeUpdater(jeditPath, label, progressbar); 280*cdf0e10cSrcweir // ideup.run(); 281*cdf0e10cSrcweir //} 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir private static void printUsage() { 285*cdf0e10cSrcweir System.err.println("java -jar SFrameworkInstall.jar"); 286*cdf0e10cSrcweir System.err.println("\t[-office <path_to_office_installation]"); 287*cdf0e10cSrcweir System.err.println("\t[-netbeans <path_to_netbeans_installation]"); 288*cdf0e10cSrcweir System.err.println("\t[-net]"); 289*cdf0e10cSrcweir System.err.println("\t[-bindings]"); 290*cdf0e10cSrcweir System.err.println("\n\n-net indicates that this is the network part of a network install."); 291*cdf0e10cSrcweir System.err.println("-bindings will only install the menu & key bindings in user/config/soffice.cfg."); 292*cdf0e10cSrcweir //System.err.println("\t[-jedit <path_to_jedit_installation]"); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir public static synchronized boolean isPatchedTypes() 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir return bPatchedTypes; 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir public static synchronized boolean isPatchedJava() 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir return bPatchedJava; 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir public static synchronized boolean isPatchedRDB() 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir return bPatchedRDB; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir public static synchronized boolean isInstallStarted() 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir return bInstallStarted; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir public static synchronized void setPatchedTypes(boolean value) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir bPatchedTypes = value; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir public static synchronized void setPatchedJava(boolean value) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir bPatchedJava = value; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir public static synchronized void setPatchedRDB(boolean value) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir bPatchedRDB = value; 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir public static synchronized void setInstallStarted(boolean value) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir bInstallStarted = value; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir public static synchronized void setTypesPath(String path) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir typesPath = path; 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir public static synchronized void setJavaPath(String path) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir javaPath = path; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir public static synchronized String getTypesPath() 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir return typesPath; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir public static synchronized String getJavaPath() 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir return javaPath; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir private javax.swing.JPanel navigation; 356*cdf0e10cSrcweir private javax.swing.JButton navBack; 357*cdf0e10cSrcweir private javax.swing.JButton navNext; 358*cdf0e10cSrcweir private javax.swing.JButton navCancel; 359*cdf0e10cSrcweir private javax.swing.JPanel screens; 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir private Version version = null; 362*cdf0e10cSrcweir private Final _final = null; 363*cdf0e10cSrcweir private IdeVersion ideversion = null; 364*cdf0e10cSrcweir private IdeFinal idefinal = null; 365*cdf0e10cSrcweir private IdeWelcome idewelcome = null; 366*cdf0e10cSrcweir private static ArrayList locations = null; 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir public static String VERSIONS = "VERSIONS"; 369*cdf0e10cSrcweir public static String WELCOME = "WELCOME"; 370*cdf0e10cSrcweir public static String FINAL = "FINAL"; 371*cdf0e10cSrcweir public static String IDEVERSIONS = "IDEVERSIONS"; 372*cdf0e10cSrcweir public static String IDEWELCOME = "IDEWELCOME"; 373*cdf0e10cSrcweir public static String IDEFINAL = "IDEFINAL"; 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir public static int DEFWIDTH = 480; 376*cdf0e10cSrcweir public static int DEFHEIGHT = 240; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir private static String typesPath = null; 379*cdf0e10cSrcweir private static String javaPath = null; 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir public static boolean bNetworkInstall = false; 382*cdf0e10cSrcweir public static boolean bBindingsInstall = false; 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir private static boolean bPatchedTypes = false; 385*cdf0e10cSrcweir private static boolean bPatchedJava = false; 386*cdf0e10cSrcweir private static boolean bPatchedRDB = false; 387*cdf0e10cSrcweir private static boolean bInstallStarted = false; 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir }// InstallWizard 390