Changeset 758
- Timestamp:
- 01/28/14 09:55:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/JSWidget.java
r752 r758 23 23 public class JSWidget extends DataFrameWidget { 24 24 25 // a method to run before running the constructor 26 private final String preCreate; 27 // a method to run that will return a JComponent 28 private final String constructor; 29 // a method to run after running the constructor 30 private final String postCreate; 25 // a method to run that will set up and return the root JComponent for this Widget 26 private final String init; 31 27 // a method to run to generate a List<String> to save the state 32 28 private final String save; … … 47 43 } 48 44 49 private JSWidget(Text source, String preCreate, String constructor, String postCreate, String save, String load) throws Exception {45 private JSWidget(Text source, String init, String save, String load) throws Exception { 50 46 super(source, new JPanel(new BorderLayout()), -1, 100, -1, -1, 100, -1); 51 this.preCreate = preCreate; 52 this.constructor = constructor; 53 this.postCreate = postCreate; 47 this.init = init; 54 48 this.save = save; 55 49 this.load = load; … … 59 53 this.scriptEngine.put("widget", this); 60 54 this.scriptEngine.put("container", this.container); 61 System.out.println(this.preCreate); 62 this.scriptEngine.eval("var pre = " + this.preCreate + "\npre()"); 63 System.out.println(this.constructor); 64 this.component = (JComponent) this.scriptEngine.eval("var constructor = " + this.constructor + "\nconstructor()"); 55 System.out.println(this.init); 56 this.component = (JComponent) this.scriptEngine.eval("var init = " + this.init + "\ninit()"); 65 57 this.container.add(component); 66 58 this.scriptEngine.put("component", this.component); 67 System.out.println(this.postCreate);68 this.scriptEngine.eval("var post = " + this.postCreate + "\npost()");69 59 } 70 60 … … 72 62 this(source, source.getData().get(0).replaceAll("\\\\n", "\n"), 73 63 source.getData().get(1).replaceAll("\\\\n", "\n"), 74 source.getData().get(2).replaceAll("\\\\n", "\n"), 75 source.getData().get(3).replaceAll("\\\\n", "\n"), 76 source.getData().get(4).replaceAll("\\\\n", "\n")); 64 source.getData().get(2).replaceAll("\\\\n", "\n")); 77 65 this.scriptEngine.eval("var load = " + this.load); 78 66 ((Invocable)this.scriptEngine).invokeFunction("load", (Object) args); 79 67 } 80 68 81 public JSWidget(String preCreate, String constructor, String postCreate, String save, String load) throws Exception {82 this(getSauce(), preCreate, constructor, postCreate, save, load);69 public JSWidget(String init, String save, String load) throws Exception { 70 this(getSauce(), init, save, load); 83 71 } 84 72 … … 86 74 protected List<String> getData() { 87 75 List<String> value = new LinkedList<String>(); 88 value.add(this.preCreate.replaceAll("[\n\r]", "\\\\n")); 89 value.add(this.constructor.replaceAll("[\n\r]", "\\\\n")); 90 value.add(this.postCreate.replaceAll("[\n\r]", "\\\\n")); 76 value.add(this.init.replaceAll("[\n\r]", "\\\\n")); 91 77 value.add(this.save.replaceAll("[\n\r]", "\\\\n")); 92 78 value.add(this.load.replaceAll("[\n\r]", "\\\\n"));
Note:
See TracChangeset
for help on using the changeset viewer.