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 var db = project.roo_database;
70 var runhtml = "<script type=\"text/javascript\">\n" ;
74 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
76 runhtml += builderhtml + "\n";
80 "Builder.saveHTML = function() {};\n" +
81 "Roo.onReady(function() {\n" +
83 "Roo.XComponent.build();\n" +
89 var ar = db.readForeignKeys(tbl);
90 var generator = new Json.Generator ();
91 var root = new Json.Node(Json.NodeType.OBJECT);
93 generator.set_root (root);
95 generator.pretty = true;
99 " Roo.XComponent.on('buildcomplete', function() {\n" +
100 " Editor." + cls + ".panel.loadData(" + generator.to_data (null) + "); " +
107 runhtml += "</script>\n" ;
110 // fix to make sure they are the same..
112 // need to modify paths
116 GLib.FileUtils.get_contents(
117 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
121 // fetch the json from the database...
125 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
126 "<script type=\"text/javascript\" src=\"xhttp://localhost/app.Builder.js/resources/Editors/Editor." + cls + ".js\"></script>" +
130 //print("LOAD HTML " + html);
132 //var rootURL = _this.file.project.rootURL;
136 this.webview.el.load_html( html ,
137 //fixme - should be a config option!
138 "xhttp://localhost/app.Builder.js/"
144 var response_id = this.el.run();
146 if (response_id == 1) { // OK...
147 var loop = new MainLoop();
148 // run toBJS to get the data... (calls back into alert handler)
149 this.webview.el.run_javascript.begin("Editor." + cls + ".panel.toBJS();", null, (obj, res) => {
151 this.webview.el.run_javascript.end(res);
156 // print("LOOP END?");
157 // try and get the resopse...
160 if (response_id < 1) {
176 public bool has_plugin (string cls) {
178 return GLib.FileUtils.test(
179 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
180 GLib.FileTest.IS_REGULAR
186 public class Xcls_VBox2 : Object
189 private Xcls_DialogPluginWebkit _this;
195 public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
198 this.el = new Gtk.VBox( false, 0 );
202 // set gobject values
203 var child_0 = new Xcls_ScrolledWindow3( _this );
205 this.el.pack_start ( child_0.el , false,true,3 );
208 // user defined functions
210 public class Xcls_ScrolledWindow3 : Object
212 public Gtk.ScrolledWindow el;
213 private Xcls_DialogPluginWebkit _this;
219 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
222 this.el = new Gtk.ScrolledWindow( null, null );
226 // set gobject values
227 this.el.expand = true;
228 var child_0 = new Xcls_webview( _this );
230 this.el.add ( child_0.el );
234 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
237 // user defined functions
239 public class Xcls_webview : Object
241 public WebKit.WebView el;
242 private Xcls_DialogPluginWebkit _this;
248 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
251 _this.webview = this;
252 this.el = new WebKit.WebView();
256 // set gobject values
261 // this may not work!?
262 var settings = this.el.get_settings();
263 settings.enable_write_console_messages_to_stdout = true;
265 var fs= new FakeServer(this.el);
267 // this was an attempt to change the url perms.. did not work..
268 // settings.enable_file_access_from_file_uris = true;
269 // settings.enable_offline_web_application_cache - true;
270 // settings.enable_universal_access_from_file_uris = true;
277 // FIXME - base url of script..
278 // we need it so some of the database features work.
279 this.el.load_html( "Render not ready" ,
280 //fixme - should be a config option!
281 // or should we catch stuff and fix it up..
282 "xhttp://localhost/app.Builder/"
291 this.el.script_dialog.connect( (dialog) => {
292 if (this.el == null) {
296 var msg = dialog.get_message();
297 if (msg.length < 4) {
300 if (msg.substring(0,4) != "IPC:") {
303 var ar = msg.split(":", 3);
307 print("CMD: %s\n",ar[1]);
308 print("ARGS: %s\n",ar[2]);
312 // _this.file.saveHTML(ar[2]);
321 // user defined functions
323 public class Xcls_Button5 : Object
325 public Gtk.Button el;
326 private Xcls_DialogPluginWebkit _this;
332 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
335 this.el = new Gtk.Button();
339 // set gobject values
340 this.el.label = "Reload";
343 // user defined functions
345 public class Xcls_Button6 : Object
347 public Gtk.Button el;
348 private Xcls_DialogPluginWebkit _this;
354 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
357 this.el = new Gtk.Button();
361 // set gobject values
362 this.el.label = "Cancel";
365 // user defined functions
367 public class Xcls_Button7 : Object
369 public Gtk.Button el;
370 private Xcls_DialogPluginWebkit _this;
376 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
379 this.el = new Gtk.Button();
383 // set gobject values
384 this.el.label = "OK";
387 // user defined functions