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;
19 public string result_json;
22 public Xcls_DialogPluginWebkit()
25 this.el = new Gtk.Dialog();
30 this.el.title = "Add / Edit Component";
31 this.el.default_height = 500;
32 this.el.default_width = 500;
33 this.el.deletable = true;
35 var child_0 = new Xcls_VBox2( _this );
37 this.el.get_content_area().add ( child_0.el );
38 var child_1 = new Xcls_Button5( _this );
40 this.el.add_action_widget ( child_1.el , 3 );
41 var child_2 = new Xcls_Button6( _this );
43 this.el.add_action_widget ( child_2.el , 0 );
44 var child_3 = new Xcls_Button7( _this );
46 this.el.add_action_widget ( child_3.el , 1 );
49 this.el.delete_event.connect( (self, event) => {
56 // user defined functions
57 public string show (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {
60 this.el.set_transient_for(parent);
63 this.result_json = "";
64 var db = project.roo_database;
71 var runhtml = "<script type=\"text/javascript\">\n" ;
75 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
77 runhtml += builderhtml + "\n";
81 "Builder.saveHTML = function() {};\n" +
82 "Roo.onReady(function() {\n" +
84 "Roo.XComponent.build();\n" +
90 var ar = db.readForeignKeys(tbl);
91 var generator = new Json.Generator ();
92 var root = new Json.Node(Json.NodeType.OBJECT);
94 generator.set_root (root);
96 generator.pretty = true;
100 " Roo.XComponent.on('buildcomplete', function() {\n" +
101 " Editor." + cls + ".panel.loadData(" + generator.to_data (null) + "); " +
108 runhtml += "</script>\n" ;
111 // fix to make sure they are the same..
113 // need to modify paths
117 GLib.FileUtils.get_contents(
118 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
122 // fetch the json from the database...
126 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
127 "<script type=\"text/javascript\" src=\"xhttp://localhost/app.Builder.js/resources/Editors/Editor." + cls + ".js\"></script>" +
131 //print("LOAD HTML " + html);
133 //var rootURL = _this.file.project.rootURL;
137 this.webview.el.load_html( html ,
138 //fixme - should be a config option!
139 "xhttp://localhost/app.Builder.js/"
145 var response_id = this.el.run();
147 if (response_id == 1) { // OK...
148 var loop = new MainLoop();
149 // run toBJS to get the data... (calls back into alert handler)
150 this.webview.el.run_javascript.begin("Editor." + cls + ".panel.toBJS();", null, (obj, res) => {
152 this.webview.el.run_javascript.end(res);
157 ret = _this.result_json;
158 // print("LOOP END?");
159 // try and get the resopse...
162 if (response_id < 1) {
178 public bool has_plugin (string cls) {
180 return GLib.FileUtils.test(
181 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
182 GLib.FileTest.IS_REGULAR
188 public class Xcls_VBox2 : Object
191 private Xcls_DialogPluginWebkit _this;
197 public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
200 this.el = new Gtk.VBox( false, 0 );
204 // set gobject values
205 var child_0 = new Xcls_ScrolledWindow3( _this );
207 this.el.pack_start ( child_0.el , false,true,3 );
210 // user defined functions
212 public class Xcls_ScrolledWindow3 : Object
214 public Gtk.ScrolledWindow el;
215 private Xcls_DialogPluginWebkit _this;
221 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
224 this.el = new Gtk.ScrolledWindow( null, null );
228 // set gobject values
229 this.el.expand = true;
230 var child_0 = new Xcls_webview( _this );
232 this.el.add ( child_0.el );
236 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
239 // user defined functions
241 public class Xcls_webview : Object
243 public WebKit.WebView el;
244 private Xcls_DialogPluginWebkit _this;
250 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
253 _this.webview = this;
254 this.el = new WebKit.WebView();
258 // set gobject values
263 // this may not work!?
264 var settings = this.el.get_settings();
265 settings.enable_write_console_messages_to_stdout = true;
267 var fs= new FakeServer(this.el);
269 // this was an attempt to change the url perms.. did not work..
270 // settings.enable_file_access_from_file_uris = true;
271 // settings.enable_offline_web_application_cache - true;
272 // settings.enable_universal_access_from_file_uris = true;
279 // FIXME - base url of script..
280 // we need it so some of the database features work.
281 this.el.load_html( "Render not ready" ,
282 //fixme - should be a config option!
283 // or should we catch stuff and fix it up..
284 "xhttp://localhost/app.Builder/"
293 this.el.script_dialog.connect( (dialog) => {
294 if (this.el == null) {
298 var msg = dialog.get_message();
299 if (msg.length < 4) {
302 if (msg.substring(0,4) != "IPC:") {
305 var ar = msg.split(":", 3);
309 print("CMD: %s\n",ar[1]);
310 print("ARGS: %s\n",ar[2]);
314 // _this.file.saveHTML(ar[2]);
323 // user defined functions
325 public class Xcls_Button5 : Object
327 public Gtk.Button el;
328 private Xcls_DialogPluginWebkit _this;
334 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
337 this.el = new Gtk.Button();
341 // set gobject values
342 this.el.label = "Reload";
345 // user defined functions
347 public class Xcls_Button6 : Object
349 public Gtk.Button el;
350 private Xcls_DialogPluginWebkit _this;
356 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
359 this.el = new Gtk.Button();
363 // set gobject values
364 this.el.label = "Cancel";
367 // user defined functions
369 public class Xcls_Button7 : Object
371 public Gtk.Button el;
372 private Xcls_DialogPluginWebkit _this;
378 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
381 this.el = new Gtk.Button();
385 // set gobject values
386 this.el.label = "OK";
389 // user defined functions