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 = 750;
33 this.el.deletable = true;
35 var child_0 = new Xcls_Box2( _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);
81 runhtml += builderhtml + "\n";
85 "Builder.saveHTML = function() {};\n" +
86 "Roo.onReady(function() {\n" +
88 "Roo.XComponent.build();\n" +
94 var ar = db.readForeignKeys(tbl);
95 var generator = new Json.Generator ();
96 var root = new Json.Node(Json.NodeType.OBJECT);
98 generator.set_root (root);
100 generator.pretty = true;
101 generator.indent = 4;
104 " Roo.XComponent.on('buildcomplete', function() {\n" +
105 " Editor." + cls + ".panel.loadData(" + generator.to_data (null) + "); " +
112 runhtml += "</script>\n" ;
115 // fix to make sure they are the same..
117 // need to modify paths
121 GLib.FileUtils.get_contents(
122 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
128 // fetch the json from the database...
132 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
133 "<script type=\"text/javascript\" src=\"resources://localhost/Editors/Editor." + cls + ".js\"></script>" +
137 //print("LOAD HTML " + html);
139 //var rootURL = _this.file.project.rootURL;
143 this.webview.el.load_html( html ,
144 //fixme - should be a config option!
145 "xhttp://localhost/app.Builder.js/"
151 var response_id = this.el.run();
153 if (response_id == 1) { // OK...
154 var loop = new MainLoop();
155 // run toBJS to get the data... (calls back into alert handler)
156 this.webview.el.run_javascript.begin("Editor." + cls + ".panel.toBJS();", null, (obj, res) => {
158 this.webview.el.run_javascript.end(res);
163 ret = _this.result_json;
164 // print("LOOP END?");
165 // try and get the resopse...
168 if (response_id < 1) {
184 public bool has_plugin (string cls) {
186 return GLib.FileUtils.test(
187 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
188 GLib.FileTest.IS_REGULAR
194 public class Xcls_Box2 : Object
197 private Xcls_DialogPluginWebkit _this;
203 public Xcls_Box2(Xcls_DialogPluginWebkit _owner )
206 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
210 // set gobject values
211 this.el.homogeneous = false;
212 var child_0 = new Xcls_ScrolledWindow3( _this );
214 this.el.pack_start ( child_0.el , false,true,3 );
217 // user defined functions
219 public class Xcls_ScrolledWindow3 : Object
221 public Gtk.ScrolledWindow el;
222 private Xcls_DialogPluginWebkit _this;
228 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
231 this.el = new Gtk.ScrolledWindow( null, null );
235 // set gobject values
236 this.el.expand = true;
237 var child_0 = new Xcls_webview( _this );
239 this.el.add ( child_0.el );
243 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
246 // user defined functions
248 public class Xcls_webview : Object
250 public WebKit.WebView el;
251 private Xcls_DialogPluginWebkit _this;
257 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
260 _this.webview = this;
261 this.el = new WebKit.WebView();
265 // set gobject values
270 // this may not work!?
271 var settings = this.el.get_settings();
272 settings.enable_write_console_messages_to_stdout = true;
274 var fs= new FakeServer(this.el);
276 // this was an attempt to change the url perms.. did not work..
277 // settings.enable_file_access_from_file_uris = true;
278 // settings.enable_offline_web_application_cache - true;
279 // settings.enable_universal_access_from_file_uris = true;
286 // FIXME - base url of script..
287 // we need it so some of the database features work.
288 this.el.load_html( "Render not ready" ,
289 //fixme - should be a config option!
290 // or should we catch stuff and fix it up..
291 "xhttp://localhost/app.Builder/"
300 this.el.script_dialog.connect( (dialog) => {
301 if (this.el == null) {
305 var msg = dialog.get_message();
306 if (msg.length < 4) {
309 if (msg.substring(0,4) != "IPC:") {
312 var ar = msg.split(":", 3);
316 print("CMD: %s\n",ar[1]);
317 print("ARGS: %s\n",ar[2]);
321 // print("%sw",ar[2]);
322 // _this.file.saveHTML(ar[2]);
326 _this.result_json = ar[2];
336 // user defined functions
341 public class Xcls_Button5 : Object
343 public Gtk.Button el;
344 private Xcls_DialogPluginWebkit _this;
350 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
353 this.el = new Gtk.Button();
357 // set gobject values
358 this.el.label = "Reload";
361 // user defined functions
364 public class Xcls_Button6 : Object
366 public Gtk.Button el;
367 private Xcls_DialogPluginWebkit _this;
373 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
376 this.el = new Gtk.Button();
380 // set gobject values
381 this.el.label = "Cancel";
384 // user defined functions
387 public class Xcls_Button7 : Object
389 public Gtk.Button el;
390 private Xcls_DialogPluginWebkit _this;
396 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
399 this.el = new Gtk.Button();
403 // set gobject values
404 this.el.label = "OK";
407 // user defined functions