summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneilm <neilm@openoffice.org>2002-11-13 12:04:39 +0000
committerneilm <neilm@openoffice.org>2002-11-13 12:04:39 +0000
commit5be524976e257b56ace9d219f9af82eb41abea17 (patch)
treee6a45b3e180e41c09469404785e1b0ed4c6ac9e8
parent64b8f1ca6d3b2020c847b04c9038b92897c8d95b (diff)
Initial Import of source files for the Scripting Framework Installer
-rw-r--r--scripting/workben/installer/Banner.java28
-rw-r--r--scripting/workben/installer/FileUpdater.java268
-rw-r--r--scripting/workben/installer/Final.java121
-rw-r--r--scripting/workben/installer/InstUtil.java403
-rw-r--r--scripting/workben/installer/InstallListener.java4
-rw-r--r--scripting/workben/installer/InstallWizard.java281
-rw-r--r--scripting/workben/installer/InstallationEvent.java20
-rw-r--r--scripting/workben/installer/NavPanel.java100
-rw-r--r--scripting/workben/installer/Navigation.java56
-rw-r--r--scripting/workben/installer/Register.java163
-rw-r--r--scripting/workben/installer/Version.java202
-rw-r--r--scripting/workben/installer/Welcome.java69
-rw-r--r--scripting/workben/installer/XmlUpdater.java391
-rw-r--r--scripting/workben/installer/ZipData.java107
14 files changed, 2213 insertions, 0 deletions
diff --git a/scripting/workben/installer/Banner.java b/scripting/workben/installer/Banner.java
new file mode 100644
index 000000000000..da2170c8ad4a
--- /dev/null
+++ b/scripting/workben/installer/Banner.java
@@ -0,0 +1,28 @@
+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/FileUpdater.java b/scripting/workben/installer/FileUpdater.java
new file mode 100644
index 000000000000..9d2b9ef30685
--- /dev/null
+++ b/scripting/workben/installer/FileUpdater.java
@@ -0,0 +1,268 @@
+import java.io.*;
+
+public class FileUpdater {
+
+ public static void updateProtocolHandler( String installPath ) {
+ 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;
+ //System.out.println(count + s);
+ if(s != null) {
+ s.trim();
+ xmlArray[count] = s;
+ }
+ else
+ break;
+ }
+ }
+ catch( IOException ioe ) {
+ System.out.println( "Error reading Netbeans location information" );
+ }
+
+ 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++) {
+ //System.err.println(xmlArray[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 ) {
+ System.out.println("\n Update ProtocolHandler Failed!");
+ System.err.println(e);
+ }
+ finally {
+ try {
+ out.close();
+ System.out.println("File closed");
+ }
+ catch(Exception e) {
+ System.out.println("\n Update ProtocolHandler Failed! (Write error)");
+ System.err.println(e);
+ }
+ }
+ }// updateProtocolHandler
+
+ /*
+ public static void main( String[] args ) {
+ FileUpdater.updateProtocolHandler( "/scriptdev/neil/openoffice1.0.1ScriptFrame" );
+ FileUpdater.updateStarBasicXLC( "/scriptdev/neil/openoffice1.0.1ScriptFrame" );
+ }*/
+
+ public static void updateScriptXLC( String installPath ) {
+
+ 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;
+ //System.out.println(count + s);
+ if(s != null) {
+ s.trim();
+ xmlArray[count] = s;
+ }
+ else
+ break;
+ }
+ }
+ catch( IOException ioe ) {
+ System.out.println( "Error reading updateScriptXLC information" );
+ }
+
+ in_file.delete();
+
+
+ /*
+ 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()) {
+ count = count + 1;
+ if(s != null) {
+ s.trim();
+ xmlArray[count] = s;
+ }
+ else
+ break;
+ }
+ }
+ catch( IOException ioe ) {
+ System.out.println( "Error reading Netbeans location information" );
+ }
+
+
+
+ in_file.delete();
+ */
+
+ out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" );
+ out_file.createNewFile();
+ // FileWriter
+ //out = new FileOutputStream( out_file );
+ 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<xmlArray.length; i++) {
+ for(int i=0; i<count + 1; i++) {
+ //System.out.println(xmlArray[i]);
+ //out.write(xmlArray[i].getBytes());
+ out.write(xmlArray[i]+"\n");
+ //if( ( xmlArray[i].indexOf( "<node oor:name=\"HandlerSet\">" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptProtocolHandler" ) == -1 ) ) {
+ if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) {
+//<library:library library:name="Depot" xlink:href="file:///scriptdev/neil/openoffice1.0.1ScriptFrame/share/basic/Depot/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
+//<library:library library:name="Standard" xlink:href="file:///scriptdev/neil/openoffice1.0.1ScriptFrame/user/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
+ //System.out.println(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/user/basic/ScriptBindingLibrary/script.xlb/\" xlink:type=\"simple\" library:link=\"false\"/>\n" );
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/user/basic/ScriptBindingLibrary/script.xlb/\" xlink:type=\"simple\" library:link=\"false\"/>\n" );
+ }
+ }
+ }
+ catch( Exception e ) {
+ System.out.println("\n Update Script.xlc Failed!");
+ System.err.println(e);
+ }
+ finally {
+ try {
+ out.close();
+ //System.out.println("File closed");
+ }
+ catch(Exception e) {
+ System.out.println("\n Update Script.xlc Failed! (Write error)");
+ System.err.println(e);
+ }
+ }
+ }// updateScriptXLC
+
+
+ public static void updateDialogXLC( String installPath ) {
+ //System.out.println( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" );
+ 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" );
+ //in = new FileInputStream( in_file );
+ //parse the xml file
+ //byte[] buffer = new byte[4096];
+ //int bytes_read = 0;
+ 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()) {
+ //System.out.println( s );
+ count = count + 1;
+ if(s != null) {
+ s.trim();
+ xmlArray[count] = s;
+ }
+ else
+ break;
+ }
+ }
+ catch( IOException ioe ) {
+ System.out.println( "Error reading Netbeans location information" );
+ }
+
+
+ /*
+ while((bytes_read = in.read(buffer)) != -1) {
+ //read the contents of the file into a string
+ String tempXMLLine = new String(buffer, 0, bytes_read);
+ xmlLine = xmlLine + tempXMLLine;
+ }
+ */
+
+ //in.close();
+ in_file.delete();
+
+ out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" );
+ out_file.createNewFile();
+ // FileWriter
+ //out = new FileOutputStream( out_file );
+ 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<xmlArray.length; i++) {
+ for(int i=0; i<count + 1; i++) {
+ //System.out.println(xmlArray[i]);
+ //out.write(xmlArray[i].getBytes());
+ out.write(xmlArray[i]+"\n");
+ //if( ( xmlArray[i].indexOf( "<node oor:name=\"HandlerSet\">" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptProtocolHandler" ) == -1 ) ) {
+ if( ( xmlArray[i].indexOf( "<library:libraries xmlns:library" ) != -1 ) && ( xmlArray[i+1].indexOf( "ScriptBindingLibrary" ) == -1 ) ) {
+//<library:library library:name="Depot" xlink:href="file:///scriptdev/neil/openoffice1.0.1ScriptFrame/share/basic/Depot/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
+//<library:library library:name="Standard" xlink:href="file:///scriptdev/neil/openoffice1.0.1ScriptFrame/user/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
+ //System.out.println( " <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/user/basic/ScriptBindingLibrary/dialog.xlb/\" xlink:type=\"simple\" library:link=\"false\"/>\n" );
+ out.write(" <library:library library:name=\"ScriptBindingLibrary\" xlink:href=\"file://"+installPath+"/user/basic/ScriptBindingLibrary/dialog.xlb/\" xlink:type=\"simple\" library:link=\"false\"/>\n" );
+ }
+ }
+ }
+ catch( Exception e ) {
+ System.out.println("\n Update Dialog.xlc Failed!");
+ System.err.println(e);
+ }
+ finally {
+ try {
+ out.close();
+ //System.out.println("File closed");
+ }
+ catch(Exception e) {
+ System.out.println("\n Update Dialog.xlc Failed! (Write error)");
+ System.err.println(e);
+ }
+ }
+ }// updateScriptXLC
+
+
+} \ No newline at end of file
diff --git a/scripting/workben/installer/Final.java b/scripting/workben/installer/Final.java
new file mode 100644
index 000000000000..5cd058a2bc95
--- /dev/null
+++ b/scripting/workben/installer/Final.java
@@ -0,0 +1,121 @@
+/*
+ * 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) {
+ 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);
+ xud.addInstallListener(this);
+ InstallWizard.setInstallStarted(true);
+ InstallWizard.setPatchedTypes(false);
+ InstallWizard.setPatchedJava(false);
+ InstallWizard.setPatchedRDB(false);
+ xud.start();
+ }
+ }
+ if (e.getSource() == nav.navCancel)
+ {
+ //xud.setSuspend();
+ 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");
+ nav.removeCancelListener(this);
+ nav.setCancelListener(nav);
+ nav.navCancel.setText("Exit");
+ 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/InstUtil.java b/scripting/workben/installer/InstUtil.java
new file mode 100644
index 000000000000..8c93ddf10c61
--- /dev/null
+++ b/scripting/workben/installer/InstUtil.java
@@ -0,0 +1,403 @@
+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 boolean createTmpDir() {
+ String sysTemp = System.getProperty("java.io.tmpdir");
+ if (tmpDir == null) {
+ tmpDir = new File(sysTemp + File.separator + "xmergeinst");
+ if (tmpDir.exists())
+ return true;
+ }
+
+ return tmpDir.mkdir();
+ }
+
+ public static File getTmpDir() {
+ return tmpDir;
+ }
+
+ public static void removeTmpDir() {
+ if ((tmpDir != null) && (tmpDir.exists())) {
+ File types = new File(tmpDir, "TypeDetection.xml");
+ if (types.exists())
+ {
+ if (types.delete())
+ {
+ //System.out.println("Success:type");;
+ }
+ }
+ File java = new File(tmpDir, "Java.xml");
+ if (java.exists()) java.delete();
+ File rdb = new File(tmpDir, "applicat.rdb");
+ if (rdb.exists()) rdb.delete();
+ tmpDir.delete();
+ tmpDir = null;
+ }
+ }
+
+ public static boolean copy(File inputFile, File outputFile) {
+ try {
+ FileInputStream in = new FileInputStream(inputFile);
+ FileOutputStream out = new FileOutputStream(outputFile);
+ byte buffer[] = new byte[4096];
+ int c;
+
+ while ((c = in.read(buffer)) != -1) {
+ //out.write(buffer, 0, c);
+ out.write(buffer, 0, c);
+ }
+
+ in.close();
+ out.close();
+ } catch (IOException eIO) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static File buildSversionLocation() throws IOException {
+ File theFile = null;
+ StringBuffer str = new StringBuffer();
+ String sep = System.getProperty("file.separator");
+ str.append(System.getProperty("user.home"));
+ str.append(sep);
+ StringBuffer thePath = new StringBuffer(str.toString());
+
+ String os = System.getProperty("os.name");
+
+ if (os.indexOf("Windows") != -1) {
+ /*String appData = winGetAppData;
+ if (os.equals("Windows 2000")) {
+ thePath.append("Application Data");
+ thePath.append(sep);
+ theFile = new File(thePath.toString());
+ } else if (os.indexOf("Windows") != -1) {
+ thePath.append(sep);
+ thePath.append("sversion.ini");
+ theFile = new File(thePath.toString());
+ if (!theFile.exists())
+ {
+ thePath.delete(0, thePath.length());
+ thePath.append(str);
+ thePath.append("Application Data");
+ thePath.append(sep);
+ thePath.append("sversion.ini");
+ theFile = new File(thePath.toString());
+ }
+ }*/
+ theFile = findVersionFile(new File(str.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 Properties getNetbeansLocation() throws IOException {
+ File theFile = null;
+ Properties results = new Properties();
+
+ StringBuffer str = new StringBuffer();
+ String sep = System.getProperty("file.separator");
+ str.append(System.getProperty("user.home"));
+ str.append(sep);
+ StringBuffer thePath = new StringBuffer(str.toString());
+
+ String os = System.getProperty("os.name");
+
+ if (os.indexOf("Windows") != -1) {
+ /*String appData = winGetAppData;
+ if (os.equals("Windows 2000")) {
+ thePath.append("Application Data");
+ thePath.append(sep);
+ theFile = new File(thePath.toString());
+ } else if (os.indexOf("Windows") != -1) {
+ thePath.append(sep);
+ thePath.append("sversion.ini");
+ theFile = new File(thePath.toString());
+ if (!theFile.exists())
+ {
+ thePath.delete(0, thePath.length());
+ thePath.append(str);
+ thePath.append("Application Data");
+ thePath.append(sep);
+ thePath.append("sversion.ini");
+ theFile = new File(thePath.toString());
+ }
+ }*/
+ //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 (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 location;
+
+ if ( thePath.toString().indexOf( ".netbeans" ) == -1 )
+ return null;
+ else if ( new File( thePath.append( sep+"3.4"+sep ).toString() ).isDirectory() ) {
+ System.out.println( "Found NetBeans 3.4 on user home Directory " + thePath );
+ File netbeansLogFile = new File( thePath.toString() + sep + "system" + sep + "ide.log" );
+ if( netbeansLogFile.exists() ) {
+ String installPath = getNetbeansInstallation( netbeansLogFile );
+ File f = new File(installPath);
+ results.put("NetBeans 3.4", f.getPath());
+ /*
+ try {
+ URI uri = new URI(installPath);
+ File f = new File(uri);
+
+ //.sversion: OpenOffice.org 643=file:///scriptdev/neil/ScriptFrameOpenoffice1.0.1
+ // parts = Installation name. f.getPath = Installation path
+ results.put("NetBeans 3.4", f.getPath());
+ //System.out.println("Putting " + parts[0] + " : " + f.getPath());
+ }
+ catch (URISyntaxException eSyntax) {
+ throw new IOException("Error while reading NetBeans version information");
+ //results.put(parts[0].trim(), parts[1].trim());
+ //System.out.println(parts[0].trim() + " : " + parts[1].trim());
+ }
+ */
+ }
+ else {
+ System.out.println( "Prompt user for NetBeans installation path" );
+ }
+ }
+
+
+ return results;
+ }
+
+
+
+ public 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( "=" );
+ //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();
+ //System.out.println( "installPath 2 " + installPath );
+ break;
+ }
+ }
+ }
+ catch( IOException ioe ) {
+ System.out.println( "Error reading Netbeans location information" );
+ }
+ //catch( FileNotFoundException fnfe ) {
+ //System.out.println( "NetBeans ide.log FileNotFoundException" );
+ //}
+
+ return installPath;
+ }
+
+
+
+ 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( "officeName " + officeName );
+ //System.out.println( "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 {
+ URI uri = new URI(parts[1].trim());
+ File f = new File(uri);
+
+ //.sversion: OpenOffice.org 643=file:///scriptdev/neil/ScriptFrameOpenoffice1.0.1
+ // parts = Installation name. f.getPath = Installation path
+ results.put(parts[0].trim(), f.getPath());
+ //System.out.println("Putting " + parts[0] + " : " + f.getPath());
+ }
+ catch (URISyntaxException 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());
+ }
+ catch (IllegalArgumentException eArg) {
+ results.put(parts[0].trim(), parts[1].trim());
+ //System.out.println(parts[0].trim() + ": " + parts[1].trim());
+ }
+ */
+ }
+ 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");
+ }
+ }
+
+ 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..f34802cd4b9a
--- /dev/null
+++ b/scripting/workben/installer/InstallListener.java
@@ -0,0 +1,4 @@
+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..732541f359c5
--- /dev/null
+++ b/scripting/workben/installer/InstallWizard.java
@@ -0,0 +1,281 @@
+/*
+ * 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("Scripting Framework Installer (prototype)");
+ //setBackground(Color.WHITE);
+ setBackground(new Color(0,0,0));
+ locations = new ArrayList();
+ //Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
+ Point center = new Point( 300, 300 );
+ int windowWidth=200;
+ int windowHeight=300;
+ setSize(windowWidth,windowHeight);
+ setBounds((center.x-windowWidth/2)-115,(center.y-windowWidth/2)-100, windowWidth,windowHeight);
+ setResizable(false);
+ initComponents();
+ }
+
+ /** 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));
+ //screens.add("EULA", new EULA());
+ // ----------------
+ netbeansVersion = new NetbeansVersion(this);
+ screens.add(NETBEANSVERSIONS, netbeansVersion);
+ // ----------------
+ version = new Version(this);
+ screens.add(VERSIONS, version);
+ _final = new Final(this);
+ screens.add(FINAL, _final);
+
+ getContentPane().add(screens, java.awt.BorderLayout.CENTER);
+
+ navNext.addActionListener(this);
+ navNext.addActionListener(netbeansVersion);
+ navNext.addActionListener(version);
+ navNext.addActionListener(netbeansVersion);
+ navNext.addActionListener(_final);
+ 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[]) {
+ new InstallWizard().show();
+ }
+
+ 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;
+ private NetbeansVersion netbeansVersion;
+ private Final _final;
+ private static ArrayList locations;
+
+ public static String VERSIONS = "VERSIONS";
+ public static String WELCOME = "WELCOME";
+ public static String FINAL = "FINAL";
+ public static String NETBEANSVERSIONS = "NETBEANSVERSIONS";
+
+ public static int DEFWIDTH = 480;
+ public static int DEFHEIGHT = 240;
+
+ private static String typesPath = null;
+ private static String javaPath = null;
+
+ 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..bd4234c39e1c
--- /dev/null
+++ b/scripting/workben/installer/InstallationEvent.java
@@ -0,0 +1,20 @@
+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/NavPanel.java b/scripting/workben/installer/NavPanel.java
new file mode 100644
index 000000000000..57077b388ce6
--- /dev/null
+++ b/scripting/workben/installer/NavPanel.java
@@ -0,0 +1,100 @@
+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 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) {
+ wizard.exitForm(null);
+ }
+ }
+
+ 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;
+}
diff --git a/scripting/workben/installer/Navigation.java b/scripting/workben/installer/Navigation.java
new file mode 100644
index 000000000000..332d69f3d3d6
--- /dev/null
+++ b/scripting/workben/installer/Navigation.java
@@ -0,0 +1,56 @@
+/*
+ * 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/Register.java b/scripting/workben/installer/Register.java
new file mode 100644
index 000000000000..a473ad669dcf
--- /dev/null
+++ b/scripting/workben/installer/Register.java
@@ -0,0 +1,163 @@
+import java.lang.String;
+import java.io.*;
+import javax.swing.*;
+
+public class Register{
+
+ private static JProgressBar progressBar;
+
+ // not required
+ private static void unx(String url,String path, javax.swing.JLabel statusLabel){
+ System.out.println("\nFound a Unix path:"+path);
+ System.out.println("\nThis Script does not support Unix");
+ }// unx
+
+ private static void windows(String url,String path, javax.swing.JLabel statusLabel){
+ try {
+ String s=null;
+ String classpath="";
+ int exitcode=0;
+ boolean passed=true;
+ String env[] = new String[1];
+ Runtime rt= Runtime.getRuntime();
+ String progpath=path.concat(File.separator+"program"+File.separator);
+ BufferedReader stdInput;
+ Process p;
+
+ statusLabel.setText("Registering Scripting Framework...");
+ progressBar.setString("Registering Scripting Framework ");
+ progressBar.setValue(7);
+ String opSys =System.getProperty("os.name");
+
+ // pkgchk Scripting Framework Components
+ statusLabel.setText("Registering Scripting Framework Components...");
+ if (opSys.indexOf("Windows")==-1){
+ //System.out.println( "Not Windows");
+ env[0]="LD_LIBRARY_PATH="+progpath;
+
+ p=rt.exec("chmod a+x "+progpath+"pkgchk");
+ exitcode=p.waitFor();
+ if (exitcode ==0){
+ //scriptnm.zip is an old SF. Works with SO6.1 EA2
+ p=rt.exec(progpath+"./pkgchk "+progpath+"ooscriptframe.zip", env);
+ //p=rt.exec(progpath+"pkgchk "+progpath+"scriptnm.zip" );
+ }
+ }
+ else {
+ //progpath = "C:\\Progra~1\\OpenOffice.org643\\program\\";
+ System.out.println( "Windows" );
+ String pkgStr = new String("\""+progpath+"pkgchk.exe\" \""+progpath+"ooscriptframe.zip\"\"");
+ System.err.println("\""+progpath+"pkgchk.exe\" \""+progpath+"ooscriptframe.zip\"");
+ p=rt.exec("\""+progpath+"pkgchk.exe\" \""+progpath+"ooscriptframe.zip\"");
+ }
+ exitcode=p.waitFor();
+ if (exitcode !=0){
+ System.out.println("\n PkgChk Failed!");
+ passed=false;
+ }
+
+ // regsingleton ScriptRuntimeForJava
+ statusLabel.setText("Registering Singleton ScriptRuntimeForJava...");
+ if (opSys.indexOf("Windows")==-1){
+ //System.out.println( "Not Windows");
+ env[0]="LD_LIBRARY_PATH="+progpath;
+
+ /*
+ p=rt.exec("mkdir /scriptdev/neil/DeleteThisVV");
+ exitcode=p.waitFor();
+ if (exitcode ==0) {
+ System.out.println( "mkdir cmd succeeded" );
+ }else{ System.out.println( "mkdir cmd failed" ); }
+ */
+
+ p=rt.exec("chmod a+x "+progpath+"regsingleton");
+ exitcode=p.waitFor();
+ if (exitcode ==0)
+ p=rt.exec(progpath+"./regsingleton "+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava", env );
+ }
+ else {
+ System.out.println( "Windows" );
+ //path = "C:\\Progra~1\\OpenOffice.org643";
+ //progpath = path + "\\program\\";
+ //System.out.println("\""+progpath+"regsingleton.exe\" \""+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava\"");
+ p=rt.exec("\""+progpath+"regsingleton.exe\" \""+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava\"");
+ }
+ exitcode=p.waitFor();
+ if (exitcode !=0){
+ //System.out.println("\n Regsingleton ScriptRuntimeForJava Failed!");
+ passed=false;
+ }
+
+
+ // regsingleton ScriptStorageManager
+ statusLabel.setText("Registering Singleton ScriptStorageManager...");
+ if (opSys.indexOf("Windows")==-1){
+ //System.out.println( "Not Windows");
+ env[0]="LD_LIBRARY_PATH="+progpath;
+
+ p=rt.exec("chmod a+x "+progpath+"regsingleton");
+ exitcode=p.waitFor();
+ if (exitcode ==0)
+ p=rt.exec(progpath+"./regsingleton "+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager", env );
+ }
+ else {
+ //System.out.println( "Windows" );
+ //System.out.println("\""+progpath+"regsingleton.exe\" \""+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager\"");
+ p=rt.exec("\""+progpath+"regsingleton.exe\" \""+path+File.separator+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager\"");
+ }
+ exitcode=p.waitFor();
+ if (exitcode !=0){
+ //System.out.println("\n Regsingleton ScriptStorageManager Failed!");
+ passed=false;
+ }
+
+ // Commands:
+ //regsingleton <Office Installation>/user/uno_packages/cache/services.rdb drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava
+ //regsingleton <Office Installation>/user/uno_packages/cache/services.rdb drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager
+
+
+ // updating ProtocolHandler
+ statusLabel.setText("Updating ProtocolHandler...");
+ FileUpdater.updateProtocolHandler(path);
+
+ // updating StarBasic libraries
+ statusLabel.setText("Updating StarBasic libraries...");
+ FileUpdater.updateScriptXLC(path);
+ FileUpdater.updateDialogXLC(path);
+ }
+ catch(Exception e){
+ System.out.println("Error:"+e);
+ }
+ }// windows
+
+
+
+ public static void register(String path, javax.swing.JLabel statusLabel,JProgressBar pBar){
+ progressBar=pBar;
+ boolean win =false;
+ String newString= "file://";
+ if (path.indexOf(":")==1){
+ newString=newString.concat("/");
+ win=true;
+ }
+ String tmpStr1="";
+ String tmpStr2="";
+ newString=newString.concat(path.replace('\\','/'));
+ int i=0;
+ if (newString.indexOf(" ")>0){
+ tmpStr1=tmpStr1.concat(newString.substring(i,newString.indexOf(" ")));
+ tmpStr1=tmpStr1.concat("\\ ");
+ newString=newString.substring(newString.indexOf(" ")+1,newString.length());
+ }
+ tmpStr1=tmpStr1.concat(newString);
+ //System.out.println(""+tmpStr1);
+ char url[]=path.toCharArray();
+ char test[]=new char[path.length()*2];
+ int j=0;
+
+ path = path.substring (0,path.length()-1);
+ windows(tmpStr1,path, statusLabel);
+
+ }// register
+
+}//Register
diff --git a/scripting/workben/installer/Version.java b/scripting/workben/installer/Version.java
new file mode 100644
index 000000000000..228fa54b28ec
--- /dev/null
+++ b/scripting/workben/installer/Version.java
@@ -0,0 +1,202 @@
+/*
+ * 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());
+
+
+ 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);
+ tableVersions.setPreferredSize(new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT));
+ tableVersions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
+ tableVersions.doLayout();
+ setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.RAISED));
+ //JScrollPane scroll = new JScrollPane(tableVersions);
+ //versionPanel.add(scroll);
+ versionPanel.add(tableVersions);
+ JTextArea area = new JTextArea("\n Please select the Office version you wish to Update \n ");
+ 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.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);
+ }
+ }
+
+ // 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"};
+ // End of variables declaration//GEN-END:variables
+
+}
+
+class MyTableModel extends AbstractTableModel {
+ ArrayList data;
+ String colNames[] = {"Install", "Name", "Location"};
+
+ MyTableModel(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);
+ row.add(2, properties.getProperty(key));
+ 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) {
+ 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..9988f81fe318
--- /dev/null
+++ b/scripting/workben/installer/Welcome.java
@@ -0,0 +1,69 @@
+/*
+ * Welcome.java
+ *
+ * Created on 04 July 2002, 15:43
+ */
+
+/**
+ *
+ * @author mike
+ */
+import java.awt.event.*;
+import javax.swing.*;
+import java.io.*;
+import java.net.*;
+
+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();
+
+ 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 \t Please ensure that you have exited from Office");
+
+ welcomePanel.add(area, java.awt.BorderLayout.CENTER);
+ add(welcomePanel, java.awt.BorderLayout.CENTER);
+ NavPanel nav = new NavPanel(wizard, false, true, true, "", InstallWizard.VERSIONS);
+ 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/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java
new file mode 100644
index 000000000000..f92846167f6a
--- /dev/null
+++ b/scripting/workben/installer/XmlUpdater.java
@@ -0,0 +1,391 @@
+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 XmlUpdater extends Thread {
+
+ /*
+ private final static String TAG_TYPES = "Types";
+ private final static String TAG_TYPEDETECTION = "TypeDetection";
+ private final static String TAG_TYPE = "Type";
+ private final static String TAG_DATA = "Data";
+ private final static String TAG_FILTERS = "Filters";
+ private final static String TAG_FILTER = "Filter";
+ private final static String TAG_CLASSPATH = "UserClassPath";
+ */
+
+ private String classesPath = null;
+ private String jarfilename;
+ private String installPath;
+
+ /*
+ private Document document;
+
+ private Element filterNode;
+ private Element installedNode;
+ private Element uinameNode;
+ private Element cfgvalueNode;
+ private Element dataNode;
+ private Element typeNode;
+ */
+ private JLabel statusLabel;
+
+ private Vector listeners;
+ private Thread internalThread;
+ private boolean threadSuspended;
+ private JProgressBar progressBar;
+
+
+ public XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar) {
+ 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;
+ //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 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 starBasicPath=installPath;
+ starBasicPath= starBasicPath.concat(File.separator+"user"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator);
+ //System.out.println( "Office StarBasic path: " + starBasicPath );
+
+ String scriptsPath=installPath;
+ scriptsPath= scriptsPath.concat(File.separator+"user"+File.separator+"Scripts"+File.separator+"java"+File.separator);
+ //System.out.println( " Office Scripts Path: " + scriptsPath );
+
+ // Get the NetBeans installation
+ //String netbeansPath=
+
+ progressBar.setString("Unzipping Required Files");
+ ZipData zd = new ZipData("SFrameworkInstall.jar");
+
+
+ // 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 <Office>/user/config/soffice.cfg/
+ File configDir = new File( configPath );
+ if( !configDir.isDirectory() ) {
+ if( !configDir.mkdir() ) {
+ System.out.println( "soffice.cfg directory failed!!!!");
+ }
+ else {
+ System.out.println( "soffice.cfg directory created");
+ }
+ }
+ else
+ System.out.println( "soffice.cfg exists" );
+
+ //Adding <Office>/user/Scripts/java/
+ File scriptsDir = new File( scriptsPath );
+ File highlightDir = new File( scriptsPath+File.separator+"Highlight"+File.separator );
+ File spellDir = new File( scriptsPath+File.separator+"Spell"+File.separator );
+ if( !scriptsDir.isDirectory() ) {
+ //File highlightDir = new File( scriptsPath+File.separator+"Highlight"+File.separator );
+ //File spellDir = new File( scriptsPath+File.separator+"Spell"+File.separator );
+ if( !highlightDir.mkdirs() ) {
+ System.out.println( "Highlight script directory failed!!!!");
+ }
+ if( !spellDir.mkdirs() ) {
+ System.out.println( "Spell script directory failed!!!!");
+ }
+ else {
+ System.out.println( "Scripts/java directory created");
+ }
+ }
+ else
+ System.out.println( "Scripts/java directory exists" );
+
+
+
+
+//--------------------------------
+ // Adding Scripting Framework and tools
+ if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (opSys.indexOf("Windows")!=-1){
+ if (!zd.extractEntry("windows/regsingleton.exe",progpath, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ }
+ else if (opSys.indexOf("Linux")!=-1){
+ if (!zd.extractEntry("linux/regsingleton",progpath, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ }
+ else if (opSys.indexOf("SunOS")!=-1){
+ if (!zd.extractEntry("solaris/regsingleton",progpath, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ }
+
+//--------------------------------
+
+ // adding (JAVA) script examples
+ File highlightScript = new File( scriptsPath+File.separator+"Highlight"+File.separator+"HighlightUtil.java" );
+ if( !highlightScript.exists() ) {
+ if (!zd.extractEntry("examples/Highlight/HighlightUtil.java",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (!zd.extractEntry("examples/Highlight/HighlightText.java",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (!zd.extractEntry("examples/Highlight/Highlight.jar",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (!zd.extractEntry("examples/Highlight/parcel-descriptor.xml",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ }
+ else {
+ System.out.println( "Highlight script already deployed" );
+ }
+ File spellScript = new File( scriptsPath+File.separator+"Spell"+File.separator+"Spellcheck.java" );
+ if( !spellScript.exists() ) {
+ if (!zd.extractEntry("examples/Spell/Spellcheck.java",scriptsPath+File.separator+"Spell"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (!zd.extractEntry("examples/Spell/Spellcheck.jar",scriptsPath+File.separator+"Spell"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ if (!zd.extractEntry("examples/Spell/parcel-descriptor.xml",scriptsPath+File.separator+"Spell"+File.separator, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ }
+ }
+ else {
+ System.out.println( "Spell script already deployed" );
+ }
+//--------------------------------
+
+ // 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/HelpBinding.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;
+ }
+
+//--------------------------------
+
+ // 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;
+ }
+
+//--------------------------------
+
+ // Adding IDE support
+ /* if (!zd.extractEntry("ide/netbeans/office.jar",netbeansPath, statusLabel))
+ {
+ onInstallComplete();
+ return;
+ } */
+ /* if (!zd.extractEntry("ide/jedit/?.jar",jeditPath, 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
+
+/*
+ private void checkexists(String path){
+ File checkFile = new File(path);
+ String justPath= path.substring(0,path.lastIndexOf(File.separator)+1);
+ //System.out.println("\n"+justPath);
+ if(!checkFile.exists()){
+ ZipData zd = new ZipData("XMergeInstall.jar");
+ if (!zd.extractEntry("xml/Java.xml",justPath, statusLabel))
+ {
+ System.out.println("Fail");
+ }
+ }
+ }// checkexists
+*/
+
+ 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..f2600a8b3600
--- /dev/null
+++ b/scripting/workben/installer/ZipData.java
@@ -0,0 +1,107 @@
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class ZipData
+{
+ private static String zipfile=null;
+
+ public ZipData(String file){
+ zipfile=file;
+ }
+
+ public static boolean extractEntry(String entry, String destination, javax.swing.JLabel statusLabel){
+ boolean status = false;
+ if (statusLabel != null)
+ statusLabel.setText("Copying " + entry);
+ try{
+ ZipFile zip = new ZipFile(zipfile);
+ ZipEntry zentry = zip.getEntry(entry);
+ InputStream is =zip.getInputStream(zentry);
+ if (entry.lastIndexOf("/")!=-1){
+ entry=entry.substring(entry.lastIndexOf("/")+1,entry.length());
+ destination = destination.concat(entry);
+ }
+ else{
+ destination = destination.concat(entry);
+ }
+
+ //System.out.println("\n Unzipping "+zentry.getName()+" to "+destination);
+ FileOutputStream fos = new FileOutputStream(destination);
+ int bytesread=0,offset=0;
+ byte[] bytearr = new byte[10000];
+ bytesread= is.read(bytearr);
+ while (bytesread!=-1){
+ fos.write(bytearr, 0,bytesread);
+ bytesread= is.read(bytearr);
+ offset=offset+bytesread;
+ }
+ fos.close();
+ is.close();
+ status = true;
+
+ }
+ catch(Exception e){
+ System.out.println("\nZip Error: File not found");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ status = false;
+ if (statusLabel != null)
+ statusLabel.setText("Failed extracting " + entry + " to " + destination);
+ }
+ return status;
+ }
+
+
+ public static void getContents(){
+ try
+ {
+ ZipFile zip = new ZipFile(zipfile);
+
+ ZipEntry entry = null;
+
+ Object ObjArray[] =new Object[zip.size()];
+ int i =0;
+ for (Enumeration e = zip.entries(); e.hasMoreElements(); entry = (ZipEntry)e.nextElement())
+ {
+ if (entry != null){
+ //System.out.println(entry.getName()+"\n");
+ ObjArray[i]=entry.getName();
+ i++;
+ }
+
+ }
+
+ }
+ catch (IOException e)
+ {
+ System.err.println(e);
+ }
+ }
+
+ public static void getContents(String zipfile){
+ try
+ {
+ ZipFile zip = new ZipFile(zipfile);
+
+ ZipEntry entry = null;
+ for (Enumeration e = zip.entries(); e.hasMoreElements(); entry = (ZipEntry)e.nextElement())
+ {
+ //System.out.println(entry);
+ }
+ }
+ catch (IOException e)
+ {
+ System.err.println(e);
+ }
+ }
+
+
+ public static void main(String args[])
+ {
+ getContents(args[0]);
+ }
+}