Changeset 1080 for trunk/src/org/expeditee/items/widgets/JSWidget.java
- Timestamp:
- 07/04/17 14:42:52 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/JSWidget.java
r1078 r1080 27 27 import javax.script.Invocable; 28 28 import javax.script.ScriptEngine; 29 import javax.script.ScriptEngineManager; 30 import javax.script.ScriptException; 31 29 32 import javax.swing.JPanel; 30 33 31 import org.expeditee.actions.Javascript2;32 34 import org.expeditee.gui.DisplayIO; 33 35 import org.expeditee.items.ItemParentStateChangedEvent; … … 43 45 public class JSWidget extends DataFrameWidget implements JSThreadable { 44 46 47 private static ScriptEngineManager scriptEngineManager = null; 48 private static ScriptEngine globalScriptEngine = null; 45 49 private static Object global = null; 46 50 … … 59 63 // container for our component 60 64 private final JPanel container; 61 65 66 static { 67 try { 68 scriptEngineManager = new ScriptEngineManager(); 69 globalScriptEngine = scriptEngineManager.getEngineByMimeType("application/javascript"); 70 global = globalScriptEngine.eval("new Object()"); 71 } catch (ScriptException e) { 72 e.printStackTrace(); 73 } 74 } 75 62 76 private static Text getSauce() { 63 77 Text source = new Text(DisplayIO.getCurrentFrame().getNextItemID(), "@iw: org.expeditee.items.widgets.JSWidget"); … … 68 82 private JSWidget(Text source, int width, int height, String init, String save, String load) throws Exception { 69 83 super(source, new JPanel(new BorderLayout()), -1, width, -1, -1, height, -1); 70 if (global == null) { 71 global = Javascript2.eval("new Object()"); 72 } 84 73 85 this.init = init; 74 86 this.save = save; 75 87 this.load = load; 76 88 this.container = (JPanel) super._swingComponent; 77 this.scriptEngine = Javascript2.scriptEngineManager.getEngineByMimeType("application/javascript");89 this.scriptEngine = scriptEngineManager.getEngineByMimeType("application/javascript"); 78 90 this.invocable = (Invocable) this.scriptEngine; 79 91 this.scriptEngine.put("global", global);
Note:
See TracChangeset
for help on using the changeset viewer.