summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2004-07-23 13:03:38 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2004-07-23 13:03:38 +0000
commit3637361af0307edeffcc069c0d14e59fae8c1ffe (patch)
tree9d9771f4907163120e393d0e45b4cdb7b0b8f669 /scripting
parent679b4b044caccc9a38166f942b0dce0b1a3173dc (diff)
INTEGRATION: CWS scriptingf7 (1.3.14); FILE MERGED
2004/07/14 09:07:10 npower 1.3.14.3: #i25260# Editors changes to support new methods in ScriptEditor interface { execute & indicateErrorLine }. ScriptProviders now raise editors with line of error highlighted. 2004/07/12 16:34:37 npower 1.3.14.2: #i25260# Changes to support error displayed in IDE for javascript and beanshell when script that is invoked is opened in IDE Issue number: Submitted by: Reviewed by: 2004/06/30 11:57:37 npower 1.3.14.1: #i25870# Changes to BeanshellProvider and editor to make sure that the classloader is setup correctly such that scripts run from the IDE use the classpath defined in parcel-descriptor.xml
Diffstat (limited to 'scripting')
-rw-r--r--scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java58
1 files changed, 40 insertions, 18 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
index ffd378fff3aa..d103a1dd6248 100644
--- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
+++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptSourceModel.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ScriptSourceModel.java,v $
*
-* $Revision: 1.3 $
+* $Revision: 1.4 $
*
-* last change: $Author: svesik $ $Date: 2004-04-19 23:11:30 $
+* last change: $Author: hr $ $Date: 2004-07-23 14:03:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -126,36 +126,58 @@ public class ScriptSourceModel {
return false;
}
- public void execute(final XScriptContext context)
- throws InvocationTargetException
+ public Object execute(final XScriptContext context, ClassLoader cl )
+ throws Exception
{
+ Object result = null;
// Thread execThread = new Thread() {
// public void run() {
+ if ( cl != null )
+ {
+ // sets this threads class loader
+ // hopefully any threads spawned by this
+ // will inherit this cl
+ // this enables any class files imported
+ // from the interpreter to be loaded
+ // note: setting the classloader on the
+ // interpreter has a slightly different
+ // meaning in that the classloader for
+ // the interpreter seems only to look for
+ // source files ( bla.java ) in the classpath
+ Thread.currentThread().setContextClassLoader(cl);
+ }
bsh.Interpreter interpreter = new bsh.Interpreter();
- interpreter.getNameSpace().clear();
+ if ( cl != null )
+ {
+ // additionally set class loader on the interpreter
+ // to allow it to load java classes defined in source
+ // files e.g. bla.java
+ interpreter.getNameSpace().clear();
+ }
+
// reset position
currentPosition = -1;
view.update();
- try {
- interpreter.set("context", context);
- interpreter.set("ARGUMENTS", new Object[0]);
+ interpreter.set("context", context);
+ interpreter.set("ARGUMENTS", new Object[0]);
- if (view.isModified()) {
- interpreter.eval(view.getText());
- }
- else {
- interpreter.eval(getText());
- }
+ if (view.isModified()) {
+ result = interpreter.eval(view.getText());
}
- catch (bsh.EvalError err) {
- currentPosition = err.getErrorLineNumber() - 1;
- view.update();
- throw new InvocationTargetException(err, err.getErrorText());
+ else {
+ result = interpreter.eval(getText());
}
// }
// };
// execThread.start();
+ return result;
+ }
+ public void indicateErrorLine( int lineNum )
+ {
+ System.out.println("Beanshell indicateErrorLine " + lineNum );
+ currentPosition = lineNum - 1;
+ view.update();
}
}