I got problem with following code while using Rhino as a script
language in Eclipse.
/*
* Inforom message
*/
jface = JavaImporter(
org.eclipse.swt,
org.eclipse.swt.widgets,
org.eclipse.jface.dialogs);
with(jface) {
function inform(msg){
println('inform: ' + msg);
Display.getDefault().syncExec(new java.lang.Runnable({
run: function () {
MessageDialog.openInformation(null,
'Information', msg);
}
}));
}
}
inform('Hi~');
Will rise javax.script.ScriptException:
sun.org.mozilla.javascript.internal.EcmaError: ReferenceError:
"MessageDialog" is not defined. at line "MessageDialog.openInformation
(null, 'Information', msg);"
I found a workaround, but can't explain why. The workaround is to add
println(MessageDialog); before the line Display.getDefault().syncExec
(....
Like following:
/*
* Inforom message
*/
jface = JavaImporter(
org.eclipse.swt,
org.eclipse.swt.widgets,
org.eclipse.jface.dialogs);
with(jface) {
println(MessageDialog);
function inform(msg){
println('inform: ' + msg);
Display.getDefault().syncExec(new java.lang.Runnable({
run: function () {
MessageDialog.openInformation(null,
'Information', msg);
}
}));
}
}
inform('Hi~');
Don't know if it is a bug.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino