{
- "name" : "DialogPluginWebkit",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/DialogPluginWebkit.bjs",
- "permname" : "",
- "modOrder" : "",
"build_module" : "builder",
"items" : [
{
- "listeners" : {
- "delete_event" : "(self, event) => {\n this.el.hide();\n return true; \n //test \n} \n "
- },
- "string tmpjs" : "",
- "id" : "DialogPluginWebkit",
- "utf8 title" : "Add / Edit Component",
- "gint default_height" : 500,
- "gboolean deletable" : true,
- "xtype" : "Dialog",
- "| string show" : " (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {\n \n if (parent != null) {\n this.el.set_transient_for(parent);\n this.el.modal = true;\n }\n this.result_json = \"\";\n var db = project.roo_database;\n \n \n this.el.show_all();\n var ret = \"\";\n while (true) {\n \n var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;\n string builderhtml;\n \n try {\n GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);\n } catch (Error e) {\n builderhtml = \"\";\n }\n \n\n runhtml += builderhtml + \"\\n\";\n \n \n runhtml += \"\\n\" +\n \"Builder.saveHTML = function() {};\\n\" + \n\t \"Roo.onReady(function() {\\n\" +\n\n\t \"Roo.XComponent.build();\\n\" +\n\t \"});\\n\";\n\t\n\t\n \n\n var ar = db.readForeignKeys(tbl);\n var generator = new Json.Generator ();\n var root = new Json.Node(Json.NodeType.OBJECT);\n root.init_object(ar);\n generator.set_root (root);\n \n generator.pretty = true;\n generator.indent = 4;\n \n runhtml += \"\\n\" +\n \" Roo.XComponent.on('buildcomplete', function() {\\n\" +\n \" Editor.\" + cls + \".panel.loadData(\" + generator.to_data (null) + \"); \" +\n \"});\\n\";\n\n \n\t\n\t\n\n runhtml += \"</script>\\n\" ;\n\n print(runhtml);\n // fix to make sure they are the same..\n \n // need to modify paths\n\n string inhtml;\n try {\n GLib.FileUtils.get_contents(\n BuilderApplication.configDirectory() + \"/resources/roo.builder.html\"\n , out inhtml);\n \n } catch (Error e) {\n inhtml = \"\";\n }\n // fetch the json from the database...\n \n //print(runhtml);\n \n var html = inhtml.replace(\"</head>\", runhtml + // + this.runhtml + \n \"<script type=\\\"text/javascript\\\" src=\\\"resources://localhost/Editors/Editor.\" + cls + \".js\\\"></script>\" + \n \n \n \"</head>\");\n //print(\"LOAD HTML \" + html);\n \n //var rootURL = _this.file.project.rootURL;\n \n \n \n this.webview.el.load_html( html , \n //fixme - should be a config option!\n \"xhttp://localhost/roobuilder/\"\n );\n \n \n \n \n var response_id = this.el.run();\n \n if (response_id == 1) { // OK...\n var loop = new MainLoop();\n // run toBJS to get the data... (calls back into alert handler)\n _this.result_json = \"\";\n this.webview.el.run_javascript.begin(\"Editor.\" + cls + \".panel.toBJS();\", null, (obj, res) => {\n try {\n this.webview.el.run_javascript.end(res);\n } catch(Error e) {\n \n }\n loop.quit();\n });\n loop.run();\n ret = _this.result_json;\n \n \n // print(\"LOOP END?\");\n // try and get the resopse...\n break;\n }\n if (response_id < 1) {\n this.el.hide();\n return \"\";\n }\n // keep showing...?\n continue;\n }\n \n // now we save it..\n this.el.hide();\n \n return ret;\n \n \n \n}\n",
- "| bool has_plugin" : "(string cls) {\n\n return GLib.FileUtils.test(\n BuilderApplication.configDirectory() + \"/resources/Editors/Editor.\" + cls + \".js\",\n GLib.FileTest.IS_REGULAR\n );\n \n\n\n}\n",
"$ xns" : "Gtk",
- "gint default_width" : 750,
+ "gboolean deletable" : true,
"gboolean modal" : true,
- "string result_json" : "",
+ "gint default_height" : 500,
+ "gint default_width" : 750,
+ "id" : "DialogPluginWebkit",
"items" : [
{
- "xtype" : "Box",
"$ pack" : "get_content_area().add",
- "gboolean homogeneous" : false,
"$ xns" : "Gtk",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+ "gboolean homogeneous" : false,
"items" : [
{
- "* init" : " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);\n \n",
+ "$ xns" : "Gtk",
+ "* init" : [
+ " this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
+ " ",
+ ""
+ ],
"* pack" : "pack_start,false,true,3",
- "xtype" : "ScrolledWindow",
"gboolean expand" : true,
- "$ xns" : "Gtk",
"items" : [
{
+ "$ xns" : "WebKit",
+ "* init" : [
+ " {",
+ " // this may not work!?",
+ " var settings = this.el.get_settings();",
+ " settings.enable_write_console_messages_to_stdout = true;",
+ " ",
+ " var fs= new FakeServer(this.el);",
+ " fs.ref();",
+ " // this was an attempt to change the url perms.. did not work..",
+ " // settings.enable_file_access_from_file_uris = true;",
+ " // settings.enable_offline_web_application_cache - true;",
+ " // settings.enable_universal_access_from_file_uris = true;",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ "",
+ " // FIXME - base url of script..",
+ " // we need it so some of the database features work.",
+ " this.el.load_html( \"Render not ready\" , ",
+ " //fixme - should be a config option!",
+ " // or should we catch stuff and fix it up..",
+ " \"xhttp://localhost/roobuilder/\"",
+ " );",
+ " ",
+ " ",
+ " ",
+ " ",
+ "}",
+ ""
+ ],
+ "* pack" : "add",
+ "id" : "webview",
"listeners" : {
- "script_dialog" : " (dialog) => {\n if (this.el == null) {\n return true;\n }\n \n var msg = dialog.get_message();\n if (msg.length < 4) {\n return false;\n }\n if (msg.substring(0,4) != \"IPC:\") {\n return false;\n }\n var ar = msg.split(\":\", 3);\n if (ar.length < 3) {\n return false;\n }\n print(\"CMD: %s\\n\",ar[1]);\n print(\"ARGS: %s\\n\",ar[2]);\n switch(ar[1]) {\n \n case \"SAVEHTML\":\n // print(\"%sw\",ar[2]);\n // _this.file.saveHTML(ar[2]);\n return true;\n \n case \"OUT\":\n _this.result_json = ar[2];\n return true;\n \n default:\n return true;\n }\n \n}"
+ "script_dialog" : [
+ " (dialog) => {",
+ " if (this.el == null) {",
+ " return true;",
+ " }",
+ " ",
+ " var msg = dialog.get_message();",
+ " if (msg.length < 4) {",
+ " return false;",
+ " }",
+ " if (msg.substring(0,4) != \"IPC:\") {",
+ " return false;",
+ " }",
+ " var ar = msg.split(\":\", 3);",
+ " if (ar.length < 3) {",
+ " return false;",
+ " }",
+ " print(\"CMD: %s\\n\",ar[1]);",
+ " print(\"ARGS: %s\\n\",ar[2]);",
+ " switch(ar[1]) {",
+ " ",
+ " case \"SAVEHTML\":",
+ " // print(\"%sw\",ar[2]);",
+ " // _this.file.saveHTML(ar[2]);",
+ " return true;",
+ " ",
+ " case \"OUT\":",
+ " _this.result_json = ar[2];",
+ " return true;",
+ " ",
+ " default:",
+ " return true;",
+ " }",
+ " ",
+ "}"
+ ]
},
- "id" : "webview",
- "* init" : " {\n // this may not work!?\n var settings = this.el.get_settings();\n settings.enable_write_console_messages_to_stdout = true;\n \n var fs= new FakeServer(this.el);\n fs.ref();\n // this was an attempt to change the url perms.. did not work..\n // settings.enable_file_access_from_file_uris = true;\n // settings.enable_offline_web_application_cache - true;\n // settings.enable_universal_access_from_file_uris = true;\n \n \n \n \n \n\n // FIXME - base url of script..\n // we need it so some of the database features work.\n this.el.load_html( \"Render not ready\" , \n //fixme - should be a config option!\n // or should we catch stuff and fix it up..\n \"xhttp://localhost/roobuilder/\"\n );\n \n \n \n \n}\n",
- "xtype" : "WebView",
- "* pack" : "add",
- "$ xns" : "WebKit"
+ "xtype" : "WebView"
}
- ]
+ ],
+ "xtype" : "ScrolledWindow"
}
- ]
+ ],
+ "xtype" : "Box"
},
{
- "label" : "Reload",
- "xtype" : "Button",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,3",
- "$ xns" : "Gtk"
+ "label" : "Reload",
+ "xtype" : "Button"
},
{
- "label" : "Cancel",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,0",
- "xtype" : "Button",
- "$ xns" : "Gtk"
+ "label" : "Cancel",
+ "xtype" : "Button"
},
{
- "label" : "OK",
- "xtype" : "Button",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,1",
- "$ xns" : "Gtk"
+ "label" : "OK",
+ "xtype" : "Button"
}
+ ],
+ "listeners" : {
+ "delete_event" : [
+ "(self, event) => {",
+ " this.el.hide();",
+ " return true; ",
+ " //test ",
+ "} "
+ ]
+ },
+ "string result_json" : "",
+ "string tmpjs" : "",
+ "utf8 title" : "Add / Edit Component",
+ "xtype" : "Dialog",
+ "| bool has_plugin" : [
+ "(string cls) {",
+ "",
+ " return GLib.FileUtils.test(",
+ " BuilderApplication.configDirectory() + \"/resources/Editors/Editor.\" + cls + \".js\",",
+ " GLib.FileTest.IS_REGULAR",
+ " );",
+ " ",
+ "",
+ "",
+ "}",
+ ""
+ ],
+ "| string show" : [
+ " (Gtk.Window ?parent, Project.Project project, string cls, string tbl) {// JsRender.Node node) {",
+ " ",
+ " if (parent != null) {",
+ " this.el.set_transient_for(parent);",
+ " this.el.modal = true;",
+ " }",
+ " this.result_json = \"\";",
+ " var db = project.roo_database;",
+ " ",
+ " ",
+ " this.el.show_all();",
+ " var ret = \"\";",
+ " while (true) {",
+ " ",
+ " var runhtml = \"<script type=\\\"text/javascript\\\">\\n\" ;",
+ " string builderhtml;",
+ " ",
+ " try {",
+ " GLib.FileUtils.get_contents(BuilderApplication.configDirectory() + \"/resources/roo.builder.js\", out builderhtml);",
+ " } catch (Error e) {",
+ " builderhtml = \"\";",
+ " }",
+ " ",
+ "",
+ " runhtml += builderhtml + \"\\n\";",
+ " ",
+ " ",
+ " runhtml += \"\\n\" +",
+ " \"Builder.saveHTML = function() {};\\n\" + ",
+ "\t \"Roo.onReady(function() {\\n\" +",
+ "",
+ "\t \"Roo.XComponent.build();\\n\" +",
+ "\t \"});\\n\";",
+ "\t",
+ "\t",
+ " ",
+ "",
+ " var ar = db.readForeignKeys(tbl);",
+ " var generator = new Json.Generator ();",
+ " var root = new Json.Node(Json.NodeType.OBJECT);",
+ " root.init_object(ar);",
+ " generator.set_root (root);",
+ " ",
+ " generator.pretty = true;",
+ " generator.indent = 4;",
+ " ",
+ " runhtml += \"\\n\" +",
+ " \" Roo.XComponent.on('buildcomplete', function() {\\n\" +",
+ " \" Editor.\" + cls + \".panel.loadData(\" + generator.to_data (null) + \"); \" +",
+ " \"});\\n\";",
+ "",
+ " ",
+ "\t",
+ "\t",
+ "",
+ " runhtml += \"</script>\\n\" ;",
+ "",
+ " print(runhtml);",
+ " // fix to make sure they are the same..",
+ " ",
+ " // need to modify paths",
+ "",
+ " string inhtml;",
+ " try {",
+ " GLib.FileUtils.get_contents(",
+ " BuilderApplication.configDirectory() + \"/resources/roo.builder.html\"",
+ " , out inhtml);",
+ " ",
+ " } catch (Error e) {",
+ " inhtml = \"\";",
+ " }",
+ " // fetch the json from the database...",
+ " ",
+ " //print(runhtml);",
+ " ",
+ " var html = inhtml.replace(\"</head>\", runhtml + // + this.runhtml + ",
+ " \"<script type=\\\"text/javascript\\\" src=\\\"resources://localhost/Editors/Editor.\" + cls + \".js\\\"></script>\" + ",
+ " ",
+ " ",
+ " \"</head>\");",
+ " //print(\"LOAD HTML \" + html);",
+ " ",
+ " //var rootURL = _this.file.project.rootURL;",
+ " ",
+ " ",
+ " ",
+ " this.webview.el.load_html( html , ",
+ " //fixme - should be a config option!",
+ " \"xhttp://localhost/roobuilder/\"",
+ " );",
+ " ",
+ " ",
+ " ",
+ " ",
+ " var response_id = this.el.run();",
+ " ",
+ " if (response_id == 1) { // OK...",
+ " var loop = new MainLoop();",
+ " // run toBJS to get the data... (calls back into alert handler)",
+ " _this.result_json = \"\";",
+ " this.webview.el.run_javascript.begin(\"Editor.\" + cls + \".panel.toBJS();\", null, (obj, res) => {",
+ " try {",
+ " this.webview.el.run_javascript.end(res);",
+ " } catch(Error e) {",
+ " ",
+ " }",
+ " loop.quit();",
+ " });",
+ " loop.run();",
+ " ret = _this.result_json;",
+ " ",
+ " ",
+ " // print(\"LOOP END?\");",
+ " // try and get the resopse...",
+ " break;",
+ " }",
+ " if (response_id < 1) {",
+ " this.el.hide();",
+ " return \"\";",
+ " }",
+ " // keep showing...?",
+ " continue;",
+ " }",
+ " ",
+ " // now we save it..",
+ " this.el.hide();",
+ " ",
+ " return ret;",
+ " ",
+ " ",
+ " ",
+ "}",
+ ""
]
}
- ]
-}
+ ],
+ "modOrder" : "",
+ "name" : "DialogPluginWebkit",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogPluginWebkit.bjs",
+ "permname" : "",
+ "title" : ""
+}
\ No newline at end of file