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