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, string text) {// JsRender.Node node) {
59 this.el.set_transient_for(parent);
62 var db = new JsRender.RooDatabase.from_cfg ("MySQL", "hydra", "root", "");
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("Person");
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.Roo.grid.Grid.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.Roo.grid.Grid.js\"></script>" +
126 // "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +
127 // "<script type=\"text/javascript\">\n" +
132 //print("LOAD HTML " + html);
134 //var rootURL = _this.file.project.rootURL;
138 this.webview.el.load_html( html ,
139 //fixme - should be a config option!
140 "xhttp://localhost/app.Builder.js/"
146 var response_id = this.el.run();
148 if (response_id == 3) {
149 this.webview.el.execute_script("Editor.Roo.grid.Grid.panel.toBJS()");
153 if (response_id < 1) {
169 public class Xcls_VBox2 : Object
172 private Xcls_DialogPluginWebkit _this;
178 public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
181 this.el = new Gtk.VBox( false, 0 );
185 // set gobject values
186 var child_0 = new Xcls_ScrolledWindow3( _this );
188 this.el.pack_start ( child_0.el , false,true,3 );
191 // user defined functions
193 public class Xcls_ScrolledWindow3 : Object
195 public Gtk.ScrolledWindow el;
196 private Xcls_DialogPluginWebkit _this;
202 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
205 this.el = new Gtk.ScrolledWindow( null, null );
209 // set gobject values
210 this.el.expand = true;
211 var child_0 = new Xcls_webview( _this );
213 this.el.add ( child_0.el );
217 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
220 // user defined functions
222 public class Xcls_webview : Object
224 public WebKit.WebView el;
225 private Xcls_DialogPluginWebkit _this;
231 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
234 _this.webview = this;
235 this.el = new WebKit.WebView();
239 // set gobject values
244 // this may not work!?
245 var settings = this.el.get_settings();
246 settings.enable_write_console_messages_to_stdout = true;
248 var fs= new FakeServer(this.el);
250 // this was an attempt to change the url perms.. did not work..
251 // settings.enable_file_access_from_file_uris = true;
252 // settings.enable_offline_web_application_cache - true;
253 // settings.enable_universal_access_from_file_uris = true;
260 // FIXME - base url of script..
261 // we need it so some of the database features work.
262 this.el.load_html( "Render not ready" ,
263 //fixme - should be a config option!
264 // or should we catch stuff and fix it up..
265 "xhttp://localhost/app.Builder/"
274 this.el.script_dialog.connect( (dialog) => {
275 if (this.el == null) {
279 var msg = dialog.get_message();
280 if (msg.length < 4) {
283 if (msg.substring(0,4) != "IPC:") {
286 var ar = msg.split(":", 3);
290 print("CMD: %s\n",ar[1]);
291 print("ARGS: %s\n",ar[2]);
295 // _this.file.saveHTML(ar[2]);
304 // user defined functions
306 public class Xcls_Button5 : Object
308 public Gtk.Button el;
309 private Xcls_DialogPluginWebkit _this;
315 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
318 this.el = new Gtk.Button();
322 // set gobject values
323 this.el.label = "Reload";
326 // user defined functions
328 public class Xcls_Button6 : Object
330 public Gtk.Button el;
331 private Xcls_DialogPluginWebkit _this;
337 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
340 this.el = new Gtk.Button();
344 // set gobject values
345 this.el.label = "Cancel";
348 // user defined functions
350 public class Xcls_Button7 : Object
352 public Gtk.Button el;
353 private Xcls_DialogPluginWebkit _this;
359 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
362 this.el = new Gtk.Button();
366 // set gobject values
367 this.el.label = "OK";
370 // user defined functions