merge the formfield patch from ooo-build
[ooovba.git] / scripting / workben / installer / Register.java
blobe6e792dfdf1a72cced7c6eb5fcf489bbd609e520
1 package installer;
3 import java.lang.String;
4 import java.io.*;
5 import javax.swing.*;
6 public class Register{
7 private static String[] singletonDefParams = { "drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava",
8 "drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager",
9 "drafts.com.sun.star.script.framework.theScriptRuntimeManager=drafts.com.sun.star.script.framework.ScriptRuntimeManager"};
12 private static String quotedString ( String stringToQuote ) {
13 String doubleQuote = "\"";
14 String result = new String ( doubleQuote + stringToQuote + doubleQuote );
15 return result;
17 private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) {
18 try{
19 boolean goodResult = false;
20 String[] env = new String[1];
21 String regCmd = null;
22 ExecCmd command = new ExecCmd();
23 for ( int i=0; i<singletonDefParams.length; i++){
24 if ( opSys.indexOf( "Windows" ) == -1 ){
25 // Not windows
26 env[0] = "LD_LIBRARY_PATH=" + progPath;
27 command.exec( "chmod a+x " + progPath + "regsingleton", null );
28 regCmd = progPath + "regsingleton " + path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb " + singletonDefParams[i];
29 goodResult = command.exec( regCmd, env );
31 else {
32 // Windows
33 regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] );
34 goodResult = command.exec( regCmd,null );
36 if ( !goodResult ){
37 System.out.println("Regsingleton cmd failed, cmd: " + regCmd );
38 statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log");
39 return false;
43 catch ( Exception e ) {
44 String message = "\nError installing scripting package, please view SFrameworkInstall.log.";
45 System.out.println(message);
46 e.printStackTrace();
47 statusLabel.setText(message);
48 return false;
50 return true;
54 public static boolean register(String path, JLabel statusLabel) {
55 String[] packages = {"ooscriptframe.zip", "bshruntime.zip", "jsruntime.zip"};
57 try {
58 String s=null;
59 boolean goodResult = false;
60 String env[] = new String[1];
61 ExecCmd command = new ExecCmd();
62 boolean isWindows =
63 (System.getProperty("os.name").indexOf("Windows") != -1);
65 String progpath = path.concat("program" + File.separator);
67 statusLabel.setText("Registering Scripting Framework...");
69 // pkgchk Scripting Framework Components
70 statusLabel.setText("Registering Scripting Framework Components...");
71 System.out.println("Registering Scripting Framework Components...");
73 for (int i = 0; i < packages.length; i++) {
74 String cmd = "";
76 if (!isWindows) {
77 env[0]="LD_LIBRARY_PATH=" + progpath;
79 goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null );
81 if ( goodResult ){
82 cmd = progpath + "pkgchk -s -f " + progpath + packages[i];
84 System.err.println(cmd);
85 goodResult = command.exec(cmd, env);
88 else {
89 cmd = "\"" + progpath + "pkgchk.exe\" -s -f \"" + progpath +
90 packages[i] + "\"";
92 System.err.println(cmd);
93 goodResult =command.exec(cmd,null);
96 if (!goodResult) {
97 System.err.println("\nPkgChk Failed");
99 if(!isWindows)
100 System.err.println("Command: " + cmd + "\n" + env[0]);
101 else
102 System.err.println("Command: \"" + cmd + "\"");
104 statusLabel.setText(
105 "PkgChk Failed, please view SFrameworkInstall.log");
107 return false;
111 // if ( !regSingletons( path, progpath, opSys, statusLabel ) )
112 // {
113 // return false;
114 // }
115 // updating ProtocolHandler
116 /* statusLabel.setText("Updating ProtocolHandler...");
117 if(!FileUpdater.updateProtocolHandler(path, statusLabel)) {
118 statusLabel.setText("Updating ProtocolHandler failed, please view SFrameworkInstall.log");
119 return false;
120 } */
122 // updating StarBasic libraries
123 statusLabel.setText("Updating StarBasic libraries...");
124 if(!FileUpdater.updateScriptXLC(path, statusLabel)) {
125 statusLabel.setText("Updating user/basic/script.xlc failed, please view SFrameworkInstall.log");
126 return false;
128 if(!FileUpdater.updateDialogXLC(path, statusLabel)) {
129 statusLabel.setText("Updating user/basic/dialog.xlc failed, please view SFrameworkInstall.log");
130 return false;
134 catch(Exception e){
135 String message = "\nError installing scripting package, please view SFrameworkInstall.log.";
136 System.out.println(message);
137 e.printStackTrace();
138 statusLabel.setText(message);
139 return false;
141 return true;
142 }// register
144 }//Register