src/Builder4/PopoverFileDetails.bjs
[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    "id" : "PopoverFileDetails",
12    "| void show" : "(JsRender.JsRender c, Gtk.Widget btn) \n{\n    this.project = c.project;\n    \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    if (c.path.length > 0) {\n    \n        //this.el.set_title(\"Edit File Details - \" + c.name);\n    } else {\n        //this.el.set_title(\"Create New File\");\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.set_relative_to(btn);\n    \n    \n    this.el.show_all();\n    \n    //this.success = c.success;\n    \n    \n}",
13    "# Project.Project project" : "",
14    "xtype" : "Popover",
15    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
16    "# JsRender.JsRender file" : "null",
17    "$ xns" : "Gtk",
18    "bool modal" : true,
19    "items" : [
20     {
21      "xtype" : "VBox",
22      "$ pack" : "get_content_area().add",
23      "$ xns" : "Gtk",
24      "items" : [
25       {
26        "* pack" : "pack_start,false,false,0",
27        "xtype" : "Table",
28        "n_columns" : 2,
29        "$ xns" : "Gtk",
30        "n_rows" : 3,
31        "$ homogeneous" : true,
32        "items" : [
33         {
34          "label" : "Component Name",
35          "xalign" : 0.90000000000000002,
36          "* pack" : "attach_defaults,0,1,0,1",
37          "xtype" : "Label",
38          "$ justify" : "Gtk.Justification.RIGHT",
39          "x_options" : 4,
40          "$ xns" : "Gtk"
41         },
42         {
43          "id" : "name",
44          "$ visible" : true,
45          "xtype" : "Entry",
46          "* pack" : "attach_defaults,1,2,0,1",
47          "$ xns" : "Gtk"
48         },
49         {
50          "label" : "Title",
51          "$ visible" : true,
52          "xalign" : 0.90000000000000002,
53          "* pack" : "attach_defaults,0,1,1,2",
54          "xtype" : "Label",
55          "$ justify" : "Gtk.Justification.RIGHT",
56          "x_options" : 4,
57          "$ xns" : "Gtk"
58         },
59         {
60          "id" : "title",
61          "$ visible" : true,
62          "xtype" : "Entry",
63          "* pack" : "attach_defaults,1,2,1,2",
64          "$ xns" : "Gtk"
65         },
66         {
67          "label" : "Region",
68          "tooltip_text" : "center, north, south, east, west",
69          "$ visible" : true,
70          "xalign" : 0.90000000000000002,
71          "* pack" : "attach_defaults,0,1,2,3",
72          "xtype" : "Label",
73          "$ justify" : "Gtk.Justification.RIGHT",
74          "x_options" : 4,
75          "$ xns" : "Gtk"
76         },
77         {
78          "id" : "region",
79          "$ visible" : true,
80          "xtype" : "Entry",
81          "* pack" : "attach_defaults,1,2,2,3",
82          "$ xns" : "Gtk"
83         },
84         {
85          "label" : "Parent Name",
86          "$ visible" : true,
87          "xalign" : 0.90000000000000002,
88          "* pack" : "attach_defaults,0,1,3,4",
89          "xtype" : "Label",
90          "$ justify" : "Gtk.Justification.RIGHT",
91          "x_options" : 4,
92          "$ xns" : "Gtk"
93         },
94         {
95          "id" : "parent",
96          "$ visible" : true,
97          "xtype" : "Entry",
98          "* pack" : "attach_defaults,1,2,3,4",
99          "$ xns" : "Gtk"
100         },
101         {
102          "label" : "Permission Name",
103          "$ visible" : true,
104          "xalign" : 0.90000000000000002,
105          "* pack" : "attach_defaults,0,1,4,5",
106          "xtype" : "Label",
107          "$ justify" : "Gtk.Justification.RIGHT",
108          "x_options" : 4,
109          "$ xns" : "Gtk"
110         },
111         {
112          "id" : "permname",
113          "$ visible" : true,
114          "xtype" : "Entry",
115          "* pack" : "attach_defaults,1,2,4,5",
116          "$ xns" : "Gtk"
117         },
118         {
119          "label" : "Order (for tabs)",
120          "$ visible" : true,
121          "xalign" : 0.90000000000000002,
122          "* pack" : "attach_defaults,0,1,5,6",
123          "xtype" : "Label",
124          "$ justify" : "Gtk.Justification.RIGHT",
125          "x_options" : 4,
126          "$ xns" : "Gtk"
127         },
128         {
129          "id" : "modOrder",
130          "$ visible" : true,
131          "xtype" : "Entry",
132          "* pack" : "attach_defaults,1,2,5,6",
133          "$ xns" : "Gtk"
134         },
135         {
136          "label" : "Module to build (Vala only)",
137          "$ visible" : true,
138          "xalign" : 0.90000000000000002,
139          "* pack" : "attach_defaults,0,1,6,7",
140          "xtype" : "Label",
141          "$ justify" : "Gtk.Justification.RIGHT",
142          "x_options" : 4,
143          "$ xns" : "Gtk"
144         },
145         {
146          "id" : "build_module",
147          "* init" : "this.el.add_attribute(_this.dbcellrenderer.el , \"markup\", 1 );",
148          "* pack" : "attach_defaults,1,2,6,7",
149          "xtype" : "ComboBox",
150          "$ xns" : "Gtk",
151          "items" : [
152           {
153            "id" : "dbcellrenderer",
154            "* pack" : "pack_start,true",
155            "xtype" : "CellRendererText",
156            "$ xns" : "Gtk"
157           },
158           {
159            "id" : "dbmodel",
160            "* pack" : "set_model",
161            "xtype" : "ListStore",
162            "$ columns" : "typeof(string),typeof(string)",
163            "n_columns" : 2,
164            "$ xns" : "Gtk",
165            "| 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"
166           }
167          ]
168         }
169        ]
170       },
171       {
172        "* pack" : "pack_end,false,false,5",
173        "xtype" : "HButtonBox",
174        "$ xns" : "Gtk",
175        "items" : [
176         {
177          "listeners" : {
178           "activate" : "() => { this.el.hide(); }"
179          },
180          "* pack" : "add",
181          "xtype" : "Button",
182          "string label" : "Cancel",
183          "$ xns" : "Gtk"
184         },
185         {
186          "listeners" : {
187           "activate" : " ( ) =>  { \n  \n\t \n\n\n        if (_this.name.el.get_text().length  < 1) {\n            StandardErrorDialog.show(\n                this.el,\n                \"You have to set Component name \"\n            );\n             \n            return;\n        }\n        // what does this do?\n        \n        var isNew = _this.file.name.length  > 0 ? false : true;\n        /*\n        if (!isNew && this.file.name != _this.name.el.get_text()) {\n            Xcls_StandardErrorDialog.singleton().show(\n                this.el,\n                \"Sorry changing names does not work yet. \"\n            );\n             \n            return;\n        }\n        */\n         \n        \n      \n        // FIXME - this may be more complicated...\n        //for (var i in this.def) {\n        //    this.file[i] =  this.get(i).el.get_text();\n        //}\n\n        if (!isNew) {\n            try {\n                 this.updateFileFromEntry();\n             } catch( JsRender.Error.RENAME_FILE_EXISTS er) {\n                  Xcls_StandardErrorDialog.singleton().show(\n                    this.el,\n                    \"The name you used already exists \"\n                );\n                return;\n                 \n             }\n                                                        \n        \n            _this.file.save();\n            this.el.hide();\n            return;\n        }\n        var fn = this.name.el.get_text();\n        var dir = _this.project.firstPath();\n       \n        if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {\n            Xcls_StandardErrorDialog.singleton().show(\n                this.el,\n                \"That file already exists\"\n            ); \n            return;\n        }\n       \n       var f =  JsRender.JsRender.factory(\n                _this.file.project.xtype,  \n                _this.file.project, \n                dir + \"/\" + fn + \".bjs\");\n\n        _this.file = f;\n        \n\n        \n        this.updateFileFromEntry();\n        _this.file.save();\n        _this.file.project.addFile(_this.file);\n        \n\t \n        // what about .js ?\n       \n        this.el.hide();\n        \n        \n        \n        _this.success(_this.project, _this.file);\n       \n}"
188          },
189          "@ void success" : "(Project.Project pr, JsRender.JsRender file)",
190          "* pack" : "add",
191          "xtype" : "Button",
192          "string label" : "Save",
193          "$ xns" : "Gtk"
194         }
195        ]
196       }
197      ]
198     }
199    ]
200   }
201  ]
202 }