{
- "name" : "DialogTemplateSelect",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/DialogTemplateSelect.bjs",
- "permname" : "",
- "modOrder" : "",
"build_module" : "builder",
+ "gen_extended" : false,
"items" : [
{
- "listeners" : {
- "delete_event" : " (self, event) =>{\n this.el.hide();\n return true;\n} "
- },
- "default_width" : 400,
- "title" : "Add an Object",
- "xtype" : "Dialog",
- "default_height" : 200,
+ "# JsRender.Node node" : "",
+ "# Palete.Palete palete" : "",
+ "# Project.Project project" : "",
+ "# Xcls_MainWindow window" : "",
"$ modal" : true,
"$ xns" : "Gtk",
- "| JsRender.Node? show" : " (Xcls_MainWindow mwindow, Palete.Palete pal, JsRender.Node node, Project.Project project) {\n \n this.el.show_all();\n var opts = pal.listTemplates(node);\n if (opts.length() < 1) {\n this.el.hide();\n return node;\n }\n this.el.set_attached_to( mwindow.el);\n this.el.set_transient_for( mwindow.el);\n \n //opts.unshift({ path: '' , name :'Just add Element' });\n _this.model.loadData(opts);\n _this.combo.el.set_active(-1);\n \n \n var db = new Palete.RooDatabase.from_project(project);\n _this.dbmodel.loadData(db.readTablesGee());\n \n var plug = mwindow.windowstate.webkit_plugin;\n \n _this.dbcombo.el.set_active(-1);\n \n \n \n var res = this.el.run();\n this.el.hide(); \n //var ix = _this.combo.el.get_active();\n if (res < 1 ) {\n return null; // 0 = cancel.\n }\n if (res < 2 ) {\n return node; // 1 = just add it..\n }\n \n // have they selected a table??\n \n Gtk.TreeIter iter; \n Value vfname; \n if (_this.dbcombo.el.get_active_iter (out iter)) { \n this.dbmodel.el.get_value (iter, 0, out vfname);\n if (((string)vfname).length > 0 && plug.has_plugin(node.fqn())) {\n var json_str = plug.show(mwindow.el, project, node.fqn(), (string)vfname);\n print(\"json_str = %s\\n\", json_str);\n if (json_str.length < 1) {\n\n return node;\n }\n var pa = new Json.Parser();\n try {\n\n\t pa.load_from_data(json_str);\n\t } catch(Error e) {\n\t return node;\n\t }\n\t var new_node = pa.get_root();\n \n\t if (new_node.get_node_type () != Json.NodeType.OBJECT) {\n\t\t return node;\n\t }\n\t var obj = new_node.get_object ();\n\n\t var ret = new JsRender.Node();\n\n\t ret.loadFromJson(obj, 1);\n\t return ret;\n }\n \n }\n\n if (!_this.combo.el.get_active_iter (out iter)) {\n\n return node; // nothing selected...\n }\n \n this.model.el.get_value (iter, 0, out vfname);\n \n \n return pal.loadTemplate((string)vfname);\n\n}\n",
+ "@ void complete" : "(JsRender.Node? node)",
+ "default_height" : 200,
+ "default_width" : 400,
"items" : [
{
- "xtype" : "Box",
- "$ pack" : "get_content_area().add ",
"$ xns" : "Gtk",
+ "* pack" : "get_content_area().append",
"Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
"items" : [
{
- "* pack" : "pack_start,false,false,0",
- "xtype" : "Box",
- "gint margin" : 3,
"$ xns" : "Gtk",
+ "* pack" : "append",
"Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+ "int margin_end" : 3,
+ "int margin_start" : 3,
"items" : [
{
+ "$ xns" : "Gtk",
+ "* pack" : "append",
"label" : "Select Template : ",
- "xtype" : "Label",
- "* pack" : "pack_start,false,false",
- "$ xns" : "Gtk"
+ "xtype" : "Label"
},
{
- "id" : "combo",
- "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );",
- "xtype" : "ComboBox",
- "* pack" : "add",
"$ xns" : "Gtk",
+ "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );",
+ "* pack" : "append",
+ "id" : "combo",
"items" : [
{
- "id" : "cellrenderer",
- "xtype" : "CellRendererText",
+ "$ xns" : "Gtk",
"* pack" : "pack_start,true",
- "$ xns" : "Gtk"
+ "id" : "cellrenderer",
+ "xtype" : "CellRendererText"
},
{
- "id" : "model",
- "* pack" : "set_model",
- "xtype" : "ListStore",
"$ columns" : "typeof(string),typeof(string)",
- "n_columns" : 2,
"$ xns" : "Gtk",
- "| void loadData" : " (GLib.List<string> data) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n \n for (var i = 0; i < data.length();i++) {\n \n\n el.append(out iter);\n var str = data.nth_data(i);\n var fn = Path.get_basename (str);\n fn.replace(\".json\", \"\");\n \n el.set_value(iter, 0, str);\n el.set_value(iter, 1, fn);\n \n }\n this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); \n \n}\n"
+ "* pack" : "set_model",
+ "id" : "model",
+ "n_columns" : 2,
+ "xtype" : "ListStore",
+ "| void loadData" : [
+ " (GLib.List<string> data) {",
+ " this.el.clear(); ",
+ " Gtk.TreeIter iter;",
+ " var el = this.el;",
+ " ",
+ " /// el.append(out iter);",
+ " ",
+ " ",
+ " // el.set_value(iter, 0, \"\");",
+ " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
+ " ",
+ " for (var i = 0; i < data.length();i++) {",
+ " ",
+ "",
+ " el.append(out iter);",
+ " var str = data.nth_data(i);",
+ " var fn = Path.get_basename (str);",
+ " fn.replace(\".json\", \"\");",
+ " ",
+ " el.set_value(iter, 0, str);",
+ " el.set_value(iter, 1, fn);",
+ " ",
+ " }",
+ " this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING); ",
+ " ",
+ "}",
+ ""
+ ]
}
- ]
+ ],
+ "xtype" : "ComboBox"
}
- ]
+ ],
+ "xtype" : "Box"
},
{
- "* pack" : "pack_start,false,false,0",
- "xtype" : "Box",
- "gint margin" : 3,
"$ xns" : "Gtk",
+ "* pack" : "append",
"Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
+ "int margin_end" : 3,
+ "int margin_start" : 3,
"items" : [
{
+ "$ xns" : "Gtk",
+ "* pack" : "append",
"label" : "Select Database Table : ",
- "xtype" : "Label",
- "* pack" : "pack_start,false,false",
- "$ xns" : "Gtk"
+ "xtype" : "Label"
},
{
- "id" : "dbcombo",
- "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
- "xtype" : "ComboBox",
- "* pack" : "add",
"$ xns" : "Gtk",
+ "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
+ "* pack" : "append",
+ "id" : "dbcombo",
"items" : [
{
- "id" : "dbcellrenderer",
- "xtype" : "CellRendererText",
+ "$ xns" : "Gtk",
"* pack" : "pack_start,true",
- "$ xns" : "Gtk"
+ "id" : "dbcellrenderer",
+ "xtype" : "CellRendererText"
},
{
- "id" : "dbmodel",
- "* pack" : "set_model",
- "xtype" : "ListStore",
"$ columns" : "typeof(string),typeof(string)",
- "n_columns" : 2,
"$ xns" : "Gtk",
- "| void loadData" : " (Gee.ArrayList<string> data) {\n this.el.clear(); \n Gtk.TreeIter iter;\n var el = this.el;\n \n /// el.append(out iter);\n \n \n // el.set_value(iter, 0, \"\");\n // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");\n\n el.append(out iter);\n\n \n el.set_value(iter, 0, \"\");\n el.set_value(iter, 1, \"-- select a table --\");\n \n \n for (var i = 0; i < data.size;i++) {\n \n\n el.append(out iter);\n \n el.set_value(iter, 0, data.get(i));\n el.set_value(iter, 1, data.get(i));\n \n }\n this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); \n \n}\n"
+ "* pack" : "set_model",
+ "id" : "dbmodel",
+ "n_columns" : 2,
+ "xtype" : "ListStore",
+ "| void loadData" : [
+ " (Gee.ArrayList<string> data) {",
+ " this.el.clear(); ",
+ " Gtk.TreeIter iter;",
+ " var el = this.el;",
+ " ",
+ " /// el.append(out iter);",
+ " ",
+ " ",
+ " // el.set_value(iter, 0, \"\");",
+ " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
+ "",
+ " el.append(out iter);",
+ "",
+ " ",
+ " el.set_value(iter, 0, \"\");",
+ " el.set_value(iter, 1, \"-- select a table --\");",
+ " ",
+ " ",
+ " for (var i = 0; i < data.size;i++) {",
+ " ",
+ "",
+ " el.append(out iter);",
+ " ",
+ " el.set_value(iter, 0, data.get(i));",
+ " el.set_value(iter, 1, data.get(i));",
+ " ",
+ " }",
+ " this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ",
+ " ",
+ "}",
+ ""
+ ]
}
- ]
+ ],
+ "xtype" : "ComboBox"
}
- ]
+ ],
+ "xtype" : "Box"
}
- ]
+ ],
+ "xtype" : "Box"
},
{
- "label" : "Cancel",
- "xtype" : "Button",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,0",
- "$ xns" : "Gtk"
+ "label" : "Cancel",
+ "xtype" : "Button"
},
{
- "label" : "Just add it",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,1",
- "xtype" : "Button",
- "$ xns" : "Gtk"
+ "label" : "Just add it",
+ "xtype" : "Button"
},
{
- "label" : "OK",
- "xtype" : "Button",
+ "$ xns" : "Gtk",
"* pack" : "add_action_widget,2",
- "$ xns" : "Gtk"
+ "label" : "OK",
+ "xtype" : "Button"
}
+ ],
+ "listeners" : {
+ "close_request" : [
+ "( ) => {",
+ "",
+ " this.el.hide();",
+ " return true;;",
+ "}",
+ ""
+ ],
+ "response" : [
+ "(res) => {",
+ "",
+ "\t//var node = _this.node;",
+ "\t//var project = _this.project;",
+ "\treturn;",
+ " /*",
+ " ",
+ " if (this.plugin == null) {",
+ "\t this.plugin = new Xcls_DialogPluginWebkit();",
+ "\t this.plugin.complete.connect((json_str) => {",
+ " \t\t\tprint(\"json_str = %s\\n\", json_str);",
+ " if (json_str.length < 1) {",
+ "\t\t\t\tthis.complete(_this.node);",
+ "\t\t\t\treturn; ",
+ " }",
+ " var pa = new Json.Parser();",
+ " try {",
+ "",
+ "\t \tpa.load_from_data(json_str);",
+ "\t\t\t} catch(Error e) {",
+ "\t\t\t this.complete(node);",
+ " \t\treturn; // 1 = just add it..",
+ " \t\t}",
+ " \t\tvar new_node = pa.get_root();",
+ "\t\t",
+ "\t\t\tif (new_node.get_node_type () != Json.NodeType.OBJECT) {",
+ "\t\t\t\t this.complete(node);",
+ "\t\t\t\t\t\treturn; ",
+ "\t\t\t}",
+ "\t\t\tvar obj = new_node.get_object ();",
+ "",
+ "\t\t\tvar ret = new JsRender.Node();",
+ "",
+ "\t\t\tret.loadFromJson(obj, 1);",
+ "\t \t\tthis.complete(ret);",
+ " \t\t});",
+ " ",
+ " }",
+ " ",
+ " ",
+ " ",
+ "\t",
+ " this.el.hide(); ",
+ " //var ix = _this.combo.el.get_active();",
+ " if (res < 1 ) {",
+ " \tthis.complete(null);",
+ " return; // 0 = cancel.",
+ " }",
+ " if (res < 2 ) {",
+ " this.complete(node);",
+ " return; // 1 = just add it..",
+ " }",
+ " ",
+ " ",
+ " // have they selected a table??",
+ " ",
+ " Gtk.TreeIter iter; ",
+ " Value vfname; ",
+ " if (_this.dbcombo.el.get_active_iter (out iter)) { ",
+ " this.dbmodel.el.get_value (iter, 0, out vfname);",
+ " if (((string)vfname).length > 0 && this.plugin.has_plugin(node.fqn())) {",
+ " this.plugin.showIt(this.window.el, project, node.fqn(), (string)vfname);",
+ " return;",
+ " }",
+ "\t this.complete(node);",
+ " return; // 1 = just add it..",
+ " ",
+ " ",
+ " }",
+ "",
+ " if (!_this.combo.el.get_active_iter (out iter)) {",
+ "",
+ " this.complete(node);",
+ " return; // 1 = just add it../ nothing selected...",
+ " }",
+ " ",
+ " this.model.el.get_value (iter, 0, out vfname);",
+ " ",
+ " this.complete(this.palete.loadTemplate((string)vfname));",
+ " return; // 1 = just add it..",
+ " ",
+ "*/",
+ "}",
+ ""
+ ]
+ },
+ "title" : "Add an Object",
+ "xtype" : "Dialog",
+ "| void showIt" : [
+ " (",
+ " \tXcls_MainWindow mwindow, ",
+ " \tPalete.Palete pal, ",
+ "\t JsRender.Node node, ",
+ "\t Project.Project project",
+ " ) {",
+ "",
+ "\tthis.el.show();",
+ "",
+ "\tvar opts = pal.listTemplates(node);",
+ "\tif (opts.length() < 1) {",
+ "\tthis.el.hide();",
+ "\t\tthis.complete(node);",
+ "\t\treturn; ",
+ "\t}",
+ "\tthis.el.set_transient_for( mwindow.el);",
+ "",
+ "\t//opts.unshift({ path: '' , name :'Just add Element' });",
+ "\t_this.model.loadData(opts);",
+ "\t_this.combo.el.set_active(-1);",
+ "",
+ " ",
+ "\tvar db = new Palete.RooDatabase.from_project((Project.Roo) project);",
+ "\t_this.dbmodel.loadData(db.readTablesGee());",
+ "",
+ "",
+ "\t_this.dbcombo.el.set_active(-1);",
+ " ",
+ "\tthis.window = mwindow;",
+ "\tthis.palete = pal;",
+ "\tthis.node = node;",
+ "\tthis.project = project;",
+ " ",
+ "}",
+ ""
]
}
- ]
+ ],
+ "name" : "DialogTemplateSelect"
}
\ No newline at end of file