resources/RooUsage.txt
[app.Builder.js] / src / Builder4 / PopoverFileDetails.bjs
1 {
2  "name" : "PopoverFileDetails",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/PopoverFileDetails.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "listeners" : {
12     "closed" : "() => {\n  if (!this.done) {\n    _this.el.show();\n  \n  }\n} "
13    },
14    "|   void updateFileFromEntry" : "() {\n\n        _this.file.title = _this.title.el.get_text();\n        _this.file.region = _this.region.el.get_text();            \n        _this.file.parent = _this.parent.el.get_text();                        \n        _this.file.permname = _this.permname.el.get_text();                                    \n        _this.file.modOrder = _this.modOrder.el.get_text();\n        \n        if (_this.file.name.length  > 0 && _this.file.name != _this.name.el.get_text()) {\n            _this.file.renameTo(_this.name.el.get_text());\n        }\n        // store the module...\n        _this.file.build_module = \"\";        \n         Gtk.TreeIter iter; \n        if (_this.build_module.el.get_active_iter (out iter)) {\n             Value vfname;\n             this.dbmodel.el.get_value (iter, 0, out vfname);\n             if (((string)vfname).length > 0) {\n                 _this.file.build_module = (string)vfname;\n             }\n    \n        }\n        \n        \n\n                                                    \n}    ",
15    "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
16    "id" : "PopoverFileDetails",
17    "| void show" : "(JsRender.JsRender c, Gtk.Widget btn) \n{\n    this.project = c.project;\n    this.done = false;\n    \n    \n    //if (!this.el) {\n        //this.init();\n     //}\n    \n    _this.name.el.set_text(c.name);\n    _this.title.el.set_text(c.title);\n    _this.parent.el.set_text(c.parent);    \n    _this.region.el.set_text(c.region);\n    _this.modOrder.el.set_text(c.modOrder);\n     _this.permname.el.set_text(c.permname);\n    \n    \n    \n    \n    \n    \n    \n    \n     var ar = new Gee.ArrayList<string>();\n     _this.dbmodel.loadData(ar,\"\");\n    // load the modules... if relivant..\n    if (this.project.xtype == \"Gtk\") {\n        var p = (Project.Gtk)c.project;\n          var cg = p.compilegroups;\n\n        var iter = cg.map_iterator();\n       while(iter.next()) {\n            var key = iter.get_key();\n            if (key == \"_default_\") {\n                continue;\n            }\n            ar.add(key);\n        };\n        _this.dbmodel.loadData(ar, c.build_module);\n\n    }\n    \n     \n    _this.file = c;\n    //console.log('show all');\n   this.el.set_modal(true);\n    this.el.set_relative_to(btn);\n\n    this.el.set_position(Gtk.PositionType.RIGHT);\n    \n    // window + header?\n     print(\"SHOWALL - POPIP\\n\");\n    this.el.show_all();\n    this.name.el.grab_focus();\n    \n    \n    \n    if (c.path.length > 0) {\n\t    this.save_btn.el.set_label(\"Save\");\n\t\t_this.filetype.el.hide();\n\t\t_this.filetypelbl.el.hide();\n\t\t_this.filetype.showhide(true); // as we only work on bjs files currently\n    } else {\n        this.save_btn.el.set_label(\"Create\");\n        _this.ftdbmodel.loadData(\"bjs\"); // fixme - need to determine type..\n\t    _this.filetype.el.show();\n\t    _this.filetypelbl.el.show();\n    }\n    \n    \n    //this.success = c.success;\n    \n    \n}",
18    "bool done" : false,
19    "# Project.Project project" : "",
20    "xtype" : "Popover",
21    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
22    "# JsRender.JsRender file" : "null",
23    "$ xns" : "Gtk",
24    "Xcls_MainWindow mainwindow" : "null",
25    "bool modal" : true,
26    "uint border_width" : 0,
27    "items" : [
28     {
29      "bool homogeneous" : false,
30      "xtype" : "Box",
31      "$ pack" : "add",
32      "$ xns" : "Gtk",
33      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
34      "items" : [
35       {
36        "* pack" : "pack_start,false,true,0",
37        "xtype" : "HeaderBar",
38        "$ xns" : "Gtk",
39        "string title" : "Add / Edit File"
40       },
41       {
42        "id" : "grid",
43        "int margin_right" : 4,
44        "* pack" : "pack_start,false,false,4",
45        "xtype" : "Grid",
46        "uint row_spacing" : 2,
47        "n_columns" : 2,
48        "$ xns" : "Gtk",
49        "n_rows" : 7,
50        "$ homogeneous" : true,
51        "int margin_left" : 4,
52        "items" : [
53         {
54          "label" : "File type",
55          "id" : "filetypelbl",
56          "xalign" : 0.90000000000000002,
57          "* pack" : "attach,0,0,1,1",
58          "xtype" : "Label",
59          "$ justify" : "Gtk.Justification.RIGHT",
60          "x_options" : 4,
61          "$ xns" : "Gtk"
62         },
63         {
64          "listeners" : {
65           "changed" : "() => {\n\tGtk.TreeIter iter;\n\tbool is_bjs = true;\n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.ftdbmodel.el.get_value (iter, 0, out vfname);\n\t\t is_bjs = ((string)vfname) == \"bjs\";\n\t}\n    \n  \n    // directory is only available for non-bjs \n    this.showhide(is_bjs);\n\n\n}\n"
66          },
67          "id" : "filetype",
68          "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );",
69          "* pack" : "attach,1,0,1,1",
70          "xtype" : "ComboBox",
71          "| void showhide" : "(bool is_bjs) {\n\tfor (var i = 2; i < 9;i++) {\n\t\tvar el = _this.grid.el.get_child_at(0,i);\n\t\t\n\t\tvar showhide= is_bjs;\n\t\tif (i> 7) {\n\t\t\tshowhide = !showhide;\n\t\t}\n\t\t\n\t\tif (showhide) {\n\t\t   el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}\n\t\t el = _this.grid.el.get_child_at(1,i);\n\t\tif (showhide) {\n\t\t   el.show();\n\t\t} else {\n\t\t\tel.hide();\n\t\t}     \n    }\n    // load up the directories\n    //??? why can we not create bjs files in other directories??\n\tif (!is_bjs && _this.file.path.length < 1) {\n\t\t_this.dirmodel.loadData();\n\t\t\n\t\t\n\t}\n   \n    \n}\n",
72          "$ xns" : "Gtk",
73          "items" : [
74           {
75            "id" : "ftdbcellrenderer",
76            "* pack" : "pack_start,true",
77            "xtype" : "CellRendererText",
78            "$ xns" : "Gtk"
79           },
80           {
81            "id" : "ftdbmodel",
82            "* pack" : "set_model",
83            "xtype" : "ListStore",
84            "$ columns" : "typeof(string),typeof(string)",
85            "n_columns" : 2,
86            "$ xns" : "Gtk",
87            "| void loadData" : "  (string cur) {\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, \"bjs\");\n    el.set_value(iter, 1, \"User Interface File (bjs)\");\n    _this.filetype.el.set_active_iter(iter);\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"vala\");\n    el.set_value(iter, 1, \"Vala\");\n\tif (cur == \"vala\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n\n\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"js\");\n    el.set_value(iter, 1, \"Javascript\");\n\n\tif (cur == \"js\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n\n    el.append(out iter);\n    \n    el.set_value(iter, 0, \"css\");\n    el.set_value(iter, 1, \"CSS\");\n\n\tif (cur == \"css\") {\n\t    _this.filetype.el.set_active_iter(iter);\n    }\n                                     \n}\n"
88           }
89          ]
90         },
91         {
92          "label" : "Component Name",
93          "xalign" : 0.90000000000000002,
94          "* pack" : "attach,0,1,1,1",
95          "xtype" : "Label",
96          "$ justify" : "Gtk.Justification.RIGHT",
97          "x_options" : 4,
98          "$ xns" : "Gtk"
99         },
100         {
101          "id" : "name",
102          "$ visible" : true,
103          "xtype" : "Entry",
104          "* pack" : "attach,1,1,1,1",
105          "$ xns" : "Gtk"
106         },
107         {
108          "label" : "Title",
109          "$ visible" : true,
110          "xalign" : 0.90000000000000002,
111          "* pack" : "attach,0,2,1,1",
112          "xtype" : "Label",
113          "$ justify" : "Gtk.Justification.RIGHT",
114          "x_options" : 4,
115          "$ xns" : "Gtk"
116         },
117         {
118          "id" : "title",
119          "$ visible" : true,
120          "xtype" : "Entry",
121          "* pack" : "attach,1,2,1,1",
122          "$ xns" : "Gtk"
123         },
124         {
125          "label" : "Region",
126          "$ visible" : true,
127          "tooltip_text" : "center, north, south, east, west",
128          "xalign" : 0.90000000000000002,
129          "* pack" : "attach,0,3,1,1",
130          "xtype" : "Label",
131          "$ justify" : "Gtk.Justification.RIGHT",
132          "x_options" : 4,
133          "$ xns" : "Gtk"
134         },
135         {
136          "id" : "region",
137          "$ visible" : true,
138          "xtype" : "Entry",
139          "* pack" : "attach,1,3,1,1",
140          "$ xns" : "Gtk"
141         },
142         {
143          "label" : "Parent Name",
144          "$ visible" : true,
145          "xalign" : 0.90000000000000002,
146          "* pack" : "attach,0,4,1,1",
147          "xtype" : "Label",
148          "$ justify" : "Gtk.Justification.RIGHT",
149          "x_options" : 4,
150          "$ xns" : "Gtk"
151         },
152         {
153          "id" : "parent",
154          "$ visible" : true,
155          "xtype" : "Entry",
156          "* pack" : "attach,1,4,1,1",
157          "$ xns" : "Gtk"
158         },
159         {
160          "label" : "Permission Name",
161          "$ visible" : true,
162          "xalign" : 0.90000000000000002,
163          "* pack" : "attach,0,5,1,1",
164          "xtype" : "Label",
165          "$ justify" : "Gtk.Justification.RIGHT",
166          "x_options" : 4,
167          "$ xns" : "Gtk"
168         },
169         {
170          "id" : "permname",
171          "$ visible" : true,
172          "xtype" : "Entry",
173          "* pack" : "attach,1,5,1,1",
174          "$ xns" : "Gtk"
175         },
176         {
177          "label" : "Order (for tabs)",
178          "$ visible" : true,
179          "xalign" : 0.90000000000000002,
180          "* pack" : "attach,0,6,1,1",
181          "xtype" : "Label",
182          "$ justify" : "Gtk.Justification.RIGHT",
183          "x_options" : 4,
184          "$ xns" : "Gtk"
185         },
186         {
187          "id" : "modOrder",
188          "$ visible" : true,
189          "xtype" : "Entry",
190          "* pack" : "attach,1,6,1,1",
191          "$ xns" : "Gtk"
192         },
193         {
194          "label" : "Module to build (Vala only)",
195          "$ visible" : true,
196          "xalign" : 0.90000000000000002,
197          "* pack" : "attach,0,7,1,1",
198          "xtype" : "Label",
199          "$ justify" : "Gtk.Justification.RIGHT",
200          "x_options" : 4,
201          "$ xns" : "Gtk"
202         },
203         {
204          "id" : "build_module",
205          "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
206          "* pack" : "attach,1,7,1,1",
207          "xtype" : "ComboBox",
208          "$ xns" : "Gtk",
209          "items" : [
210           {
211            "id" : "dbcellrenderer",
212            "xtype" : "CellRendererText",
213            "* pack" : "pack_start,true",
214            "$ xns" : "Gtk"
215           },
216           {
217            "id" : "dbmodel",
218            "xtype" : "ListStore",
219            "* pack" : "set_model",
220            "$ columns" : "typeof(string),typeof(string)",
221            "n_columns" : 2,
222            "$ xns" : "Gtk",
223            "| void loadData" : "  (Gee.ArrayList<string> data, string cur) {\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 module --\");\n    _this.build_module.el.set_active_iter(iter);\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        if (data.get(i) == cur) {\n            _this.build_module.el.set_active_iter(iter);\n        }\n        \n    }\n     this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n"
224           }
225          ]
226         },
227         {
228          "label" : "Directory",
229          "$ visible" : true,
230          "xalign" : 0.90000000000000002,
231          "* pack" : "attach,0,8",
232          "xtype" : "Label",
233          "$ justify" : "Gtk.Justification.RIGHT",
234          "x_options" : 4,
235          "$ xns" : "Gtk"
236         },
237         {
238          "id" : "dir",
239          "* init" : "this.el.add_attribute(_this.dircellrenderer.el , \"markup\", 1 );",
240          "* pack" : "attach,1,8",
241          "xtype" : "ComboBox",
242          "$ xns" : "Gtk",
243          "items" : [
244           {
245            "id" : "dircellrenderer",
246            "* pack" : "pack_start,true",
247            "xtype" : "CellRendererText",
248            "$ xns" : "Gtk"
249           },
250           {
251            "id" : "dirmodel",
252            "* pack" : "set_model",
253            "xtype" : "ListStore",
254            "$ columns" : "typeof(string),typeof(string)",
255            "n_columns" : 2,
256            "$ xns" : "Gtk",
257            "| void loadData" : "  () {\n\t\n\t\n  \n    this.el.clear();                                    \n    \n    if (!(_this.project is Project.Gtk)) {\n\t\treturn;\n\t}\n    var sd = ((Project.Gtk)_this.project).sourcedirs();\n    \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 directoyr --\");\n    //_this.build_module.el.set_active_iter(iter);\n    \n    for (var i = 0; i < sd.length;i++) {\n    \n\n        el.append(out iter);\n        \n        el.set_value(iter, 0, sd[i]);\n        el.set_value(iter, 1, sd[i]);\n        \n        //if (data.get(i) == cur) {\n        //    _this.build_module.el.set_active_iter(iter);\n       // }\n        \n    }\n  //  this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);          \n                                     \n}\n"
258           }
259          ]
260         }
261        ]
262       },
263       {
264        "int margin_bottom" : 4,
265        "int margin_right" : 4,
266        "* pack" : "pack_end,false,true,0",
267        "xtype" : "HButtonBox",
268        "$ xns" : "Gtk",
269        "int margin_left" : 4,
270        "items" : [
271         {
272          "listeners" : {
273           "clicked" : "() => { \n\n  _this.done = true;\n    _this.el.hide(); \n}"
274          },
275          "string label" : "Cancel",
276          "* pack" : "add",
277          "xtype" : "Button",
278          "$ xns" : "Gtk"
279         },
280         {
281          "listeners" : {
282           "clicked" : "( ) =>  { \n\n \n\n\n\tif (_this.name.el.get_text().length  < 1) {\n\t    StandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You have to set Component name \"\n\t    );\n\t     \n\t    return;\n\t}\n\t// what does this do?\n\t\n\tvar isNew = _this.file.name.length  > 0 ? false : true;\n\t/*\n\tif (!isNew && this.file.name != _this.name.el.get_text()) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        this.el,\n\t        \"Sorry changing names does not work yet. \"\n\t    );\n\t     \n\t    return;\n\t}\n\t*/\n\t \n\t\n  \n\t// FIXME - this may be more complicated...\n\t//for (var i in this.def) {\n\t//    this.file[i] =  this.get(i).el.get_text();\n\t//}\n\n\tif (!isNew) {\n\t    try {\n\t         _this.updateFileFromEntry();\n\t     } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n\t          Xcls_StandardErrorDialog.singleton().show(\n\t            _this.mainwindow.el,\n\t            \"The name you used already exists \"\n\t        );\n\t        return;\n\t         \n\t     }\n\n\t      _this.done = true;\n\t    _this.file.save();\n\t    _this.el.hide();\n\t    return;\n\t}\n\t\n\t// ---------------- NEW FILES...\n\tGtk.TreeIter iter;\n\n\tif (!_this.filetype.el.get_active_iter(out iter)) {\n\t\t// should not happen...\n\t\t// so we are jut going to return without \n\t\tStandardErrorDialog.show(\n\t        _this.mainwindow.el,\n\t        \"You must select a file type. \"\n\t    );\n\t    return;\n\t\t \n\t}\n\t\n\t\n\tvar fn = _this.name.el.get_text();\n\t\n\tValue ftypename;\n\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);\n\tvar ext = ((string)ftypename);\n\tvar dir = _this.project.firstPath(); \n\tif (ext != \"bjs\") {\n\t \n\t\tif (!_this.dir.el.get_active_iter(out iter)) {\n\t\t\t// should not happen...\n\t\t\t// so we are jut going to return without \n\t\t\tStandardErrorDialog.show(\n\t\t\t    _this.mainwindow.el,\n\t\t\t    \"You must select a directory \"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tValue vdir;\n\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);\n\t\tdir = (string)vdir;\n\t}\n\t\n\tvar targetfile = dir + \"/\" + fn;\n\t\n\t// strip the file type off the end..\n\t\n\t\n    var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);\n    targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); \n   \n\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {\n\t    Xcls_StandardErrorDialog.singleton().show(\n\t        _this.mainwindow.el,\n\t        \"That file already exists\"\n\t    ); \n\t    return;\n\t}\n   \n   var f =  JsRender.JsRender.factory(\n\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\",  \n\t\t_this.file.project, \n\t\ttargetfile + \".\" + ext);\n\n\t_this.file = f;\n\t\n\n\t\n\t_this.updateFileFromEntry();\n\t_this.file.loaded = true;\n\t_this.file.save();\n\tif (ext == \"bjs\") {\n\t\t_this.file.project.addFile(_this.file);\n\t}\n\t\n \n\t// what about .js ?\n   _this.done = true;\n\t_this.el.hide();\n\n// hopefull this will work with bjs files..\n\t\n\t_this.success(_this.project, _this.file);\n   \n}"
283          },
284          "id" : "save_btn",
285          "xtype" : "Button",
286          "* pack" : "add",
287          "string label" : "Save",
288          "$ xns" : "Gtk"
289         }
290        ]
291       }
292      ]
293     }
294    ]
295   }
296  ]
297 }