diff options
Diffstat (limited to 'scripting/workben/installer')
26 files changed, 3650 insertions, 0 deletions
diff --git a/scripting/workben/installer/Banner.java b/scripting/workben/installer/Banner.java new file mode 100644 index 000000000000..c6d0f0b0bd5e --- /dev/null +++ b/scripting/workben/installer/Banner.java @@ -0,0 +1,30 @@ +package installer; + +import java.awt.*; + +public class Banner extends Canvas +{ + Image img; + Banner() + { + setBackground(Color.white); + img = Toolkit.getDefaultToolkit().createImage("sidebar.jpg"); + } + + public void paint(Graphics g) + { + g.drawImage(img, 0, 0, Color.white, null); + g.dispose(); + } + + public void update(Graphics g) + { + super.update(g); + } + + public Dimension getPreferredSize() + { + return new Dimension(137, 358); + } + +} diff --git a/scripting/workben/installer/ExceptionTraceHelper.java b/scripting/workben/installer/ExceptionTraceHelper.java new file mode 100644 index 000000000000..c661c8d36216 --- /dev/null +++ b/scripting/workben/installer/ExceptionTraceHelper.java @@ -0,0 +1,64 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ +package installer; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +// class for propagating the exception stack traces across the Java/UNO bridge +public class ExceptionTraceHelper +{ + public static String getTrace( Exception e ) + { + ByteArrayOutputStream baos = null; + PrintStream ps = null; + String result = ""; + try + { + baos = new ByteArrayOutputStream( 128 ); + ps = new PrintStream( baos ); + e.printStackTrace( ps ); + } + finally + { + try + { + if ( baos != null ) + { + baos.close(); + } + if ( ps != null ) + { + ps.close(); + } + } + catch ( Exception excp ) + { + } + } + return result; + } +} diff --git a/scripting/workben/installer/ExecCmd.java b/scripting/workben/installer/ExecCmd.java new file mode 100644 index 000000000000..fa5f9a8b2dcd --- /dev/null +++ b/scripting/workben/installer/ExecCmd.java @@ -0,0 +1,100 @@ +package installer; +import java.util.*; +import java.io.*; +public class ExecCmd +{ + + public boolean exec( String cmd, String[] env ) + { + System.out.println("About to exectute " + cmd); + final Process p; + boolean result = false; + try + { + Runtime rt = Runtime.getRuntime(); + p=rt.exec( cmd, env ); + new Thread(new Runnable() { + public void run() + { + BufferedReader br_in = null; + try + { + br_in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String buff = null; + while ((buff = br_in.readLine()) != null) + { + System.out.println("Process out :" + buff); + /*try + { + Thread.sleep(100); + } + catch(Exception e) {}*/ + } + System.out.println("finished reading out"); + } + catch (IOException ioe) + { + System.out.println("Exception caught printing javac result"); + ioe.printStackTrace(); + } + finally + { + if ( br_in != null ) + { + try + { + br_in.close(); + } + catch( Exception e ) {} // nothing can be done + } + } + } } ).start(); + + new Thread(new Runnable() { + public void run() { + BufferedReader br_err = null; + try { + br_err = new BufferedReader(new InputStreamReader(p.getErrorStream())); + String buff = null; + while ((buff = br_err.readLine()) != null) { + System.out.println("Process err :" + buff); + /*try {Thread.sleep(100); } catch(Exception e) {}*/ + } + System.out.println("finished reading err"); + } catch (IOException ioe) { + System.out.println("Exception caught printing javac result"); + ioe.printStackTrace(); + } + finally + { + if ( br_err != null ) + { + try + { + br_err.close(); + } + catch( Exception e ) {} // nothing can be done + } + } + } }).start(); + int exitcode = p.waitFor(); + if ( exitcode != 0 ) + { + System.out.println("cmd [" + cmd + "] failed" ); + result= false; + } + else + { + System.out.println("cmd [" + cmd + "] completed successfully"); + result= true; + } + } + catch (Exception e) { + System.out.println("Exception"); + e.printStackTrace(); + } + System.out.println("command complete"); + return result; + } +} + diff --git a/scripting/workben/installer/FileUpdater.java b/scripting/workben/installer/FileUpdater.java new file mode 100644 index 000000000000..76b5358eb6fe --- /dev/null +++ b/scripting/workben/installer/FileUpdater.java @@ -0,0 +1,232 @@ +package installer; + +import java.io.*; +import javax.swing.JLabel; + +public class FileUpdater { + + public static boolean updateProtocolHandler( String installPath, JLabel statusLabel ) { + File in_file = null; + FileInputStream in = null; + File out_file = null; + FileWriter out = null; + int count = 0; + + try { + in_file = new File( installPath+File.separator+"share"+File.separator+"registry"+File.separator+"data"+File.separator+"org"+File.separator+"openoffice"+File.separator+"Office"+File.separator+"ProtocolHandler.xcu" ); + + String[] xmlArray = new String[50]; + try { + BufferedReader reader = new BufferedReader(new FileReader(in_file)); + count = -1; + for (String s = reader.readLine(); s != null; s = reader.readLine()) { //</oor:node> + count = count + 1; + if(s != null) { + s.trim(); + xmlArray[count] = s; + } + else + break; + } + } + catch( IOException ioe ) { + String message = "\nError reading ProtocolHandler.xcu, please view SFrameworkInstall.log."; + System.out.println(message); + ioe.printStackTrace(); + statusLabel.setText(message); + return false; + } + + in_file.delete(); + + out_file = new File( installPath+File.separator+"share"+File.separator+"registry"+File.separator+"data"+File.separator+"org"+File.separator+"openoffice"+File.separator+"Office"+File.separator+"ProtocolHandler.xcu" ); + out_file.createNewFile(); + out = new FileWriter( out_file ); + + for(int i=0; i<count + 1; i++) { + out.write(xmlArray[i]+"\n"); + if( ( xmlArray[i].indexOf( "<node oor:name=\"HandlerSet\">" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptProtocolHandler" ) == -1 ) ) { + out.write( " <node oor:name=\"com.sun.star.comp.ScriptProtocolHandler\" oor:op=\"replace\">\n" ); + out.write( " <prop oor:name=\"Protocols\">\n" ); + out.write( " <value>script:*</value>\n" ); + out.write( " </prop>\n" ); + out.write( " </node>\n" ); + } + } + } + catch( Exception e ) { + String message = "\nError updating ProtocolHandler.xcu, please view SFrameworkInstall.log."; + System.out.println(message); + e.printStackTrace(); + statusLabel.setText(message); + return false; + } + finally { + try { + out.close(); + System.out.println("File closed"); + } + catch(Exception e) { + System.out.println("Update ProtocolHandler Failed, please view SFrameworkInstall.log."); + System.err.println(e); + e.printStackTrace(); + } + } + return true; + + }// updateProtocolHandler + + + public static boolean updateScriptXLC( String installPath, JLabel statusLabel ) { + + File in_file = null; + FileInputStream in = null; + File out_file = null; + FileWriter out = null; + int count = 0; + + //System.out.println("updateScriptXLC"); + try { + in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" ); + + String[] xmlArray = new String[50]; + try { + BufferedReader reader = new BufferedReader(new FileReader(in_file)); + count = -1; + for (String s = reader.readLine(); s != null; s = reader.readLine()) { //</oor:node> + count = count + 1; + if(s != null) { + s.trim(); + xmlArray[count] = s; + } + else + break; + } + } + catch( IOException ioe ) { + String message = "Error reading script.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + ioe.printStackTrace(); + statusLabel.setText(message); + return false; + } + + in_file.delete(); + + out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" ); + out_file.createNewFile(); + out = new FileWriter( out_file ); + + //split the string into a string array with one line of xml in each element + //String[] xmlArray = xmlLine.split("\n"); + for(int i=0; i<count + 1; i++) { + out.write(xmlArray[i]+"\n"); + if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) { + String opSys = System.getProperty("os.name"); + if (opSys.indexOf("Windows") != -1) { + out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n" ); + } + else { + out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/share/basic/ScriptBindingLibrary/script.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n" ); + } + } + } + } + catch( Exception e ) { + String message = "\nError updating script.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + e.printStackTrace(); + statusLabel.setText(message); + return false; + } + finally { + try { + out.close(); + } + catch(Exception e) { + System.out.println("Update Script.xlc Failed, please view SFrameworkInstall.log."); + e.printStackTrace(); + System.err.println(e); + } + } + return true; + }// updateScriptXLC + + + public static boolean updateDialogXLC( String installPath, JLabel statusLabel ) { + File in_file = null; + FileInputStream in = null; + File out_file = null; + FileWriter out = null; + int count = 0; + + //System.out.println( "updateDialogXLC" ); + try { + in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" ); + String xmlLine = ""; + + String[] xmlArray = new String[50]; + try { + BufferedReader reader = new BufferedReader(new FileReader(in_file)); + count = -1; + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + count = count + 1; + if(s != null) { + s.trim(); + xmlArray[count] = s; + } + else + break; + } + } + catch( IOException ioe ) { + + String message = "\nError reading dialog.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + statusLabel.setText(message); + return false; + } + in_file.delete(); + + out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" ); + out_file.createNewFile(); + + out = new FileWriter( out_file ); + + //split the string into a string array with one line of xml in each element + // String[] xmlArray = xmlLine.split("\n"); + for(int i=0; i<count + 1; i++) { + out.write(xmlArray[i]+"\n"); + if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) { + String opSys = System.getProperty("os.name"); + if (opSys.indexOf("Windows") != -1) { + out.write(" <library:library library:name=\"ScriptBindingLibrary\" library:link=\"true\"/>\n" ); + } + else { + out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/share/basic/ScriptBindingLibrary/dialog.xlb/\" xlink:type=\"simple\" library:link=\"true\"/>\n" ); + } + } + } + } + catch( Exception e ) { + String message = "\nError updating dialog.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + e.printStackTrace(); + statusLabel.setText(message); + return false; + } + finally { + try { + out.close(); + } + catch(Exception e) { + System.out.println("Update dialog.xlc Failed, please view SFrameworkInstall.log."); + e.printStackTrace(); + System.err.println(e); + } + } + return true; + }// updateScriptXLC + + +} diff --git a/scripting/workben/installer/Final.java b/scripting/workben/installer/Final.java new file mode 100644 index 000000000000..ea543d45ccec --- /dev/null +++ b/scripting/workben/installer/Final.java @@ -0,0 +1,136 @@ +package installer; + +/* + * Welcome.java + * + * Created on 04 July 2002, 15:43 + */ + +/** + * + * @author mike + */ + +import java.awt.event.*; +import java.util.*; +import java.net.*; +import javax.swing.*; + +public class Final extends javax.swing.JPanel implements ActionListener, InstallListener { + + /** Creates new form Welcome */ + public Final(InstallWizard wizard) { + this.wizard = wizard; + setBackground(java.awt.Color.white); + xud = null; + 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 + statusPanel = new javax.swing.JPanel(); + statusPanel.setBackground(java.awt.Color.white); + statusLine = new javax.swing.JLabel("Ready", javax.swing.JLabel.CENTER); + + setLayout(new java.awt.BorderLayout()); + + statusPanel.setLayout(new java.awt.BorderLayout()); + + statusLine.setText("Waiting to install. \n All Office processes must be terminated."); + statusPanel.add(statusLine, java.awt.BorderLayout.CENTER); + + add(statusPanel, java.awt.BorderLayout.CENTER); + nav = new NavPanel(wizard, true, true, true, InstallWizard.VERSIONS, ""); + nav.setNextListener(this); + nav.removeCancelListener(nav); + nav.setCancelListener(this); + nav.navNext.setText("Install"); + add(nav, java.awt.BorderLayout.SOUTH); + + + + }//GEN-END:initComponents + + public java.awt.Dimension getPreferredSize() { + return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT); + } + + public void actionPerformed(ActionEvent e) { + // navNext is "Install" + if (e.getSource() == nav.navNext) + { + JProgressBar progressBar=new JProgressBar(); + progressBar.setMaximum(10); + progressBar.setValue(0); + statusPanel.add(progressBar, java.awt.BorderLayout.SOUTH); + nav.enableNext(false); + nav.enableBack(false); + nav.enableCancel(false); + ArrayList locations = wizard.getLocations(); + //System.out.println("here "+locations.size()); + // Returned 1 + String progpath=null; + String path=null; + String classespath=null; + for (int i =0;i<locations.size();i++){ + path= (String)locations.get(i); + //InstallWizard.currentPath = path; + xud = new XmlUpdater(path, statusLine,progressBar,InstallWizard.bNetworkInstall,InstallWizard.bBindingsInstall); + xud.addInstallListener(this); + InstallWizard.setInstallStarted(true); + InstallWizard.setPatchedTypes(false); + InstallWizard.setPatchedJava(false); + InstallWizard.setPatchedRDB(false); + xud.start(); + } + } + + // set to "Exit" at end of installation process + if (e.getSource() == nav.navCancel) { + int answer = JOptionPane.showConfirmDialog(wizard, "Are you sure you want to exit?"); + if (answer == JOptionPane.YES_OPTION) + { + wizard.exitForm(null); + } + else + { + return; + } + } + }// actionPerformed + + + public void installationComplete(InstallationEvent ev) { + //System.out.println("Detected installation complete"); + if( InstUtil.hasNetbeansInstallation() ) { + //System.out.println("Detected installation complete (IDE(s) detected)"); + nav.removeCancelListener(this); + nav.setCancelListener(nav); + nav.navCancel.setText("Finish"); + nav.enableIDE(true); + nav.enableCancel(true); + xud = null; + } + else { + //System.out.println("Detected installation complete (No IDE(s) detected)"); + nav.removeCancelListener(this); + nav.setCancelListener(nav); + nav.navCancel.setText("Finish"); + nav.enableCancel(true); + xud = null; + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel statusPanel; + private javax.swing.JLabel statusLine; + private InstallWizard wizard; + private NavPanel nav; + private XmlUpdater xud; + // End of variables declaration//GEN-END:variables + +} diff --git a/scripting/workben/installer/IdeFinal.java b/scripting/workben/installer/IdeFinal.java new file mode 100644 index 000000000000..d7b622a02bef --- /dev/null +++ b/scripting/workben/installer/IdeFinal.java @@ -0,0 +1,125 @@ +package installer; + +/* + * Welcome.java + * + * Created on 04 July 2002, 15:43 + */ + +/** + * + * @author mike + */ + +import java.awt.event.*; +import java.util.*; +import java.net.*; +import javax.swing.*; + +public class IdeFinal extends javax.swing.JPanel implements ActionListener, InstallListener { + + /** Creates new form Welcome */ + public IdeFinal(InstallWizard wizard) { + this.wizard = wizard; + setBackground(java.awt.Color.white); + ideupdater = null; + 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 + statusPanel = new javax.swing.JPanel(); + statusPanel.setBackground(java.awt.Color.white); + statusLine = new javax.swing.JLabel("Ready", javax.swing.JLabel.CENTER); + + setLayout(new java.awt.BorderLayout()); + + statusPanel.setLayout(new java.awt.BorderLayout()); + + statusLine.setText("Waiting to install IDE support."); + statusPanel.add(statusLine, java.awt.BorderLayout.CENTER); + + add(statusPanel, java.awt.BorderLayout.CENTER); + nav = new NavPanel(wizard, true, true, true, InstallWizard.IDEVERSIONS, ""); + nav.setNextListener(this); + nav.removeCancelListener(nav); + nav.setCancelListener(this); + nav.navNext.setText("Install"); + add(nav, java.awt.BorderLayout.SOUTH); + }//GEN-END:initComponents + + public java.awt.Dimension getPreferredSize() { + return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT); + } + + public void actionPerformed(ActionEvent e) { + // navNext is "Install" + if (e.getSource() == nav.navNext) + { + JProgressBar progressBar=new JProgressBar(); + progressBar.setMaximum(10); + progressBar.setValue(0); + statusPanel.add(progressBar, java.awt.BorderLayout.SOUTH); + nav.enableNext(false); + nav.enableBack(false); + nav.enableCancel(false); + ArrayList locations = wizard.getLocations(); + //System.out.println("here "+locations.size()); + // Returned 1 + String progpath=null; + String path=null; + String classespath=null; + for (int i =0;i<locations.size();i++){ + path= (String)locations.get(i); + + //InstallWizard.currentPath = path; + ideupdater = new IdeUpdater( path, statusLine, progressBar ); + ideupdater.addInstallListener(this); + InstallWizard.setInstallStarted(true); + //InstallWizard.setPatchedTypes(false); + //InstallWizard.setPatchedJava(false); + //InstallWizard.setPatchedRDB(false); + ideupdater.start(); + } + } + + // set to "Exit" at end of installation process + if (e.getSource() == nav.navCancel) { + int answer = JOptionPane.showConfirmDialog(wizard, "Are you sure you want to exit?"); + if (answer == JOptionPane.YES_OPTION) + { + wizard.exitForm(null); + } + else + { + return; + } + } + }// actionPerformed + + + public void installationComplete(InstallationEvent ev) { + //System.out.println("Detected installation complete"); + //if( InstUtil.hasNetbeansInstallation() || InstUtil.hasJeditInstallation() ) { + //System.out.println("Detected installation complete (IDE(s) detected)"); + nav.removeCancelListener(this); + nav.setCancelListener(nav); + nav.navCancel.setText("Finish"); + nav.enableCancel(true); + ideupdater = null; + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel statusPanel; + private javax.swing.JLabel statusLine; + private InstallWizard wizard; + private NavPanel nav; + //private XmlUpdater xud; + private IdeUpdater ideupdater; + // End of variables declaration//GEN-END:variables + +} diff --git a/scripting/workben/installer/IdeUpdater.java b/scripting/workben/installer/IdeUpdater.java new file mode 100644 index 000000000000..dd7dbb0991a8 --- /dev/null +++ b/scripting/workben/installer/IdeUpdater.java @@ -0,0 +1,172 @@ +package installer; + +import java.io.*; +import java.util.*; +import java.util.jar.*; +//import org.xml.sax.*; +//import org.w3c.dom.*; +//import javax.xml.parsers.*; +import java.net.URL; +import java.net.JarURLConnection; +//import javax.xml.parsers.*; +import javax.swing.*; + +/** + * The <code>XmlUpdater</code> pulls a META-INF/converter.xml + * file out of a jar file and parses it, providing access to this + * information in a <code>Vector</code> of <code>ConverterInfo</code> + * objects. + * + * @author Aidan Butler + */ +public class IdeUpdater extends Thread { + + private String classesPath = null; + private String jarfilename; + private String installPath; + + private JLabel statusLabel; + + private Vector listeners; + private Thread internalThread; + private boolean threadSuspended; + private JProgressBar progressBar; + + private boolean isNetbeansPath = false; + + + public IdeUpdater(String installPath, JLabel statusLabel, JProgressBar pBar) { + + if (installPath.endsWith(File.separator) == false) + installPath += File.separator; + + //File jeditLauncher = new File( installPath + "jedit.jar" ); + File netbeansLauncher = new File( installPath + "bin" ); + + if( netbeansLauncher.isDirectory() ) { + isNetbeansPath = true; + installPath = installPath +"modules" + File.separator; + } + /* + else if( jeditLauncher.isFile() ){ + isNetbeansPath = false; + installPath = installPath + "jars" + File.separator; + } + */ + + System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath ); + this.installPath = installPath; + this.statusLabel = statusLabel; + listeners = new Vector(); + threadSuspended = false; + progressBar=pBar; + progressBar.setStringPainted(true); + }// XmlUpdater + + + public boolean checkStop() + { + if (internalThread == Thread.currentThread()) + return false; + return true; + }// checkStop + + + public void checkSuspend() + { + if (threadSuspended) + { + synchronized(this) + { + while (threadSuspended) + { + try { + wait(); + } catch (InterruptedException eInt) { + //... + } + } + } + } + }// checkSuspend + + + public void setSuspend() + { + threadSuspended = true; + }// setSuspend + + + public void setResume() + { + threadSuspended = false; + notify(); + }// setResume + + + public void setStop() + { + internalThread = null; + }// setStop + + + public void run() { + + //InputStream istream; + //URL url; + //String fileName = null; + + internalThread = Thread.currentThread(); + + progressBar.setString("Unzipping Required Files"); + ZipData zd = new ZipData("SFrameworkInstall.jar"); + + // Adding IDE support + if( isNetbeansPath ) { + if (!zd.extractEntry("ide/office.jar",installPath, statusLabel)) + { + onInstallComplete(); + return; + } + } + else { + if (!zd.extractEntry("ide/idesupport.jar",installPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("ide/OfficeScripting.jar",installPath, statusLabel)) + { + onInstallComplete(); + return; + } + } + + //System.out.println("About to call register"); + //Register.register(installPath+File.separator, statusLabel, progressBar); + + statusLabel.setText("Installation Complete"); + progressBar.setString("Installation Complete"); + progressBar.setValue(10); + onInstallComplete(); + + }// run + + + public void addInstallListener(InstallListener listener) + { + listeners.addElement(listener); + }// addInstallListener + + + private void onInstallComplete() + { + Enumeration e = listeners.elements(); + while (e.hasMoreElements()) + { + InstallListener listener = (InstallListener)e.nextElement(); + listener.installationComplete(null); + } + }// onInstallComplete + +}// XmlUpdater class diff --git a/scripting/workben/installer/IdeVersion.java b/scripting/workben/installer/IdeVersion.java new file mode 100644 index 000000000000..9d35f5bd623a --- /dev/null +++ b/scripting/workben/installer/IdeVersion.java @@ -0,0 +1,349 @@ +package installer; + +/* + * Welcome.java + * + * Created on 04 July 2002, 15:43 + */ + +/** + * + * @author mike + */ + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; +import javax.swing.SwingUtilities.*; + +public class IdeVersion extends javax.swing.JPanel implements ActionListener, TableModelListener { + + /** Creates new form Welcome */ + public IdeVersion(InstallWizard wizard) { + this.wizard=wizard; + setBackground(Color.white); + 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() { + Properties props = null; + JPanel versionPanel = new JPanel(); + setLayout(new BorderLayout()); + + + try { + //props = InstUtil.getNetbeansLocation(); + + Properties netbeansProps = InstUtil.getNetbeansLocation(); + //Properties jeditProps = InstUtil.getJeditLocation(); + Properties ideProps = new Properties(); + if(netbeansProps!=null ) + { + System.out.println("**** Found netbeans install"); + for( int n = 0; n < netbeansProps.size(); n++ ) { + for( int v = 0; v < InstUtil.versions.length; v++ ) { + System.out.println("n: " +n+" v: " +v); + String key = InstUtil.versions[v]; + System.out.println("It got here1"); + String path = null; + if ( (path = netbeansProps.getProperty(key) ) != null ) { + //System.out.println( "n="+n+" v="+v + " Netbeans " + " key=" + key + " path=" + path ); + ideProps.put(key, path); + } + } + } + } + //System.out.println("*** About to look for jedit install"); + /* + if(jeditProps!=null) + { + for( int j = 0; j < jeditProps.size(); j++ ) { + for( int v = 0; v < InstUtil.versions.length; v++ ) { + System.out.println("j: " +j+" v: " +v); + String key = InstUtil.versions[v]; + String path = null; + if ((path = jeditProps.getProperty(key)) != null) { + //System.out.println( "j="+j+" v="+v + " jEdit " + " key=" + key + " path=" + path ); + ideProps.put(key, path); + } + } + } + } + */ + props = ideProps; + } + catch (IOException eIO) { + System.err.println("Failed to parse .netbeans/ide.log"); + //JOptionPane.showMessageDialog(this, "There was a problem reading from the NetBeans ide.log file.", "Parse Error", JOptionPane.ERROR_MESSAGE); + } + catch (Exception e) { + System.err.println("Exception thrown in initComponents"); + } + + tableModel = new MyTableModelIDE (props, InstUtil.versions); + + if (tableModel.getRowCount() == 0) + { + JOptionPane.showMessageDialog(this, "No compatible IDEs were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE); + //wizard.exitForm(null); + } + + tableModel.addTableModelListener(this); + JTable tableVersions = new JTable(tableModel) { + public String getToolTipText(MouseEvent event) + { + int col = columnAtPoint( event.getPoint() ); + if (col != 2) + return null; + + int row = rowAtPoint( event.getPoint() ); + Object o = getValueAt(row, col); + + if (o == null) + return null; + + if (o.toString().equals("")) + return null; + + return o.toString(); + } + + public Point getToolTipLocation(MouseEvent event) + { + int col = columnAtPoint( event.getPoint() ); + if (col != 2) + return null; + + int row = rowAtPoint( event.getPoint() ); + Object o = getValueAt(row,col); + + if (o == null) + return null; + + if (o.toString().equals("")) + return null; + + Point pt = getCellRect(row, col, true).getLocation(); + pt.translate(-1,-2); + return pt; + } + }; + + JScrollPane scroll = new JScrollPane(tableVersions); + + tableVersions.setPreferredSize( + new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT)); + + tableVersions.setRowSelectionAllowed(false); + tableVersions.setColumnSelectionAllowed(false); + tableVersions.setCellSelectionEnabled(false); + + initColumnSizes(tableVersions, tableModel); + versionPanel.add(scroll); + + JTextArea area = new JTextArea("Please select IDEs below that you wish to add Scripting support to"); + area.setLineWrap(true); + area.setEditable(false); + add(area, BorderLayout.NORTH); + add(versionPanel, BorderLayout.CENTER); + nav = new NavPanel(wizard, true, false, true, InstallWizard.IDEWELCOME, InstallWizard.IDEFINAL); + nav.setNextListener(this); + add(nav, BorderLayout.SOUTH); + + }// initComponents + + + public java.awt.Dimension getPreferredSize() { + return new java.awt.Dimension(320, 280); + } + + + public void actionPerformed(ActionEvent ev) { + wizard.clearLocations(); + int len = tableModel.data.size(); + for (int i = 0; i < len; i++) { + ArrayList list = (ArrayList)tableModel.data.get(i); + if (((Boolean)list.get(0)).booleanValue() == true) + wizard.storeLocation((String)list.get(2)); + } + + //System.out.println(wizard.getLocations()); + } + + + public void tableChanged(TableModelEvent e) { + if (tableModel.isAnySelected()) { + nav.enableNext(true); + } + else { + nav.enableNext(false); + } + } + + private void initColumnSizes(JTable table, MyTableModelIDE model) { + TableColumn column = null; + Component comp = null; + int headerWidth = 0; + int cellWidth = 0; + int preferredWidth = 0; + int totalWidth = 0; + Object[] longValues = model.longValues; + + for (int i = 0; i < 3; i++) { + column = table.getColumnModel().getColumn(i); + + try { + comp = column.getHeaderRenderer(). + getTableCellRendererComponent( + null, column.getHeaderValue(), + false, false, 0, 0); + headerWidth = comp.getPreferredSize().width; + } catch (NullPointerException e) { + // System.err.println("Null pointer exception!"); + // System.err.println(" getHeaderRenderer returns null in 1.3."); + // System.err.println(" The replacement is getDefaultRenderer."); + } + + // need to replace spaces in String before getting preferred width + if (longValues[i] instanceof String) { + longValues[i] = ((String)longValues[i]).replace(' ', '_'); + } + + System.out.println("longValues: " + longValues[i]); + comp = table.getDefaultRenderer(model.getColumnClass(i)). + getTableCellRendererComponent( + table, longValues[i], + false, false, 0, i); + cellWidth = comp.getPreferredSize().width; + + preferredWidth = Math.max(headerWidth, cellWidth); + + if (false) { + System.out.println("Initializing width of column " + + i + ". " + + "preferredWidth = " + preferredWidth + + "; totalWidth = " + totalWidth + + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth)); + } + + //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead. + if (i == 2) { + if (preferredWidth > InstallWizard.DEFWIDTH - totalWidth) + column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth); + else + column.setPreferredWidth(preferredWidth); + } + else { + column.setMinWidth(preferredWidth); + totalWidth += preferredWidth; + } + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField jTextField2; + private InstallWizard wizard; + private MyTableModelIDE tableModel; + private NavPanel nav; + // End of variables declaration//GEN-END:variables + + } + +class MyTableModelIDE extends AbstractTableModel { + ArrayList data; + String colNames[] = {"", "IDE Name", "IDE Location"}; + Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"}; + + MyTableModelIDE (Properties properties, String [] validVersions) { + data = new ArrayList(); + //System.out.println(properties); + + int len = validVersions.length; + for (int i = 0; i < len; i++) { + String key = validVersions[i]; + String path = null; + + if ((path = properties.getProperty(key)) != null) { + ArrayList row = new ArrayList(); + row.add(0, new Boolean(false)); + + row.add(1, key); + if (key.length() > ((String)longValues[1]).length()) { + longValues[1] = key; + } + + row.add(2, path); + if (path.length() > ((String)longValues[2]).length()) { + longValues[2] = path; + } + + data.add(row); + } + } + }// MyTableModel + + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return data.size(); + } + + public String getColumnName(int col) { + return colNames[col]; + } + + public Object getValueAt(int row, int col) { + if (row < 0 || row > getRowCount() || + col < 0 || col > getColumnCount()) + return null; + + ArrayList aRow = (ArrayList)data.get(row); + return aRow.get(col); + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + if (col == 0) { + return true; + } else { + return false; + } + } + + public void setValueAt(Object value, int row, int col) { + ArrayList aRow = (ArrayList)data.get(row); + aRow.set(col, value); + fireTableCellUpdated(row, col); + } + + String [] getSelected() { + return null; + } + + public boolean isAnySelected() { + Iterator iter = data.iterator(); + while (iter.hasNext()) { + ArrayList row = (ArrayList)iter.next(); + if (((Boolean)row.get(0)).booleanValue() == true) { + return true; + } + } + return false; + } + +} + diff --git a/scripting/workben/installer/IdeWelcome.java b/scripting/workben/installer/IdeWelcome.java new file mode 100644 index 000000000000..93ce8ec5e22a --- /dev/null +++ b/scripting/workben/installer/IdeWelcome.java @@ -0,0 +1,79 @@ +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.awt.*; + +public class IdeWelcome extends javax.swing.JPanel implements ActionListener { + + /** Creates new form Welcome */ + public IdeWelcome(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(); + + setLayout(new java.awt.BorderLayout()); + + welcomePanel.setLayout(new java.awt.BorderLayout()); + //area.setHorizontalAlignment(javax.swing.JTextField.CENTER); + area.setEditable(false); + area.setLineWrap(true); + area.setText("\n Click Next to include Scripting Framework support for IDEs."); + area.append("\n Click Cancel exit the Installation process. \n"); + if( InstUtil.hasNetbeansInstallation() ) { + area.append("\n \tA version of Netbeans has been detected. \n"); + } + //if( InstUtil.hasJeditInstallation() ) { + // area.append("\n \tA version of jEdit has been detected."); + //} + + welcomePanel.add(area, java.awt.BorderLayout.CENTER); + add(welcomePanel, java.awt.BorderLayout.CENTER); + NavPanel nav = new NavPanel(wizard, false, true, true, "", InstallWizard.IDEVERSIONS); + nav.setNextListener(this); + add(nav, java.awt.BorderLayout.SOUTH); + + //Banner br = new Banner(); + //add(br, java.awt.BorderLayout.WEST); + + }//GEN-END:initComponents + + 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; + + // End of variables declaration//GEN-END:variables +} diff --git a/scripting/workben/installer/InstUtil.java b/scripting/workben/installer/InstUtil.java new file mode 100644 index 000000000000..5ca03e27a19b --- /dev/null +++ b/scripting/workben/installer/InstUtil.java @@ -0,0 +1,463 @@ +package installer; + +import java.net.URLDecoder; +import java.io.*; +import java.util.*; +import java.util.zip.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.net.*; + +public class InstUtil { + + public static File buildSversionLocation() throws IOException { + File theFile = null; + StringBuffer str = new StringBuffer(); + str.append(System.getProperty("user.home")); + str.append(File.separator); + StringBuffer thePath = new StringBuffer(str.toString()); + + String os = System.getProperty("os.name"); + + if (os.indexOf("Windows") != -1) { + boolean bSVersionInHomeDir = new File(thePath.toString() + "sversion.ini").exists(); + + if (!bSVersionInHomeDir) { + thePath.append("Application Data"); + thePath.append(File.separator); + } + theFile = findVersionFile(new File(thePath.toString())); + } else if (os.indexOf("SunOS") != -1) { + thePath.append(".sversionrc"); + theFile = new File(thePath.toString()); + } else if (os.indexOf("Linux") != -1) { + thePath.append(".sversionrc"); + theFile = new File(thePath.toString()); + } + + if (theFile == null) + { + throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?"); + } + if (!theFile.exists()) + { + throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?"); + } + return theFile; + } + + + + public static boolean hasNetbeansInstallation() { + boolean result = false; + try + { + result = checkForSupportedVersion( getNetbeansLocation(), versions ); + + if (result == false) + System.out.println("No supported version of NetBeans found."); + } + catch ( IOException ioe ) + { + System.err.println("Exception caught trying to determine netbeans installation: " + ioe ); + ioe.printStackTrace(); + result = false; + } + return result; + } + + private static boolean checkForSupportedVersion( Properties installs, String[] supportedVersions ) + { + if ( installs != null ) + { + for ( int index = 0; index < supportedVersions.length; index++ ) + { + String key = supportedVersions[ index ]; + String path = null; + if ( ( path = installs.getProperty(key) ) != null ) + { + // at least one supported version for netbeans present, so return; + return true; + } + + } + } + return false; + } + + + public static boolean hasJeditInstallation() { + boolean result = false; + try + { + result = checkForSupportedVersion( getJeditLocation(), versions ); + if ( !result ) + { + System.out.println("No supported version for JEdit found."); + } + } + catch ( IOException ioe ) + { + System.err.println("Exception caught trying to determine jedit installation: " + ioe ); + ioe.printStackTrace(); + result = false; + } + return result; + } + + + + public static Properties getNetbeansLocation() throws IOException { + File theFile = null; + Properties results = new Properties(); + + StringBuffer str = new StringBuffer(); + str.append(System.getProperty("user.home")); + str.append(File.separator); + StringBuffer thePath = new StringBuffer(str.toString()); + + String os = System.getProperty("os.name"); + + if (os.indexOf("Windows") != -1) { + //theFile = findVersionFile(new File(str.toString())); + thePath.append(".netbeans"); + //theFile = new File(thePath.toString()); + } else if (os.indexOf("SunOS") != -1) { + thePath.append(".netbeans"); + //theFile = new File(thePath.toString()); + } else if (os.indexOf("Linux") != -1) { + thePath.append(".netbeans"); + //theFile = new File(thePath.toString()); + } + + if ( thePath.toString().indexOf( ".netbeans" ) == -1 ) + return null; + else if ( new File( thePath.append( File.separator+"3.4"+File.separator ).toString() ).isDirectory() ) { + + System.out.println( "Found NetBeans 3.4 user directory: " + thePath ); + File netbeansLogFile = new File( thePath.toString() + File.separator + "system" + File.separator + "ide.log" ); + if( netbeansLogFile.exists() ) { + String installPath = getNetbeansInstallation( netbeansLogFile ); + File f = new File(installPath); + results.put("NetBeans 3.4", f.getPath()+File.separator); + System.out.println( "NetBeans Installation directory: " + f.getPath()); + } + else { + System.out.println( "No NetBeans log file found" ); + return null; + } + } + else + { + System.out.println( "No NetBeans user directory found" ); + return null; + } + + + return results; + } + + + + public static Properties getJeditLocation() throws IOException { + + /*if( !hasJeditInstallation() ) { + System.out.println( "No Jedit found (line195 InstUtil"); + return null; + }*/ + + File theFile = null; + Properties results = new Properties(); + + StringBuffer str = new StringBuffer(); + str.append(System.getProperty("user.home")); + str.append(File.separator); + StringBuffer thePath = new StringBuffer(str.toString()); + + String os = System.getProperty("os.name"); + thePath.append(".jedit"); + //System.out.println( ".jedit path " + thePath ); + + File jeditLogFile = new File( thePath.toString() + File.separator + "activity.log" ); + if( jeditLogFile.exists() ) { + String[] jeditDetails = getJeditInstallation( jeditLogFile ); + System.out.println( "getJeditLocation ) " + jeditDetails[0] ); + File f = new File(jeditDetails[0]); + results.put("jEdit "+jeditDetails[1], jeditDetails[0]); + System.out.println( "jeditDetails[0] is " + jeditDetails[0]); + } + else { + System.out.println( "Prompt user for Jedit installation path" ); + } + + + return results; + } + + + + + + private static String getNetbeansInstallation( File logFile ) { + String installPath = ""; + try { + BufferedReader reader = new BufferedReader(new FileReader(logFile)); + + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + s.trim(); + if( s.indexOf( "IDE Install" ) != -1 ) { + int pathStart = s.indexOf( "=" ) + 2; + //System.out.println( "pathStart " + pathStart ); + installPath = s.substring( pathStart, s.length() ); + //System.out.println( "installPath 1" + installPath ); + int pathEnd = installPath.indexOf( ";"); + //System.out.println( "pathEnd " + pathEnd ); + installPath = installPath.substring( 0, pathEnd ) +File.separator; + //System.out.println( "pathStart " + pathStart ); + //int pathEnd = s.indexOf( ";"); + //System.out.println( "pathEnd " + pathEnd ); + //System.out.println( "s is " + s + " and " + s.length() + " long" ); + //installPath = s.substring( pathStart, pathEnd - 1 ); + installPath.trim(); + break; + } + } + } + catch( IOException ioe ) { + System.out.println( "Error reading Netbeans location information" ); + } + //catch( FileNotFoundException fnfe ) { + //System.out.println( "NetBeans ide.log FileNotFoundException" ); + //} + + return installPath; + } + + + private static String[] getJeditInstallation( File logFile ) { + String[] jeditDetails = new String[2]; + try { + BufferedReader reader = new BufferedReader(new FileReader(logFile)); + String installPath = ""; + String version = ""; + + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + s.trim(); + if( s.indexOf( "jEdit home directory is" ) != -1 ) { + int pathStart = new String( "[message] jEdit: jEdit home directory is " ).length(); + //System.out.println( "pathStart " + pathStart ); + installPath = s.substring( pathStart, s.length() ) +File.separator; + System.out.println( "installPath 1" + installPath ); + //int pathEnd = installPath.indexOf( ";"); + //System.out.println( "pathEnd " + pathEnd ); + //installPath = installPath.substring( 0, pathEnd ) +File.separator; + //System.out.println( "pathStart " + pathStart ); + //int pathEnd = s.indexOf( ";"); + //System.out.println( "pathEnd " + pathEnd ); + //System.out.println( "s is " + s + " and " + s.length() + " long" ); + //installPath = s.substring( pathStart, pathEnd - 1 ); + installPath.trim(); + //System.out.println( "installPath 2 " + installPath ); + //break; + jeditDetails[0] = installPath; + } + if( s.indexOf( "jEdit: jEdit version" ) != -1 ) { + int versionStart = s.indexOf( "version" ) + 8; + System.out.println( "versionStart is: " + versionStart ); + version = s.substring( versionStart, s.length() ); + version.trim(); + System.out.println( "jEdit version is: " + version ); + jeditDetails[1] = version; + } + } + } + catch( IOException ioe ) { + System.out.println( "Error reading Jedit location information" ); + } + //catch( FileNotFoundException fnfe ) { + //System.out.println( "Jedit activity.log FileNotFoundException" ); + //} + + return jeditDetails; + } + + + + public static File findVersionFile(File start) + { + File versionFile = null; + + File files[] = start.listFiles(new VersionFilter()); + if (files.length == 0) + { + File dirs[] = start.listFiles(new DirFilter()); + for (int i=0; i< dirs.length; i++) + { + versionFile = findVersionFile(dirs[i]); + if (versionFile != null) + { + break; + } + } + } + else + { + versionFile = files[0]; + } + + return versionFile; + } + + public static boolean verifySversionExists(File sversionFile) { + if (!sversionFile.exists()) + return false; + return true; + } + + public static Properties getOfficeVersions(File sversionFile) throws IOException { + BufferedReader reader = new BufferedReader(new FileReader(sversionFile)); + Vector values; + String sectionName = null; + Properties results = new Properties(); + + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + s.trim(); + //System.out.println(s); + if (s.length() == 0) + continue; + if (s.charAt(0) == '[') { + sectionName = s.substring(1, s.length() - 1); + //System.out.println(sectionName); + continue; + } + if ((sectionName != null) && sectionName.equalsIgnoreCase("Versions")) { + int equals = s.indexOf( "=" ); + String officeName = s.substring(0, equals ); + + String instPath = s.substring(equals + 8, s.length()); + String [] parts = new String[2]; + parts[0] = officeName; + parts[1] = instPath + File.separator; + //System.out.println( "InstUtil officeName " + officeName ); + //System.out.println( "InstUtil instPath " + instPath ); + + //String [] parts = s.split("="); + if (parts.length == 2) { + //ver.version = parts[0].trim(); + //File f = new File(parts[1].trim()); + //results.put(parts[0].trim(), f.getPath()); + try { + URL url = new URL("file://" + parts[1].trim()); + String opSys =System.getProperty("os.name"); + if (opSys.indexOf("Windows")!=-1){ + String windowsPath = URLDecoder.decode( url.getPath() ); + boolean firstSlash = true; + while( windowsPath.indexOf("/") != -1 ) { + int forwardSlashPos = windowsPath.indexOf("/"); + String firstPart = windowsPath.substring( 0, forwardSlashPos ); + String lastPart = windowsPath.substring( forwardSlashPos + 1, windowsPath.length() ); + if( firstSlash ) { + windowsPath = lastPart; + firstSlash = false; + } + else { + windowsPath = firstPart + "\\" + lastPart; + } + } + int lastSlash = windowsPath.lastIndexOf("\\"); + windowsPath = windowsPath.substring( 0, lastSlash ); + results.put( parts[0].trim(), windowsPath ); + } + else { + //System.err.println( " InstUtil URLDecoder " + URLDecoder.decode(url.getPath()) ); + results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); + } + //File f = new File(url); + + //.sversion: OpenOffice.org 643=file:///scriptdev/neil/ScriptFrameOpenoffice1.0.1 + // parts = Installation name. f.getPath = Installation path + //results.put(parts[0].trim(), f.getPath()); + + //results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); + //results.put( parts[0].trim(), windowsPath ); + + } + catch (MalformedURLException eSyntax) { + //throw new IOException("Error while reading version information"); + results.put(parts[0].trim(), parts[1].trim()); + //System.out.println(parts[0].trim() + " : " + parts[1].trim()); + System.err.println("GotHereException"); + } + } + else { + System.out.println("not splitting on equals"); + } + } + } + + return results; + } + + public static String getJavaVersion() { + return System.getProperty("java.version"); + } + + public static boolean isCorrectJavaVersion() { + if (System.getProperty("java.version").startsWith("1.4")) + return true; + return false; + } + + public static void main(String args[]) { + InstUtil inst = new InstUtil(); + File f = null; + try + { + f = inst.buildSversionLocation(); + } + catch (IOException e) + { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + if (!inst.verifySversionExists(f)) { + System.err.println("Problem with sversion.ini"); + } + try { + Properties vers = inst.getOfficeVersions(f); + } catch (IOException e) { + e.printStackTrace(); + System.err.println(e); + } + System.out.println(inst.getJavaVersion()); + if (!inst.isCorrectJavaVersion()) { + System.err.println("Not correct Java Version"); + } + } + + public static final String [] versions = {"NetBeans 3.4", "jEdit 4.0.3", "jEdit 4.1pre5" }; + private static File tmpDir = null; +} + + + +class DirFilter implements java.io.FileFilter +{ + public boolean accept(File aFile) + { + return aFile.isDirectory(); + } +} +class VersionFilter implements java.io.FileFilter +{ + public boolean accept(File aFile) + { + if (aFile.getName().compareToIgnoreCase("sversion.ini") == 0) + { + return true; + } + + return false; + } +} diff --git a/scripting/workben/installer/InstallListener.java b/scripting/workben/installer/InstallListener.java new file mode 100644 index 000000000000..eade1ef413c8 --- /dev/null +++ b/scripting/workben/installer/InstallListener.java @@ -0,0 +1,6 @@ +package installer; + +public interface InstallListener +{ + public void installationComplete(InstallationEvent e); +} diff --git a/scripting/workben/installer/InstallWizard.java b/scripting/workben/installer/InstallWizard.java new file mode 100644 index 000000000000..14fae1c5dfcd --- /dev/null +++ b/scripting/workben/installer/InstallWizard.java @@ -0,0 +1,389 @@ +package installer; + +/* + * InstallWizard.java + * + * Created on 04 July 2002, 15:09 + */ + +/** + * + * @author mike + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import java.net.*; +import java.io.*; + +public class InstallWizard extends javax.swing.JFrame implements ActionListener { +/* + private static class ShutdownHook extends Thread { + public void run() + { + if (InstallWizard.isInstallStarted()) + { + // Check for and backup any config.xml files + // Check for and backup any StarBasic macro files + // Check for and backup ProtocolHandler + + if (!InstallWizard.isPatchedTypes()) + { + File backup = new File(InstUtil.getTmpDir(), "TypeDetection.xml"); + File destination = new File(InstallWizard.getTypesPath()); + InstUtil.copy(backup, destination); //Restore typedetection.xml + } + if (!InstallWizard.isPatchedJava()) + { + File backup = new File(InstUtil.getTmpDir(), "Java.xml"); + File destination = new File(InstallWizard.getJavaPath()); + InstUtil.copy(backup, destination); //Restore typedetection.xml + } + if (!InstallWizard.isPatchedRDB()) + { + File backup = new File(InstUtil.getTmpDir(), "applicat.rdb"); + File destination = new File(InstallWizard.getJavaPath()); + //InstUtil.copy(backup, destination); //Restore typedetection.xml + } + + System.out.println( "ShutdownHook" ); + } + + InstUtil.removeTmpDir(); + } + }// class ShutdownHook + + static { + Runtime rt=Runtime.getRuntime(); + rt.addShutdownHook(new ShutdownHook()); + } +*/ + /** Creates new form InstallWizard */ + public InstallWizard() { + super("Office Scripting Framework Installer - Early Developer Release"); + + try { + System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n"); + System.out.print("Location: "+ System.getProperty( "user.dir" ) + + File.separator + "SFrameworkInstall.log\n"); + + LogStream log = new LogStream( "SFrameworkInstall.log" ); + System.setErr(log); + + System.setOut(log); + } + catch( FileNotFoundException fnfe ) { + System.err.println("Office Scripting Framework Installer - Error: "); + System.err.println("Unable to create log file for installation."); + exitForm(null); + } + + //setBackground(Color.WHITE); + setBackground(new Color(0,0,0)); + locations = new ArrayList(); + //Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); + Point center = new Point( 400, 400 ); + int windowWidth=200; + int windowHeight=300; + setSize(windowWidth,windowHeight); + setBounds((center.x-windowWidth/2)-115,(center.y-windowWidth/2)-100, windowWidth,windowHeight); + initComponents(); + setResizable(false); + } + + /** This method is called from within the constructor to + * initialize the form. + */ + private void initComponents() { + navigation = new javax.swing.JPanel(); + navBack = new javax.swing.JButton(); + navNext = new javax.swing.JButton(); + navCancel = new javax.swing.JButton(); + screens = new javax.swing.JPanel(); + + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + exitForm(evt); + } + }); + + navigation.setLayout(new java.awt.GridBagLayout()); + java.awt.GridBagConstraints gridBagConstraints1; + + navBack.setText("<< Back"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1); + + navNext.setText("Next >>"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 0; + + navCancel.setText("Cancel"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 6; + gridBagConstraints1.gridy = 0; + //navigation.add(navNext, gridBagConstraints1); + //navigation.add(navBack, gridBagConstraints1); + //navigation.add(navCancel, gridBagConstraints1); + + getContentPane().add(navigation, java.awt.BorderLayout.SOUTH); + screens.setLayout(new java.awt.CardLayout()); + screens.add(WELCOME, new Welcome(this)); + version = new Version(this); + screens.add(VERSIONS, version); + _final = new Final(this); + screens.add(FINAL, _final); + + //boolean hasIDEInstallation = (InstUtil.hasNetbeansInstallation() || InstUtil.hasJeditInstallation()) ; + boolean hasIDEInstallation = ( InstUtil.hasNetbeansInstallation() ) ; + + if( hasIDEInstallation ) + { + idewelcome = new IdeWelcome(this); + screens.add(IDEWELCOME, idewelcome); + ideversion = new IdeVersion(this); + screens.add(IDEVERSIONS, ideversion); + idefinal = new IdeFinal(this); + screens.add(IDEFINAL, idefinal); + } + getContentPane().add(screens, java.awt.BorderLayout.CENTER); + + navNext.addActionListener(this); + navNext.addActionListener(version); + navNext.addActionListener(_final); + + if( hasIDEInstallation ) + { + navNext.addActionListener(ideversion); + navNext.addActionListener(idefinal); + } + + navCancel.addActionListener(this); + navBack.addActionListener(this); + + + URL url = this.getClass().getResource("sidebar.jpg"); + JLabel sideBar = new JLabel(); + sideBar.setIcon(new ImageIcon(url)); + getContentPane().add (sideBar, java.awt.BorderLayout.WEST); + pack(); + }// initComponents + + /** Exit the Application */ + public void exitForm(java.awt.event.WindowEvent evt) { + System.exit(0); + } + + + public void actionPerformed(ActionEvent e) + { + if (e.getSource() == navNext) + { + ((CardLayout)screens.getLayout()).next(screens); + } + + if (e.getSource() == navCancel) + { + exitForm(null); + } + + if (e.getSource() == navBack) + { + ((CardLayout)screens.getLayout()).previous(screens); + } + }// actionPerformed + + public static void storeLocation(String path) + { + locations.add(path); + } + + public static ArrayList getLocations() + { + return locations; + } + + public static void clearLocations() + { + locations.clear(); + } + + public void show(String cardName) + { + ((CardLayout)screens.getLayout()).show(screens, cardName); + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + String officePath = null; + String netbeansPath = null; + //String jeditPath = null; + int i = 0; + + while (i < args.length) { + if (args[i].equals("-help")) { + printUsage(); + System.exit(0); + } + if (args[i].equals("-office")) + officePath = args[++i]; + if (args[i].equals("-netbeans")) + netbeansPath = args[++i]; + if (args[i].equals("-net")) + bNetworkInstall = true; + if (args[i].equals("-bindings")) + bBindingsInstall = true; + //if (args[i].equals("-jedit")) + // jeditPath = args[++i]; + i++; + } + + //if (officePath == null && netbeansPath == null && jeditPath == null) + if (officePath == null && netbeansPath == null) + new InstallWizard().show(); + + JLabel label = new JLabel(); + JProgressBar progressbar = new JProgressBar(); + + try { + System.out.println("Log file is: " + + System.getProperty("user.dir") + + File.separator + "SFrameworkInstall.log"); + + LogStream log = new LogStream( "SFrameworkInstall.log" ); + System.setErr(log); + System.setOut(log); + } + catch( FileNotFoundException fnfe ) { + System.err.println("Error: Unable to create log file: " + + fnfe.getMessage()); + System.exit(-1); + } + + if (officePath != null) { + XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall, bBindingsInstall ); + xud.run(); + } + + if (netbeansPath != null) { + IdeUpdater ideup = new IdeUpdater(netbeansPath, label, progressbar); + ideup.run(); + } + + //if (jeditPath != null) { + // IdeUpdater ideup = new IdeUpdater(jeditPath, label, progressbar); + // ideup.run(); + //} + } + + private static void printUsage() { + System.err.println("java -jar SFrameworkInstall.jar"); + System.err.println("\t[-office <path_to_office_installation]"); + System.err.println("\t[-netbeans <path_to_netbeans_installation]"); + System.err.println("\t[-net]"); + System.err.println("\t[-bindings]"); + System.err.println("\n\n-net indicates that this is the network part of a network install."); + System.err.println("-bindings will only install the menu & key bindings in user/config/soffice.cfg."); + //System.err.println("\t[-jedit <path_to_jedit_installation]"); + } + + public static synchronized boolean isPatchedTypes() + { + return bPatchedTypes; + } + + public static synchronized boolean isPatchedJava() + { + return bPatchedJava; + } + + public static synchronized boolean isPatchedRDB() + { + return bPatchedRDB; + } + + public static synchronized boolean isInstallStarted() + { + return bInstallStarted; + } + + public static synchronized void setPatchedTypes(boolean value) + { + bPatchedTypes = value; + } + + public static synchronized void setPatchedJava(boolean value) + { + bPatchedJava = value; + } + + public static synchronized void setPatchedRDB(boolean value) + { + bPatchedRDB = value; + } + + public static synchronized void setInstallStarted(boolean value) + { + bInstallStarted = value; + } + + public static synchronized void setTypesPath(String path) + { + typesPath = path; + } + + public static synchronized void setJavaPath(String path) + { + javaPath = path; + } + + public static synchronized String getTypesPath() + { + return typesPath; + } + + public static synchronized String getJavaPath() + { + return javaPath; + } + + private javax.swing.JPanel navigation; + private javax.swing.JButton navBack; + private javax.swing.JButton navNext; + private javax.swing.JButton navCancel; + private javax.swing.JPanel screens; + + private Version version = null; + private Final _final = null; + private IdeVersion ideversion = null; + private IdeFinal idefinal = null; + private IdeWelcome idewelcome = null; + private static ArrayList locations = null; + + public static String VERSIONS = "VERSIONS"; + public static String WELCOME = "WELCOME"; + public static String FINAL = "FINAL"; + public static String IDEVERSIONS = "IDEVERSIONS"; + public static String IDEWELCOME = "IDEWELCOME"; + public static String IDEFINAL = "IDEFINAL"; + + public static int DEFWIDTH = 480; + public static int DEFHEIGHT = 240; + + private static String typesPath = null; + private static String javaPath = null; + + public static boolean bNetworkInstall = false; + public static boolean bBindingsInstall = false; + + private static boolean bPatchedTypes = false; + private static boolean bPatchedJava = false; + private static boolean bPatchedRDB = false; + private static boolean bInstallStarted = false; + +}// InstallWizard diff --git a/scripting/workben/installer/InstallationEvent.java b/scripting/workben/installer/InstallationEvent.java new file mode 100644 index 000000000000..d00dbe45a53e --- /dev/null +++ b/scripting/workben/installer/InstallationEvent.java @@ -0,0 +1,22 @@ +package installer; + +public class InstallationEvent +{ + private Object source; + private String message; + InstallationEvent(Object source, String message) + { + this.source = source; + this.message = message; + } + + public Object getSource() + { + return source; + } + + public String getMessage() + { + return message; + } +} diff --git a/scripting/workben/installer/LogStream.java b/scripting/workben/installer/LogStream.java new file mode 100644 index 000000000000..073c945579cb --- /dev/null +++ b/scripting/workben/installer/LogStream.java @@ -0,0 +1,54 @@ +package installer; +import java.io.PrintStream; +import java.io.FileOutputStream; + +import java.util.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + + +//import java.io.PrintWriter; +public class LogStream extends PrintStream +{ + static final private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z: "); + + private String getTimeStamp() + { + String timeStamp = formatter.format( new Date() ); + return timeStamp; + } + public LogStream( String logFileName ) throws java.io.FileNotFoundException + { + super( new FileOutputStream( logFileName ) ); + } + public void println(String x) + { + super.println( getTimeStamp() + x ); + } + public static void main(String[] args) + { + if ( args.length > 0 ) + { + try + { + LogStream log = new LogStream( args[0] ); + System.setErr(log); + System.setOut(log); + System.out.println("Test from logger from out"); + System.err.println("Test from logger from err"); + System.out.println("finised test from out"); + System.err.println("finised test from err"); + } + catch( java.io.FileNotFoundException fe ) + { + System.err.println("Error creating logStream: " + fe ); + fe.printStackTrace(); + } + } + else + { + System.err.println("specify log file java LogStream [logfile]"); + System.exit(1); + } + } +} diff --git a/scripting/workben/installer/NavPanel.java b/scripting/workben/installer/NavPanel.java new file mode 100644 index 000000000000..8c6cecc3042b --- /dev/null +++ b/scripting/workben/installer/NavPanel.java @@ -0,0 +1,113 @@ +package installer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +public class NavPanel extends JPanel implements ActionListener { + + NavPanel(InstallWizard wizard, boolean bBack, boolean bNext, boolean bCancel, String prev, String next) { + setBackground(Color.white); + setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); + this.wizard = wizard; + this.next = next; + this.prev = prev; + navBack = new javax.swing.JButton("<< Back"); + navNext = new javax.swing.JButton("Next >>"); + navCancel = new javax.swing.JButton("Cancel"); + setLayout(new GridBagLayout()); + + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1); + gridBagConstraints1.anchor = gridBagConstraints1.WEST; + + gridBagConstraints2 = new java.awt.GridBagConstraints(); + gridBagConstraints2.gridx = 2; + gridBagConstraints2.gridy = 0; + + gridBagConstraints3 = new java.awt.GridBagConstraints(); + gridBagConstraints3.gridx = 6; + gridBagConstraints3.gridy = 0; + + navNext.setEnabled(bNext); + navBack.setEnabled(bBack); + navCancel.setEnabled(bCancel); + navNext.addActionListener(this); + navBack.addActionListener(this); + navCancel.addActionListener(this); + add(navBack, gridBagConstraints1); + add(navNext, gridBagConstraints2); + add(navCancel, gridBagConstraints3); + } + + public void enableNext(boolean bEnable) { + navNext.setEnabled(bEnable); + } + + public void enableBack(boolean bEnable) { + navBack.setEnabled(bEnable); + } + + public void enableCancel(boolean bEnable) { + navCancel.setEnabled(bEnable); + } + + public void enableIDE(boolean bEnable) { + ideDetected = bEnable; + } + + public void actionPerformed(ActionEvent ev) { + if ((ev.getSource() == navNext) && (next.length() != 0)) { + wizard.show(next); + } + if ((ev.getSource() == navBack) && (prev.length() != 0)) { + wizard.show(prev); + } + if (ev.getSource() == navCancel) { + if( ideDetected ) { + wizard.show(InstallWizard.IDEWELCOME); + } + else { + wizard.exitForm(null); + } + enableIDE(false); + } + } + + public void setNextListener(ActionListener listener) { + navNext.addActionListener(listener); + } + + public void setBackListener(ActionListener listener) { + navBack.addActionListener(listener); + } + + public void setCancelListener(ActionListener listener) { + navCancel.addActionListener(listener); + } + + public void removeNextListener(ActionListener listener) + { + navNext.removeActionListener(listener); + } + + public void removeBackListener(ActionListener listener) + { + navBack.removeActionListener(listener); + } + + public void removeCancelListener(ActionListener listener) + { + navCancel.removeActionListener(listener); + } + + public JButton navBack; + public JButton navNext; + public JButton navCancel; + private GridBagConstraints gridBagConstraints1; + private GridBagConstraints gridBagConstraints2; + private GridBagConstraints gridBagConstraints3; + private InstallWizard wizard; + private String next; + private String prev; + private boolean ideDetected = false; +} diff --git a/scripting/workben/installer/Navigation.java b/scripting/workben/installer/Navigation.java new file mode 100644 index 000000000000..6cba1980a427 --- /dev/null +++ b/scripting/workben/installer/Navigation.java @@ -0,0 +1,58 @@ +package installer; + +/* + * Navigation.java + * + * Created on 04 July 2002, 15:10 + */ + +/** + * + * @author mike + */ +public class Navigation extends javax.swing.JPanel { + + /** Creates new form Navigation */ + public Navigation() { + 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 + navBack = new javax.swing.JButton(); + navNext = new javax.swing.JButton(); + navCancel = new javax.swing.JButton(); + + setLayout(new java.awt.GridBagLayout()); + java.awt.GridBagConstraints gridBagConstraints1; + + navBack.setText("<< Back"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + add(navBack, gridBagConstraints1); + + navNext.setText("Next >>"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 2; + gridBagConstraints1.gridy = 0; + add(navNext, gridBagConstraints1); + + navCancel.setText("Cancel"); + gridBagConstraints1 = new java.awt.GridBagConstraints(); + gridBagConstraints1.gridx = 6; + gridBagConstraints1.gridy = 0; + add(navCancel, gridBagConstraints1); + + }//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton navBack; + private javax.swing.JButton navNext; + private javax.swing.JButton navCancel; + // End of variables declaration//GEN-END:variables + +} diff --git a/scripting/workben/installer/ProtocolHandler.xcu b/scripting/workben/installer/ProtocolHandler.xcu new file mode 100644 index 000000000000..c4dafd6e678f --- /dev/null +++ b/scripting/workben/installer/ProtocolHandler.xcu @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<oor:node xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="ProtocolHandler" oor:package="org.openoffice.Office"> + <node oor:name="HandlerSet"> + <node oor:name="com.sun.star.comp.ScriptProtocolHandler" oor:op="replace"> + <prop oor:name="Protocols" oor:type="oor:string-list"> + <value>script:*</value> + </prop> + </node> + </node> +</oor:node> diff --git a/scripting/workben/installer/Register.java b/scripting/workben/installer/Register.java new file mode 100644 index 000000000000..69557f59fe34 --- /dev/null +++ b/scripting/workben/installer/Register.java @@ -0,0 +1,144 @@ +package installer; + +import java.lang.String; +import java.io.*; +import javax.swing.*; +public class Register{ + private static String[] singletonDefParams = { "drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava", + "drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager", + "drafts.com.sun.star.script.framework.theScriptRuntimeManager=drafts.com.sun.star.script.framework.ScriptRuntimeManager"}; + + + private static String quotedString ( String stringToQuote ) { + String doubleQuote = "\""; + String result = new String ( doubleQuote + stringToQuote + doubleQuote ); + return result; + } + private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) { + try{ + boolean goodResult = false; + String[] env = new String[1]; + String regCmd = null; + ExecCmd command = new ExecCmd(); + for ( int i=0; i<singletonDefParams.length; i++){ + if ( opSys.indexOf( "Windows" ) == -1 ){ + // Not windows + env[0] = "LD_LIBRARY_PATH=" + progPath; + command.exec( "chmod a+x " + progPath + "regsingleton", null ); + regCmd = progPath + "regsingleton " + path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb " + singletonDefParams[i]; + goodResult = command.exec( regCmd, env ); + } + else { + // Windows + regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] ); + goodResult = command.exec( regCmd,null ); + } + if ( !goodResult ){ + System.out.println("Regsingleton cmd failed, cmd: " + regCmd ); + statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log"); + return false; + } + } + } + catch ( Exception e ) { + String message = "\nError installing scripting package, please view SFrameworkInstall.log."; + System.out.println(message); + e.printStackTrace(); + statusLabel.setText(message); + return false; + } + return true; + + + } + public static boolean register(String path, JLabel statusLabel) { + String[] packages = {"ooscriptframe.zip", "bshruntime.zip", "jsruntime.zip"}; + + try { + String s=null; + boolean goodResult = false; + String env[] = new String[1]; + ExecCmd command = new ExecCmd(); + boolean isWindows = + (System.getProperty("os.name").indexOf("Windows") != -1); + + String progpath = path.concat("program" + File.separator); + + statusLabel.setText("Registering Scripting Framework..."); + + // pkgchk Scripting Framework Components + statusLabel.setText("Registering Scripting Framework Components..."); + System.out.println("Registering Scripting Framework Components..."); + + for (int i = 0; i < packages.length; i++) { + String cmd = ""; + + if (!isWindows) { + env[0]="LD_LIBRARY_PATH=" + progpath; + + goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null ); + + if ( goodResult ){ + cmd = progpath + "pkgchk -s -f " + progpath + packages[i]; + + System.err.println(cmd); + goodResult = command.exec(cmd, env); + } + } + else { + cmd = "\"" + progpath + "pkgchk.exe\" -s -f \"" + progpath + + packages[i] + "\""; + + System.err.println(cmd); + goodResult =command.exec(cmd,null); + + } + if (!goodResult) { + System.err.println("\nPkgChk Failed"); + + if(!isWindows) + System.err.println("Command: " + cmd + "\n" + env[0]); + else + System.err.println("Command: \"" + cmd + "\""); + + statusLabel.setText( + "PkgChk Failed, please view SFrameworkInstall.log"); + + return false; + } + } + + // if ( !regSingletons( path, progpath, opSys, statusLabel ) ) + // { + // return false; + // } + // updating ProtocolHandler + /* statusLabel.setText("Updating ProtocolHandler..."); + if(!FileUpdater.updateProtocolHandler(path, statusLabel)) { + statusLabel.setText("Updating ProtocolHandler failed, please view SFrameworkInstall.log"); + return false; + } */ + + // updating StarBasic libraries + statusLabel.setText("Updating StarBasic libraries..."); + if(!FileUpdater.updateScriptXLC(path, statusLabel)) { + statusLabel.setText("Updating user/basic/script.xlc failed, please view SFrameworkInstall.log"); + return false; + } + if(!FileUpdater.updateDialogXLC(path, statusLabel)) { + statusLabel.setText("Updating user/basic/dialog.xlc failed, please view SFrameworkInstall.log"); + return false; + } + + } + catch(Exception e){ + String message = "\nError installing scripting package, please view SFrameworkInstall.log."; + System.out.println(message); + e.printStackTrace(); + statusLabel.setText(message); + return false; + } + return true; + }// register + +}//Register diff --git a/scripting/workben/installer/Scripting.BeanShell.xcu b/scripting/workben/installer/Scripting.BeanShell.xcu new file mode 100644 index 000000000000..d763aa8ff7d9 --- /dev/null +++ b/scripting/workben/installer/Scripting.BeanShell.xcu @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<oor:node xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Scripting" oor:package="org.openoffice.Office"> + <node oor:name="ScriptRuntimes"> + <node oor:name="BeanShell" oor:op="replace"> + <prop oor:name="SupportedFileExtensions"> + <value xml:lang="x-no-translate">bsh</value> + <value xml:lang="en-US">bsh</value> + </prop> + </node> + </node> +</oor:node> diff --git a/scripting/workben/installer/Scripting.JavaScript.xcu b/scripting/workben/installer/Scripting.JavaScript.xcu new file mode 100755 index 000000000000..562189acc93d --- /dev/null +++ b/scripting/workben/installer/Scripting.JavaScript.xcu @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<oor:node xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Scripting" oor:package="org.openoffice.Office"> + <node oor:name="ScriptRuntimes"> + <node oor:name="JavaScript" oor:op="replace"> + <prop oor:name="SupportedFileExtensions"> + <value xml:lang="x-no-translate">js</value> + <value xml:lang="en-US">js</value> + </prop> + </node> + </node> +</oor:node> diff --git a/scripting/workben/installer/Scripting.xcs b/scripting/workben/installer/Scripting.xcs new file mode 100644 index 000000000000..efac10769915 --- /dev/null +++ b/scripting/workben/installer/Scripting.xcs @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--*********************************************************************** + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************ --> +<!DOCTYPE oor:component-schema SYSTEM "../../../../component-schema.dtd"> +<oor:component-schema xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oor:name="Scripting" oor:package="org.openoffice.Office" xml:lang="en-US"> + <info> + <author>DF</author> + <desc xml:lang="x-no-translate"></desc> + <desc xml:lang="en-US">Contains the various settings needed by the Scripting Framework and its runtimes.</desc> + </info> + <templates> + <group oor:name="RuntimeNode"> + <info> + <desc xml:lang="x-no-translate"></desc> + <desc xml:lang="en-US">Specifies the runtimes available to the Scriptying Framework.</desc> + </info> + <prop oor:name="SupportedFileExtensions" oor:type="oor:string-list"> + <info> + <desc xml:lang="x-no-translate"></desc> + <desc xml:lang="en-US">Lists the file extensions that are recognized by this runtime.</desc> + </info> + </prop> + </group> + </templates> + <component> + <set oor:name="ScriptRuntimes" oor:node-type="RuntimeNode"> + <info> + <desc xml:lang="x-no-translate"></desc> + <desc xml:lang="en-US">Lists the registered Scripting Framework runtimes.</desc> + </info> + </set> + </component> +</oor:component-schema> diff --git a/scripting/workben/installer/Version.java b/scripting/workben/installer/Version.java new file mode 100644 index 000000000000..56e78024769e --- /dev/null +++ b/scripting/workben/installer/Version.java @@ -0,0 +1,339 @@ +package installer; + +/* + * Welcome.java + * + * Created on 04 July 2002, 15:43 + */ + +/** + * + * @author mike + */ + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.util.*; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; +import javax.swing.SwingUtilities.*; + +public class Version extends javax.swing.JPanel implements ActionListener, TableModelListener { + + /** Creates new form Welcome */ + public Version(InstallWizard wizard) { + this.wizard=wizard; + setBackground(Color.white); + 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() { + Properties props = null; + JPanel versionPanel = new JPanel(); + setLayout(new BorderLayout()); + + System.out.println("Initialising versions"); + + 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); + } + + tableModel = new MyTableModel(props, versions); + if (tableModel.getRowCount() == 0) + { + JOptionPane.showMessageDialog(this, "No compatible versions of Office were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE); + wizard.exitForm(null); + } + + tableModel.addTableModelListener(this); + JTable tableVersions = new JTable(tableModel) { + public String getToolTipText(MouseEvent event) + { + int col = columnAtPoint( event.getPoint() ); + if (col != 2) + return null; + + int row = rowAtPoint( event.getPoint() ); + Object o = getValueAt(row, col); + + if (o == null) + return null; + + if (o.toString().equals("")) + return null; + + return o.toString(); + } + + public Point getToolTipLocation(MouseEvent event) + { + int col = columnAtPoint( event.getPoint() ); + if (col != 2) + return null; + + int row = rowAtPoint( event.getPoint() ); + Object o = getValueAt(row,col); + + if (o == null) + return null; + + if (o.toString().equals("")) + return null; + + Point pt = getCellRect(row, col, true).getLocation(); + pt.translate(-1,-2); + return pt; + } + }; + + JScrollPane scroll = new JScrollPane(tableVersions); + + tableVersions.setPreferredSize( + new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT)); + + tableVersions.setRowSelectionAllowed(false); + tableVersions.setColumnSelectionAllowed(false); + tableVersions.setCellSelectionEnabled(false); + + initColumnSizes(tableVersions, tableModel); + versionPanel.add(scroll); + + JTextArea area = new JTextArea("Please select the Office version you wish to Update"); + area.setLineWrap(true); + area.setEditable(false); + add(area, BorderLayout.NORTH); + add(versionPanel, BorderLayout.CENTER); + //nav = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME, InstallWizard.FINAL); + nav = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME, InstallWizard.FINAL); + nav.setNextListener(this); + add(nav, BorderLayout.SOUTH); + + }// initComponents + + private void initColumnSizes(JTable table, MyTableModel model) { + TableColumn column = null; + Component comp = null; + int headerWidth = 0; + int cellWidth = 0; + int preferredWidth = 0; + int totalWidth = 0; + Object[] longValues = model.longValues; + + for (int i = 0; i < 3; i++) { + column = table.getColumnModel().getColumn(i); + + try { + comp = column.getHeaderRenderer(). + getTableCellRendererComponent( + null, column.getHeaderValue(), + false, false, 0, 0); + headerWidth = comp.getPreferredSize().width; + } catch (NullPointerException e) { + // System.err.println("Null pointer exception!"); + // System.err.println(" getHeaderRenderer returns null in 1.3."); + // System.err.println(" The replacement is getDefaultRenderer."); + } + + // need to replace spaces in String before getting preferred width + if (longValues[i] instanceof String) { + longValues[i] = ((String)longValues[i]).replace(' ', '_'); + } + + System.out.println("longValues: " + longValues[i]); + comp = table.getDefaultRenderer(model.getColumnClass(i)). + getTableCellRendererComponent( + table, longValues[i], + false, false, 0, i); + cellWidth = comp.getPreferredSize().width; + + preferredWidth = Math.max(headerWidth, cellWidth); + + if (false) { + System.out.println("Initializing width of column " + + i + ". " + + "preferredWidth = " + preferredWidth + + "; totalWidth = " + totalWidth + + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth)); + } + + //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead. + if (i == 2) { + if (preferredWidth > InstallWizard.DEFWIDTH - totalWidth) + column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth); + else + column.setPreferredWidth(preferredWidth); + } + else { + column.setMinWidth(preferredWidth); + totalWidth += preferredWidth; + } + } + } + + public java.awt.Dimension getPreferredSize() { + return new java.awt.Dimension(320, 280); + } + + + public void actionPerformed(ActionEvent ev) { + wizard.clearLocations(); + int len = tableModel.data.size(); + for (int i = 0; i < len; i++) { + ArrayList list = (ArrayList)tableModel.data.get(i); + if (((Boolean)list.get(0)).booleanValue() == true) + wizard.storeLocation((String)list.get(2)); + } + + //System.out.println(wizard.getLocations()); + } + + + public void tableChanged(TableModelEvent e) { + if (tableModel.isAnySelected()) { + nav.enableNext(true); + } + else { + nav.enableNext(false); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField jTextField2; + private InstallWizard wizard; + private MyTableModel tableModel; + private NavPanel nav; + //private static final String [] versions = {"StarOffice 6.0", "OpenOffice.org 1.0","OpenOffice.org 1.0.1","OpenOffice.org 642","OpenOffice.org 643","StarOffice 6.1"}; + //private static final String [] versions = {"OpenOffice.org 643"}; + //private static final String [] versions = {"OpenOffice.org 643", "StarOffice 6.1"}; + private static final String [] versions = {"StarOffice 6.1", "OpenOffice.org 1.1Beta", "OpenOffice.org 644", "OpenOffice.org 1.1"}; + // End of variables declaration//GEN-END:variables + +} + +class MyTableModel extends AbstractTableModel { + ArrayList data; + String colNames[] = {"", "Name", "Location"}; + Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"}; + + MyTableModel (Properties properties, String [] validVersions) { + data = new ArrayList(); + boolean isWindows = + (System.getProperty("os.name").indexOf("Windows") != -1); + int len = validVersions.length; + for (Enumeration e = properties.propertyNames(); e.hasMoreElements() ;) { + String key = (String)e.nextElement(); + String path = null; + + if ( !( key.startsWith("#") ) && + ( path = properties.getProperty(key)) != null) { + String pkgChkPath = path + File.separator + "program" + File.separator; + if ( isWindows ) + { + pkgChkPath += "pkgchk.exe"; + } + else + { + pkgChkPath += "pkgchk"; + } + File pkgChk = new File( pkgChkPath ); + if ( pkgChk.exists() ) + { + ArrayList row = new ArrayList(); + row.add(0, new Boolean(false)); + + row.add(1, key); + if (key.length() > ((String)longValues[1]).length()) { + longValues[1] = key; + } + + row.add(2, path); + if (path.length() > ((String)longValues[2]).length()) { + longValues[2] = path; + } + + data.add(row); + } + } + } + }// MyTableModel + + public int getColumnCount() { + return 3; + } + + public int getRowCount() { + return data.size(); + } + + public String getColumnName(int col) { + return colNames[col]; + } + + public Object getValueAt(int row, int col) { + if (row < 0 || row > getRowCount() || + col < 0 || col > getColumnCount()) + return null; + + ArrayList aRow = (ArrayList)data.get(row); + return aRow.get(col); + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + + public boolean isCellEditable(int row, int col) { + if (col == 0) { + return true; + } else { + return false; + } + } + + public void setValueAt(Object value, int row, int col) { + ArrayList aRow = (ArrayList)data.get(row); + aRow.set(col, value); + fireTableCellUpdated(row, col); + } + + String [] getSelected() { + return null; + } + + public boolean isAnySelected() { + Iterator iter = data.iterator(); + while (iter.hasNext()) { + ArrayList row = (ArrayList)iter.next(); + if (((Boolean)row.get(0)).booleanValue() == true) { + return true; + } + } + return false; + } + +} diff --git a/scripting/workben/installer/Welcome.java b/scripting/workben/installer/Welcome.java new file mode 100644 index 000000000000..e73cdca87728 --- /dev/null +++ b/scripting/workben/installer/Welcome.java @@ -0,0 +1,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 +} diff --git a/scripting/workben/installer/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java new file mode 100644 index 000000000000..a0b79c2ecbb8 --- /dev/null +++ b/scripting/workben/installer/XmlUpdater.java @@ -0,0 +1,427 @@ +package installer; + +import java.io.*; +import java.util.*; +import java.util.jar.*; +import java.net.URL; +import java.net.JarURLConnection; +import javax.swing.*; + +/** + * + * + * @author Aidan Butler + */ +public class XmlUpdater extends Thread { + + private String classesPath = null; + private String jarfilename; + private String installPath; + private boolean netInstall; + private boolean bindingsInstall; + + private JLabel statusLabel; + + private Vector listeners; + private Thread internalThread; + private boolean threadSuspended; + private JProgressBar progressBar; + + private final String[] bakFiles = + { + "writermenubar.xml", + "writerkeybinding.xml", + "calcmenubar.xml", + "calckeybinding.xml", + "impressmenubar.xml", + "impresskeybinding.xml", + "drawmenubar.xml", + "drawkeybinding.xml", + "eventbindings.xml", + "META-INF" + File.separator + "manifest.xml" + }; + + private final String[] dirs = + { + "java" + File.separator + "Highlight", + "java" + File.separator + "MemoryUsage", + "java" + File.separator + "ScriptFrmwrkHelper", + "java" + File.separator + "debugger", + "java" + File.separator + "debugger" + File.separator + "rhino", + "beanshell" + File.separator + "InteractiveBeanShell", + "beanshell" + File.separator + "Highlight", + "beanshell" + File.separator + "MemoryUsage", + "javascript" + File.separator + "ExportSheetsToHTML" + }; + + private final String[] names = + { + "java/Highlight/HighlightUtil.java", + "java/Highlight/HighlightText.java", + "java/Highlight/Highlight.jar", + "java/Highlight/parcel-descriptor.xml", + "java/MemoryUsage/MemoryUsage.java", + "java/MemoryUsage/MemoryUsage.class", + "java/MemoryUsage/parcel-descriptor.xml", + "java/MemoryUsage/ExampleSpreadSheet.sxc", + "java/ScriptFrmwrkHelper/parcel-descriptor.xml", + "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.java", + "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.class", + "java/ScriptFrmwrkHelper/ScriptFrmwrkHelper.jar", + "java/debugger/debugger.jar", + "java/debugger/OOBeanShellDebugger.java", + "java/debugger/OOScriptDebugger.java", + "java/debugger/DebugRunner.java", + "java/debugger/OORhinoDebugger.java", + "java/debugger/parcel-descriptor.xml", + "java/debugger/rhino/Main.java", + "beanshell/InteractiveBeanShell/parcel-descriptor.xml", + "beanshell/InteractiveBeanShell/interactive.bsh", + "beanshell/Highlight/parcel-descriptor.xml", + "beanshell/Highlight/highlighter.bsh", + "beanshell/MemoryUsage/parcel-descriptor.xml", + "beanshell/MemoryUsage/memusage.bsh", + "javascript/ExportSheetsToHTML/parcel-descriptor.xml", + "javascript/ExportSheetsToHTML/exportsheetstohtml.js" + }; + + + public XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar, boolean netInstall, boolean bindingsInstall) { + this.installPath = installPath; + this.statusLabel = statusLabel; + this.netInstall = netInstall; + this.bindingsInstall = bindingsInstall; + listeners = new Vector(); + threadSuspended = false; + progressBar=pBar; + progressBar.setStringPainted(true); + }// XmlUpdater + + + public boolean checkStop() + { + if (internalThread == Thread.currentThread()) + return false; + return true; + }// checkStop + + + public void checkSuspend() + { + if (threadSuspended) { + synchronized(this) { + while (threadSuspended) { + try { + wait(); + } catch (InterruptedException eInt) { + //... + } + } + } + } + }// checkSuspend + + + public void setSuspend() + { + threadSuspended = true; + }// setSuspend + + + public void setResume() + { + threadSuspended = false; + notify(); + }// setResume + + + public void setStop() + { + internalThread = null; + }// setStop + + + public void run() { + + InputStream istream; + //InputSource isource; + //DocumentBuilderFactory builderFactory; + //DocumentBuilder builder = null; + URL url; + String fileName = null; + + internalThread = Thread.currentThread(); + + //System.out.println("\n\n\n\nFileName: "+installPath); + classesPath= installPath.concat(File.separator+"program"+File.separator+"classes"+File.separator); + String opSys =System.getProperty("os.name"); + //System.out.println("\n System "+opSys); + + String progpath=installPath; + progpath= progpath.concat(File.separator+"program"+File.separator); + //System.out.println("Office progpath" + progpath ); + //System.out.println("\nModifying Installation "+installPath); + + String starBasicPath=installPath; + starBasicPath= starBasicPath.concat(File.separator+"share"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator); + //System.out.println( "Office StarBasic path: " + starBasicPath ); + + String regSchemaOfficePath=installPath; + regSchemaOfficePath= regSchemaOfficePath.concat(File.separator+"share"+File.separator+"registry"+File.separator+"schema"+File.separator+"org"+File.separator+"openoffice"+File.separator+"Office"+File.separator); + //System.out.println( "Office schema path: " + regSchemaOfficePath ); + + // Get the NetBeans installation + //String netbeansPath= + + progressBar.setString("Unzipping Required Files"); + ZipData zd = new ZipData("SFrameworkInstall.jar"); + + + if( (!netInstall) || bindingsInstall) { + String configPath=installPath; + configPath= configPath.concat(File.separator+"user"+File.separator+"config"+File.separator+"soffice.cfg"+File.separator); + //System.out.println( "Office configuration path: " + configPath ); + String manifestPath=configPath + "META-INF" + File.separator; + + //Adding <Office>/user/config/soffice.cfg/ + File configDir = new File( configPath ); + if( !configDir.isDirectory() ) { + if( !configDir.mkdir() ) { + System.out.println( "creating " + configDir + "directory failed"); + } + else { + System.out.println( configDir + "directory created"); + } + } + else + System.out.println( "soffice.cfg exists" ); + + File manifestDir = new File( manifestPath ); + if( !manifestDir.isDirectory() ) { + if( !manifestDir.mkdir() ) { + System.out.println( "creating " + manifestPath + "directory failed"); + } + else { + System.out.println( manifestPath + " directory created"); + } + } + else + System.out.println( manifestPath + " exists" ); + + // Backup the confguration files in + // <office>/user/config/soffice.cfg/ + // If they already exist. + + for( int i=0; i < bakFiles.length; i++ ) + { + String pathNameBak = configPath + bakFiles[i]; + File origFile = new File( pathNameBak ); + if( origFile.exists() ) + { + System.out.println( "Attempting to backup " + pathNameBak + " to " + pathNameBak + ".bak" ); + if(! origFile.renameTo( new File( pathNameBak + ".bak" ) ) ) + { + System.out.println( "Failed to backup " + pathNameBak + " to " + pathNameBak + ".bak" ); + } + } + } + + // Adding Office configuration files + if (!zd.extractEntry("bindingdialog/writermenubar.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/writerkeybinding.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/calcmenubar.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/calckeybinding.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/impressmenubar.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/impresskeybinding.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/drawmenubar.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/drawkeybinding.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/eventbindings.xml",configPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/manifest.xml",manifestPath, statusLabel)) + { + onInstallComplete(); + return; + } + } + + if(!bindingsInstall) { + // Adding new directories to Office + // Adding <Office>/user/basic/ScriptBindingLibrary/ + File scriptBindingLib = new File( starBasicPath ); + if( !scriptBindingLib.isDirectory() ) { + if( !scriptBindingLib.mkdir() ) { + System.out.println( "ScriptBindingLibrary failed"); + } + else { + System.out.println( "ScriptBindingLibrary directory created"); + } + } + else + System.out.println( "ScriptBindingLibrary exists" ); + + // Adding Scripting Framework and tools + if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel)) + { + onInstallComplete(); + return; + } + + if (!zd.extractEntry("sframework/bshruntime.zip",progpath, statusLabel)) + { + onInstallComplete(); + return; + } + + if (!zd.extractEntry("sframework/jsruntime.zip",progpath, statusLabel)) + { + onInstallComplete(); + return; + } + + if (!zd.extractEntry("schema/Scripting.xcs",regSchemaOfficePath, statusLabel)) + { + onInstallComplete(); + return; + } + + //-------------------------------- + + progressBar.setString("Registering Scripting Framework"); + progressBar.setValue(3); + if(!Register.register(installPath+File.separator, statusLabel) ) { + onInstallComplete(); + return; + } + progressBar.setValue(5); + + String path = installPath + File.separator + + "share" + File.separator + "Scripts" + File.separator; + + for (int i = 0; i < dirs.length; i++) { + File dir = new File(path + dirs[i]); + + if (!dir.exists()) { + if (!dir.mkdirs()) { + System.err.println("Error making dir: " + + dir.getAbsolutePath()); + onInstallComplete(); + return; + } + } + } + + for (int i = 0; i < names.length; i++) { + String source = "/examples/" + names[i]; + String dest = path + names[i].replace('/', File.separatorChar); + + if (!zd.extractEntry(source, dest, statusLabel)) { + onInstallComplete(); + return; + } + } + + + // Adding binding dialog + if (!zd.extractEntry("bindingdialog/ScriptBinding.xba",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/MenuBinding.xdl",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/KeyBinding.xdl",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/EventsBinding.xdl",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/HelpBinding.xdl",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/EditDebug.xdl",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/dialog.xlb",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + if (!zd.extractEntry("bindingdialog/script.xlb",starBasicPath, statusLabel)) + { + onInstallComplete(); + return; + } + } + + + statusLabel.setText("Installation Complete"); + progressBar.setString("Installation Complete"); + progressBar.setValue(10); + onInstallComplete(); + + }// run + + + public void addInstallListener(InstallListener listener) + { + listeners.addElement(listener); + }// addInstallListener + + + private void onInstallComplete() + { + Enumeration e = listeners.elements(); + while (e.hasMoreElements()) + { + InstallListener listener = (InstallListener)e.nextElement(); + listener.installationComplete(null); + } + }// onInstallComplete + +}// XmlUpdater class diff --git a/scripting/workben/installer/ZipData.java b/scripting/workben/installer/ZipData.java new file mode 100644 index 000000000000..301d2ef58b64 --- /dev/null +++ b/scripting/workben/installer/ZipData.java @@ -0,0 +1,103 @@ +package installer; + +import java.io.*; +import java.util.*; +import java.util.zip.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class ZipData +{ + public ZipData(String file) { + } + + public boolean extractEntry(String entry, String destination, + JLabel statusLabel) { + + OutputStream out = null; + InputStream in = null; + + System.out.println("Copying: " + entry); + System.out.println("To: " + destination); + + if (statusLabel != null) { + statusLabel.setText("Copying " + entry); + } + + String entryName; + if (entry.lastIndexOf("/") != -1) { + entryName = entry.substring(entry.lastIndexOf("/") + 1); + } + else { + entryName = entry; + } + + String destName; + if (destination.lastIndexOf(File.separator) != -1) { + destName = destination.substring(destination.lastIndexOf(File.separator) + 1); + } + else { + destName = destination; + } + + if (!destName.equals(entryName)) + destination = destination.concat(entryName); + + System.out.println("Unzipping " + entry + " to " + destination); + + try { + out = new FileOutputStream(destination); + } + catch (IOException ioe) { + System.err.println("Error opening " + destination + + ": " + ioe.getMessage()); + + if (statusLabel != null) + statusLabel.setText("Error opening" + destination + + "see SFramework.log for more information"); + + return false; + } + + if (entry.startsWith("/") == false) + entry = "/" + entry; + + in = this.getClass().getResourceAsStream(entry); + if (in == null) { + System.err.println("File " + entry + " not found in jar file"); + + if (statusLabel != null) + statusLabel.setText("Failed extracting " + entry + + "see SFramework.log for more information"); + + return false; + } + + try { + byte[] bytes = new byte[1024]; + int len; + + while ((len = in.read(bytes)) != -1) + out.write(bytes, 0, len); + } + catch (IOException ioe) { + System.err.println("Error writing " + destination + ": " + + ioe.getMessage()); + + if (statusLabel != null) + statusLabel.setText("Failed writing " + destination + + "see SFramework.log for more information"); + return false; + } + finally { + try { + in.close(); + out.close(); + } + catch (IOException ioe) { + } + } + return true; + } +} diff --git a/scripting/workben/installer/sidebar.jpg b/scripting/workben/installer/sidebar.jpg Binary files differnew file mode 100644 index 000000000000..c2b366f74e76 --- /dev/null +++ b/scripting/workben/installer/sidebar.jpg |