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 boolean has_plugin (string cls) {
58 return GLib.FileUtils.test(
59 BuilderApplication.configDirectory() + "/resources/Editors/Editor." + cls + ".js",
60 GLib.FileTest.IS_REGULAR
66 public string show (Gtk.Window ?parent, string text) {// JsRender.Node node) {
69 this.el.set_transient_for(parent);
72 var db = new JsRender.RooDatabase.from_cfg ("MySQL", "hydra", "root", "");
79 var runhtml = "<script type=\"text/javascript\">\n" ;
83 GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + "/resources/roo.builder.js", out builderhtml);
85 runhtml += builderhtml + "\n";
89 "Builder.saveHTML = function() {};\n" +
90 "Roo.onReady(function() {\n" +
92 "Roo.XComponent.build();\n" +
98 var ar = db.readForeignKeys("Person");
99 var generator = new Json.Generator ();
100 var root = new Json.Node(Json.NodeType.OBJECT);
101 root.init_object(ar);
102 generator.set_root (root);
104 generator.pretty = true;
105 generator.indent = 4;
108 " Roo.XComponent.on('buildcomplete', function() {\n" +
109 " Editor.Roo.grid.Grid.panel.loadData(" + generator.to_data (null) + "); " +
116 runhtml += "</script>\n" ;
119 // fix to make sure they are the same..
121 // need to modify paths
125 GLib.FileUtils.get_contents(
126 BuilderApplication.configDirectory() + "/resources/roo.builder.html"
130 // fetch the json from the database...
134 var html = inhtml.replace("</head>", runhtml + // + this.runhtml +
135 "<script type=\"text/javascript\" src=\"xhttp://localhost/app.Builder.js/resources/Editors/Editor.Roo.grid.Grid.js\"></script>" +
136 // "<script type=\"text/javascript\" src=\"xhttp://localhost" + fc.fname + "\"></script>" +
137 // "<script type=\"text/javascript\">\n" +
142 //print("LOAD HTML " + html);
144 //var rootURL = _this.file.project.rootURL;
148 this.webview.el.load_html( html ,
149 //fixme - should be a config option!
150 "xhttp://localhost/app.Builder.js/"
156 var response_id = this.el.run();
158 if (response_id == 1) { // OK...
159 var loop = new MainLoop();
160 this.webview.el.run_javascript.begin("Editor.Roo.grid.Grid.panel.toBJS();", null, (obj, res) => {
161 // print("GOT END?");
162 this.webview.el.run_javascript.end(res);
163 // print("GOT DATA?");
167 // print("LOOP END?");
168 // try and get the resopse...
171 if (response_id < 1) {
187 public class Xcls_VBox2 : Object
190 private Xcls_DialogPluginWebkit _this;
196 public Xcls_VBox2(Xcls_DialogPluginWebkit _owner )
199 this.el = new Gtk.VBox( false, 0 );
203 // set gobject values
204 var child_0 = new Xcls_ScrolledWindow3( _this );
206 this.el.pack_start ( child_0.el , false,true,3 );
209 // user defined functions
211 public class Xcls_ScrolledWindow3 : Object
213 public Gtk.ScrolledWindow el;
214 private Xcls_DialogPluginWebkit _this;
220 public Xcls_ScrolledWindow3(Xcls_DialogPluginWebkit _owner )
223 this.el = new Gtk.ScrolledWindow( null, null );
227 // set gobject values
228 this.el.expand = true;
229 var child_0 = new Xcls_webview( _this );
231 this.el.add ( child_0.el );
235 this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
238 // user defined functions
240 public class Xcls_webview : Object
242 public WebKit.WebView el;
243 private Xcls_DialogPluginWebkit _this;
249 public Xcls_webview(Xcls_DialogPluginWebkit _owner )
252 _this.webview = this;
253 this.el = new WebKit.WebView();
257 // set gobject values
262 // this may not work!?
263 var settings = this.el.get_settings();
264 settings.enable_write_console_messages_to_stdout = true;
266 var fs= new FakeServer(this.el);
268 // this was an attempt to change the url perms.. did not work..
269 // settings.enable_file_access_from_file_uris = true;
270 // settings.enable_offline_web_application_cache - true;
271 // settings.enable_universal_access_from_file_uris = true;
278 // FIXME - base url of script..
279 // we need it so some of the database features work.
280 this.el.load_html( "Render not ready" ,
281 //fixme - should be a config option!
282 // or should we catch stuff and fix it up..
283 "xhttp://localhost/app.Builder/"
292 this.el.script_dialog.connect( (dialog) => {
293 if (this.el == null) {
297 var msg = dialog.get_message();
298 if (msg.length < 4) {
301 if (msg.substring(0,4) != "IPC:") {
304 var ar = msg.split(":", 3);
308 print("CMD: %s\n",ar[1]);
309 print("ARGS: %s\n",ar[2]);
313 // _this.file.saveHTML(ar[2]);
322 // user defined functions
324 public class Xcls_Button5 : Object
326 public Gtk.Button el;
327 private Xcls_DialogPluginWebkit _this;
333 public Xcls_Button5(Xcls_DialogPluginWebkit _owner )
336 this.el = new Gtk.Button();
340 // set gobject values
341 this.el.label = "Reload";
344 // user defined functions
346 public class Xcls_Button6 : Object
348 public Gtk.Button el;
349 private Xcls_DialogPluginWebkit _this;
355 public Xcls_Button6(Xcls_DialogPluginWebkit _owner )
358 this.el = new Gtk.Button();
362 // set gobject values
363 this.el.label = "Cancel";
366 // user defined functions
368 public class Xcls_Button7 : Object
370 public Gtk.Button el;
371 private Xcls_DialogPluginWebkit _this;
377 public Xcls_Button7(Xcls_DialogPluginWebkit _owner )
380 this.el = new Gtk.Button();
384 // set gobject values
385 this.el.label = "OK";
388 // user defined functions