{ "build_module" : "builder", "gen_extended" : false, "items" : [ { "# JsRender.Node node" : "", "# Palete.Palete palete" : "", "# Project.Project project" : "", "# Xcls_MainWindow window" : "", "$ modal" : true, "$ xns" : "Gtk", "@ void complete" : "(JsRender.Node? node)", "default_height" : 200, "default_width" : 400, "items" : [ { "$ xns" : "Gtk", "* pack" : "get_content_area().append", "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL", "items" : [ { "$ 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" }, { "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );", "* pack" : "append", "id" : "combo", "items" : [ { "$ xns" : "Gtk", "* pack" : "pack_start,true", "id" : "cellrenderer", "xtype" : "CellRendererText" }, { "$ columns" : "typeof(string),typeof(string)", "$ xns" : "Gtk", "* pack" : "set_model", "id" : "model", "n_columns" : 2, "xtype" : "ListStore", "| void loadData" : [ " (GLib.List 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" }, { "$ 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" }, { "$ xns" : "Gtk", "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", "* pack" : "append", "id" : "dbcombo", "items" : [ { "$ xns" : "Gtk", "* pack" : "pack_start,true", "id" : "dbcellrenderer", "xtype" : "CellRendererText" }, { "$ columns" : "typeof(string),typeof(string)", "$ xns" : "Gtk", "* pack" : "set_model", "id" : "dbmodel", "n_columns" : 2, "xtype" : "ListStore", "| void loadData" : [ " (Gee.ArrayList 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" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,0", "label" : "Cancel", "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,1", "label" : "Just add it", "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,2", "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" }