X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FBuilder4%2FDialogTemplateSelect.bjs;h=c0d04c701ab63607cdbfcc1fb4e866038c748e58;hb=1eb7406e95f4a90ed6e88f4a57efa53c329dc46d;hp=21e56c0c92ae5ec91899425611f26bf2de18b22c;hpb=193830fa89ab329b309b8a7f7aff16db390a5825;p=app.Builder.js diff --git a/src/Builder4/DialogTemplateSelect.bjs b/src/Builder4/DialogTemplateSelect.bjs index 21e56c0c9..c0d04c701 100644 --- a/src/Builder4/DialogTemplateSelect.bjs +++ b/src/Builder4/DialogTemplateSelect.bjs @@ -11,12 +11,12 @@ "delete_event" : " (self, event) =>{\n this.el.hide();\n return true;\n}" }, "default_width" : 400, - "xtype" : "Dialog", "title" : "Add an Object", + "xtype" : "Dialog", "default_height" : 200, "$ modal" : true, "$ xns" : "Gtk", - "| JsRender.Node? show" : " (Gtk.Window pwindow, Palete.Palete pal, JsRender.Node node) {\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( pwindow);\n this.el.set_transient_for( pwindow);\n \n //opts.unshift({ path: '' , name :'Just add Element' });\n _this.model.loadData(opts);\n _this.combo.el.set_active(0);\n \n \n this.el.run();\n this.el.hide(); \n //var ix = _this.combo.el.get_active();\n //if (ix < 1 ) {\n // return node;\n // }\n Gtk.TreeIter iter;\n _this.combo.el.get_active_iter (out iter);\n Value vfname;\n this.model.el.get_value (iter, 0, out vfname);\n \n if (((string)vfname).length < 1) {\n return node;\n }\n return pal.loadTemplate((string)vfname);\n\n}\n", + "| 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\t pa.load_from_data(json_str);\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", "items" : [ { "xtype" : "VBox", @@ -24,14 +24,15 @@ "$ xns" : "Gtk", "items" : [ { - "* pack" : "pack_start,false,false,0", "xtype" : "HBox", + "gint margin" : 3, + "* pack" : "pack_start,false,false,0", "$ xns" : "Gtk", "items" : [ { "label" : "Select Template : ", - "* pack" : "pack_start,false,false", "xtype" : "Label", + "* pack" : "pack_start,false,false", "$ xns" : "Gtk" }, { @@ -43,14 +44,14 @@ "items" : [ { "id" : "cellrenderer", - "* pack" : "pack_start,true", "xtype" : "CellRendererText", + "* pack" : "pack_start,true", "$ xns" : "Gtk" }, { "id" : "model", - "xtype" : "ListStore", "* pack" : "set_model", + "xtype" : "ListStore", "$ columns" : "typeof(string),typeof(string)", "n_columns" : 2, "$ xns" : "Gtk", @@ -59,25 +60,63 @@ ] } ] + }, + { + "xtype" : "HBox", + "gint margin" : 3, + "* pack" : "pack_start,false,false,0", + "$ xns" : "Gtk", + "items" : [ + { + "label" : "Select Database Table : ", + "xtype" : "Label", + "* pack" : "pack_start,false,false", + "$ xns" : "Gtk" + }, + { + "id" : "dbcombo", + "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );", + "xtype" : "ComboBox", + "* pack" : "add", + "$ xns" : "Gtk", + "items" : [ + { + "id" : "dbcellrenderer", + "xtype" : "CellRendererText", + "* pack" : "pack_start,true", + "$ xns" : "Gtk" + }, + { + "id" : "dbmodel", + "* pack" : "set_model", + "xtype" : "ListStore", + "$ columns" : "typeof(string),typeof(string)", + "n_columns" : 2, + "$ xns" : "Gtk", + "| void loadData" : " (Gee.ArrayList 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" + } + ] + } + ] } ] }, { - "label" : "OK", - "* pack" : "add_action_widget,0", + "label" : "Cancel", "xtype" : "Button", + "* pack" : "add_action_widget,0", "$ xns" : "Gtk" }, { - "label" : "OK", + "label" : "Just add it", + "* pack" : "add_action_widget,1", "xtype" : "Button", - "* pack" : "add_action_widget,0", "$ xns" : "Gtk" }, { "label" : "OK", - "* pack" : "add_action_widget,0", "xtype" : "Button", + "* pack" : "add_action_widget,2", "$ xns" : "Gtk" } ]