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" : "()",
12    "id" : "ProjectSettings",
13    "| void show" : " (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    \n        lm.get_language(\"html\"));\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    _this.base_template.el.set_text(_this.project.base_template);    \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    //this.el.show_all();\n}\n",
14    "xtype" : "Popover",
15    "| 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    _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}",
16    "$ xns" : "Gtk",
17    "items" : [
18     {
19      "@ void buttonPressed" : "(string btn)",
20      "id" : "ProjectSettings",
21      "| void show" : " (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    \n        lm.get_language(\"html\"));\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    _this.base_template.el.set_text(_this.project.base_template);    \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    //this.el.show_all();\n}\n",
22      "# Project.Project project" : "",
23      "xtype" : "Box",
24      "| 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    _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}",
25      "$ xns" : "Gtk",
26      "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
27      "border_width" : 5,
28      "$ homogeneous" : false,
29      "items" : [
30       {
31        "* pack" : "pack_start,false,false,0",
32        "xtype" : "Box",
33        "gboolean expand" : false,
34        "$ xns" : "Gtk",
35        "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
36        "$ homogeneous" : true,
37        "gboolean vexpand" : false,
38        "items" : [
39         {
40          "listeners" : {
41           "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
42          },
43          "label" : "Apply",
44          "* pack" : "add",
45          "xtype" : "Button",
46          "$ xns" : "Gtk"
47         },
48         {
49          "listeners" : {
50           "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
51          },
52          "label" : "Save",
53          "* pack" : "add",
54          "xtype" : "Button",
55          "$ xns" : "Gtk"
56         }
57        ]
58       },
59       {
60        "* pack" : "pack_end,true,true,0",
61        "xtype" : "Notebook",
62        "$ xns" : "Gtk",
63        "items" : [
64         {
65          "id" : "label_global",
66          "xtype" : "Label",
67          "* pack" : false,
68          "$ xns" : "Gtk",
69          "utf8 label" : "Global"
70         },
71         {
72          "id" : "label_database",
73          "* pack" : false,
74          "xtype" : "Label",
75          "$ xns" : "Gtk",
76          "utf8 label" : "Database"
77         },
78         {
79          "* pack" : "append_page,_this.label_global.el",
80          "xtype" : "Box",
81          "gboolean homogeneous" : false,
82          "$ xns" : "Gtk",
83          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
84          "items" : [
85           {
86            "label" : "filename",
87            "id" : "path",
88            "xalign" : 0,
89            "* pack" : "pack_start,false,false,0",
90            "xtype" : "Label",
91            "gint margin" : 3,
92            "$ xns" : "Gtk"
93           },
94           {
95            "* pack" : "pack_start,false,false,0",
96            "xtype" : "Box",
97            "gboolean expand" : false,
98            "$ xns" : "Gtk",
99            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
100            "$ homogeneous" : false,
101            "items" : [
102             {
103              "label" : "HTML template file",
104              "xtype" : "Label",
105              "* pack" : "pack_start,false,false,0",
106              "gint margin" : 3,
107              "$ xns" : "Gtk"
108             },
109             {
110              "id" : "base_template",
111              "xtype" : "Entry",
112              "* pack" : "add",
113              "$ xns" : "Gtk"
114             }
115            ]
116           },
117           {
118            "* pack" : "pack_start,false,false,0",
119            "xtype" : "Box",
120            "gboolean expand" : false,
121            "$ xns" : "Gtk",
122            "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
123            "$ homogeneous" : false,
124            "items" : [
125             {
126              "label" : "root URL",
127              "xtype" : "Label",
128              "* pack" : "pack_start,false,false,0",
129              "gint margin" : 3,
130              "$ xns" : "Gtk"
131             },
132             {
133              "id" : "rootURL",
134              "xtype" : "Entry",
135              "* pack" : "add",
136              "$ xns" : "Gtk"
137             }
138            ]
139           },
140           {
141            "label" : "HTML To insert at end of <HEAD>",
142            "xtype" : "Label",
143            "* pack" : "pack_start,false,false,0",
144            "$ xns" : "Gtk"
145           },
146           {
147            "* pack" : "pack_start,true,true,0",
148            "xtype" : "ScrolledWindow",
149            "$ xns" : "Gtk",
150            "items" : [
151             {
152              "listeners" : {
153               "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}"
154              },
155              "id" : "view",
156              "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
157              "xtype" : "View",
158              "* pack" : "add",
159              "$ xns" : "GtkSource"
160             }
161            ]
162           }
163          ]
164         },
165         {
166          "* pack" : "append_page,_this.label_database.el",
167          "xtype" : "Box",
168          "gboolean homogeneous" : false,
169          "$ xns" : "Gtk",
170          "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
171          "items" : [
172           {
173            "label" : "Type (eg. MySQL or PostgreSQL)",
174            "xalign" : 0,
175            "* pack" : "pack_start,false,false,0",
176            "xtype" : "Label",
177            "$ xns" : "Gtk"
178           },
179           {
180            "listeners" : {
181             "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"
182            },
183            "id" : "database_DBTYPE",
184            "* pack" : "pack_start,false,false,0",
185            "xtype" : "Entry",
186            "$ xns" : "Gtk"
187           },
188           {
189            "label" : "Name",
190            "xalign" : 0,
191            "* pack" : "pack_start,false,false,0",
192            "xtype" : "Label",
193            "$ xns" : "Gtk"
194           },
195           {
196            "listeners" : {
197             "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"
198            },
199            "id" : "database_DBNAME",
200            "xtype" : "Entry",
201            "* pack" : "pack_start,false,false,0",
202            "$ xns" : "Gtk"
203           },
204           {
205            "label" : "Username",
206            "xalign" : 0,
207            "* pack" : "pack_start,false,false,0",
208            "xtype" : "Label",
209            "$ xns" : "Gtk"
210           },
211           {
212            "listeners" : {
213             "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"
214            },
215            "id" : "database_DBUSERNAME",
216            "* pack" : "pack_start,false,false,0",
217            "xtype" : "Entry",
218            "$ xns" : "Gtk"
219           },
220           {
221            "label" : "Password",
222            "xalign" : 0,
223            "* pack" : "pack_start,false,false,0",
224            "xtype" : "Label",
225            "$ xns" : "Gtk"
226           },
227           {
228            "id" : "database_DBPASSWORD",
229            "xtype" : "Entry",
230            "* pack" : "pack_start,false,false,0",
231            "$ xns" : "Gtk"
232           },
233           {
234            "listeners" : {
235             "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}"
236            },
237            "* pack" : "pack_start,false,false,0",
238            "xtype" : "Button",
239            "$ xns" : "Gtk",
240            "utf8 label" : "Check Connection"
241           },
242           {
243            "label" : " ",
244            "id" : "database_ERROR",
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       }
255      ]
256     }
257    ]
258   }
259  ]
260 }