1 static Xcls_DialogPluginWebkit _DialogPluginWebkit;
3 public class Xcls_DialogPluginWebkit : Object
6 private Xcls_DialogPluginWebkit _this;
8 public static Xcls_DialogPluginWebkit singleton()
10 if (_DialogPluginWebkit == null) {
11 _DialogPluginWebkit= new Xcls_DialogPluginWebkit();
13 return _DialogPluginWebkit;
15 public Xcls_webview webview;
18 public signal void complete (string result);
21 public string result_json;
24 public Xcls_DialogPluginWebkit()
27 this.el = new Gtk.Dialog();
32 this.el.title = "Add / Edit Component";
33 this.el.default_height = 500;
34 this.el.default_width = 750;
35 this.el.deletable = true;
37 var child_0 = new Xcls_Box2( _this );
39 this.el.get_content_area().append ( child_0.el );
40 var child_1 = new Xcls_Button5( _this );
42 this.el.add_action_widget ( child_1.el , 3 );
43 var child_2 = new Xcls_Button6( _this );
45 this.el.add_action_widget ( child_2.el , 0 );
46 var child_3 = new Xcls_Button7( _this );
48 this.el.add_action_widget ( child_3.el , 1 );
51 this.el.response.connect( (response_id) => {
54 if (response_id == 1) { // OK...
55 var loop = new MainLoop();
56 // run toBJS to get the data... (calls back into alert handler)
57 _this.result_json = "";
58 this.webview.el.run_javascript.begin("Editor." + this.cls + ".panel.toBJS();", null, (obj, res) => {
60 this.webview.el.run_javascript.end(res);
67 _this.complete(_this.result_json);
70 // print("LOOP END?");
71 // try and get the resopse...
74 if (response_id < 1) {
82 // user defined functions
83 public bool has_plugin (string cls) {
85 return GLib.FileUtils.test(
86 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
87 GLib.FileTest.IS_REGULAR
93 public void showIt // for result hook into complete
95 (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {
100 this.el.set_transient_for(parent);
101 this.el.modal = true;
103 this.result_json = "";
104 var db = project.roo_database;
110 var runhtml = "<script type=\"text/javascript\">\n" ;
114 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
120 runhtml += builderhtml + "\n";
124 "Builder.saveHTML = function() {};\n" +
125 "Roo.onReady(function() {\n" +
127 "Roo.XComponent.build();\n" +
133 var ar = db.readForeignKeys(tbl);
134 var generator = new Json.Generator ();
135 var root = new Json.Node(Json.NodeType.OBJECT);
136 root.init_object(ar);
137 generator.set_root (root);
139 generator.pretty = true;
140 generator.indent = 4;
143 " Roo.XComponent.on('buildcomplete', function() {\n" +
144 " Editor." + cls + ".panel.loadData(" + generator.to_data (null) + "); " +
151 runhtml += "</script>\n" ;
154 // fix to make sure they are the same..
156 // need to modify paths
160 GLib.FileUtils.get_contents(
161 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
167 // fetch the json from the database...
171 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
172 "<script type=\"text/javascript\" src=\"resources://localhost/Editors/Editor." + cls + ".js\"></script>" +
176 //print("LOAD HTML " + html);
178 //var rootURL = _this.file.project.rootURL;
182 this.webview.el.load_html( html ,
183 //fixme - should be a config option!
184 "xhttp://localhost/roobuilder/"
192 public class Xcls_Box2 : Object
195 private Xcls_DialogPluginWebkit _this;
201 public Xcls_Box2(Xcls_DialogPluginWebkit _owner )
204 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
208 // set gobject values
209 this.el.homogeneous = false;
210 var child_0 = new Xcls_ScrolledWindow3( _this );
212 this.el.append ( child_0.el );
215 // user defined functions
217 public class Xcls_ScrolledWindow3 : Object
219 public Gtk.ScrolledWindow el;
220 private Xcls_DialogPluginWebkit _this;
226 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
229 this.el = new Gtk.ScrolledWindow();
233 // set gobject values
234 this.el.hexpand = true;
235 this.el.vexpand = true;
236 var child_0 = new Xcls_webview( _this );
238 this.el.set_child ( child_0.el );
242 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
245 // user defined functions
247 public class Xcls_webview : Object
249 public WebKit.WebView el;
250 private Xcls_DialogPluginWebkit _this;
256 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
259 _this.webview = this;
260 this.el = new WebKit.WebView();
264 // set gobject values
269 // this may not work!?
270 var settings = this.el.get_settings();
271 settings.enable_write_console_messages_to_stdout = true;
273 var fs= new FakeServer(this.el);
275 // this was an attempt to change the url perms.. did not work..
276 // settings.enable_file_access_from_file_uris = true;
277 // settings.enable_offline_web_application_cache - true;
278 // settings.enable_universal_access_from_file_uris = true;
285 // FIXME - base url of script..
286 // we need it so some of the database features work.
287 this.el.load_html( "Render not ready" ,
288 //fixme - should be a config option!
289 // or should we catch stuff and fix it up..
290 "xhttp://localhost/roobuilder/"
299 this.el.script_dialog.connect( (dialog) => {
300 if (this.el == null) {
304 var msg = dialog.get_message();
305 if (msg.length < 4) {
308 if (msg.substring(0,4) != "IPC:") {
311 var ar = msg.split(":", 3);
315 print("CMD: %s\n",ar[1]);
316 print("ARGS: %s\n",ar[2]);
320 // print("%sw",ar[2]);
321 // _this.file.saveHTML(ar[2]);
325 _this.result_json = ar[2];
335 // user defined functions
340 public class Xcls_Button5 : Object
342 public Gtk.Button el;
343 private Xcls_DialogPluginWebkit _this;
349 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
352 this.el = new Gtk.Button();
356 // set gobject values
357 this.el.label = "Reload";
360 // user defined functions
363 public class Xcls_Button6 : Object
365 public Gtk.Button el;
366 private Xcls_DialogPluginWebkit _this;
372 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
375 this.el = new Gtk.Button();
379 // set gobject values
380 this.el.label = "Cancel";
383 // user defined functions
386 public class Xcls_Button7 : Object
388 public Gtk.Button el;
389 private Xcls_DialogPluginWebkit _this;
395 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
398 this.el = new Gtk.Button();
402 // set gobject values
403 this.el.label = "OK";
406 // user defined functions