5 "# JsRender.JsRender file" : "null",
6 "# Project.Project project" : "",
10 "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
11 "default_height" : 200,
12 "default_width" : 500,
13 "id" : "DialogNewComponent",
16 "$ pack" : "get_content_area().add",
18 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
21 "$ homogeneous" : true,
23 "* pack" : "pack_start,false,false,0",
27 "* pack" : "attach,0,0",
28 "Gtk.Justification justify" : "Gtk.Justification.RIGHT",
29 "label" : "Component Name",
31 "xalign" : 0.90000000000000002,
37 "* pack" : "attach,1,0",
44 "* pack" : "attach,0,1",
45 "Gtk.Justification justify" : "Gtk.Justification.RIGHT",
48 "xalign" : 0.90000000000000002,
54 "* pack" : "attach,1,1",
59 "$ justify" : "Gtk.Justification.RIGHT",
62 "* pack" : "attach,0,2",
64 "tooltip_text" : "center, north, south, east, west",
66 "xalign" : 0.90000000000000002,
72 "* pack" : "attach,1,2",
77 "$ justify" : "Gtk.Justification.RIGHT",
80 "* pack" : "attach,0,3",
81 "label" : "Parent Name",
83 "xalign" : 0.90000000000000002,
89 "* pack" : "attach,1,3",
94 "$ justify" : "Gtk.Justification.RIGHT",
97 "* pack" : "attach,0,4",
98 "label" : "Permission Name",
100 "xalign" : 0.90000000000000002,
106 "* pack" : "attach,1,4",
111 "$ justify" : "Gtk.Justification.RIGHT",
114 "* pack" : "attach,0,6",
115 "label" : "Order (for tabs)",
117 "xalign" : 0.90000000000000002,
123 "* pack" : "attach,1,6",
128 "$ justify" : "Gtk.Justification.RIGHT",
131 "* pack" : "attach,0,7",
132 "label" : "Module to build (Vala only)",
134 "xalign" : 0.90000000000000002,
139 "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
140 "* pack" : "attach,1,7",
141 "id" : "build_module",
145 "* pack" : "pack_start,true",
146 "id" : "dbcellrenderer",
147 "xtype" : "CellRendererText"
150 "$ columns" : "typeof(string),typeof(string)",
152 "* pack" : "set_model",
155 "xtype" : "ListStore",
156 "| void loadData" : [
157 " (Gee.ArrayList<string> data, string cur) {",
158 " this.el.clear(); ",
159 " Gtk.TreeIter iter;",
160 " var el = this.el;",
162 " /// el.append(out iter);",
165 " // el.set_value(iter, 0, \"\");",
166 " // el.set_value(iter, 1, \"aaa - Just add Element - aaa\");",
168 " el.append(out iter);",
171 " el.set_value(iter, 0, \"\");",
172 " el.set_value(iter, 1, \"-- select a module --\");",
173 " _this.build_module.el.set_active_iter(iter);",
175 " for (var i = 0; i < data.size;i++) {",
178 " el.append(out iter);",
180 " el.set_value(iter, 0, data.get(i));",
181 " el.set_value(iter, 1, data.get(i));",
183 " if (data.get(i) == cur) {",
184 " _this.build_module.el.set_active_iter(iter);",
188 " this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING); ",
207 "* pack" : "add_action_widget,0",
213 "* pack" : "add_action_widget,1",
220 "(self, event) => {",
227 " (self, response_id) => { ",
229 "\tif (response_id < 1) { // cancel!",
236 " if (_this.name.el.get_text().length < 1) {",
237 " Xcls_StandardErrorDialog.singleton().show(",
239 " \"You have to set Component name \"",
244 " // what does this do?",
246 " var isNew = _this.file.name.length > 0 ? false : true;",
248 " if (!isNew && this.file.name != _this.name.el.get_text()) {",
249 " Xcls_StandardErrorDialog.singleton().show(",
251 " \"Sorry changing names does not work yet. \"",
260 " // FIXME - this may be more complicated...",
261 " //for (var i in this.def) {",
262 " // this.file[i] = this.get(i).el.get_text();",
267 " this.updateFileFromEntry();",
270 " _this.file.save();",
274 " var fn = this.name.el.get_text();",
275 " var dir = _this.project.firstPath();",
277 " if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {",
278 " Xcls_StandardErrorDialog.singleton().show(",
280 " \"That file already exists\"",
285 "\t\t var f = JsRender.JsRender.factory(",
286 "\t\t _this.file.project.xtype, ",
287 "\t\t _this.file.project, ",
288 "\t\t dir + \"/\" + fn + \".bjs\");",
290 "\t\t _this.file = f;",
292 "\t\t} catch (JsRender.Error e) {",
293 "\t\t Xcls_StandardErrorDialog.singleton().show(",
295 " \"Error creating file? \"",
301 " this.updateFileFromEntry();",
302 " _this.file.save();",
303 " _this.file.project.addFile(_this.file);",
306 " // what about .js ?",
311 " //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());",
313 " //var nf = _this.project.create(dir + \"/\" + _this.file.name + \".bjs\");",
314 " //for (var i in this.file) {",
315 " // nf[i] = this.file[i];",
317 " _this.success(_this.project, _this.file);",
320 " -- fixme -- needs to be a signal..",
321 " if (DialogNewComponent.success != null) {",
322 " DialogNewComponent.success(_this.project, nf);",
329 " this.el.show_all();",
334 "title" : "New Component",
337 "(JsRender.JsRender c) ",
339 " this.project = c.project;",
341 " //if (!this.el) {",
345 " _this.name.el.set_text(c.name);",
346 " _this.title.el.set_text(c.title);",
347 " _this.parent.el.set_text(c.parent); ",
348 " _this.region.el.set_text(c.region);",
349 " _this.modOrder.el.set_text(c.modOrder);",
350 " _this.permname.el.set_text(c.permname);",
352 " if (c.path.length > 0) {",
353 " this.el.set_title(\"Edit File Details - \" + c.name);",
355 " this.el.set_title(\"Create New File\");",
358 " var ar = new Gee.ArrayList<string>();",
359 " _this.dbmodel.loadData(ar,\"\");",
360 " // load the modules... if relivant..",
361 " if (this.project.xtype == \"Gtk\") {",
362 " var p = (Project.Gtk)c.project;",
363 " var cg = p.compilegroups;",
365 " var iter = cg.map_iterator();",
366 " while(iter.next()) {",
367 " var key = iter.get_key();",
368 " if (key == \"_default_\") {",
373 " _this.dbmodel.loadData(ar, c.build_module);",
378 " //console.log('show all');",
379 " this.el.show_all();",
381 " //this.success = c.success;",
386 "| void updateFileFromEntry" : [
389 " _this.file.title = _this.title.el.get_text();",
390 " _this.file.region = _this.region.el.get_text(); ",
391 " _this.file.parent = _this.parent.el.get_text(); ",
392 " _this.file.permname = _this.permname.el.get_text(); ",
393 " _this.file.modOrder = _this.modOrder.el.get_text();",
395 " if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {",
397 " \t_this.file.renameTo(_this.name.el.get_text());",
398 " \t} catch (JsRender.Error e) {",
402 " // store the module...",
403 " _this.file.build_module = \"\"; ",
404 " Gtk.TreeIter iter; ",
405 " if (_this.build_module.el.get_active_iter (out iter)) {",
407 " this.dbmodel.el.get_value (iter, 0, out vfname);",
408 " if (((string)vfname).length > 0) {",
409 " _this.file.build_module = (string)vfname;",
422 "name" : "DialogNewComponent",
424 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/DialogNewComponent.bjs",