diff options
author | Robert Antoni Buj i Gelonch <robert.buj@gmail.com> | 2014-09-25 19:41:12 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-10-02 15:25:29 +0200 |
commit | 6f42a714399f4d0c46dad95c7c11bcd513c27eaa (patch) | |
tree | b5ea97f0171124e8232fe909e86ac0a087e8a3d0 /scripting/workben | |
parent | 36d24bced0ea5fcbbd380b15e9d1a813fbef32cf (diff) |
scripting: Format_java_code.sh initial run
Conflicts:
scripting/java/com/sun/star/script/framework/io/UCBStreamHandler.java
Change-Id: I09b94d8c96dfbaf498bd93a0088feb80a9e4afb6
Diffstat (limited to 'scripting/workben')
39 files changed, 1424 insertions, 1399 deletions
diff --git a/scripting/workben/ifc/scripting/ScriptingUtils.java b/scripting/workben/ifc/scripting/ScriptingUtils.java index eb317036e2ab..03ef3f5ca680 100644 --- a/scripting/workben/ifc/scripting/ScriptingUtils.java +++ b/scripting/workben/ifc/scripting/ScriptingUtils.java @@ -37,6 +37,7 @@ public class ScriptingUtils { public static synchronized ScriptingUtils getDefault() { if (utils == null) utils = new ScriptingUtils(); + return utils; } @@ -63,23 +64,23 @@ public class ScriptingUtils { if (storageManager == null) { try { XPropertySet xProp = UnoRuntime.queryInterface( - XPropertySet.class, xMSF); + XPropertySet.class, xMSF); XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, - xProp.getPropertyValue("DefaultContext")); + xProp.getPropertyValue("DefaultContext")); XInterface ifc = (XInterface) - xContext.getValueByName("/singletons/drafts.com.sun.star." + - "script.framework.storage.theScriptStorageManager"); + xContext.getValueByName("/singletons/drafts.com.sun.star." + + "script.framework.storage.theScriptStorageManager"); storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc); - } - catch( Exception e ) { + } catch (Exception e) { return -1; } } access = getXSimpleFileAccess(xMSF); + if (access == null) return -1; @@ -96,10 +97,10 @@ public class ScriptingUtils { xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { return null; } + return access; } } diff --git a/scripting/workben/ifc/scripting/SecurityDialogUtil.java b/scripting/workben/ifc/scripting/SecurityDialogUtil.java index fbcee55b5431..349b70bfa24f 100644 --- a/scripting/workben/ifc/scripting/SecurityDialogUtil.java +++ b/scripting/workben/ifc/scripting/SecurityDialogUtil.java @@ -33,116 +33,112 @@ import util.AccessibilityTools; */ public class SecurityDialogUtil extends Thread { -private XMultiServiceFactory xMSF = null; -private String errorMsg; -private String btnName; -private boolean checkBox; + private XMultiServiceFactory xMSF = null; + private String errorMsg; + private String btnName; + private boolean checkBox; + + /** + * Constructor. + */ + public SecurityDialogUtil(XMultiServiceFactory xMSF, String btnName, + boolean checkBox) { + this.xMSF = xMSF; + this.btnName = btnName; + this.checkBox = checkBox; + this.errorMsg = ""; + } -/** - * Constructor. - */ -public SecurityDialogUtil(XMultiServiceFactory xMSF, String btnName, boolean checkBox ) -{ - this.xMSF = xMSF; - this.btnName = btnName; - this.checkBox = checkBox; - this.errorMsg = ""; -} + /** + * Returns the error message that occurred while + * accessing and pressing the button. + * @return Error message. + */ + public String getErrorMessage() { + return errorMsg; + } -/** - * Returns the error message that occurred while - * accessing and pressing the button. - * @return Error message. - */ -public String getErrorMessage() -{ - return errorMsg; -} + /** + * Press the named button in the currently visible dialog box. + */ + @Override + public void run() { + // wait for the message box to appear + try { + Thread.sleep(4000) ; + } catch (InterruptedException e) { + System.err.println("While waiting :" + e.getMessage()) ; + } -/** - * Press the named button in the currently visible dialog box. - */ -@Override -public void run() -{ - // wait for the message box to appear - try - { - Thread.sleep(4000) ; - } - catch (InterruptedException e) - { - System.err.println("While waiting :" + e.getMessage()) ; - } + // access the message box - // access the message box + XAccessibleContext xCon = null; - XAccessibleContext xCon = null; - try - { - XInterface x = (XInterface) xMSF.createInstance( - "com.sun.star.awt.Toolkit") ; - XExtendedToolkit tk = + try { + XInterface x = (XInterface) xMSF.createInstance( + "com.sun.star.awt.Toolkit") ; + XExtendedToolkit tk = UnoRuntime.queryInterface( - XExtendedToolkit.class,x); - new AccessibilityTools(); - XWindow xWindow = UnoRuntime.queryInterface( - XWindow.class,tk.getActiveTopWindow()); - XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); - xCon = xRoot.getAccessibleContext(); - } - catch (Exception e) - { - errorMsg="Exception while using Accessibility\n"+ - e.getMessage(); - return; - } - // get the button - XInterface oObj = null; - try - { - int count = xCon.getAccessibleChildCount(); - for (int i=0; i<count; i++) { - XAccessible xAcc = xCon.getAccessibleChild(i); - String name = + XExtendedToolkit.class, x); + new AccessibilityTools(); + XWindow xWindow = UnoRuntime.queryInterface( + XWindow.class, tk.getActiveTopWindow()); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + xCon = xRoot.getAccessibleContext(); + } catch (Exception e) { + errorMsg = "Exception while using Accessibility\n" + + e.getMessage(); + return; + } + + // get the button + XInterface oObj = null; + + try { + int count = xCon.getAccessibleChildCount(); + + for (int i = 0; i < count; i++) { + XAccessible xAcc = xCon.getAccessibleChild(i); + String name = xAcc.getAccessibleContext().getAccessibleName(); - // check for button - if ( name.equals( btnName ) && ( UnoRuntime.queryInterface( - XButton.class, xAcc ) != null ) ) - { - oObj = xAcc.getAccessibleContext(); - } - // check for checkbox - if ( checkBox && ( UnoRuntime.queryInterface( XCheckBox.class, xAcc ) != null ) ) - { - // want to do this action now - // probably equates to toggle cb - XAccessibleAction xAction = + + // check for button + if (name.equals(btnName) && (UnoRuntime.queryInterface( + XButton.class, xAcc) != null)) { + oObj = xAcc.getAccessibleContext(); + } + + // check for checkbox + if (checkBox && (UnoRuntime.queryInterface(XCheckBox.class, xAcc) != null)) { + // want to do this action now + // probably equates to toggle cb + XAccessibleAction xAction = UnoRuntime.queryInterface( - XAccessibleAction.class, xAcc.getAccessibleContext()); - xAction.doAccessibleAction(0); + XAccessibleAction.class, xAcc.getAccessibleContext()); + xAction.doAccessibleAction(0); - // might be worth using oObj2 to double check the new state?? + // might be worth using oObj2 to double check the new state?? + } } - } - if (oObj == null) { - errorMsg="No button has been found:\n"+ - "No action is triggered."; - return; - } - // press button - XAccessibleAction xAction = + + if (oObj == null) { + errorMsg = "No button has been found:\n" + + "No action is triggered."; + return; + } + + // press button + XAccessibleAction xAction = UnoRuntime.queryInterface( - XAccessibleAction.class, oObj); - xAction.doAccessibleAction(0); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) { - errorMsg="Exception\n"+ - e.getMessage(); + XAccessibleAction.class, oObj); + xAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + errorMsg = "Exception\n" + + e.getMessage(); + } } -} } diff --git a/scripting/workben/ifc/scripting/_XFunction.java b/scripting/workben/ifc/scripting/_XFunction.java index e4c04b257c0d..31c1742b2d8b 100644 --- a/scripting/workben/ifc/scripting/_XFunction.java +++ b/scripting/workben/ifc/scripting/_XFunction.java @@ -40,6 +40,7 @@ public class _XFunction extends MultiMethodTest { public void before() throws StatusException { log.println("getting provider"); oProvider = (XFunctionProvider) tEnv.getObjRelation("provider"); + if (oProvider == null) log.println("it's null"); else @@ -60,8 +61,7 @@ public class _XFunction extends MultiMethodTest { while (tests.hasNext()) { result &= runInvokeTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -85,7 +85,7 @@ public class _XFunction extends MultiMethodTest { log.println(testdata.get("description")); - try{ + try { Object[] aParams = new Object[0]; short[][] aOutParamIndex = new short[1][]; aOutParamIndex[0] = new short[0]; @@ -93,12 +93,13 @@ public class _XFunction extends MultiMethodTest { aOutParam[0] = new Object[0]; XFunction func = oProvider.getFunction(logicalname); + if (func == null) { log.println("Couldn't get XFunction for:" + logicalname); return false; } - Object ret = func.invoke( aParams, aOutParamIndex, aOutParam ); + Object ret = func.invoke(aParams, aOutParamIndex, aOutParam); if (ret != null) { gotreturntype = ret.getClass().getName(); @@ -106,31 +107,26 @@ public class _XFunction extends MultiMethodTest { } output = "success"; - } - catch (com.sun.star.lang.IllegalArgumentException iae) { + } catch (com.sun.star.lang.IllegalArgumentException iae) { log.println("Couldn't invoke script:" + iae); output = "com.sun.star.lang.IllegalArgumentException"; - } - catch (com.sun.star.script.CannotConvertException cce) { + } catch (com.sun.star.script.CannotConvertException cce) { log.println("Couldn't invoke script:" + cce); output = "com.sun.star.script.CannotConvertException"; - } - catch (com.sun.star.reflection.InvocationTargetException ite) { + } catch (com.sun.star.reflection.InvocationTargetException ite) { log.println("Couldn't invoke script:" + ite); output = "com.sun.star.reflection.InvocationTargetException"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Couldn't invoke script:" + re); output = "com.sun.star.uno.RuntimeException"; - } - catch(java.lang.Exception e){ + } catch (java.lang.Exception e) { log.println("Couldn't invoke script:" + e); output = "java.lang.Exception"; } if (expreturntype != null) { log.println("expected return type: " + expreturntype + - ", got return type: " + gotreturntype); + ", got return type: " + gotreturntype); if (!gotreturntype.equals(expreturntype)) result = false; @@ -138,13 +134,14 @@ public class _XFunction extends MultiMethodTest { if (expreturnvalue != null) { log.println("expected return value: " + expreturnvalue + - ", got return value: " + gotreturnvalue); + ", got return value: " + gotreturnvalue); if (!gotreturnvalue.equals(expreturnvalue)) result = false; } log.println("expected: " + expected + ", output: " + output); + if (!output.equals(expected)) result = false; diff --git a/scripting/workben/ifc/scripting/_XFunctionProvider.java b/scripting/workben/ifc/scripting/_XFunctionProvider.java index 7a51288885e8..a8bfbca6b687 100644 --- a/scripting/workben/ifc/scripting/_XFunctionProvider.java +++ b/scripting/workben/ifc/scripting/_XFunctionProvider.java @@ -53,8 +53,7 @@ public class _XFunctionProvider extends MultiMethodTest { while (tests.hasNext()) { result &= runGetFunctionTest((Parameters)tests.next()); } - } - else { + } else { result = false; } diff --git a/scripting/workben/ifc/scripting/_XScriptInfo.java b/scripting/workben/ifc/scripting/_XScriptInfo.java index cd78ad7b1817..8e1cff6bf5ea 100644 --- a/scripting/workben/ifc/scripting/_XScriptInfo.java +++ b/scripting/workben/ifc/scripting/_XScriptInfo.java @@ -63,8 +63,7 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } - } - else { + } else { result = false; } @@ -94,10 +93,10 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.endsWith(expected); } - } - else { + } else { result = false; } + tRes.tested("getParcelURI()", result); } @@ -124,10 +123,10 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } - } - else { + } else { result = false; } + tRes.tested("getLanguage()", result); } @@ -154,10 +153,10 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } - } - else { + } else { result = false; } + tRes.tested("getFunctionName()", result); } @@ -184,8 +183,7 @@ public class _XScriptInfo extends MultiMethodTest { if (output == null) output = "null"; - } - catch( com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { log.println("caught UNO Exception:" + e); output = "com.sun.star.uno.Exception"; } @@ -193,6 +191,7 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); } } + tRes.tested("getLanguageProperties()", true); } @@ -226,10 +225,10 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } - } - else { + } else { result = false; } + tRes.tested("getFileSetNames()", result); } @@ -264,10 +263,10 @@ public class _XScriptInfo extends MultiMethodTest { log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } - } - else { + } else { result = false; } + tRes.tested("getFilesInFileSet()", result); } @@ -297,11 +296,10 @@ public class _XScriptInfo extends MultiMethodTest { output = "empty"; log.println("expected: [" + expected + "], output: [" + - output + "]"); + output + "]"); result &= output.equals(expected); } - } - else { + } else { result = false; } diff --git a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java index 18b8a41d4d0e..bf2095635fdb 100644 --- a/scripting/workben/ifc/scripting/_XScriptInfoAccess.java +++ b/scripting/workben/ifc/scripting/_XScriptInfoAccess.java @@ -54,8 +54,7 @@ public class _XScriptInfoAccess extends MultiMethodTest { while (tests.hasNext()) { result &= runGetScriptLogicalNamesTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -69,21 +68,21 @@ public class _XScriptInfoAccess extends MultiMethodTest { log.println(testdata.get("description")); - log.println("In _XScriptInfoAccess.getScriptLogicalNames()"); - String[] logicalNames = oObj.getScriptLogicalNames(); + log.println("In _XScriptInfoAccess.getScriptLogicalNames()"); + String[] logicalNames = oObj.getScriptLogicalNames(); - if (logicalNames == null) - output = "null"; - else if (logicalNames.length == 0) - output = "empty"; - else { - for (int i = 0; i < logicalNames.length; i++) { - if (logicalNames[i].equals(expected)) { - output = logicalNames[i]; - break; - } + if (logicalNames == null) + output = "null"; + else if (logicalNames.length == 0) + output = "empty"; + else { + for (int i = 0; i < logicalNames.length; i++) { + if (logicalNames[i].equals(expected)) { + output = logicalNames[i]; + break; } } + } log.println("expected: " + expected + ", output: " + output); return (output.equals(expected)); @@ -103,8 +102,7 @@ public class _XScriptInfoAccess extends MultiMethodTest { while (tests.hasNext()) { result &= runGetImplementationsTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -119,9 +117,9 @@ public class _XScriptInfoAccess extends MultiMethodTest { log.println(testdata.get("description")); - // performs a basic check to see if 1 match (XScriptInfo) is returned - // the XScriptInfo object is tested more completely in _XScriptInfo - // which is drive from ScriptInfo + // performs a basic check to see if 1 match (XScriptInfo) is returned + // the XScriptInfo object is tested more completely in _XScriptInfo + // which is drive from ScriptInfo try { XScriptInfo[] impls = oObj.getImplementations(logicalname); @@ -133,8 +131,7 @@ public class _XScriptInfoAccess extends MultiMethodTest { output = "empty"; else output = impls[0].getLogicalName(); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { log.println("Caught UNO Exception:" + e); output = "com.sun.star.uno.Exception"; } @@ -157,8 +154,7 @@ public class _XScriptInfoAccess extends MultiMethodTest { while (tests.hasNext()) { result &= runGetAllImplementationsTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -174,18 +170,19 @@ public class _XScriptInfoAccess extends MultiMethodTest { log.println(testdata.get("description")); Object obj = ScriptingUtils.getDefault().getScriptStorage( - tParam.getMSF(), location); + tParam.getMSF(), location); - XScriptInfoAccess access = UnoRuntime.queryInterface(XScriptInfoAccess.class, obj); + XScriptInfoAccess access = UnoRuntime.queryInterface(XScriptInfoAccess.class, + obj); XScriptInfo[] impls = access.getAllImplementations(); if (impls == null || impls.length == 0) { output = "empty"; - } - else { + } else { for (int i = 0; i < impls.length - 1; i++) output += impls[i].getLogicalName() + ","; + output += impls[impls.length - 1].getLogicalName(); } diff --git a/scripting/workben/ifc/scripting/_XScriptInvocation.java b/scripting/workben/ifc/scripting/_XScriptInvocation.java index a829fb553c67..06c76e75ba06 100644 --- a/scripting/workben/ifc/scripting/_XScriptInvocation.java +++ b/scripting/workben/ifc/scripting/_XScriptInvocation.java @@ -67,8 +67,7 @@ public class _XScriptInvocation extends MultiMethodTest { while (tests.hasNext()) { result &= runInvokeTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -86,12 +85,14 @@ public class _XScriptInvocation extends MultiMethodTest { int storageId = getStorageId(location); XModel ctx = null; + if (!context.equals("null")) ctx = loadDocument(context); - HashMap<String,Object> map = new HashMap<String,Object>(); + HashMap<String, Object> map = new HashMap<String, Object>(); map.put("SCRIPTING_DOC_STORAGE_ID", Integer.valueOf(storageId)); map.put("SCRIPTING_DOC_URI", "hahaha"); + if (ctx != null) map.put("SCRIPTING_DOC_REF", ctx); @@ -109,22 +110,18 @@ public class _XScriptInvocation extends MultiMethodTest { try { Object ret = oObj.invoke(logicalname, params, args, num, result); log.println("return type is: " + ret.getClass().getName() + - ", value is: " + ret.toString()); + ", value is: " + ret.toString()); output = "success"; - } - catch (com.sun.star.lang.IllegalArgumentException iae) { + } catch (com.sun.star.lang.IllegalArgumentException iae) { log.println("Couldn't invoke script:" + iae); output = "com.sun.star.lang.IllegalArgumentException"; - } - catch (com.sun.star.script.CannotConvertException cce) { + } catch (com.sun.star.script.CannotConvertException cce) { log.println("Couldn't invoke script:" + cce); output = "com.sun.star.script.CannotConvertException"; - } - catch (com.sun.star.reflection.InvocationTargetException ite) { + } catch (com.sun.star.reflection.InvocationTargetException ite) { log.println("Couldn't invoke script:" + ite); output = "com.sun.star.reflection.InvocationTargetException"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Couldn't invoke script:" + re); output = "com.sun.star.uno.RuntimeException"; } @@ -150,23 +147,23 @@ public class _XScriptInvocation extends MultiMethodTest { if (storageManager == null) { try { XPropertySet xProp = UnoRuntime.queryInterface( - XPropertySet.class, tParam.getMSF()); + XPropertySet.class, tParam.getMSF()); XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, - xProp.getPropertyValue("DefaultContext")); + xProp.getPropertyValue("DefaultContext")); XInterface ifc = (XInterface) - xContext.getValueByName("/singletons/drafts.com.sun.star." + - "script.framework.storage.theScriptStorageManager"); + xContext.getValueByName("/singletons/drafts.com.sun.star." + + "script.framework.storage.theScriptStorageManager"); storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc); - } - catch( Exception e ) { + } catch (Exception e) { return -1; } } access = getXSimpleFileAccess(); + if (access == null) return -1; @@ -180,13 +177,13 @@ public class _XScriptInvocation extends MultiMethodTest { try { Object fa = tParam.getMSF().createInstance( - "com.sun.star.ucb.SimpleFileAccess"); + "com.sun.star.ucb.SimpleFileAccess"); access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { return null; } + return access; } @@ -199,18 +196,15 @@ public class _XScriptInvocation extends MultiMethodTest { try { Object obj = factory.loadDocument(fullname); model = UnoRuntime.queryInterface(XModel.class, obj); - } - catch (com.sun.star.lang.IllegalArgumentException iae) { + } catch (com.sun.star.lang.IllegalArgumentException iae) { return null; - } - catch (Exception e) { + } catch (Exception e) { return null; } try { Thread.sleep(5000); - } - catch (InterruptedException ie) { + } catch (InterruptedException ie) { } return model; diff --git a/scripting/workben/ifc/scripting/_XScriptNameResolver.java b/scripting/workben/ifc/scripting/_XScriptNameResolver.java index b2f264d1e4b1..851ed9c936e5 100644 --- a/scripting/workben/ifc/scripting/_XScriptNameResolver.java +++ b/scripting/workben/ifc/scripting/_XScriptNameResolver.java @@ -62,8 +62,7 @@ public class _XScriptNameResolver extends MultiMethodTest { while (tests.hasNext()) { result &= runResolveTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -81,7 +80,7 @@ public class _XScriptNameResolver extends MultiMethodTest { log.println(description + ": " + logicalname); - HashMap<String,Object> map = new HashMap<String,Object>(); + HashMap<String, Object> map = new HashMap<String, Object>(); map.put("SCRIPTING_DOC_STORAGE_ID", Integer.valueOf(storageId)); map.put("SCRIPTING_DOC_URI", util.utils.getFullTestURL(location)); @@ -97,16 +96,13 @@ public class _XScriptNameResolver extends MultiMethodTest { output = "null"; else output = "XScriptInfo.class"; - } - catch (com.sun.star.lang.IllegalArgumentException iae) { + } catch (com.sun.star.lang.IllegalArgumentException iae) { log.println("caught IllegalArgumentException: " + iae); output = "com.sun.star.lang.IllegalArgumentException"; - } - catch (com.sun.star.script.CannotConvertException cce) { + } catch (com.sun.star.script.CannotConvertException cce) { log.println("caught CannotConvertException: " + cce); output = "com.sun.star.script.CannotConvertException"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("caught RuntimeException: " + re); output = "com.sun.star.uno.RuntimeException"; } @@ -129,23 +125,23 @@ public class _XScriptNameResolver extends MultiMethodTest { if (storageManager == null) { try { XPropertySet xProp = UnoRuntime.queryInterface( - XPropertySet.class, tParam.getMSF()); + XPropertySet.class, tParam.getMSF()); XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, - xProp.getPropertyValue("DefaultContext")); + xProp.getPropertyValue("DefaultContext")); XInterface ifc = (XInterface) - xContext.getValueByName("/singletons/drafts.com.sun.star." + - "script.framework.storage.theScriptStorageManager"); + xContext.getValueByName("/singletons/drafts.com.sun.star." + + "script.framework.storage.theScriptStorageManager"); storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc); - } - catch( Exception e ) { + } catch (Exception e) { return -1; } } access = getXSimpleFileAccess(); + if (access == null) return -1; @@ -159,13 +155,13 @@ public class _XScriptNameResolver extends MultiMethodTest { try { Object fa = tParam.getMSF().createInstance( - "com.sun.star.ucb.SimpleFileAccess"); + "com.sun.star.ucb.SimpleFileAccess"); access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { return null; } + return access; } } diff --git a/scripting/workben/ifc/scripting/_XScriptSecurity.java b/scripting/workben/ifc/scripting/_XScriptSecurity.java index cd3b65668f7f..f06d4288a6c4 100644 --- a/scripting/workben/ifc/scripting/_XScriptSecurity.java +++ b/scripting/workben/ifc/scripting/_XScriptSecurity.java @@ -67,8 +67,7 @@ public class _XScriptSecurity extends MultiMethodTest { while (tests.hasNext()) { result &= runCheckPermissionTest((Parameters)tests.next()); } - } - else { + } else { result = false; } @@ -110,200 +109,196 @@ public class _XScriptSecurity extends MultiMethodTest { // get the officeBasic setting int officeBasic = 0; - if( runmacro.equals("never") ) - { + + if (runmacro.equals("never")) { officeBasic = 0; - } - else if ( runmacro.equals("pathlist") ) - { + } else if (runmacro.equals("pathlist")) { officeBasic = 1; - } - else if ( runmacro.equals("always") ) - { + } else if (runmacro.equals("always")) { officeBasic = 2; } // should pathlist include doc? String secureURLs = null; - if( pathlist.equals("true") ) - { + + if (pathlist.equals("true")) { String uri = util.utils.getFullTestURL(location); secureURLs = uri.substring(0, uri.lastIndexOf('/')); } - if ( !setSecurity( officeBasic, confirm, warning, secureURLs ) ) - { - log.println( "failed to set security" ); + if (!setSecurity(officeBasic, confirm, warning, secureURLs)) { + log.println("failed to set security"); return false; } - if( dialog.equals( "true" ) ) - { + if (dialog.equals("true")) { // is the checkbox to be ticked? boolean checkBox = false; - if( checkBoxStr.equals( "true" ) ) - { + + if (checkBoxStr.equals("true")) { checkBox = true; } - new SecurityDialogUtil( tParam.getMSF(), buttonName, checkBox ).start(); + + new SecurityDialogUtil(tParam.getMSF(), buttonName, checkBox).start(); } + // need to set up dialog utils thread first int storageId = getStorageId(location); try { String uri = util.utils.getFullTestURL(location); - oObj.checkPermission(uri, "execute" ); + oObj.checkPermission(uri, "execute"); output = "true"; - } - catch (com.sun.star.security.AccessControlException ace) { + } catch (com.sun.star.security.AccessControlException ace) { log.println("Couldn't invoke script:" + ace); output = "com.sun.star.security.AccessControlException"; - } - catch (com.sun.star.lang.IllegalArgumentException iae) { + } catch (com.sun.star.lang.IllegalArgumentException iae) { log.println("Couldn't invoke script:" + iae); output = "com.sun.star.lang.IllegalArgumentException"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Couldn't invoke script:" + re); output = "com.sun.star.uno.RuntimeException"; } log.println("expected: " + expected + ", output: " + output); - if (output.equals(expected)) - { - if( checkpath.equals("true") ) - { + + if (output.equals(expected)) { + if (checkpath.equals("true")) { String setPath = getPathList(); String expectedPath = "empty"; - if( checkBoxStr.equals( "true" ) ) - { + + if (checkBoxStr.equals("true")) { String uri = util.utils.getFullTestURL(location); expectedPath = uri.substring(0, uri.lastIndexOf('/')); } + log.println("pathlist: expected: " + expectedPath + ", output: " + setPath); - return setPath.equals( expectedPath ); + return setPath.equals(expectedPath); } + return true; - } - else + } else return false; } - private String getPathList() - { + private String getPathList() { String result = ""; + try { - Object oProv = tParam.getMSF().createInstance( - "com.sun.star.configuration.ConfigurationProvider" ); - - XMultiServiceFactory xProv = UnoRuntime.queryInterface(XMultiServiceFactory.class, oProv); - - //the path to the security settings in the registry - PropertyValue aPathArg = new PropertyValue(); - aPathArg.Name="nodepath"; - aPathArg.Value="org.openoffice.Office.Common/Security/Scripting"; - // we don't want to cache the write - PropertyValue aModeArg = new PropertyValue(); - aModeArg.Name="lazywrite"; - aModeArg.Value=Boolean.FALSE; - - Object[] aArgs = new Object[2]; - aArgs[0]=aPathArg; - aArgs[1]=aModeArg; - Object oConfigUpdate = xProv.createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationAccess", - aArgs ); - XPropertySet xPropertySet = UnoRuntime.queryInterface( - XPropertySet.class, oConfigUpdate ); - - String[] paths = (String[])xPropertySet.getPropertyValue("SecureURL"); - if (paths == null || paths.length == 0) - result = "empty"; - else - result = paths[0]; - - } catch (Exception e) - { + Object oProv = tParam.getMSF().createInstance( + "com.sun.star.configuration.ConfigurationProvider"); + + XMultiServiceFactory xProv = UnoRuntime.queryInterface( + XMultiServiceFactory.class, oProv); + + //the path to the security settings in the registry + PropertyValue aPathArg = new PropertyValue(); + aPathArg.Name = "nodepath"; + aPathArg.Value = "org.openoffice.Office.Common/Security/Scripting"; + // we don't want to cache the write + PropertyValue aModeArg = new PropertyValue(); + aModeArg.Name = "lazywrite"; + aModeArg.Value = Boolean.FALSE; + + Object[] aArgs = new Object[2]; + aArgs[0] = aPathArg; + aArgs[1] = aModeArg; + Object oConfigUpdate = xProv.createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationAccess", + aArgs); + XPropertySet xPropertySet = UnoRuntime.queryInterface( + XPropertySet.class, oConfigUpdate); + + String[] paths = (String[])xPropertySet.getPropertyValue("SecureURL"); + + if (paths == null || paths.length == 0) + result = "empty"; + else + result = paths[0]; + + } catch (Exception e) { result = e.getClass().getName() + " getting list of secure URLs"; } + return result; } - private boolean setSecurity( int officeBasic, String confirm, - String warning, String secureURLs ) - { - boolean success=false; + private boolean setSecurity(int officeBasic, String confirm, + String warning, String secureURLs) { + boolean success = false; + try { - Object oProv = tParam.getMSF().createInstance( - "com.sun.star.configuration.ConfigurationProvider" ); - - XMultiServiceFactory xProv = UnoRuntime.queryInterface(XMultiServiceFactory.class, oProv); - - //the path to the security settings in the registry - PropertyValue aPathArg = new PropertyValue(); - aPathArg.Name="nodepath"; - aPathArg.Value="org.openoffice.Office.Common/Security/Scripting"; - // we don't want to cache the write - PropertyValue aModeArg = new PropertyValue(); - aModeArg.Name="lazywrite"; - aModeArg.Value=Boolean.FALSE; - - Object[] aArgs = new Object[2]; - aArgs[0]=aPathArg; - aArgs[1]=aModeArg; - Object oConfigUpdate = xProv.createInstanceWithArguments( - "com.sun.star.configuration.ConfigurationUpdateAccess", - aArgs ); - XNameReplace xNameReplace = UnoRuntime.queryInterface( - XNameReplace.class, oConfigUpdate ); - XChangesBatch xChangesBatch = UnoRuntime.queryInterface( - XChangesBatch.class, oConfigUpdate ); - - Object[] aSecureURLs; - if (secureURLs == null) { - aSecureURLs = new Object[0]; - } - else { - aSecureURLs = new Object[1]; - aSecureURLs[0] = secureURLs; - } - log.println("setting SecureURL"); - xNameReplace.replaceByName( "SecureURL", aSecureURLs ); + Object oProv = tParam.getMSF().createInstance( + "com.sun.star.configuration.ConfigurationProvider"); + + XMultiServiceFactory xProv = UnoRuntime.queryInterface( + XMultiServiceFactory.class, oProv); + + //the path to the security settings in the registry + PropertyValue aPathArg = new PropertyValue(); + aPathArg.Name = "nodepath"; + aPathArg.Value = "org.openoffice.Office.Common/Security/Scripting"; + // we don't want to cache the write + PropertyValue aModeArg = new PropertyValue(); + aModeArg.Name = "lazywrite"; + aModeArg.Value = Boolean.FALSE; + + Object[] aArgs = new Object[2]; + aArgs[0] = aPathArg; + aArgs[1] = aModeArg; + Object oConfigUpdate = xProv.createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationUpdateAccess", + aArgs); + XNameReplace xNameReplace = UnoRuntime.queryInterface( + XNameReplace.class, oConfigUpdate); + XChangesBatch xChangesBatch = UnoRuntime.queryInterface( + XChangesBatch.class, oConfigUpdate); + + Object[] aSecureURLs; + + if (secureURLs == null) { + aSecureURLs = new Object[0]; + } else { + aSecureURLs = new Object[1]; + aSecureURLs[0] = secureURLs; + } - log.println("setting OfficeBasic"); - xNameReplace.replaceByName( "OfficeBasic", Integer.valueOf(officeBasic) ); + log.println("setting SecureURL"); + xNameReplace.replaceByName("SecureURL", aSecureURLs); - Boolean bConfirm = null; - if( ( confirm != null ) && ( confirm.equals("true") ) ) - { - bConfirm = Boolean.TRUE; - } - else - { - bConfirm = Boolean.FALSE; - } - log.println("setting Confirmation"); - xNameReplace.replaceByName( "Confirmation", bConfirm ); + log.println("setting OfficeBasic"); + xNameReplace.replaceByName("OfficeBasic", Integer.valueOf(officeBasic)); - Boolean bWarning = null; - if( ( warning != null ) && ( warning.equals("true") ) ) - { - bWarning = Boolean.TRUE; - } - else - { - bWarning = Boolean.FALSE; - } - log.println("setting Warning"); - xNameReplace.replaceByName( "Warning", bWarning ); + Boolean bConfirm = null; + + if ((confirm != null) && (confirm.equals("true"))) { + bConfirm = Boolean.TRUE; + } else { + bConfirm = Boolean.FALSE; + } - // and now commit the changes - xChangesBatch.commitChanges(); - success=true; + log.println("setting Confirmation"); + xNameReplace.replaceByName("Confirmation", bConfirm); + + Boolean bWarning = null; + + if ((warning != null) && (warning.equals("true"))) { + bWarning = Boolean.TRUE; + } else { + bWarning = Boolean.FALSE; + } + + log.println("setting Warning"); + xNameReplace.replaceByName("Warning", bWarning); + + // and now commit the changes + xChangesBatch.commitChanges(); + success = true; } catch (Exception e) { log.println("Error updating security settings: " + - e.getMessage() ); + e.getMessage()); } + return success; } @@ -315,23 +310,23 @@ public class _XScriptSecurity extends MultiMethodTest { if (storageManager == null) { try { XPropertySet xProp = UnoRuntime.queryInterface( - XPropertySet.class, tParam.getMSF()); + XPropertySet.class, tParam.getMSF()); XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, - xProp.getPropertyValue("DefaultContext")); + xProp.getPropertyValue("DefaultContext")); XInterface ifc = (XInterface) - xContext.getValueByName("/singletons/drafts.com.sun.star." + - "script.framework.storage.theScriptStorageManager"); + xContext.getValueByName("/singletons/drafts.com.sun.star." + + "script.framework.storage.theScriptStorageManager"); storageManager = UnoRuntime.queryInterface(XScriptStorageManager.class, ifc); - } - catch( Exception e ) { + } catch (Exception e) { return -1; } } access = getXSimpleFileAccess(); + if (access == null) return -1; @@ -345,13 +340,13 @@ public class _XScriptSecurity extends MultiMethodTest { try { Object fa = tParam.getMSF().createInstance( - "com.sun.star.ucb.SimpleFileAccess"); + "com.sun.star.ucb.SimpleFileAccess"); access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { return null; } + return access; } diff --git a/scripting/workben/ifc/scripting/_XScriptStorageManager.java b/scripting/workben/ifc/scripting/_XScriptStorageManager.java index f8eab044c772..0e300317cb60 100644 --- a/scripting/workben/ifc/scripting/_XScriptStorageManager.java +++ b/scripting/workben/ifc/scripting/_XScriptStorageManager.java @@ -66,20 +66,20 @@ public class _XScriptStorageManager extends MultiMethodTest { if (access == null) { output = "Couldn't create XSimpleFileAccess"; - } - else { + } else { try { int id = oObj.createScriptStorage(access); output = "success"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Exception from createScriptStorage: " + re); output = "com.sun.star.uno.RuntimeException"; } } + log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } + tRes.tested("createScriptStorage()", result); } @@ -116,18 +116,18 @@ public class _XScriptStorageManager extends MultiMethodTest { output = "null"; else { Object info = UnoRuntime.queryInterface( - XScriptInfoAccess.class, ifc); + XScriptInfoAccess.class, ifc); if (info == null) output = "null"; else output = "XScriptInfoAccess.class"; } - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Caught RuntimeException: " + re); output = "com.sun.star.uno.RuntimeException"; } + log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } @@ -165,21 +165,22 @@ public class _XScriptStorageManager extends MultiMethodTest { output = "null"; else { Object info = UnoRuntime.queryInterface( - XScriptInfoAccess.class, ifc); + XScriptInfoAccess.class, ifc); if (info == null) output = "null"; else output = "XScriptInfoAccess.class"; } - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Caught RuntimeException: " + re); output = "com.sun.star.uno.RuntimeException"; } + log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } + tRes.tested("getScriptStorage()", result); } @@ -209,14 +210,15 @@ public class _XScriptStorageManager extends MultiMethodTest { log.println("calling refreshScriptStorage with URI: " + uri); oObj.refreshScriptStorage(uri); output = "success"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Caught RuntimeException: " + re); output = "com.sun.star.uno.RuntimeException"; } + log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } + tRes.tested("refreshScriptStorage()", result); } @@ -231,6 +233,7 @@ public class _XScriptStorageManager extends MultiMethodTest { String uri = util.utils.getFullTestURL(location); XSimpleFileAccess access = getXSimpleFileAccess(); + if (access == null) return -1; @@ -242,13 +245,13 @@ public class _XScriptStorageManager extends MultiMethodTest { try { Object fa = tParam.getMSF().createInstance( - "com.sun.star.ucb.SimpleFileAccess"); + "com.sun.star.ucb.SimpleFileAccess"); access = UnoRuntime.queryInterface(XSimpleFileAccess.class, fa); - } - catch (com.sun.star.uno.Exception e) { + } catch (com.sun.star.uno.Exception e) { return null; } + return access; } } diff --git a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java index bae6a3e5a20d..fb4bd7c0a316 100644 --- a/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java +++ b/scripting/workben/ifc/scripting/_XScriptStorageRefresh.java @@ -61,14 +61,15 @@ public class _XScriptStorageRefresh extends MultiMethodTest { try { oObj.refresh(); output = "success"; - } - catch (com.sun.star.uno.RuntimeException re) { + } catch (com.sun.star.uno.RuntimeException re) { log.println("Caught RuntimeException: " + re); output = "com.sun.star.uno.RuntimeException"; } + log.println("expected: " + expected + ", output: " + output); result &= output.equals(expected); } + tRes.tested("refresh()", result); } } diff --git a/scripting/workben/installer/Banner.java b/scripting/workben/installer/Banner.java index aea91a2caebd..d9945acd7331 100644 --- a/scripting/workben/installer/Banner.java +++ b/scripting/workben/installer/Banner.java @@ -20,31 +20,26 @@ package installer; import java.awt.*; -public class Banner extends Canvas -{ +public class Banner extends Canvas { Image img; - Banner() - { + Banner() { setBackground(Color.white); img = Toolkit.getDefaultToolkit().createImage("sidebar.jpg"); } @Override - public void paint(Graphics g) - { + public void paint(Graphics g) { g.drawImage(img, 0, 0, Color.white, null); g.dispose(); } @Override - public void update(Graphics g) - { + public void update(Graphics g) { super.update(g); } @Override - public Dimension getPreferredSize() - { + public Dimension getPreferredSize() { return new Dimension(137, 358); } diff --git a/scripting/workben/installer/ExceptionTraceHelper.java b/scripting/workben/installer/ExceptionTraceHelper.java index e0e5c92558da..ecde5e448072 100644 --- a/scripting/workben/installer/ExceptionTraceHelper.java +++ b/scripting/workben/installer/ExceptionTraceHelper.java @@ -21,36 +21,29 @@ 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 ) - { +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 ) - { + + try { + baos = new ByteArrayOutputStream(128); + ps = new PrintStream(baos); + e.printStackTrace(ps); + } finally { + try { + if (baos != null) { baos.close(); } - if ( ps != null ) - { + + if (ps != null) { ps.close(); } - } - catch ( Exception excp ) - { + } catch (Exception excp) { } } + return result; } } diff --git a/scripting/workben/installer/ExecCmd.java b/scripting/workben/installer/ExecCmd.java index c812ae6229b7..e52a63aefac0 100644 --- a/scripting/workben/installer/ExecCmd.java +++ b/scripting/workben/installer/ExecCmd.java @@ -18,99 +18,88 @@ package installer; import java.io.*; -public class ExecCmd -{ +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) - { + 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 + } } - finally - { - if ( br_in != null ) - { - try - { - br_in.close(); - } - catch( Exception e ) {} // nothing can be done - } - } - } } ).start(); + } + }).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); - } - 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(); + 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); + } + + 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 } - catch( Exception e ) {} // nothing can be done } - } - } }).start(); + } + }).start(); int exitcode = p.waitFor(); - if ( exitcode != 0 ) - { - System.out.println("cmd [" + cmd + "] failed" ); - result= false; - } - else - { + + if (exitcode != 0) { + System.out.println("cmd [" + cmd + "] failed"); + result = false; + } else { System.out.println("cmd [" + cmd + "] completed successfully"); - result= true; + result = true; } + } catch (Exception e) { + System.out.println("Exception"); + e.printStackTrace(); } - catch (Exception e) { - System.out.println("Exception"); - e.printStackTrace(); - } - System.out.println("command complete"); - return result; + + System.out.println("command complete"); + return result; } } diff --git a/scripting/workben/installer/FileUpdater.java b/scripting/workben/installer/FileUpdater.java index 5c628dbd89c4..6ba73692ca99 100644 --- a/scripting/workben/installer/FileUpdater.java +++ b/scripting/workben/installer/FileUpdater.java @@ -26,141 +26,158 @@ public class FileUpdater { - public static boolean updateScriptXLC( String installPath, JLabel statusLabel ) { + public static boolean updateScriptXLC(String installPath, JLabel statusLabel) { - File in_file = null; - File out_file = null; - FileWriter out = null; - int count = 0; + File in_file = null; + File out_file = null; + FileWriter out = null; + int count = 0; + + try { + in_file = new File(installPath + File.separator + "user" + File.separator + + "basic" + File.separator + "script.xlc"); + + String[] xmlArray = new String[50]; try { - in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"script.xlc" ); + BufferedReader reader = new BufferedReader(new FileReader(in_file)); + count = -1; - 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; - xmlArray[count] = s; + for (String s = reader.readLine(); s != null; + s = reader.readLine()) { //</oor:node> + count = count + 1; + xmlArray[count] = s; + } + + reader.close(); + } catch (IOException ioe) { + String message = "Error reading script.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + ioe.printStackTrace(); + statusLabel.setText(message); + return false; } - reader.close(); - } - 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(); + 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 ); + 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 - 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" ); - } - } + //split the string into a string array with one line of xml in each element + 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."; + } 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); } - 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 + }// updateScriptXLC - public static boolean updateDialogXLC( String installPath, JLabel statusLabel ) { - File in_file = null; - File out_file = null; - FileWriter out = null; - int count = 0; + public static boolean updateDialogXLC(String installPath, JLabel statusLabel) { + File in_file = null; + File out_file = null; + FileWriter out = null; + int count = 0; + + try { + in_file = new File(installPath + File.separator + "user" + File.separator + + "basic" + File.separator + "dialog.xlc"); + + String[] xmlArray = new String[50]; try { - in_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" ); + BufferedReader reader = new BufferedReader(new FileReader(in_file)); + count = -1; - 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; - xmlArray[count] = s; + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + count = count + 1; + xmlArray[count] = s; + } + + reader.close(); + } catch (IOException ioe) { + + String message = + "\nError reading dialog.xlc, please view SFrameworkInstall.log."; + System.out.println(message); + statusLabel.setText(message); + return false; } - reader.close(); - } - 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(); + in_file.delete(); - out_file = new File( installPath+File.separator+"user"+File.separator+"basic"+File.separator+"dialog.xlc" ); - out_file.createNewFile(); + out_file = new File(installPath + File.separator + "user" + File.separator + + "basic" + File.separator + "dialog.xlc"); + out_file.createNewFile(); - out = new FileWriter( out_file ); + out = new FileWriter(out_file); - //split the string into a string array with one line of xml in each element - 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" ); - } - } + //split the string into a string array with one line of xml in each element + 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."; + } 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); } - 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 + }// updateScriptXLC } diff --git a/scripting/workben/installer/Final.java b/scripting/workben/installer/Final.java index 640bd93d0054..b951537e8e0c 100644 --- a/scripting/workben/installer/Final.java +++ b/scripting/workben/installer/Final.java @@ -22,7 +22,8 @@ import java.awt.event.*; import java.util.*; import javax.swing.*; -public class Final extends javax.swing.JPanel implements ActionListener, InstallListener { +public class Final extends javax.swing.JPanel implements ActionListener, + InstallListener { /** Creates new form Welcome */ public Final(InstallWizard wizard) { @@ -67,10 +68,9 @@ public class Final extends javax.swing.JPanel implements ActionListener, Install } public void actionPerformed(ActionEvent e) { - // navNext is "Install" - if (e.getSource() == nav.navNext) - { - JProgressBar progressBar=new JProgressBar(); + // 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); @@ -79,50 +79,50 @@ public class Final extends javax.swing.JPanel implements ActionListener, Install nav.enableCancel(false); ArrayList<?> locations = InstallWizard.getLocations(); // Returned 1 - String path=null; - for (int i =0;i<locations.size();i++){ - path= (String)locations.get(i); - 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(); + String path = null; + + for (int i = 0; i < locations.size(); i++) { + path = (String)locations.get(i); + 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(); - } - else - { - return; + // 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(); + } else { + return; + } } - } }// actionPerformed public void installationComplete(InstallationEvent ev) { - if( InstUtil.hasNetbeansInstallation() ) { - nav.removeCancelListener(this); - nav.setCancelListener(nav); - nav.navCancel.setText("Finish"); - nav.enableIDE(true); - nav.enableCancel(true); - xud = null; - } - else { - nav.removeCancelListener(this); - nav.setCancelListener(nav); - nav.navCancel.setText("Finish"); - nav.enableCancel(true); - xud = null; - } + if (InstUtil.hasNetbeansInstallation()) { + nav.removeCancelListener(this); + nav.setCancelListener(nav); + nav.navCancel.setText("Finish"); + nav.enableIDE(true); + nav.enableCancel(true); + xud = null; + } else { + nav.removeCancelListener(this); + nav.setCancelListener(nav); + nav.navCancel.setText("Finish"); + nav.enableCancel(true); + xud = null; + } } // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/scripting/workben/installer/IdeFinal.java b/scripting/workben/installer/IdeFinal.java index 33612f1907ef..93159b7b4e2b 100644 --- a/scripting/workben/installer/IdeFinal.java +++ b/scripting/workben/installer/IdeFinal.java @@ -22,13 +22,14 @@ import java.awt.event.*; import java.util.*; import javax.swing.*; -public class IdeFinal extends javax.swing.JPanel implements ActionListener, InstallListener { +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; + ideupdater = null; initComponents(); } @@ -39,7 +40,7 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst */ private void initComponents() {//GEN-BEGIN:initComponents statusPanel = new javax.swing.JPanel(); - statusPanel.setBackground(java.awt.Color.white); + statusPanel.setBackground(java.awt.Color.white); statusLine = new javax.swing.JLabel("Ready", javax.swing.JLabel.CENTER); setLayout(new java.awt.BorderLayout()); @@ -50,12 +51,12 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst 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); + 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 @Override @@ -64,10 +65,9 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst } public void actionPerformed(ActionEvent e) { - // navNext is "Install" - if (e.getSource() == nav.navNext) - { - JProgressBar progressBar=new JProgressBar(); + // 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); @@ -76,29 +76,29 @@ public class IdeFinal extends javax.swing.JPanel implements ActionListener, Inst nav.enableCancel(false); ArrayList<?> locations = InstallWizard.getLocations(); // Returned 1 - String path=null; - for (int i =0;i<locations.size();i++){ - path= (String)locations.get(i); - - ideupdater = new IdeUpdater( path, statusLine, progressBar ); - ideupdater.addInstallListener(this); - InstallWizard.setInstallStarted(true); - ideupdater.start(); + String path = null; + + for (int i = 0; i < locations.size(); i++) { + path = (String)locations.get(i); + + ideupdater = new IdeUpdater(path, statusLine, progressBar); + ideupdater.addInstallListener(this); + InstallWizard.setInstallStarted(true); + 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(); - } - else - { - return; + // 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(); + } else { + return; + } } - } }// actionPerformed diff --git a/scripting/workben/installer/IdeUpdater.java b/scripting/workben/installer/IdeUpdater.java index b35b519abbe3..b0ec0cd35cbf 100644 --- a/scripting/workben/installer/IdeUpdater.java +++ b/scripting/workben/installer/IdeUpdater.java @@ -47,70 +47,65 @@ public class IdeUpdater extends Thread { if (!installPath.endsWith(File.separator)) installPath += File.separator; - File netbeansLauncher = new File( installPath + "bin" ); + File netbeansLauncher = new File(installPath + "bin"); - if( netbeansLauncher.isDirectory() ) { - isNetbeansPath = true; - installPath = installPath +"modules" + File.separator; - } + if (netbeansLauncher.isDirectory()) { + isNetbeansPath = true; + installPath = installPath + "modules" + File.separator; + } - System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath ); + System.out.println("IdeUpdater installPath is " + installPath + + " isNetbeansPath is " + isNetbeansPath); this.installPath = installPath; this.statusLabel = statusLabel; - listeners = new ArrayList<InstallListener>(); - threadSuspended = false; - progressBar=pBar; - progressBar.setStringPainted(true); + listeners = new ArrayList<InstallListener>(); + threadSuspended = false; + progressBar = pBar; + progressBar.setStringPainted(true); }// XmlUpdater @Override public void run() { - internalThread = Thread.currentThread(); + internalThread = Thread.currentThread(); - progressBar.setString("Unzipping Required Files"); + progressBar.setString("Unzipping Required Files"); ZipData zd = new ZipData(); - // 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; + // 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; + } } - } - statusLabel.setText("Installation Complete"); - progressBar.setString("Installation Complete"); - progressBar.setValue(10); - onInstallComplete(); + statusLabel.setText("Installation Complete"); + progressBar.setString("Installation Complete"); + progressBar.setValue(10); + onInstallComplete(); }// run - public void addInstallListener(InstallListener listener) - { + public void addInstallListener(InstallListener listener) { listeners.add(listener); }// addInstallListener - private void onInstallComplete() - { - for( InstallListener l : listeners) - { + private void onInstallComplete() { + for (InstallListener l : listeners) { l.installationComplete(null); } }// onInstallComplete diff --git a/scripting/workben/installer/IdeVersion.java b/scripting/workben/installer/IdeVersion.java index ab50752e2cd4..3a7cc5a485a4 100644 --- a/scripting/workben/installer/IdeVersion.java +++ b/scripting/workben/installer/IdeVersion.java @@ -26,12 +26,13 @@ import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; -public class IdeVersion extends javax.swing.JPanel implements ActionListener, TableModelListener { +public class IdeVersion extends javax.swing.JPanel implements ActionListener, + TableModelListener { /** Creates new form Welcome */ public IdeVersion(InstallWizard wizard) { - this.wizard=wizard; - setBackground(Color.white); + this.wizard = wizard; + setBackground(Color.white); initComponents(); } @@ -46,47 +47,49 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta setLayout(new BorderLayout()); - try { - Properties netbeansProps = InstUtil.getNetbeansLocation(); - Properties ideProps = new Properties(); - if(netbeansProps!=null ) - { + try { + Properties netbeansProps = InstUtil.getNetbeansLocation(); + 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 ) { - ideProps.put(key, path); + + 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) { + ideProps.put(key, path); + } + } } } - } - } - props = ideProps; - } - catch (Exception e) { + + props = ideProps; + } catch (Exception e) { System.err.println("Exception thrown in initComponents"); } - tableModel = new MyTableModelIDE (props, InstUtil.versions); + tableModel = new MyTableModelIDE(props, InstUtil.versions); - if (tableModel.getRowCount() == 0) - { - JOptionPane.showMessageDialog(this, "No compatible IDEs were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE); - } + if (tableModel.getRowCount() == 0) { + JOptionPane.showMessageDialog(this, "No compatible IDEs were found.", + "Invalid versions", JOptionPane.ERROR_MESSAGE); + } tableModel.addTableModelListener(this); JTable tableVersions = new JTable(tableModel) { @Override - public String getToolTipText(MouseEvent event) - { - int col = columnAtPoint( event.getPoint() ); + public String getToolTipText(MouseEvent event) { + int col = columnAtPoint(event.getPoint()); + if (col != 2) return null; - int row = rowAtPoint( event.getPoint() ); + int row = rowAtPoint(event.getPoint()); Object o = getValueAt(row, col); if (o == null) @@ -99,14 +102,14 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta } @Override - public Point getToolTipLocation(MouseEvent event) - { - int col = columnAtPoint( event.getPoint() ); + 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); + int row = rowAtPoint(event.getPoint()); + Object o = getValueAt(row, col); if (o == null) return null; @@ -115,7 +118,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta return null; Point pt = getCellRect(row, col, true).getLocation(); - pt.translate(-1,-2); + pt.translate(-1, -2); return pt; } }; @@ -123,7 +126,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta JScrollPane scroll = new JScrollPane(tableVersions); tableVersions.setPreferredSize( - new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT)); + new Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT)); tableVersions.setRowSelectionAllowed(false); tableVersions.setColumnSelectionAllowed(false); @@ -132,12 +135,14 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta initColumnSizes(tableVersions, tableModel); versionPanel.add(scroll); - JTextArea area = new JTextArea("Please select IDEs below that you wish to add Scripting support to"); + 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 = new NavPanel(wizard, true, false, true, InstallWizard.IDEWELCOME, + InstallWizard.IDEFINAL); nav.setNextListener(this); add(nav, BorderLayout.SOUTH); @@ -153,8 +158,10 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta public void actionPerformed(ActionEvent ev) { InstallWizard.clearLocations(); int len = tableModel.data.size(); + for (int i = 0; i < len; i++) { ArrayList<?> list = tableModel.data.get(i); + if (((Boolean)list.get(0)).booleanValue()) InstallWizard.storeLocation((String)list.get(2)); } @@ -164,8 +171,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta public void tableChanged(TableModelEvent e) { if (tableModel.isAnySelected()) { nav.enableNext(true); - } - else { + } else { nav.enableNext(false); } } @@ -184,9 +190,9 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta try { comp = column.getHeaderRenderer(). - getTableCellRendererComponent( - null, column.getHeaderValue(), - false, false, 0, 0); + getTableCellRendererComponent( + null, column.getHeaderValue(), + false, false, 0, 0); headerWidth = comp.getPreferredSize().width; } catch (NullPointerException e) { // System.err.println("Null pointer exception!"); @@ -201,19 +207,19 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta System.out.println("longValues: " + longValues[i]); comp = table.getDefaultRenderer(model.getColumnClass(i)). - getTableCellRendererComponent( - table, longValues[i], - false, false, 0, 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)); + + i + ". " + + "preferredWidth = " + preferredWidth + + "; totalWidth = " + totalWidth + + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth)); } //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead. @@ -222,8 +228,7 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth); else column.setPreferredWidth(preferredWidth); - } - else { + } else { column.setMinWidth(preferredWidth); totalWidth += preferredWidth; } @@ -236,17 +241,18 @@ public class IdeVersion extends javax.swing.JPanel implements ActionListener, Ta private NavPanel nav; // End of variables declaration//GEN-END:variables - } +} class MyTableModelIDE extends AbstractTableModel { ArrayList<ArrayList<Object>> data; private String colNames[] = {"", "IDE Name", "IDE Location"}; Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"}; - MyTableModelIDE (Properties properties, String [] validVersions) { + MyTableModelIDE(Properties properties, String [] validVersions) { data = new ArrayList<ArrayList<Object>>(); int len = validVersions.length; + for (int i = 0; i < len; i++) { String key = validVersions[i]; String path = null; @@ -256,11 +262,13 @@ class MyTableModelIDE extends AbstractTableModel { row.add(0, 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; } @@ -292,35 +300,38 @@ class MyTableModelIDE extends AbstractTableModel { return aRow.get(col); } - @Override - public Class getColumnClass(int c) { + @Override + public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); - } + } - @Override - public boolean isCellEditable(int row, int col) { - return (col == 0); - } + @Override + public boolean isCellEditable(int row, int col) { + return (col == 0); + } - @Override - public void setValueAt(Object value, int row, int col) { + @Override + public void setValueAt(Object value, int row, int col) { ArrayList<Object> aRow = data.get(row); aRow.set(col, value); fireTableCellUpdated(row, col); - } + } - public boolean isAnySelected() { + public boolean isAnySelected() { Iterator iter = data.iterator(); + while (iter.hasNext()) { ArrayList<?> row = (ArrayList<?>)iter.next(); + if (((Boolean)row.get(0)).booleanValue()) { - return true; + return true; } } + return false; - } + } } diff --git a/scripting/workben/installer/IdeWelcome.java b/scripting/workben/installer/IdeWelcome.java index a0d3a5145ee0..c6852bbd639c 100644 --- a/scripting/workben/installer/IdeWelcome.java +++ b/scripting/workben/installer/IdeWelcome.java @@ -25,7 +25,8 @@ 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)); + setBorder(new javax.swing.border.EtchedBorder( + javax.swing.border.EtchedBorder.RAISED)); initComponents(); } @@ -45,13 +46,15 @@ public class IdeWelcome extends javax.swing.JPanel implements ActionListener { 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.hasNetbeansInstallation()) { + area.append("\n \tA version of Netbeans has been detected. \n"); + } welcomePanel.add(area, java.awt.BorderLayout.CENTER); add(welcomePanel, java.awt.BorderLayout.CENTER); - NavPanel nav = new NavPanel(wizard, false, true, true, "", InstallWizard.IDEVERSIONS); + NavPanel nav = new NavPanel(wizard, false, true, true, "", + InstallWizard.IDEVERSIONS); nav.setNextListener(this); add(nav, java.awt.BorderLayout.SOUTH); @@ -62,8 +65,7 @@ public class IdeWelcome extends javax.swing.JPanel implements ActionListener { return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT); } - public void actionPerformed(ActionEvent ev) - { + public void actionPerformed(ActionEvent ev) { //Perform next actions here... } diff --git a/scripting/workben/installer/InstUtil.java b/scripting/workben/installer/InstUtil.java index d9bab179344f..262ce6c01e6b 100644 --- a/scripting/workben/installer/InstUtil.java +++ b/scripting/workben/installer/InstUtil.java @@ -35,12 +35,14 @@ public class InstUtil { String os = System.getProperty("os.name"); if (os.indexOf("Windows") != -1) { - boolean bSVersionInHomeDir = new File(thePath.toString() + "sversion.ini").exists(); + 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"); @@ -50,14 +52,14 @@ public class InstUtil { theFile = new File(thePath.toString()); } - if (theFile == null) - { + 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()) - { + + if (!theFile.exists()) { throw new IOException("Could not locate the OpenOffice settings file.\nAre you sure StarOffice is installed on your system?"); } + return theFile; } @@ -65,28 +67,28 @@ public class InstUtil { public static boolean hasNetbeansInstallation() { boolean result = false; - result = checkForSupportedVersion( getNetbeansLocation(), versions ); + result = checkForSupportedVersion(getNetbeansLocation(), versions); if (!result) System.out.println("No supported version of NetBeans found."); + return result; } - private static boolean checkForSupportedVersion( Properties installs, String[] supportedVersions ) - { - if ( installs != null ) - { - for ( int index = 0; index < supportedVersions.length; index++ ) - { + private static boolean checkForSupportedVersion(Properties installs, + String[] supportedVersions) { + if (installs != null) { + for (int index = 0; index < supportedVersions.length; index++) { String key = supportedVersions[ index ]; - if ( installs.getProperty(key) != null ) - { + + if (installs.getProperty(key) != null) { // at least one supported version for netbeans present, so return; return true; } } } + return false; } @@ -96,95 +98,93 @@ public class InstUtil { public static Properties getNetbeansLocation() { - Properties results = new Properties(); + Properties results = new Properties(); - StringBuffer str = new StringBuffer(); + StringBuffer str = new StringBuffer(); str.append(System.getProperty("user.home")); str.append(File.separator); - StringBuffer thePath = new StringBuffer(str.toString()); + StringBuffer thePath = new StringBuffer(str.toString()); String os = System.getProperty("os.name"); - if (os.indexOf("Windows") != -1) { - thePath.append(".netbeans"); + if (os.indexOf("Windows") != -1) { + thePath.append(".netbeans"); } else if (os.indexOf("SunOS") != -1) { - thePath.append(".netbeans"); + thePath.append(".netbeans"); } else if (os.indexOf("Linux") != -1) { - thePath.append(".netbeans"); - } - - 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; + thePath.append(".netbeans"); } - } - else - { - System.out.println( "No NetBeans user directory found" ); - return null; + + 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; + return results; } - private static String getNetbeansInstallation( File logFile ) { + private static String getNetbeansInstallation(File logFile) { String installPath = ""; + try { - BufferedReader reader = new BufferedReader(new FileReader(logFile)); + BufferedReader reader = new BufferedReader(new FileReader(logFile)); + + for (String s = reader.readLine(); s != null; s = reader.readLine()) { + if (s.indexOf("IDE Install") != -1) { + int pathStart = s.indexOf("=") + 2; + installPath = s.substring(pathStart, s.length()); + int pathEnd = installPath.indexOf(";"); + installPath = installPath.substring(0, pathEnd) + File.separator; + break; + } + } - for (String s = reader.readLine(); s != null; s = reader.readLine()) { - if( s.indexOf( "IDE Install" ) != -1 ) { - int pathStart = s.indexOf( "=" ) + 2; - installPath = s.substring( pathStart, s.length() ); - int pathEnd = installPath.indexOf( ";"); - installPath = installPath.substring( 0, pathEnd ) +File.separator; - break; - } - } - reader.close(); + reader.close(); + } catch (IOException ioe) { + System.out.println("Error reading Netbeans location information"); } - catch( IOException ioe ) { - System.out.println( "Error reading Netbeans location information" ); - } return installPath; } - private static File findVersionFile(File start) - { + private static File findVersionFile(File start) { File versionFile = null; File files[] = start.listFiles(new VersionFilter()); - if (files.length == 0) - { + + if (files.length == 0) { File dirs[] = start.listFiles(new DirFilter()); - for (int i=0; i< dirs.length; i++) - { + + for (int i = 0; i < dirs.length; i++) { versionFile = findVersionFile(dirs[i]); - if (versionFile != null) - { + + if (versionFile != null) { break; } } - } - else - { + } else { versionFile = files[0]; } @@ -194,10 +194,12 @@ public class InstUtil { private static boolean verifySversionExists(File sversionFile) { if (!sversionFile.exists()) return false; + return true; } - public static Properties getOfficeVersions(File sversionFile) throws IOException { + public static Properties getOfficeVersions(File sversionFile) throws + IOException { BufferedReader reader = new BufferedReader(new FileReader(sversionFile)); String sectionName = null; Properties results = new Properties(); @@ -205,56 +207,60 @@ public class InstUtil { for (String s = reader.readLine(); s != null; s = reader.readLine()) { if (s.length() == 0) continue; + if (s.charAt(0) == '[') { sectionName = s.substring(1, s.length() - 1); continue; } + if ((sectionName != null) && sectionName.equalsIgnoreCase("Versions")) { - int equals = s.indexOf( "=" ); - String officeName = s.substring(0, equals ); + 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; + String instPath = s.substring(equals + 8, s.length()); + String [] parts = new String[2]; + parts[0] = officeName; + parts[1] = instPath + File.separator; if (parts.length == 2) { - try { + 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 { - results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); - } + 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 { + results.put(parts[0].trim(), URLDecoder.decode(url.getPath())); + } + } catch (MalformedURLException eSyntax) { + results.put(parts[0].trim(), parts[1].trim()); + System.err.println("GotHereException"); } - catch (MalformedURLException eSyntax) { - results.put(parts[0].trim(), parts[1].trim()); - System.err.println("GotHereException"); - } - } - else { + } else { System.out.println("not splitting on equals"); } } } + reader.close(); return results; } @@ -266,31 +272,34 @@ public class InstUtil { private 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 - { + + try { f = InstUtil.buildSversionLocation(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); System.out.println(e.getMessage()); } + if (!InstUtil.verifySversionExists(f)) { System.err.println("Problem with sversion.ini"); } + try { InstUtil.getOfficeVersions(f); } catch (IOException e) { e.printStackTrace(); System.err.println(e); } + System.out.println(InstUtil.getJavaVersion()); + if (!InstUtil.isCorrectJavaVersion()) { System.err.println("Not correct Java Version"); } @@ -301,19 +310,14 @@ public class InstUtil { -class DirFilter implements java.io.FileFilter -{ - public boolean accept(File aFile) - { +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) - { +class VersionFilter implements java.io.FileFilter { + public boolean accept(File aFile) { + if (aFile.getName().compareToIgnoreCase("sversion.ini") == 0) { return true; } diff --git a/scripting/workben/installer/InstallListener.java b/scripting/workben/installer/InstallListener.java index 6dd111559902..81a005668369 100644 --- a/scripting/workben/installer/InstallListener.java +++ b/scripting/workben/installer/InstallListener.java @@ -18,7 +18,6 @@ package installer; -public interface InstallListener -{ +public interface InstallListener { void installationComplete(InstallationEvent e); } diff --git a/scripting/workben/installer/InstallWizard.java b/scripting/workben/installer/InstallWizard.java index c02f5f13b904..fc9d3bdf19da 100644 --- a/scripting/workben/installer/InstallWizard.java +++ b/scripting/workben/installer/InstallWizard.java @@ -25,77 +25,78 @@ 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()) +public class InstallWizard extends javax.swing.JFrame implements + ActionListener { + /* + private static class ShutdownHook extends Thread { + public void run() { - 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 - } + if (InstallWizard.isInstallStarted()) + { + // Check for and backup any config.xml files + // Check for and backup any StarBasic macro files + // Check for and backup ProtocolHandler - System.out.println( "ShutdownHook" ); + 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 } - InstUtil.removeTmpDir(); - } - }// class ShutdownHook + System.out.println( "ShutdownHook" ); + } - static { - Runtime rt=Runtime.getRuntime(); - rt.addShutdownHook(new 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(); - } - - setBackground(new Color(0,0,0)); - locations = new ArrayList<String>(); - 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); + 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(); + } + + setBackground(new Color(0, 0, 0)); + locations = new ArrayList<String>(); + 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 @@ -137,40 +138,39 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener screens.add(WELCOME, new Welcome(this)); version = new Version(this); screens.add(VERSIONS, version); - _final = new Final(this); + _final = new Final(this); screens.add(FINAL, _final); - boolean hasIDEInstallation = ( InstUtil.hasNetbeansInstallation() ) ; + 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); + } - 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); + navNext.addActionListener(this); + navNext.addActionListener(version); + navNext.addActionListener(_final); - if( hasIDEInstallation ) - { - navNext.addActionListener(ideversion); - navNext.addActionListener(idefinal); - } + if (hasIDEInstallation) { + navNext.addActionListener(ideversion); + navNext.addActionListener(idefinal); + } - navCancel.addActionListener(this); - navBack.addActionListener(this); + 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); + 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 @@ -180,41 +180,33 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener } - public void actionPerformed(ActionEvent e) - { - if (e.getSource() == navNext) - { + public void actionPerformed(ActionEvent e) { + if (e.getSource() == navNext) { ((CardLayout)screens.getLayout()).next(screens); - } + } - if (e.getSource() == navCancel) - { + if (e.getSource() == navCancel) { exitForm(); - } + } - if (e.getSource() == navBack) - { + if (e.getSource() == navBack) { ((CardLayout)screens.getLayout()).previous(screens); - } + } }// actionPerformed - public static void storeLocation(String path) - { + public static void storeLocation(String path) { locations.add(path); } - public static ArrayList<String> getLocations() - { + public static ArrayList<String> getLocations() { return locations; } - public static void clearLocations() - { + public static void clearLocations() { locations.clear(); } - public void show(String cardName) - { + public void show(String cardName) { ((CardLayout)screens.getLayout()).show(screens, cardName); } @@ -231,14 +223,19 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener 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; + i++; } @@ -250,21 +247,21 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener try { System.out.println("Log file is: " + - System.getProperty("user.dir") + - File.separator + "SFrameworkInstall.log"); + System.getProperty("user.dir") + + File.separator + "SFrameworkInstall.log"); - LogStream log = new LogStream( "SFrameworkInstall.log" ); + LogStream log = new LogStream("SFrameworkInstall.log"); System.setErr(log); System.setOut(log); - } - catch( FileNotFoundException fnfe ) { + } catch (FileNotFoundException fnfe) { System.err.println("Error: Unable to create log file: " - + fnfe.getMessage()); + + fnfe.getMessage()); System.exit(-1); } if (officePath != null) { - XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall, bBindingsInstall ); + XmlUpdater xud = new XmlUpdater(officePath, label, progressbar, bNetworkInstall, + bBindingsInstall); xud.run(); } @@ -292,23 +289,19 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener - public static synchronized void setPatchedTypes(boolean value) - { + public static synchronized void setPatchedTypes(boolean value) { bPatchedTypes = value; } - public static synchronized void setPatchedJava(boolean value) - { + public static synchronized void setPatchedJava(boolean value) { bPatchedJava = value; } - public static synchronized void setPatchedRDB(boolean value) - { + public static synchronized void setPatchedRDB(boolean value) { bPatchedRDB = value; } - public static synchronized void setInstallStarted(boolean value) - { + public static synchronized void setInstallStarted(boolean value) { bInstallStarted = value; } diff --git a/scripting/workben/installer/InstallationEvent.java b/scripting/workben/installer/InstallationEvent.java index cdac2dc2cda7..9d91f9bf4505 100644 --- a/scripting/workben/installer/InstallationEvent.java +++ b/scripting/workben/installer/InstallationEvent.java @@ -18,23 +18,19 @@ package installer; -public class InstallationEvent -{ +public class InstallationEvent { private Object source; private String message; - InstallationEvent(Object source, String message) - { + InstallationEvent(Object source, String message) { this.source = source; this.message = message; } - public Object getSource() - { + public Object getSource() { return source; } - public String getMessage() - { + public String getMessage() { return message; } } diff --git a/scripting/workben/installer/LogStream.java b/scripting/workben/installer/LogStream.java index 3fde653709f3..27f33860d9d2 100644 --- a/scripting/workben/installer/LogStream.java +++ b/scripting/workben/installer/LogStream.java @@ -25,46 +25,36 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; -public class LogStream extends PrintStream -{ - static final private DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z: "); +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; + private String getTimeStamp() { + String timeStamp = formatter.format(new Date()); + return timeStamp; } - public LogStream( String logFileName ) throws java.io.FileNotFoundException - { - super( new FileOutputStream( logFileName ) ); + public LogStream(String logFileName) throws java.io.FileNotFoundException { + super(new FileOutputStream(logFileName)); } @Override - public void println(String x) - { - super.println( getTimeStamp() + x ); + 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] ); + 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 ); + } catch (java.io.FileNotFoundException fe) { + System.err.println("Error creating logStream: " + fe); fe.printStackTrace(); } - } - else - { + } 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 index d8718e1257d1..89cfed25b1de 100644 --- a/scripting/workben/installer/NavPanel.java +++ b/scripting/workben/installer/NavPanel.java @@ -23,9 +23,11 @@ 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) { + 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)); + setBorder(new javax.swing.border.EtchedBorder( + javax.swing.border.EtchedBorder.LOWERED)); this.wizard = wizard; this.next = next; this.prev = prev; @@ -36,7 +38,7 @@ public class NavPanel extends JPanel implements ActionListener { gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1); - gridBagConstraints1.anchor = GridBagConstraints.WEST; + gridBagConstraints1.anchor = GridBagConstraints.WEST; gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.gridx = 2; @@ -70,24 +72,26 @@ public class NavPanel extends JPanel implements ActionListener { } public void enableIDE(boolean bEnable) { - ideDetected = 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(); - } - enableIDE(false); + if (ideDetected) { + wizard.show(InstallWizard.IDEWELCOME); + } else { + wizard.exitForm(); + } + + enableIDE(false); } } @@ -107,8 +111,7 @@ public class NavPanel extends JPanel implements ActionListener { - public void removeCancelListener(ActionListener listener) - { + public void removeCancelListener(ActionListener listener) { navCancel.removeActionListener(listener); } diff --git a/scripting/workben/installer/Register.java b/scripting/workben/installer/Register.java index a3634143bd2e..afe95f5d1de6 100644 --- a/scripting/workben/installer/Register.java +++ b/scripting/workben/installer/Register.java @@ -20,85 +20,88 @@ package installer; import java.io.*; import javax.swing.*; -public class Register{ +public class Register { public static boolean register(String path, JLabel statusLabel) { String[] packages = {"ooscriptframe.zip", "bshruntime.zip", "jsruntime.zip"}; - try { - boolean goodResult = false; - String env[] = new String[1]; + try { + boolean goodResult = false; + String env[] = new String[1]; ExecCmd command = new ExecCmd(); - boolean isWindows = + boolean isWindows = (System.getProperty("os.name").indexOf("Windows") != -1); - String progpath = path.concat("program" + File.separator); + 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..."); + 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; + if (!isWindows) { + env[0] = "LD_LIBRARY_PATH=" + progpath; - goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null ); + goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null); - if ( goodResult ){ + if (goodResult) { cmd = progpath + "pkgchk -s -f " + progpath + packages[i]; - System.err.println(cmd); + System.err.println(cmd); goodResult = command.exec(cmd, env); } - } - else { + } else { cmd = "\"" + progpath + "pkgchk.exe\" -s -f \"" + progpath + - packages[i] + "\""; + packages[i] + "\""; - System.err.println(cmd); - goodResult =command.exec(cmd,null); + 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 + "\""); + if (!isWindows) + System.err.println("Command: " + cmd + "\n" + env[0]); + else + System.err.println("Command: \"" + cmd + "\""); - statusLabel.setText( + statusLabel.setText( "PkgChk Failed, please view SFrameworkInstall.log"); - return false; + 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"); + + 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; } - } - 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; + return true; }// register }//Register diff --git a/scripting/workben/installer/Version.java b/scripting/workben/installer/Version.java index 2540f62f3dd6..8ede6c54527e 100644 --- a/scripting/workben/installer/Version.java +++ b/scripting/workben/installer/Version.java @@ -27,12 +27,13 @@ import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; -public class Version extends javax.swing.JPanel implements ActionListener, TableModelListener { +public class Version extends javax.swing.JPanel implements ActionListener, + TableModelListener { /** Creates new form Welcome */ public Version(InstallWizard wizard) { - this.wizard=wizard; - setBackground(Color.white); + this.wizard = wizard; + setBackground(Color.white); initComponents(); } @@ -49,44 +50,46 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table System.out.println("Initialising versions"); File fileVersions = null; - try - { + + try { fileVersions = InstUtil.buildSversionLocation(); - } - catch(IOException eFnF) - { + } catch (IOException eFnF) { System.err.println("Cannot find sversion.ini/.sversionrc"); - JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(this, eFnF.getMessage(), "File not Found", + JOptionPane.ERROR_MESSAGE); wizard.exitForm(); - } + } try { props = InstUtil.getOfficeVersions(fileVersions); - } - catch (IOException eIO) { + } 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); + JOptionPane.showMessageDialog(this, + "There was a problem reading from the Office settings file.", "Parse Error", + JOptionPane.ERROR_MESSAGE); wizard.exitForm(); } tableModel = new MyTableModel(props); - if (tableModel.getRowCount() == 0) - { - JOptionPane.showMessageDialog(this, "No compatible versions of Office were found.", "Invalid versions", JOptionPane.ERROR_MESSAGE); + + if (tableModel.getRowCount() == 0) { + JOptionPane.showMessageDialog(this, + "No compatible versions of Office were found.", "Invalid versions", + JOptionPane.ERROR_MESSAGE); wizard.exitForm(); - } + } tableModel.addTableModelListener(this); JTable tableVersions = new JTable(tableModel) { @Override - public String getToolTipText(MouseEvent event) - { - int col = columnAtPoint( event.getPoint() ); + public String getToolTipText(MouseEvent event) { + int col = columnAtPoint(event.getPoint()); + if (col != 2) return null; - int row = rowAtPoint( event.getPoint() ); + int row = rowAtPoint(event.getPoint()); Object o = getValueAt(row, col); if (o == null) @@ -99,14 +102,14 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table } @Override - public Point getToolTipLocation(MouseEvent event) - { - int col = columnAtPoint( event.getPoint() ); + 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); + int row = rowAtPoint(event.getPoint()); + Object o = getValueAt(row, col); if (o == null) return null; @@ -115,7 +118,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table return null; Point pt = getCellRect(row, col, true).getLocation(); - pt.translate(-1,-2); + pt.translate(-1, -2); return pt; } }; @@ -123,7 +126,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table JScrollPane scroll = new JScrollPane(tableVersions); tableVersions.setPreferredSize( - new Dimension(InstallWizard.DEFWIDTH,InstallWizard.DEFHEIGHT)); + new Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT)); tableVersions.setRowSelectionAllowed(false); tableVersions.setColumnSelectionAllowed(false); @@ -132,13 +135,15 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table initColumnSizes(tableVersions, tableModel); versionPanel.add(scroll); - JTextArea area = new JTextArea("Please select the Office version you wish to Update"); + 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 = new NavPanel(wizard, true, false, true, InstallWizard.WELCOME, + InstallWizard.FINAL); nav.setNextListener(this); add(nav, BorderLayout.SOUTH); @@ -158,9 +163,9 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table try { comp = column.getHeaderRenderer(). - getTableCellRendererComponent( - null, column.getHeaderValue(), - false, false, 0, 0); + getTableCellRendererComponent( + null, column.getHeaderValue(), + false, false, 0, 0); headerWidth = comp.getPreferredSize().width; } catch (NullPointerException e) { // System.err.println("Null pointer exception!"); @@ -175,19 +180,19 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table System.out.println("longValues: " + longValues[i]); comp = table.getDefaultRenderer(model.getColumnClass(i)). - getTableCellRendererComponent( - table, longValues[i], - false, false, 0, 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)); + + i + ". " + + "preferredWidth = " + preferredWidth + + "; totalWidth = " + totalWidth + + "; leftWidth = " + (InstallWizard.DEFWIDTH - totalWidth)); } //XXX: Before Swing 1.1 Beta 2, use setMinWidth instead. @@ -196,8 +201,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table column.setPreferredWidth(InstallWizard.DEFWIDTH - totalWidth); else column.setPreferredWidth(preferredWidth); - } - else { + } else { column.setMinWidth(preferredWidth); totalWidth += preferredWidth; } @@ -213,8 +217,10 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table public void actionPerformed(ActionEvent ev) { InstallWizard.clearLocations(); int len = tableModel.data.size(); + for (int i = 0; i < len; i++) { ArrayList<?> list = tableModel.data.get(i); + if (((Boolean)list.get(0)).booleanValue()) InstallWizard.storeLocation((String)list.get(2)); } @@ -224,8 +230,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table public void tableChanged(TableModelEvent e) { if (tableModel.isAnySelected()) { nav.enableNext(true); - } - else { + } else { nav.enableNext(false); } } @@ -244,42 +249,44 @@ class MyTableModel extends AbstractTableModel { private String colNames[] = {"", "Name", "Location"}; Object[] longValues = new Object[] {Boolean.TRUE, "Name", "Location"}; - MyTableModel (Properties properties) { + MyTableModel(Properties properties) { data = new ArrayList<ArrayList<Object>>(); boolean isWindows = (System.getProperty("os.name").indexOf("Windows") != -1); + for (Enumeration e = properties.propertyNames(); e.hasMoreElements() ;) { String key = (String)e.nextElement(); String path = null; - if ( !( key.startsWith("#") ) && - ( path = properties.getProperty(key)) != null) { + if (!(key.startsWith("#")) && + (path = properties.getProperty(key)) != null) { String pkgChkPath = path + File.separator + "program" + File.separator; - if ( isWindows ) - { + + if (isWindows) { pkgChkPath += "pkgchk.exe"; - } - else - { + } else { pkgChkPath += "pkgchk"; } - File pkgChk = new File( pkgChkPath ); - if ( pkgChk.exists() ) - { + + File pkgChk = new File(pkgChkPath); + + if (pkgChk.exists()) { ArrayList<Object> row = new ArrayList<Object>(); row.add(0, 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); + data.add(row); } } } @@ -328,12 +335,15 @@ class MyTableModel extends AbstractTableModel { public boolean isAnySelected() { Iterator iter = data.iterator(); + while (iter.hasNext()) { ArrayList<?> row = (ArrayList<?>)iter.next(); + if (((Boolean)row.get(0)).booleanValue()) { return true; } } + return false; } diff --git a/scripting/workben/installer/Welcome.java b/scripting/workben/installer/Welcome.java index a2c5f0f7ed37..c71a7af6b4fb 100644 --- a/scripting/workben/installer/Welcome.java +++ b/scripting/workben/installer/Welcome.java @@ -24,8 +24,9 @@ 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)); + this.wizard = wizard; + setBorder(new javax.swing.border.EtchedBorder( + javax.swing.border.EtchedBorder.RAISED)); initComponents(); } @@ -37,7 +38,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { private void initComponents() {//GEN-BEGIN:initComponents welcomePanel = new javax.swing.JPanel(); area = new javax.swing.JTextArea(); - nextButtonEnable = true; + nextButtonEnable = true; setLayout(new java.awt.BorderLayout()); @@ -46,19 +47,20 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { area.setLineWrap(true); String message = "\n\tOffice Scripting Framework Version 0.3" + - "\n\n\n\tPlease ensure that you have exited from Office"; + "\n\n\n\tPlease ensure that you have exited from Office"; - setUpWelcomePanel(message); + setUpWelcomePanel(message); }//GEN-END:initComponents - private void setUpWelcomePanel(String message){ - area.setText( message ); + 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); + NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", + InstallWizard.VERSIONS); + nav.setNextListener(this); + add(nav, java.awt.BorderLayout.SOUTH); } @@ -67,8 +69,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { return new java.awt.Dimension(InstallWizard.DEFWIDTH, InstallWizard.DEFHEIGHT); } - public void actionPerformed(ActionEvent ev) - { + public void actionPerformed(ActionEvent ev) { //Perform next actions here... } diff --git a/scripting/workben/installer/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java index 3424cd57d110..c7bd2ff6ac3a 100644 --- a/scripting/workben/installer/XmlUpdater.java +++ b/scripting/workben/installer/XmlUpdater.java @@ -35,8 +35,7 @@ public class XmlUpdater extends Thread { private boolean threadSuspended; private JProgressBar progressBar; - private final String[] bakFiles = - { + private final String[] bakFiles = { "writermenubar.xml", "writerkeybinding.xml", "calcmenubar.xml", @@ -49,8 +48,7 @@ public class XmlUpdater extends Thread { "META-INF" + File.separator + "manifest.xml" }; - private final String[] dirs = - { + private final String[] dirs = { "java" + File.separator + "Highlight", "java" + File.separator + "MemoryUsage", "java" + File.separator + "ScriptFrmwrkHelper", @@ -62,8 +60,7 @@ public class XmlUpdater extends Thread { "javascript" + File.separator + "ExportSheetsToHTML" }; - private final String[] names = - { + private final String[] names = { "java/Highlight/HighlightUtil.java", "java/Highlight/HighlightText.java", "java/Highlight/Highlight.jar", @@ -94,14 +91,15 @@ public class XmlUpdater extends Thread { }; - public XmlUpdater(String installPath, JLabel statusLabel,JProgressBar pBar, boolean netInstall, boolean bindingsInstall) { + 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 ArrayList<InstallListener>(); threadSuspended = false; - progressBar=pBar; + progressBar = pBar; progressBar.setStringPainted(true); }// XmlUpdater @@ -109,8 +107,7 @@ public class XmlUpdater extends Thread { - public void setResume() - { + public void setResume() { threadSuspended = false; notify(); }// setResume @@ -121,156 +118,163 @@ public class XmlUpdater extends Thread { internalThread = Thread.currentThread(); - String progpath=installPath; - progpath= progpath.concat(File.separator+"program"+File.separator); + String progpath = installPath; + progpath = progpath.concat(File.separator + "program" + File.separator); - String starBasicPath=installPath; - starBasicPath= starBasicPath.concat(File.separator+"share"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator); + String starBasicPath = installPath; + starBasicPath = starBasicPath.concat(File.separator + "share" + File.separator + + "basic" + File.separator + "ScriptBindingLibrary" + File.separator); - 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); + 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); progressBar.setString("Unzipping Required Files"); ZipData zd = new ZipData(); - if( (!netInstall) || bindingsInstall) { - String configPath=installPath; - configPath= configPath.concat(File.separator+"user"+File.separator+"config"+File.separator+"soffice.cfg"+File.separator); - String manifestPath=configPath + "META-INF" + File.separator; + if ((!netInstall) || bindingsInstall) { + String configPath = installPath; + configPath = configPath.concat(File.separator + "user" + File.separator + + "config" + File.separator + "soffice.cfg" + File.separator); + 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 configDir = new File(configPath); - File manifestDir = new File( manifestPath ); - if( !manifestDir.isDirectory() ) { - if( !manifestDir.mkdir() ) { - System.out.println( "creating " + manifestPath + "directory failed"); + if (!configDir.isDirectory()) { + if (!configDir.mkdir()) { + System.out.println("creating " + configDir + "directory failed"); + } else { + System.out.println(configDir + "directory created"); } - else { - System.out.println( manifestPath + " 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" ); + } 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++ ) - { + 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" ); + 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)) - { + if (!zd.extractEntry("bindingdialog/writermenubar.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/writerkeybinding.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/writerkeybinding.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/calcmenubar.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/calcmenubar.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/calckeybinding.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/calckeybinding.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/impressmenubar.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/impressmenubar.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/impresskeybinding.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/impresskeybinding.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/drawmenubar.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/drawmenubar.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/drawkeybinding.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/drawkeybinding.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/eventbindings.xml",configPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/eventbindings.xml", configPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/manifest.xml",manifestPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/manifest.xml", manifestPath, statusLabel)) { onInstallComplete(); return; } } - if(!bindingsInstall) { + 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"); + 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" ); + } else + System.out.println("ScriptBindingLibrary exists"); // Adding Scripting Framework and tools - if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel)) - { + if (!zd.extractEntry("sframework/ooscriptframe.zip", progpath, statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("sframework/bshruntime.zip",progpath, statusLabel)) - { + if (!zd.extractEntry("sframework/bshruntime.zip", progpath, statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("sframework/jsruntime.zip",progpath, statusLabel)) - { + if (!zd.extractEntry("sframework/jsruntime.zip", progpath, statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("schema/Scripting.xcs",regSchemaOfficePath, statusLabel)) - { + if (!zd.extractEntry("schema/Scripting.xcs", regSchemaOfficePath, + statusLabel)) { onInstallComplete(); return; } @@ -279,14 +283,16 @@ public class XmlUpdater extends Thread { progressBar.setString("Registering Scripting Framework"); progressBar.setValue(3); - if(!Register.register(installPath+File.separator, statusLabel) ) { - onInstallComplete(); - return; + + if (!Register.register(installPath + File.separator, statusLabel)) { + onInstallComplete(); + return; } + progressBar.setValue(5); String path = installPath + File.separator + - "share" + File.separator + "Scripts" + File.separator; + "share" + File.separator + "Scripts" + File.separator; for (int i = 0; i < dirs.length; i++) { File dir = new File(path + dirs[i]); @@ -294,7 +300,7 @@ public class XmlUpdater extends Thread { if (!dir.exists()) { if (!dir.mkdirs()) { System.err.println("Error making dir: " + - dir.getAbsolutePath()); + dir.getAbsolutePath()); onInstallComplete(); return; } @@ -313,43 +319,48 @@ public class XmlUpdater extends Thread { // Adding binding dialog - if (!zd.extractEntry("bindingdialog/ScriptBinding.xba",starBasicPath, statusLabel)) - { + if (!zd.extractEntry("bindingdialog/ScriptBinding.xba", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/MenuBinding.xdl",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/MenuBinding.xdl", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/KeyBinding.xdl",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/KeyBinding.xdl", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/EventsBinding.xdl",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/EventsBinding.xdl", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/HelpBinding.xdl",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/HelpBinding.xdl", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/EditDebug.xdl",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/EditDebug.xdl", starBasicPath, + statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/dialog.xlb",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/dialog.xlb", starBasicPath, statusLabel)) { onInstallComplete(); return; } - if (!zd.extractEntry("bindingdialog/script.xlb",starBasicPath, statusLabel)) - { + + if (!zd.extractEntry("bindingdialog/script.xlb", starBasicPath, statusLabel)) { onInstallComplete(); return; } @@ -364,16 +375,13 @@ public class XmlUpdater extends Thread { }// run - public void addInstallListener(InstallListener listener) - { + public void addInstallListener(InstallListener listener) { listeners.add(listener); }// addInstallListener - private void onInstallComplete() - { - for (InstallListener l : listeners) - { + private void onInstallComplete() { + for (InstallListener l : listeners) { l.installationComplete(null); } }// onInstallComplete diff --git a/scripting/workben/installer/ZipData.java b/scripting/workben/installer/ZipData.java index 466f87a6e863..6e5d513a16be 100644 --- a/scripting/workben/installer/ZipData.java +++ b/scripting/workben/installer/ZipData.java @@ -24,7 +24,7 @@ import javax.swing.*; public class ZipData { public boolean extractEntry(String entry, String destination, - JLabel statusLabel) { + JLabel statusLabel) { OutputStream out = null; InputStream in = null; @@ -37,6 +37,7 @@ public class ZipData { } String entryName; + if (entry.lastIndexOf("/") != -1) { entryName = entry.substring(entry.lastIndexOf("/") + 1); } else { @@ -44,9 +45,10 @@ public class ZipData { } String destName; + if (destination.lastIndexOf(File.separator) != -1) { destName = destination.substring(destination - .lastIndexOf(File.separator) + 1); + .lastIndexOf(File.separator) + 1); } else { destName = destination; } @@ -60,12 +62,13 @@ public class ZipData { 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"); + + "see SFramework.log for more information"); return false; } @@ -74,11 +77,11 @@ public class ZipData { out = new FileOutputStream(destination); } catch (IOException ioe) { System.err.println("Error opening " + destination + ": " - + ioe.getMessage()); + + ioe.getMessage()); if (statusLabel != null) statusLabel.setText("Error opening" + destination - + "see SFramework.log for more information"); + + "see SFramework.log for more information"); return false; } @@ -91,11 +94,12 @@ public class ZipData { out.write(bytes, 0, len); } catch (IOException ioe) { System.err.println("Error writing " + destination + ": " - + ioe.getMessage()); + + ioe.getMessage()); if (statusLabel != null) statusLabel.setText("Failed writing " + destination - + "see SFramework.log for more information"); + + "see SFramework.log for more information"); + return false; } finally { try { @@ -104,6 +108,7 @@ public class ZipData { } catch (IOException ioe) { } } + return true; } } diff --git a/scripting/workben/mod/_scripting/Dispatch.java b/scripting/workben/mod/_scripting/Dispatch.java index 00b4ee5900bf..20542cf02d10 100644 --- a/scripting/workben/mod/_scripting/Dispatch.java +++ b/scripting/workben/mod/_scripting/Dispatch.java @@ -43,30 +43,34 @@ import com.sun.star.util.XURLTransformer; public class Dispatch extends TestCase { private String scriptURL = "script://HighlightText.showForm"; @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters tParam, PrintWriter log ) throws StatusException { - log.println("creating test environment"); + TestParameters tParam, PrintWriter log) throws StatusException { + log.println("creating test environment"); XInterface oObj = null; URL dispatchURL = null; + try { XMultiServiceFactory xMSF = tParam.getMSF(); SOfficeFactory SOF = null; - SOF = SOfficeFactory.getFactory( xMSF ); - String docPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" ); - XComponent doc = SOF.loadDocument( docPath ); - XModel model = UnoRuntime.queryInterface( XModel.class, - doc ); + SOF = SOfficeFactory.getFactory(xMSF); + String docPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc"); + XComponent doc = SOF.loadDocument(docPath); + XModel model = UnoRuntime.queryInterface(XModel.class, + doc); XFrame frame = model.getCurrentController().getFrame(); - oObj = ( XInterface )xMSF.createInstanceWithArguments( "com.sun.star.comp.ScriptProtocolHandler", new Object[] { frame } ); + oObj = (XInterface) + xMSF.createInstanceWithArguments("com.sun.star.comp.ScriptProtocolHandler", + new Object[] { frame }); - XURLTransformer xParser=UnoRuntime.queryInterface(XURLTransformer.class, - tParam.getMSF().createInstance - ("com.sun.star.util.URLTransformer")); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + tParam.getMSF().createInstance + ("com.sun.star.util.URLTransformer")); // Because it's an in/out parameter we must use an array of // URL objects. URL[] aParseURL = new URL[1]; @@ -81,13 +85,14 @@ public class Dispatch extends TestCase { } TestEnvironment tEnv = new TestEnvironment(oObj) ; - tEnv.addObjRelation( "XDispatchProvider.URL", scriptURL ); - tEnv.addObjRelation( "XDispatch.URL", dispatchURL ); + tEnv.addObjRelation("XDispatchProvider.URL", scriptURL); + tEnv.addObjRelation("XDispatch.URL", dispatchURL); return tEnv ; } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/Function.java b/scripting/workben/mod/_scripting/Function.java index 97c90771a25e..9a2d8b273144 100644 --- a/scripting/workben/mod/_scripting/Function.java +++ b/scripting/workben/mod/_scripting/Function.java @@ -38,29 +38,33 @@ public class Function extends TestCase { private String doc = "doc_with_beanshell_scripts.sxw"; @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters tParam, PrintWriter log ) throws StatusException { + TestParameters tParam, PrintWriter log) throws StatusException { XInterface oObj = null; - XFunctionProvider provider = null; + XFunctionProvider provider = null; log.println("creating test environment"); + try { XMultiServiceFactory xMSF = tParam.getMSF(); SOfficeFactory SOF = null; - SOF = SOfficeFactory.getFactory( xMSF ); + SOF = SOfficeFactory.getFactory(xMSF); String docPath = util.utils.getFullTestURL(doc); - XComponent doc = SOF.loadDocument( docPath ); - XModel model = UnoRuntime.queryInterface( XModel.class, - doc ); + XComponent doc = SOF.loadDocument(docPath); + XModel model = UnoRuntime.queryInterface(XModel.class, + doc); oObj = - (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } ); - provider = UnoRuntime.queryInterface( XFunctionProvider.class, oObj ); - oObj = provider.getFunction( script ); + (XInterface) + xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider", + new Object[] { model }); + provider = UnoRuntime.queryInterface(XFunctionProvider.class, oObj); + oObj = provider.getFunction(script); } catch (com.sun.star.uno.Exception e) { e.printStackTrace(); @@ -75,7 +79,8 @@ public class Function extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/FunctionProvider.java b/scripting/workben/mod/_scripting/FunctionProvider.java index beb5d6c9f714..8cbedee9935e 100644 --- a/scripting/workben/mod/_scripting/FunctionProvider.java +++ b/scripting/workben/mod/_scripting/FunctionProvider.java @@ -34,25 +34,29 @@ public class FunctionProvider extends TestCase { String docPath = null; @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters tParam, PrintWriter log ) throws StatusException { + TestParameters tParam, PrintWriter log) throws StatusException { XInterface oObj = null; - log.println("creating test environment"); + log.println("creating test environment"); + try { XMultiServiceFactory xMSF = tParam.getMSF(); - Object xInterface = xMSF.createInstance( "com.sun.star.frame.Desktop" ); - XDesktop dtop = UnoRuntime.queryInterface( XDesktop.class, - xInterface ); + Object xInterface = xMSF.createInstance("com.sun.star.frame.Desktop"); + XDesktop dtop = UnoRuntime.queryInterface(XDesktop.class, + xInterface); XModel model = dtop.getCurrentFrame().getController().getModel(); oObj = - (XInterface)xMSF.createInstanceWithArguments( "drafts.com.sun.star.script.framework.provider.FunctionProvider", new Object[]{ model } ); + (XInterface) + xMSF.createInstanceWithArguments("drafts.com.sun.star.script.framework.provider.FunctionProvider", + new Object[] { model }); } catch (com.sun.star.uno.Exception e) { @@ -66,7 +70,8 @@ public class FunctionProvider extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/ScriptInfo.java b/scripting/workben/mod/_scripting/ScriptInfo.java index 8001ca99d5c7..05b7b3d0c80e 100644 --- a/scripting/workben/mod/_scripting/ScriptInfo.java +++ b/scripting/workben/mod/_scripting/ScriptInfo.java @@ -36,51 +36,58 @@ public class ScriptInfo extends TestCase { String docPath = null; @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { // Get path to test documents - String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" ); - System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath ); - rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" ); - if ( rootDocPath != null && rootDocPath.length() > 1 ){ + String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH"); + System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath); + rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc"); + + if (rootDocPath != null && rootDocPath.length() > 1) { // convert all "\\" to "/", necessary for UCB - if ( rootDocPath.indexOf( "\\" ) > 0 ){ - rootDocPath = rootDocPath.replace( '\\','/' ); - } + if (rootDocPath.indexOf("\\") > 0) { + rootDocPath = rootDocPath.replace('\\', '/'); + } + System.out.println("After processing the path is " + rootDocPath); - // encode the ulr (for UCB) - String encodedPath = URLEncoder.encode( rootDocPath ); - System.out.println("The encoded path is " + encodedPath ); + // encode the ulr (for UCB) + String encodedPath = URLEncoder.encode(rootDocPath); + System.out.println("The encoded path is " + encodedPath); docPath = "vnd.sun.star.pkg://" + encodedPath; - System.out.println( "docPath path is " + docPath ); + System.out.println("docPath path is " + docPath); } } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters tParam, PrintWriter log ) throws StatusException { + TestParameters tParam, PrintWriter log) throws StatusException { - log.println("creating test environment"); - if ( docPath == null ){ + log.println("creating test environment"); + + if (docPath == null) { log.println("Testdata not set up, docPath is null"); throw new StatusException( "Can't create object environment, no test document available", - new Exception() ) ; + new Exception()) ; } XInterface oObj = null; XSimpleFileAccess access = null; + try { XMultiServiceFactory xMSF = tParam.getMSF(); Object xInterface = - xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" ); - access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); + xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); Object storageObj = xMSF.createInstanceWithArguments( - "drafts.com.sun.star.script.framework.storage.ScriptStorage", - new Object[]{ access, Integer.valueOf(99), docPath } ); - XScriptInfoAccess infoAccess = UnoRuntime.queryInterface(XScriptInfoAccess.class, storageObj); - XScriptInfo[] infos = infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document"); - oObj = infos[0]; + "drafts.com.sun.star.script.framework.storage.ScriptStorage", + new Object[] { access, Integer.valueOf(99), docPath }); + XScriptInfoAccess infoAccess = UnoRuntime.queryInterface( + XScriptInfoAccess.class, storageObj); + XScriptInfo[] infos = + infoAccess.getImplementations("script://MemoryUtils.MemUsage?location=document"); + oObj = infos[0]; } catch (com.sun.star.uno.Exception e) { throw new StatusException("Can't create object environment", e) ; } @@ -92,7 +99,8 @@ public class ScriptInfo extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java index 79f84ac109ec..6051adb1ae70 100644 --- a/scripting/workben/mod/_scripting/ScriptRuntimeManager.java +++ b/scripting/workben/mod/_scripting/ScriptRuntimeManager.java @@ -28,20 +28,21 @@ import lib.TestParameters; public class ScriptRuntimeManager extends TestCase { @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log ) throws StatusException { + TestParameters Param, PrintWriter log) throws StatusException { - log.println("creating test environment"); + log.println("creating test environment"); XInterface oObj = null; try { oObj = (XInterface) Param.getMSF().createInstance - ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager"); + ("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeManager"); } catch (com.sun.star.uno.Exception e) { throw new StatusException("Can't create object environment", e) ; } @@ -53,7 +54,8 @@ public class ScriptRuntimeManager extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/ScriptStorage.java b/scripting/workben/mod/_scripting/ScriptStorage.java index dc8749bf103f..c09f24c083fd 100644 --- a/scripting/workben/mod/_scripting/ScriptStorage.java +++ b/scripting/workben/mod/_scripting/ScriptStorage.java @@ -33,48 +33,53 @@ public class ScriptStorage extends TestCase { String docPath = null; @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { // Get path to test documents - String rootDocPath = ( String )tParam.get( "TEST_DOCUMENT_PATH" ); - System.out.println( "TEST_DOCUMENT_PATH is " + rootDocPath ); - rootDocPath = util.utils.getFullTestURL( "ExampleSpreadSheetLatest.sxc" ); - if ( rootDocPath != null && rootDocPath.length() > 1 ){ + String rootDocPath = (String)tParam.get("TEST_DOCUMENT_PATH"); + System.out.println("TEST_DOCUMENT_PATH is " + rootDocPath); + rootDocPath = util.utils.getFullTestURL("ExampleSpreadSheetLatest.sxc"); + + if (rootDocPath != null && rootDocPath.length() > 1) { // convert all "\\" to "/", necessary for UCB - if ( rootDocPath.indexOf( "\\" ) > 0 ){ - rootDocPath = rootDocPath.replace( '\\','/' ); - } + if (rootDocPath.indexOf("\\") > 0) { + rootDocPath = rootDocPath.replace('\\', '/'); + } + System.out.println("After processing the path is " + rootDocPath); - // encode the ulr (for UCB) - String encodedPath = URLEncoder.encode( rootDocPath ); - System.out.println("The encoded path is " + encodedPath ); + // encode the ulr (for UCB) + String encodedPath = URLEncoder.encode(rootDocPath); + System.out.println("The encoded path is " + encodedPath); docPath = "vnd.sun.star.pkg://" + encodedPath; - System.out.println( "docPath path is " + docPath ); + System.out.println("docPath path is " + docPath); } } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters tParam, PrintWriter log ) throws StatusException { + TestParameters tParam, PrintWriter log) throws StatusException { - log.println("creating test environment"); - if ( docPath == null ){ + log.println("creating test environment"); + + if (docPath == null) { log.println("Testdata not set up, docPath is null"); throw new StatusException( "Can't create object environment, no test document available", - new Exception() ) ; + new Exception()) ; } XInterface oObj = null; XSimpleFileAccess access = null; + try { XMultiServiceFactory xMSF = tParam.getMSF(); Object xInterface = - xMSF.createInstance( "com.sun.star.ucb.SimpleFileAccess" ); - access = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); - oObj = ( XInterface )xMSF.createInstanceWithArguments( - "drafts.com.sun.star.script.framework.storage.ScriptStorage", - new Object[]{ access, Integer.valueOf(99), docPath } ); + xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); + access = UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + oObj = (XInterface)xMSF.createInstanceWithArguments( + "drafts.com.sun.star.script.framework.storage.ScriptStorage", + new Object[] { access, Integer.valueOf(99), docPath }); } catch (com.sun.star.uno.Exception e) { throw new StatusException("Can't create object environment", e) ; @@ -87,7 +92,8 @@ public class ScriptStorage extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/ScriptStorageManager.java b/scripting/workben/mod/_scripting/ScriptStorageManager.java index 64d993edfdc4..b18c613f59e8 100644 --- a/scripting/workben/mod/_scripting/ScriptStorageManager.java +++ b/scripting/workben/mod/_scripting/ScriptStorageManager.java @@ -32,31 +32,32 @@ import lib.TestParameters; public class ScriptStorageManager extends TestCase { @Override - public void initialize( TestParameters tParam, PrintWriter log ) { + public void initialize(TestParameters tParam, PrintWriter log) { } @Override + public synchronized TestEnvironment createTestEnvironment( - TestParameters Param, PrintWriter log ) throws StatusException { + TestParameters Param, PrintWriter log) throws StatusException { XInterface oObj = null; - Object oInterface = null; + Object oInterface = null; - try { + try { XMultiServiceFactory xMSF = Param.getMSF(); XPropertySet xProp = UnoRuntime.queryInterface( - XPropertySet.class, xMSF); + XPropertySet.class, xMSF); // get context XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, - xProp.getPropertyValue("DefaultContext")); + xProp.getPropertyValue("DefaultContext")); // get the script storage manager from context oInterface = xContext.getValueByName("/singletons/" + - "drafts.com.sun.star.script.framework.storage.theScriptStorageManager"); - } - catch( Exception e ) { - log.println("ScriptStorageManager singleton service not available" ); - e.printStackTrace(); + "drafts.com.sun.star.script.framework.storage.theScriptStorageManager"); + } catch (Exception e) { + log.println("ScriptStorageManager singleton service not available"); + e.printStackTrace(); } + oObj = (XInterface) oInterface; TestEnvironment tEnv = new TestEnvironment(oObj) ; @@ -66,7 +67,8 @@ public class ScriptStorageManager extends TestCase { } @Override - public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + + public synchronized void disposeTestEnvironment(TestEnvironment tEnv, TestParameters tParam) { } } diff --git a/scripting/workben/mod/_scripting/TestDataLoader.java b/scripting/workben/mod/_scripting/TestDataLoader.java index 63d360e6a678..6f8078656058 100644 --- a/scripting/workben/mod/_scripting/TestDataLoader.java +++ b/scripting/workben/mod/_scripting/TestDataLoader.java @@ -56,8 +56,7 @@ public class TestDataLoader { current = previous = st.nextToken(); list.add(getParameters(st)); - } - else { + } else { in.close(); return; } @@ -78,14 +77,13 @@ public class TestDataLoader { tEnv.addObjRelation(previous, list); in.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { } } private static Parameters getParameters(StringTokenizer st) { String separator = "="; - HashMap<String,Object> map = new HashMap<String,Object>(5); + HashMap<String, Object> map = new HashMap<String, Object>(5); while (st.hasMoreTokens()) { String pair = st.nextToken(); @@ -98,12 +96,15 @@ public class TestDataLoader { continue; name = tokens.nextToken(); + if (tokens.countTokens() == 1) value = tokens.nextToken(); else { StringBuffer buf = new StringBuffer(tokens.nextToken()); + while (tokens.hasMoreTokens()) buf.append(separator).append(tokens.nextToken()); + value = buf.toString(); } |