summaryrefslogtreecommitdiff
path: root/scripting/workben/installer
diff options
context:
space:
mode:
authorTomas O'Connor <toconnor@openoffice.org>2003-02-06 17:19:52 +0000
committerTomas O'Connor <toconnor@openoffice.org>2003-02-06 17:19:52 +0000
commit9279facce23c405806317b1e425533d1011dc177 (patch)
treeec413aadfb37a1a128eb2bd71018fb25ba4cba1a /scripting/workben/installer
parent49b7d6677227beac7b802640bbdf7862fe60676d (diff)
Add BeanShell example scripts.
Diffstat (limited to 'scripting/workben/installer')
-rw-r--r--scripting/workben/installer/XmlUpdater.java147
-rw-r--r--scripting/workben/installer/ZipData.java18
2 files changed, 61 insertions, 104 deletions
diff --git a/scripting/workben/installer/XmlUpdater.java b/scripting/workben/installer/XmlUpdater.java
index 07261146d1fd..c2dd70f2c99c 100644
--- a/scripting/workben/installer/XmlUpdater.java
+++ b/scripting/workben/installer/XmlUpdater.java
@@ -111,12 +111,6 @@ public class XmlUpdater extends Thread {
starBasicPath= starBasicPath.concat(File.separator+"user"+File.separator+"basic"+File.separator+"ScriptBindingLibrary"+File.separator);
//System.out.println( "Office StarBasic path: " + starBasicPath );
- String scriptsPath=installPath;
- scriptsPath= scriptsPath.concat(File.separator+"user"+File.separator+"Scripts"+File.separator+"java"+File.separator);
- String bshScriptsPath = installPath + File.separator + "user" +
- File.separator + "beanshell" + File.separator;
-
- //System.out.println( " Office Scripts Path: " + scriptsPath );
// Get the NetBeans installation
//String netbeansPath=
@@ -152,33 +146,6 @@ public class XmlUpdater extends Thread {
else
System.out.println( "soffice.cfg exists" );
-// Robert Kinsella test 1
-
- //Adding <Office>/user/Scripts/java/
- File scriptsDir = new File( scriptsPath );
- File highlightDir = new File( scriptsPath+"Highlight" );
- File memoryDir = new File( scriptsPath+"MemoryUsage" );
- File bshDir = new File( bshScriptsPath +"InteractiveBeanShell" );
- if( !highlightDir.mkdirs() ) {
- System.out.println( "Highlight script directory failed");
- }
- if( !bshDir.mkdirs() )
- {
- System.out.println( "InteractiveBeanShell script directory failed");
- }
- if( !memoryDir.mkdirs() )
- {
- System.out.println( "MemoryUsage script directory failed");
- }
- else
- {
- System.out.println( "Scripts/java directory created");
- }
-
-//Robert Kinsella test 1 end
-
-
-
//--------------------------------
// Adding Scripting Framework and tools
if (!zd.extractEntry("sframework/ooscriptframe.zip",progpath, statusLabel))
@@ -208,75 +175,55 @@ public class XmlUpdater extends Thread {
//--------------------------------
// Robert Kinsella test 2
- // adding (JAVA) script examples
- File highlightScript = new File( scriptsPath+File.separator+"Highlight"+File.separator+"HighlightUtil.java" );
- if( !highlightScript.exists() ) {
- if (!zd.extractEntry("examples/Highlight/HighlightUtil.java",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/Highlight/HighlightText.java",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/Highlight/Highlight.jar",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/Highlight/parcel-descriptor.xml",scriptsPath+File.separator+"Highlight"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- }
- else {
- System.out.println( "Highlight script already deployed" );
- }
- File memoryScript = new File( scriptsPath+File.separator+"MemoryUsage"+File.separator+"MemoryUsage.java" );
- if( !memoryScript.exists() ) {
- if (!zd.extractEntry("examples/MemoryUsage/MemoryUsage.java",scriptsPath+File.separator+"MemoryUsage"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/MemoryUsage/MemoryUsage.class",scriptsPath+File.separator+"MemoryUsage"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/MemoryUsage/parcel-descriptor.xml",scriptsPath+File.separator+"MemoryUsage"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/MemoryUsage/ExampleSpreadSheet.sxc",scriptsPath+File.separator+"MemoryUsage"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- }
- else {
- System.out.println( "MemoryUsage script already deployed" );
+ String path = installPath + File.separator +
+ "user" + File.separator + "Scripts" + File.separator;
+
+ String[] dirs = {
+ "java" + File.separator + "Highlight",
+ "java" + File.separator + "MemoryUsage",
+ "beanshell" + File.separator + "InteractiveBeanShell",
+ "beanshell" + File.separator + "Highlight",
+ "beanshell" + File.separator + "MemoryUsage"
+ };
+
+ String[] names = {
+ "java/Highlight/HighlightUtil.java",
+ "java/Highlight/HighlightText.java",
+ "java/Highlight/Highlight.jar",
+ "java/Highlight/parcel-descriptor.xml",
+ "java/MemoryUsage/MemoryUsage.java",
+ "java/MemoryUsage/MemoryUsage.class",
+ "java/MemoryUsage/parcel-descriptor.xml",
+ "java/MemoryUsage/ExampleSpreadSheet.sxc",
+ "beanshell/InteractiveBeanShell/parcel-descriptor.xml",
+ "beanshell/InteractiveBeanShell/interactive.bsh",
+ "beanshell/Highlight/parcel-descriptor.xml",
+ "beanshell/Highlight/highlighter.bsh",
+ "beanshell/MemoryUsage/parcel-descriptor.xml",
+ "beanshell/MemoryUsage/memusage.bsh"
+ };
+
+ for (int i = 0; i < dirs.length; i++) {
+ File dir = new File(path + dirs[i]);
+
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ System.err.println("Error making dir: " +
+ dir.getAbsolutePath());
+ onInstallComplete();
+ return;
+ }
+ }
}
- File script = new File( bshScriptsPath+File.separator+"InteractiveBeanShell"+File.separator+"interactive.bsh" );
- if( !script.exists() ) {
- if (!zd.extractEntry("examples/InteractiveBeanShell/interactive.bsh",bshScriptsPath+File.separator+"InteractiveBeanShell"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- if (!zd.extractEntry("examples/InteractiveBeanShell/parcel-descriptor.xml",bshScriptsPath+File.separator+"InteractiveBeanShell"+File.separator, statusLabel))
- {
- onInstallComplete();
- return;
- }
- }
- else {
- System.out.println( "InteractiveBeanShell script already deployed" );
+ for (int i = 0; i < names.length; i++) {
+ String source = "/examples/" + names[i];
+ String dest = path + names[i].replace('/', File.separatorChar);
+
+ if (!zd.extractEntry(source, dest, statusLabel)) {
+ onInstallComplete();
+ return;
+ }
}
// Robert Kinsella test 2 end
diff --git a/scripting/workben/installer/ZipData.java b/scripting/workben/installer/ZipData.java
index f5107e16a744..301d2ef58b64 100644
--- a/scripting/workben/installer/ZipData.java
+++ b/scripting/workben/installer/ZipData.java
@@ -23,17 +23,27 @@ public class ZipData
if (statusLabel != null) {
statusLabel.setText("Copying " + entry);
- System.out.println("Copying " + entry);
}
+ String entryName;
if (entry.lastIndexOf("/") != -1) {
- String name = entry.substring(entry.lastIndexOf("/") + 1);
- destination = destination.concat(name);
+ entryName = entry.substring(entry.lastIndexOf("/") + 1);
}
else {
- destination = destination.concat(entry);
+ entryName = entry;
}
+ String destName;
+ if (destination.lastIndexOf(File.separator) != -1) {
+ destName = destination.substring(destination.lastIndexOf(File.separator) + 1);
+ }
+ else {
+ destName = destination;
+ }
+
+ if (!destName.equals(entryName))
+ destination = destination.concat(entryName);
+
System.out.println("Unzipping " + entry + " to " + destination);
try {