src/Builder4/RooProjectSettings.bjs
[roobuilder] / src / Builder4 / RooProjectSettings.bjs
1 {
2  "name" : "RooProjectSettings",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/roobuilder/src/Builder4/RooProjectSettings.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "@ void buttonPressed" : "(string btn)",
12    "id" : "RooProjectSettings",
13    "| void show" : " (Gtk.Widget btn, Project.Project project) {\n    _this.project = project;\n    _this.path.el.label = project.firstPath();\n    // get the active project.\n     var lm = Gtk.SourceLanguageManager.get_default();\n                \n    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(\n        lm.get_language(\"html\")\n    );\n  \n    //print (project.fn);\n    //project.runhtml = project.runhtml || '';\n    _this.view.el.get_buffer().set_text(project.runhtml);\n    \n       \n    _this.rootURL.el.set_text( _this.project.rootURL );\n    \n\n    _this.base_template_model.loadData();\n    \n     var js = _this.project;\n    _this.database_DBTYPE.el.set_text(     js.get_string_member(\"DBTYPE\") );\n    _this.database_DBNAME.el.set_text(    js.get_string_member(\"DBNAME\") );\n    _this.database_DBUSERNAME.el.set_text(    js.get_string_member(\"DBUSERNAME\") );\n    _this.database_DBPASSWORD.el.set_text(    js.get_string_member(\"DBPASSWORD\") );\n    \n    \t//console.log('show all');\n\tthis.el.set_modal(true);\n\tthis.el.set_relative_to(btn);\n\n\tthis.el.set_position(Gtk.PositionType.RIGHT);\n\n\t// window + header?\n\t print(\"SHOWALL - POPIP\\n\");\n\tthis.el.show_all();\n\tthis.el.set_size_request(800,500);\n\tthis.view.el.grab_focus();\n\t\n    \n    //this.el.show_all();\n}\n",
14    "xtype" : "Popover",
15    "Gtk.PositionType position" : "Gtk.PositionType.RIGHT",
16    "| void save" : "() {\n   var buf =    _this.view.el.get_buffer();\n   Gtk.TextIter s;\n     Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n      _this.project.runhtml = buf.get_text(s,e,true);\n      \n    _this.project.rootURL = _this.rootURL.el.get_text();\n    // set by event changed...\n    //_this.project.base_template = _this.base_template.el.get_text();    \n    \n    var js = _this.project.json_project_data;\n    js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());\n   js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());\n    js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());\n    js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());\n//    _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text());    \n    \n    // need to re-init the database \n    \n    _this.project.initRooDatabase();\n     \n    \n}",
17    "$ xns" : "Gtk",
18    "Project.Project project" : "",
19    "bool modal" : true,
20    "uint border_width" : 0,
21    "items" : [
22     {
23      "xtype" : "Box",
24      "* pack" : "add",
25      "$ xns" : "Gtk",
26      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
27      "border_width" : 5,
28      "$ homogeneous" : false,
29      "items" : [
30       {
31        "* pack" : "pack_start,true,true,0",
32        "xtype" : "Notebook",
33        "$ xns" : "Gtk",
34        "items" : [
35         {
36          "id" : "label_global",
37          "* pack" : false,
38          "xtype" : "Label",
39          "$ xns" : "Gtk",
40          "utf8 label" : "Global"
41         },
42         {
43          "id" : "label_database",
44          "xtype" : "Label",
45          "* pack" : false,
46          "$ xns" : "Gtk",
47          "utf8 label" : "Database"
48         },
49         {
50          "* pack" : "append_page,_this.label_global.el",
51          "xtype" : "Box",
52          "gboolean homogeneous" : false,
53          "$ xns" : "Gtk",
54          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
55          "items" : [
56           {
57            "label" : "filename",
58            "id" : "path",
59            "xalign" : 0,
60            "* pack" : "pack_start,false,false,0",
61            "xtype" : "Label",
62            "gint margin" : 3,
63            "$ xns" : "Gtk"
64           },
65           {
66            "* pack" : "pack_start,false,false,0",
67            "xtype" : "Box",
68            "gboolean expand" : false,
69            "$ xns" : "Gtk",
70            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
71            "$ homogeneous" : false,
72            "items" : [
73             {
74              "label" : "HTML template file",
75              "* pack" : "pack_start,false,false,0",
76              "xtype" : "Label",
77              "gint margin" : 3,
78              "$ xns" : "Gtk"
79             },
80             {
81              "listeners" : {
82               "changed" : "() => {\n\tGtk.TreeIter iter;\n \n\t// this get's called when we are filling in the data... ???\n\tif (this.loading) {\n\t\treturn;\n\t}\n\t\n \n\tif (this.el.get_active_iter(out iter)) {\n\t\tValue vfname;\n\t\t_this.base_template_model.el.get_value (iter, 0, out vfname);\n\t\t_this.project.base_template = ((string)vfname) ;\n\t\t\n\t\t print(\"\\nSET base template to %s\\n\", _this.project.base_template );\n\t\t// is_bjs = ((string)vfname) == \"bjs\";\n\t}\n    \n  \n    // directory is only available for non-bjs \n \n\n\n}\n"
83              },
84              "id" : "base_template",
85              "bool loading" : false,
86              "* init" : "this.el.add_attribute(_this.base_template_cellrenderer.el , \"markup\", 0 );",
87              "* pack" : "add",
88              "xtype" : "ComboBox",
89              "$ xns" : "Gtk",
90              "items" : [
91               {
92                "id" : "base_template_cellrenderer",
93                "xtype" : "CellRendererText",
94                "* pack" : "pack_start,true",
95                "$ xns" : "Gtk"
96               },
97               {
98                "id" : "base_template_model",
99                "xtype" : "ListStore",
100                "* pack" : "set_model",
101                "$ columns" : "typeof(string)",
102                "n_columns" : 1,
103                "$ xns" : "Gtk",
104                "| void loadData" : "  () {\n\t_this.base_template.loading = true;\n  \n    this.el.clear();                                    \n    Gtk.TreeIter iter;\n    var el = this.el;\n    \n   /// el.append(out iter);\n    \n   \n    el.append(out iter);\n    el.set_value(iter, 0, \"roo.builder.html\");\n    _this.base_template.el.set_active_iter(iter);\n\tif (_this.project.base_template == \"roo.builder.html\") {\n\t   _this.base_template.el.set_active_iter(iter);\n    }\n\n    el.append(out iter);\n    el.set_value(iter, 0, \"bootstrap.builder.html\");\n \n\tprint(\"\\ncur template = %s\\n\", _this.project.base_template);\n \n    if (_this.project.base_template == \"bootstrap.builder.html\") {\n\t   _this.base_template.el.set_active_iter(iter);\n    }\n\n\tel.append(out iter);\n    el.set_value(iter, 0, \"mailer.builder.html\");\n\n\tif (_this.project.base_template == \"mailer.builder.html\") {\n\t    _this.base_template.el.set_active_iter(iter);\n    }\n\t_this.base_template.loading = false;\n                                     \n}\n"
105               }
106              ]
107             }
108            ]
109           },
110           {
111            "* pack" : "pack_start,false,false,0",
112            "xtype" : "Box",
113            "gboolean expand" : false,
114            "$ xns" : "Gtk",
115            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
116            "$ homogeneous" : false,
117            "items" : [
118             {
119              "label" : "root URL",
120              "* pack" : "pack_start,false,false,0",
121              "xtype" : "Label",
122              "gint margin" : 3,
123              "$ xns" : "Gtk"
124             },
125             {
126              "id" : "rootURL",
127              "* pack" : "add",
128              "xtype" : "Entry",
129              "$ xns" : "Gtk"
130             }
131            ]
132           },
133           {
134            "label" : "HTML To insert at end of <HEAD>",
135            "* pack" : "pack_start,false,false,0",
136            "xtype" : "Label",
137            "$ xns" : "Gtk"
138           },
139           {
140            "* pack" : "pack_start,true,true,0",
141            "xtype" : "ScrolledWindow",
142            "$ xns" : "Gtk",
143            "items" : [
144             {
145              "listeners" : {
146               "key_release_event" : " ( event) =>{\n    if (event.keyval != 115) {\n        return false;\n         \n    }\n    if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {\n        return false;\n    }\n     var buf =    this.el.get_buffer();\n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n    _this.project.runhtml = buf.get_text(s,e,true);\n    \n          \n    _this.buttonPressed(\"save\");\n     \n    return false;\n         \n}"
147              },
148              "id" : "view",
149              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
150              "xtype" : "View",
151              "* pack" : "add",
152              "$ xns" : "GtkSource"
153             }
154            ]
155           },
156           {
157            "id" : "grid",
158            "int margin_right" : 4,
159            "* pack" : "pack_start,false,false,4",
160            "xtype" : "Grid",
161            "uint row_spacing" : 2,
162            "n_columns" : 2,
163            "$ xns" : "Gtk",
164            "n_rows" : 7,
165            "$ homogeneous" : true,
166            "int margin_left" : 4,
167            "items" : [
168             {
169              "label" : "File type",
170              "id" : "filetypelbl",
171              "xalign" : 0.90000000000000002,
172              "* pack" : "attach,0,0,1,1",
173              "xtype" : "Label",
174              "$ justify" : "Gtk.Justification.RIGHT",
175              "x_options" : 4,
176              "$ xns" : "Gtk"
177             },
178             {
179              "listeners" : {
180               "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"
181              },
182              "id" : "filetype",
183              "* init" : "this.el.add_attribute(_this.ftdbcellrenderer.el , \"markup\", 1 );",
184              "* pack" : "attach,1,0,1,1",
185              "xtype" : "ComboBox",
186              "| 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",
187              "$ xns" : "Gtk",
188              "items" : [
189               {
190                "id" : "ftdbcellrenderer",
191                "xtype" : "CellRendererText",
192                "* pack" : "pack_start,true",
193                "$ xns" : "Gtk"
194               },
195               {
196                "id" : "ftdbmodel",
197                "xtype" : "ListStore",
198                "* pack" : "set_model",
199                "$ columns" : "typeof(string),typeof(string)",
200                "n_columns" : 2,
201                "$ xns" : "Gtk",
202                "| 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"
203               }
204              ]
205             },
206             {
207              "label" : "Directory",
208              "$ visible" : true,
209              "xalign" : 0.90000000000000002,
210              "* pack" : "attach,0,8,1,1",
211              "xtype" : "Label",
212              "$ justify" : "Gtk.Justification.RIGHT",
213              "x_options" : 4,
214              "$ xns" : "Gtk"
215             },
216             {
217              "id" : "dir",
218              "* init" : "this.el.add_attribute(_this.dircellrenderer.el , \"markup\", 1 );",
219              "* pack" : "attach,1,8,1,1",
220              "xtype" : "ComboBox",
221              "$ xns" : "Gtk",
222              "items" : [
223               {
224                "id" : "dircellrenderer",
225                "xtype" : "CellRendererText",
226                "* pack" : "pack_start,true",
227                "$ xns" : "Gtk"
228               },
229               {
230                "id" : "dirmodel",
231                "xtype" : "ListStore",
232                "* pack" : "set_model",
233                "$ columns" : "typeof(string),typeof(string)",
234                "n_columns" : 2,
235                "$ xns" : "Gtk",
236                "| 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"
237               }
238              ]
239             }
240            ]
241           },
242           {
243            "label" : "filename",
244            "id" : "path",
245            "xalign" : 0,
246            "* pack" : "pack_start,false,false,0",
247            "xtype" : "Label",
248            "gint margin" : 3,
249            "$ xns" : "Gtk"
250           }
251          ]
252         },
253         {
254          "* pack" : "append_page,_this.label_database.el",
255          "xtype" : "Box",
256          "gboolean homogeneous" : false,
257          "$ xns" : "Gtk",
258          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
259          "items" : [
260           {
261            "label" : "Type (eg. MySQL or PostgreSQL)",
262            "xalign" : 0,
263            "* pack" : "pack_start,false,false,0",
264            "xtype" : "Label",
265            "$ xns" : "Gtk"
266           },
267           {
268            "listeners" : {
269             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
270            },
271            "id" : "database_DBTYPE",
272            "xtype" : "Entry",
273            "* pack" : "pack_start,false,false,0",
274            "$ xns" : "Gtk"
275           },
276           {
277            "label" : "Name",
278            "xalign" : 0,
279            "* pack" : "pack_start,false,false,0",
280            "xtype" : "Label",
281            "$ xns" : "Gtk"
282           },
283           {
284            "listeners" : {
285             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBUSERNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
286            },
287            "id" : "database_DBNAME",
288            "* pack" : "pack_start,false,false,0",
289            "xtype" : "Entry",
290            "$ xns" : "Gtk"
291           },
292           {
293            "label" : "Username",
294            "xalign" : 0,
295            "* pack" : "pack_start,false,false,0",
296            "xtype" : "Label",
297            "$ xns" : "Gtk"
298           },
299           {
300            "listeners" : {
301             "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBPASSWORD.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
302            },
303            "id" : "database_DBUSERNAME",
304            "xtype" : "Entry",
305            "* pack" : "pack_start,false,false,0",
306            "$ xns" : "Gtk"
307           },
308           {
309            "label" : "Password",
310            "xalign" : 0,
311            "* pack" : "pack_start,false,false,0",
312            "xtype" : "Label",
313            "$ xns" : "Gtk"
314           },
315           {
316            "id" : "database_DBPASSWORD",
317            "* pack" : "pack_start,false,false,0",
318            "xtype" : "Entry",
319            "$ xns" : "Gtk"
320           },
321           {
322            "listeners" : {
323             "clicked" : "() => {\n\n\n  _this.database_ERROR.el.label    = \"\";\n    Gda.Connection cnc;\n    try {\n        // assumes localhost...\n         cnc = Gda.Connection.open_from_string (\n\t\t\t_this.database_DBTYPE.el.get_text(),\n\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), \n\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + \n\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),\n\t\t\tGda.ConnectionOptions.NONE\n\t\t);\n   //} catch (Gda.ConnectionError ce) { \n   //   _this.database_ERROR.el.label = ce.message;        \n   } catch(Gda.ConnectionError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }  catch(Gda.ConfigError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }\n  _this.database_ERROR.el.label = \"Connection Succeeded\";\n   cnc.close();\n}"
324            },
325            "* pack" : "pack_start,false,false,0",
326            "xtype" : "Button",
327            "$ xns" : "Gtk",
328            "utf8 label" : "Check Connection"
329           },
330           {
331            "label" : " ",
332            "id" : "database_ERROR",
333            "xalign" : 0,
334            "* pack" : "pack_start,false,false,0",
335            "xtype" : "Label",
336            "gint margin" : 3,
337            "$ xns" : "Gtk"
338           }
339          ]
340         }
341        ]
342       },
343       {
344        "* pack" : "pack_end,false,false,0",
345        "xtype" : "Box",
346        "gboolean expand" : false,
347        "$ xns" : "Gtk",
348        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
349        "$ homogeneous" : true,
350        "gboolean vexpand" : false,
351        "items" : [
352         {
353          "listeners" : {
354           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
355          },
356          "label" : "Apply",
357          "xtype" : "Button",
358          "* pack" : "add",
359          "$ xns" : "Gtk"
360         },
361         {
362          "listeners" : {
363           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
364          },
365          "label" : "Save",
366          "xtype" : "Button",
367          "* pack" : "add",
368          "$ xns" : "Gtk"
369         }
370        ]
371       }
372      ]
373     }
374    ]
375   }
376  ]
377 }