Fix #7962 - meson write
[roobuilder] / src / Builder4 / DialogTemplateSelect.bjs
1 {
2  "build_module" : "builder",
3  "gen_extended" : false,
4  "items" : [
5   {
6    "# JsRender.Node node" : "",
7    "# Palete.Palete palete" : "",
8    "# Project.Project project" : "",
9    "# Xcls_MainWindow window" : "",
10    "$ modal" : true,
11    "$ xns" : "Gtk",
12    "@ void complete" : "(JsRender.Node? node)",
13    "default_height" : 200,
14    "default_width" : 400,
15    "items" : [
16     {
17      "$ xns" : "Gtk",
18      "* pack" : "get_content_area().append",
19      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
20      "items" : [
21       {
22        "$ xns" : "Gtk",
23        "* pack" : "append",
24        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
25        "int margin_end" : 3,
26        "int margin_start" : 3,
27        "items" : [
28         {
29          "$ xns" : "Gtk",
30          "* pack" : "append",
31          "label" : "Select Template : ",
32          "xtype" : "Label"
33         },
34         {
35          "$ xns" : "Gtk",
36          "* init" : "this.el.add_attribute(_this.cellrenderer.el , \"markup\", 1 );",
37          "* pack" : "append",
38          "id" : "combo",
39          "items" : [
40           {
41            "$ xns" : "Gtk",
42            "* pack" : "pack_start,true",
43            "id" : "cellrenderer",
44            "xtype" : "CellRendererText"
45           },
46           {
47            "$ columns" : "typeof(string),typeof(string)",
48            "$ xns" : "Gtk",
49            "* pack" : "set_model",
50            "id" : "model",
51            "n_columns" : 2,
52            "xtype" : "ListStore",
53            "| void loadData" : [
54             "  (GLib.List<string> data) {",
55             "    this.el.clear();                                    ",
56             "    Gtk.TreeIter iter;",
57             "    var el = this.el;",
58             "    ",
59             "   /// el.append(out iter);",
60             "    ",
61             "     ",
62             "   // el.set_value(iter, 0, \"\");",
63             "   // el.set_value(iter, 1, \"aaa  - Just add Element - aaa\");",
64             "    ",
65             "    for (var i = 0; i < data.length();i++) {",
66             "    ",
67             "",
68             "        el.append(out iter);",
69             "        var str = data.nth_data(i);",
70             "        var fn = Path.get_basename (str);",
71             "        fn.replace(\".json\", \"\");",
72             "        ",
73             "        el.set_value(iter, 0, str);",
74             "        el.set_value(iter, 1, fn);",
75             "        ",
76             "    }",
77             "    this.el.set_sort_column_id(1, Gtk.SortType.ASCENDING);          ",
78             "                                     ",
79             "}",
80             ""
81            ]
82           }
83          ],
84          "xtype" : "ComboBox"
85         }
86        ],
87        "xtype" : "Box"
88       },
89       {
90        "$ xns" : "Gtk",
91        "* pack" : "append",
92        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
93        "int margin_end" : 3,
94        "int margin_start" : 3,
95        "items" : [
96         {
97          "$ xns" : "Gtk",
98          "* pack" : "append",
99          "label" : "Select Database Table : ",
100          "xtype" : "Label"
101         },
102         {
103          "$ xns" : "Gtk",
104          "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
105          "* pack" : "append",
106          "id" : "dbcombo",
107          "items" : [
108           {
109            "$ xns" : "Gtk",
110            "* pack" : "pack_start,true",
111            "id" : "dbcellrenderer",
112            "xtype" : "CellRendererText"
113           },
114           {
115            "$ columns" : "typeof(string),typeof(string)",
116            "$ xns" : "Gtk",
117            "* pack" : "set_model",
118            "id" : "dbmodel",
119            "n_columns" : 2,
120            "xtype" : "ListStore",
121            "| void loadData" : [
122             "  (Gee.ArrayList<string> data) {",
123             "    this.el.clear();                                    ",
124             "    Gtk.TreeIter iter;",
125             "    var el = this.el;",
126             "    ",
127             "   /// el.append(out iter);",
128             "    ",
129             "     ",
130             "   // el.set_value(iter, 0, \"\");",
131             "   // el.set_value(iter, 1, \"aaa  - Just add Element - aaa\");",
132             "",
133             "    el.append(out iter);",
134             "",
135             "    ",
136             "    el.set_value(iter, 0, \"\");",
137             "    el.set_value(iter, 1, \"-- select a table --\");",
138             "    ",
139             "    ",
140             "    for (var i = 0; i < data.size;i++) {",
141             "    ",
142             "",
143             "        el.append(out iter);",
144             "        ",
145             "        el.set_value(iter, 0, data.get(i));",
146             "        el.set_value(iter, 1, data.get(i));",
147             "        ",
148             "    }",
149             "     this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          ",
150             "                                     ",
151             "}",
152             ""
153            ]
154           }
155          ],
156          "xtype" : "ComboBox"
157         }
158        ],
159        "xtype" : "Box"
160       }
161      ],
162      "xtype" : "Box"
163     },
164     {
165      "$ xns" : "Gtk",
166      "* pack" : "add_action_widget,0",
167      "label" : "Cancel",
168      "xtype" : "Button"
169     },
170     {
171      "$ xns" : "Gtk",
172      "* pack" : "add_action_widget,1",
173      "label" : "Just add it",
174      "xtype" : "Button"
175     },
176     {
177      "$ xns" : "Gtk",
178      "* pack" : "add_action_widget,2",
179      "label" : "OK",
180      "xtype" : "Button"
181     }
182    ],
183    "listeners" : {
184     "close_request" : [
185      "( ) => {",
186      "",
187      " this.el.hide();",
188      "    return true;;",
189      "}",
190      ""
191     ],
192     "response" : [
193      "(res) => {",
194      "",
195      "\t//var node = _this.node;",
196      "\t//var project = _this.project;",
197      "\treturn;",
198      "   /*",
199      "   ",
200      "   if (this.plugin == null) {",
201      "\t   this.plugin = new Xcls_DialogPluginWebkit();",
202      "\t   this.plugin.complete.connect((json_str) => {",
203      "  \t\t\tprint(\"json_str = %s\\n\", json_str);",
204      "            if (json_str.length < 1) {",
205      "\t\t\t\tthis.complete(_this.node);",
206      "\t\t\t\treturn; ",
207      "            }",
208      "            var pa = new Json.Parser();",
209      "            try {",
210      "",
211      "\t        \tpa.load_from_data(json_str);",
212      "\t\t\t} catch(Error e) {",
213      "\t\t\t     this.complete(node);",
214      "        \t\treturn; // 1 = just add it..",
215      "    \t\t}",
216      "    \t\tvar new_node = pa.get_root();",
217      "\t\t",
218      "\t\t\tif (new_node.get_node_type () != Json.NodeType.OBJECT) {",
219      "\t\t\t\t this.complete(node);",
220      "\t\t\t\t\t\treturn; ",
221      "\t\t\t}",
222      "\t\t\tvar obj = new_node.get_object ();",
223      "",
224      "\t\t\tvar ret = new JsRender.Node();",
225      "",
226      "\t\t\tret.loadFromJson(obj, 1);",
227      "\t \t\tthis.complete(ret);",
228      "  \t\t});",
229      "  ",
230      "   }",
231      "   ",
232      "   ",
233      "     ",
234      "\t",
235      "     this.el.hide();    ",
236      "    //var ix = _this.combo.el.get_active();",
237      "    if (res < 1 ) {",
238      "    \tthis.complete(null);",
239      "        return; // 0 = cancel.",
240      "    }",
241      "    if (res < 2 ) {",
242      "        this.complete(node);",
243      "        return; // 1 = just add it..",
244      "    }",
245      "    ",
246      "    ",
247      "    // have they selected a table??",
248      "    ",
249      "   Gtk.TreeIter iter; ",
250      "    Value vfname;   ",
251      "    if (_this.dbcombo.el.get_active_iter (out iter)) {    ",
252      "         this.dbmodel.el.get_value (iter, 0, out vfname);",
253      "         if (((string)vfname).length > 0 && this.plugin.has_plugin(node.fqn())) {",
254      "            this.plugin.showIt(this.window.el, project, node.fqn(), (string)vfname);",
255      "            return;",
256      "        }",
257      "\t    this.complete(node);",
258      "         return; // 1 = just add it..",
259      "         ",
260      "        ",
261      "    }",
262      "",
263      "    if (!_this.combo.el.get_active_iter (out iter)) {",
264      "",
265      "         this.complete(node);",
266      "        return; // 1 = just add it../ nothing selected...",
267      "    }",
268      "   ",
269      "    this.model.el.get_value (iter, 0, out vfname);",
270      "    ",
271      "     this.complete(this.palete.loadTemplate((string)vfname));",
272      "      return; // 1 = just add it..",
273      "  ",
274      "*/",
275      "}",
276      ""
277     ]
278    },
279    "title" : "Add an Object",
280    "xtype" : "Dialog",
281    "| void showIt" : [
282     " (",
283     " \tXcls_MainWindow mwindow, ",
284     " \tPalete.Palete pal, ",
285     "\t JsRender.Node node, ",
286     "\t Project.Project project",
287     " ) {",
288     "",
289     "\tthis.el.show();",
290     "",
291     "\tvar opts = pal.listTemplates(node);",
292     "\tif (opts.length() < 1) {",
293     "\tthis.el.hide();",
294     "\t\tthis.complete(node);",
295     "\t\treturn; ",
296     "\t}",
297     "\tthis.el.set_transient_for( mwindow.el);",
298     "",
299     "\t//opts.unshift({ path: '' , name :'Just add Element' });",
300     "\t_this.model.loadData(opts);",
301     "\t_this.combo.el.set_active(-1);",
302     "",
303     "/*",
304     "\tvar db =  new Palete.RooDatabase.from_project((Project.Roo) project);",
305     "\t_this.dbmodel.loadData(db.readTablesGee());",
306     "",
307     "",
308     "\t_this.dbcombo.el.set_active(-1);",
309     "*/",
310     "\tthis.window = mwindow;",
311     "\tthis.palete = pal;",
312     "\tthis.node = node;",
313     "\tthis.project = project;",
314     "   ",
315     "}",
316     ""
317    ]
318   }
319  ],
320  "name" : "DialogTemplateSelect"
321 }