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;
21 public Xcls_DialogPluginWebkit()
24 this.el = new Gtk.Dialog();
29 this.el.title = "Add / Edit Component";
30 this.el.default_height = 500;
31 this.el.default_width = 500;
32 this.el.deletable = true;
34 var child_0 = new Xcls_VBox2( _this );
36 this.el.get_content_area().add ( child_0.el );
37 var child_1 = new Xcls_Button5( _this );
39 this.el.add_action_widget ( child_1.el , 3 );
40 var child_2 = new Xcls_Button6( _this );
42 this.el.add_action_widget ( child_2.el , 0 );
43 var child_3 = new Xcls_Button7( _this );
45 this.el.add_action_widget ( child_3.el , 1 );
48 this.el.delete_event.connect( (self, event) => {
55 // user defined functions
56 public string show (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {
59 this.el.set_transient_for(parent);
62 Palete.RooDatabase db = project.roo_database;
69 var runhtml = "<script type=\"text/javascript\">\n" ;
73 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
75 runhtml += builderhtml + "\n";
79 "Builder.saveHTML = function() {};\n" +
80 "Roo.onReady(function() {\n" +
82 "Roo.XComponent.build();\n" +
88 var ar = db.readForeignKeys(tbl);
89 var generator = new Json.Generator ();
90 var root = new Json.Node(Json.NodeType.OBJECT);
92 generator.set_root (root);
94 generator.pretty = true;
98 " Roo.XComponent.on('buildcomplete', function() {\n" +
99 " Editor." + cls + ".panel.loadData(" + generator.to_data (null) + "); " +
106 runhtml += "</script>\n" ;
109 // fix to make sure they are the same..
111 // need to modify paths
115 GLib.FileUtils.get_contents(
116 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
120 // fetch the json from the database...
124 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
125 "<script type=\"text/javascript\" src=\"xhttp://localhost/app.Builder.js/resources/Editors/Editor." + cls + ".js\"></script>" +
129 //print("LOAD HTML " + html);
131 //var rootURL = _this.file.project.rootURL;
135 this.webview.el.load_html( html ,
136 //fixme - should be a config option!
137 "xhttp://localhost/app.Builder.js/"
143 var response_id = this.el.run();
145 if (response_id == 1) { // OK...
146 var loop = new MainLoop();
147 // run toBJS to get the data... (calls back into alert handler)
148 this.webview.el.run_javascript.begin("Editor." + cls + ".panel.toBJS();", null, (obj, res) => {
150 this.webview.el.run_javascript.end(res);
155 // print("LOOP END?");
156 // try and get the resopse...
159 if (response_id < 1) {
175 public bool has_plugin (string cls) {
177 return GLib.FileUtils.test(
178 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
179 GLib.FileTest.IS_REGULAR
185 public class Xcls_VBox2 : Object
188 private Xcls_DialogPluginWebkit _this;
194 public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
197 this.el = new Gtk.VBox( false, 0 );
201 // set gobject values
202 var child_0 = new Xcls_ScrolledWindow3( _this );
204 this.el.pack_start ( child_0.el , false,true,3 );
207 // user defined functions
209 public class Xcls_ScrolledWindow3 : Object
211 public Gtk.ScrolledWindow el;
212 private Xcls_DialogPluginWebkit _this;
218 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
221 this.el = new Gtk.ScrolledWindow( null, null );
225 // set gobject values
226 this.el.expand = true;
227 var child_0 = new Xcls_webview( _this );
229 this.el.add ( child_0.el );
233 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
236 // user defined functions
238 public class Xcls_webview : Object
240 public WebKit.WebView el;
241 private Xcls_DialogPluginWebkit _this;
247 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
250 _this.webview = this;
251 this.el = new WebKit.WebView();
255 // set gobject values
260 // this may not work!?
261 var settings = this.el.get_settings();
262 settings.enable_write_console_messages_to_stdout = true;
264 var fs= new FakeServer(this.el);
266 // this was an attempt to change the url perms.. did not work..
267 // settings.enable_file_access_from_file_uris = true;
268 // settings.enable_offline_web_application_cache - true;
269 // settings.enable_universal_access_from_file_uris = true;
276 // FIXME - base url of script..
277 // we need it so some of the database features work.
278 this.el.load_html( "Render not ready" ,
279 //fixme - should be a config option!
280 // or should we catch stuff and fix it up..
281 "xhttp://localhost/app.Builder/"
290 this.el.script_dialog.connect( (dialog) => {
291 if (this.el == null) {
295 var msg = dialog.get_message();
296 if (msg.length < 4) {
299 if (msg.substring(0,4) != "IPC:") {
302 var ar = msg.split(":", 3);
306 print("CMD: %s\n",ar[1]);
307 print("ARGS: %s\n",ar[2]);
311 // _this.file.saveHTML(ar[2]);
320 // user defined functions
322 public class Xcls_Button5 : Object
324 public Gtk.Button el;
325 private Xcls_DialogPluginWebkit _this;
331 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
334 this.el = new Gtk.Button();
338 // set gobject values
339 this.el.label = "Reload";
342 // user defined functions
344 public class Xcls_Button6 : Object
346 public Gtk.Button el;
347 private Xcls_DialogPluginWebkit _this;
353 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
356 this.el = new Gtk.Button();
360 // set gobject values
361 this.el.label = "Cancel";
364 // user defined functions
366 public class Xcls_Button7 : Object
368 public Gtk.Button el;
369 private Xcls_DialogPluginWebkit _this;
375 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
378 this.el = new Gtk.Button();
382 // set gobject values
383 this.el.label = "OK";
386 // user defined functions