Javascript EASE script error : Invalid thread access [message #1860818] |
Mon, 04 September 2023 13:20  |
Eclipse User |
|
|
|
Hello!
I want to automate some UI action with Javascript. As a start I wanted to select the entire source code and indent the code properly.
So I wrote some code, but I get the error:
======
org.eclipse.ease.ScriptExecutionException: JavaError: Invalid thread access
at hello.js,workspace://Andy_Refactorer/scripts/hello.js
Java Stacktrace:
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4918)
at org.eclipse.swt.SWT.error(SWT.java:4833)
at org.eclipse.swt.SWT.error(SWT.java:4804)
at org.eclipse.swt.widgets.Widget.error(Widget.java:565)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:481)
at org.eclipse.swt.custom.StyledText.getBlockSelection(StyledText.java:3163)
at org.eclipse.jface.text.TextViewer.computeSelection(TextViewer.java:2487)
at org.eclipse.jface.text.TextViewer.getSelection(TextViewer.java:2481)
at org.eclipse.ui.texteditor.AbstractTextEditor.doGetSelection(AbstractTextEditor.java:2890)
at org.eclipse.ui.texteditor.AbstractTextEditor$SelectionProvider.getSelection(AbstractTextEditor.java:1428)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
at org.mozilla.javascript.gen.workspace___Andy_Refactorer_scripts_hello_js_6._c_script_0(Unknown Source)
at org.mozilla.javascript.gen.workspace___Andy_Refactorer_scripts_hello_js_6.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508)
at org.mozilla.javascript.gen.workspace___Andy_Refactorer_scripts_hello_js_6.call(Unknown Source)
at org.mozilla.javascript.gen.workspace___Andy_Refactorer_scripts_hello_js_6.exec(Unknown Source)
at org.mozilla.javascript.Context.evaluateReader(Context.java:1293)
at org.eclipse.ease.lang.javascript.rhino.RhinoScriptEngine.internalExecute(RhinoScriptEngine.java:223)
at org.eclipse.ease.lang.javascript.rhino.RhinoScriptEngine.execute(RhinoScriptEngine.java:202)
at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:190)
at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:243)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
======
So, the problem seems to be, that my code does not run in the UI thread. I found some hint, that one can add
thread: UI
to the magic header. For Java there seems to the UIJob class, but how does this work in Javascript?
Thanks in advance for any help!
Ciao,
Andreas
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02635 seconds