I'm using MagicDraw/Cameo's Scripting engine to create Role-based UI's for non-SysML users. They were developed (successfully) using Nashorn, but the newest Cameo is using Rhino. The migration breaks all of my scripts.
The script file contains functions and global variables (holding state info), and also creates the Jdialog box with components (JButton). The button has a listener, but I am unable to reference the global variables and functions.
/* Short Example, assume the JavaImporter has the write java classes*/
var _myVariable = 12;
function _myFunction(){ return true;}
function doFunction(){
var panel = new JPanel();
var dialog = new Dialog();
dialog.setConentPane(panel);
var btnSubmit = new JButton("submit");
panel.add(btnSubmit);
btnSubmit.addActionListener( new ActionListener(){
actionPerformed: function(e){
if( _myFunction() ){ /* <-- breaks here */
_myVariable += 1; /* <-- breaks here */
}
}
});
}
doFunction();
This would run under Javascript Nashorn, but in Rhino it errors out because _myFunction and _myVariable are undefined.
I tried to extend the ActionListener so I could pass in the global object, but examining the global object, it looks like I won't get any state info, only the script code.